PToken

Implementation of the interest bearing token for the ParaSpace protocol

PERMIT_TYPEHASH

bytes32 PERMIT_TYPEHASH

PTOKEN_REVISION

uint256 PTOKEN_REVISION

_treasury

address _treasury

_underlyingAsset

address _underlyingAsset

getRevision

function getRevision() internal pure virtual returns (uint256)

Returns the revision number of the contract

Needs to be defined in the inherited class as a constant.

Return Values

NameTypeDescription

[0]

uint256

The revision number

constructor

constructor(contract IPool pool) public

Constructor.

Parameters

NameTypeDescription

pool

contract IPool

The address of the Pool contract

initialize

function initialize(contract IPool initializingPool, address treasury, address underlyingAsset, contract IRewardController incentivesController, uint8 pTokenDecimals, string pTokenName, string pTokenSymbol, bytes params) external

Initializes the pToken

Parameters

NameTypeDescription

initializingPool

contract IPool

treasury

address

The address of the ParaSpace treasury, receiving the fees on this pToken

underlyingAsset

address

The address of the underlying asset of this pToken (E.g. WETH for pWETH)

incentivesController

contract IRewardController

The smart contract managing potential incentives distribution

pTokenDecimals

uint8

The decimals of the pToken, same as the underlying asset's

pTokenName

string

The name of the pToken

pTokenSymbol

string

The symbol of the pToken

params

bytes

A set of encoded parameters for additional initialization

mint

function mint(address caller, address onBehalfOf, uint256 amount, uint256 index) external virtual returns (bool)

Mints amount xTokens to user

Parameters

NameTypeDescription

caller

address

The address performing the mint

onBehalfOf

address

The address of the user that will receive the minted xTokens

amount

uint256

The amount of tokens getting minted

index

uint256

The next liquidity index of the reserve

Return Values

NameTypeDescription

[0]

bool

true if the the previous balance of the user was 0

burn

function burn(address from, address receiverOfUnderlying, uint256 amount, uint256 index) external virtual

Burns xTokens from user and sends the equivalent amount of underlying to receiverOfUnderlying

In some instances, the mint event could be emitted from a burn transaction if the amount to burn is less than the interest that the user accrued

Parameters

NameTypeDescription

from

address

The address from which the xTokens will be burned

receiverOfUnderlying

address

The address that will receive the underlying

amount

uint256

The amount being burned

index

uint256

The next liquidity index of the reserve

mintToTreasury

function mintToTreasury(uint256 amount, uint256 index) external

Mints xTokens to the reserve treasury

Parameters

NameTypeDescription

amount

uint256

The amount of tokens getting minted

index

uint256

The next liquidity index of the reserve

transferOnLiquidation

function transferOnLiquidation(address from, address to, uint256 value) external

Transfers xTokens in the event of a borrow being liquidated, in case the liquidators reclaims the xToken

Parameters

NameTypeDescription

from

address

The address getting liquidated, current owner of the xTokens

to

address

The recipient

value

uint256

The amount of tokens getting transferred

balanceOf

function balanceOf(address user) public view virtual returns (uint256)

Returns the amount of tokens owned by account.

totalSupply

function totalSupply() public view virtual returns (uint256)

Returns the amount of tokens in existence.

RESERVE_TREASURY_ADDRESS

function RESERVE_TREASURY_ADDRESS() external view returns (address)

Returns the address of the ParaSpace treasury, receiving the fees on this xToken.

Return Values

NameTypeDescription

[0]

address

Address of the ParaSpace treasury

UNDERLYING_ASSET_ADDRESS

function UNDERLYING_ASSET_ADDRESS() external view returns (address)

Returns the address of the underlying asset of this xToken (E.g. WETH for pWETH)

Return Values

NameTypeDescription

[0]

address

The address of the underlying asset

transferUnderlyingTo

function transferUnderlyingTo(address target, uint256 amount) external virtual

Transfers the underlying asset to target.

Used by the Pool to transfer assets in borrow(), withdraw() and flashLoan()

Parameters

NameTypeDescription

target

address

amount

uint256

The amount getting transferred

handleRepayment

function handleRepayment(address user, uint256 amount) external virtual

Handles the underlying received by the xToken after the transfer has been completed.

The default implementation is empty as with standard ERC20 tokens, nothing needs to be done after the transfer is concluded. However in the future there may be xTokens that allow for example to stake the underlying to receive LM rewards. In that case, handleRepayment() would perform the staking of the underlying asset.

Parameters

NameTypeDescription

user

address

The user executing the repayment

amount

uint256

The amount getting repaid

permit

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external

Allow passing a signed message to approve spending

implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md

Parameters

NameTypeDescription

owner

address

The owner of the funds

spender

address

The spender

value

uint256

The amount

deadline

uint256

The deadline timestamp, type(uint256).max for max deadline

v

uint8

Signature param

r

bytes32

Signature param

s

bytes32

Signature param

_transfer

function _transfer(address from, address to, uint256 amount, bool validate) internal

Transfers the pTokens between two users. Validates the transfer (ie checks for valid HF after the transfer) if required

Parameters

NameTypeDescription

from

address

The source address

to

address

The destination address

amount

uint256

The amount getting transferred

validate

bool

True if the transfer needs to be validated, false otherwise

_transfer

function _transfer(address from, address to, uint128 amount) internal

Overrides the parent _transfer to force validated transfer() and transferFrom()

Parameters

NameTypeDescription

from

address

The source address

to

address

The destination address

amount

uint128

The amount getting transferred

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() public view returns (bytes32)

Overrides the base function to fully implement IPToken see IncentivizedERC20.DOMAIN_SEPARATOR() for more detailed documentation

nonces

function nonces(address owner) public view returns (uint256)

Overrides the base function to fully implement IPToken see IncentivizedERC20.nonces() for more detailed documentation

_EIP712BaseId

function _EIP712BaseId() internal view returns (string)

Returns the user readable name of signing domain (e.g. token name)

Return Values

NameTypeDescription

[0]

string

The name of the signing domain

rescueTokens

function rescueTokens(address token, address to, uint256 amount) external

Rescue and transfer tokens locked in this contract

Parameters

NameTypeDescription

token

address

The address of the token

to

address

The address of the recipient

amount

uint256

The amount of token to transfer

getXTokenType

function getXTokenType() external pure virtual returns (enum XTokenType)

return token type`of xToken