NToken

Implementation of the NFT derivative token for the ParaSpace protocol

NTOKEN_REVISION

uint256 NTOKEN_REVISION

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, bool atomic_pricing) public

Constructor.

Parameters

NameTypeDescription

pool

contract IPool

The address of the Pool contract

atomic_pricing

bool

initialize

function initialize(contract IPool initializingPool, address underlyingAsset, contract IRewardController incentivesController, string nTokenName, string nTokenSymbol, bytes params) public virtual

mint

function mint(address onBehalfOf, struct DataTypes.ERC721SupplyParams[] tokenData) external virtual returns (uint64, uint64)

Mints amount nTokens to user

Parameters

NameTypeDescription

onBehalfOf

address

The address of the user that will receive the minted nTokens

tokenData

struct DataTypes.ERC721SupplyParams[]

The list of the tokens getting minted and their collateral configs

Return Values

NameTypeDescription

[0]

uint64

old and new collateralized balance

[1]

uint64

burn

function burn(address from, address receiverOfUnderlying, uint256[] tokenIds) external virtual returns (uint64, uint64)

Burns nTokens 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 nTokens will be burned

receiverOfUnderlying

address

The address that will receive the underlying

tokenIds

uint256[]

The ids of the tokens getting burned

Return Values

NameTypeDescription

[0]

uint64

old and new collateralized balance

[1]

uint64

_burn

function _burn(address from, address receiverOfUnderlying, uint256[] tokenIds) internal returns (uint64, uint64)

transferOnLiquidation

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

Transfers nTokens in the event of a borrow being liquidated, in case the liquidators reclaims the nToken

Parameters

NameTypeDescription

from

address

The address getting liquidated, current owner of the nTokens

to

address

The recipient

value

uint256

rescueERC20

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

Rescue ERC20 Token.

Parameters

NameTypeDescription

token

address

The address of the token

to

address

The address of the recipient

amount

uint256

The amount being rescued

rescueERC721

function rescueERC721(address token, address to, uint256[] ids) external

Rescue ERC721 Token.

Parameters

NameTypeDescription

token

address

The address of the token

to

address

The address of the recipient

ids

uint256[]

The ids of the tokens being rescued

rescueERC1155

function rescueERC1155(address token, address to, uint256[] ids, uint256[] amounts, bytes data) external

Rescue ERC1155 Token.

Parameters

NameTypeDescription

token

address

The address of the token

to

address

The address of the recipient

ids

uint256[]

The ids of the tokens being rescued

amounts

uint256[]

The amount of NFTs being rescued for a specific id.

data

bytes

The data of the tokens that is being rescued. Usually this is 0.

executeAirdrop

function executeAirdrop(address airdropContract, bytes airdropParams) external

Executes airdrop.

Parameters

NameTypeDescription

airdropContract

address

The address of the airdrop contract

airdropParams

bytes

Third party airdrop abi data. You need to get this from the third party airdrop.

UNDERLYING_ASSET_ADDRESS

function UNDERLYING_ASSET_ADDRESS() external view returns (address)

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

Return Values

NameTypeDescription

[0]

address

The address of the underlying asset

transferUnderlyingTo

function transferUnderlyingTo(address target, uint256 tokenId) external virtual

Transfers the underlying asset to target.

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

Parameters

NameTypeDescription

target

address

tokenId

uint256

The id of the token getting transferred

handleRepayment

function handleRepayment(address user, uint256 amount) external virtual

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

The default implementation is empty as with standard ERC721 tokens, nothing needs to be done after the transfer is concluded. However in the future there may be nTokens 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

_transfer

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

Transfers the nTokens 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

tokenId

uint256

The amount getting transferred

validate

bool

True if the transfer needs to be validated, false otherwise

_transfer

function _transfer(address from, address to, uint256 tokenId) internal

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

Parameters

NameTypeDescription

from

address

The source address

to

address

The destination address

tokenId

uint256

The token id getting transferred

onERC721Received

function onERC721Received(address, address, uint256, bytes) external virtual returns (bytes4)

onERC1155Received

function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes data) external pure returns (bytes4)

_Handles the receipt of a single ERC1155 token type. This function is called at the end of a safeTransferFrom after the balance has been updated.

NOTE: To accept the transfer, this must return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")) (i.e. 0xf23a6e61, or its own function selector)._

Parameters

NameTypeDescription

operator

address

The address which initiated the transfer (i.e. msg.sender)

from

address

The address which previously owned the token

id

uint256

The ID of the token being transferred

value

uint256

The amount of tokens being transferred

data

bytes

Additional data with no specified format

Return Values

NameTypeDescription

[0]

bytes4

bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")) if transfer is allowed

onERC1155BatchReceived

function onERC1155BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data) external pure returns (bytes4)

_Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a safeBatchTransferFrom after the balances have been updated.

NOTE: To accept the transfer(s), this must return bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) (i.e. 0xbc197c81, or its own function selector)._

Parameters

NameTypeDescription

operator

address

The address which initiated the batch transfer (i.e. msg.sender)

from

address

The address which previously owned the token

ids

uint256[]

An array containing ids of each token being transferred (order and length must match values array)

values

uint256[]

An array containing amounts of each token being transferred (order and length must match ids array)

data

bytes

Additional data with no specified format

Return Values

NameTypeDescription

[0]

bytes4

bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) if transfer is allowed

tokenURI

function tokenURI(uint256 tokenId) public view virtual returns (string)

See {IERC721Metadata-tokenURI}.

getAtomicPricingConfig

function getAtomicPricingConfig() external view returns (bool)

getXTokenType

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

return token type`of xToken