NToken
Implementation of the NFT derivative token for the ParaSpace protocol
NTOKEN_REVISION
getRevision
Returns the revision number of the contract
Needs to be defined in the inherited class as a constant.
Return Values
[0]
uint256
The revision number
constructor
Constructor.
Parameters
pool
contract IPool
The address of the Pool contract
atomic_pricing
bool
initialize
mint
Mints amount
nTokens to user
Parameters
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
[0]
uint64
old and new collateralized balance
[1]
uint64
burn
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
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
[0]
uint64
old and new collateralized balance
[1]
uint64
_burn
transferOnLiquidation
Transfers nTokens in the event of a borrow being liquidated, in case the liquidators reclaims the nToken
Parameters
from
address
The address getting liquidated, current owner of the nTokens
to
address
The recipient
value
uint256
rescueERC20
Rescue ERC20 Token.
Parameters
token
address
The address of the token
to
address
The address of the recipient
amount
uint256
The amount being rescued
rescueERC721
Rescue ERC721 Token.
Parameters
token
address
The address of the token
to
address
The address of the recipient
ids
uint256[]
The ids of the tokens being rescued
rescueERC1155
Rescue ERC1155 Token.
Parameters
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
Executes airdrop.
Parameters
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
Returns the address of the underlying asset of this nToken (E.g. WETH for pWETH)
Return Values
[0]
address
The address of the underlying asset
transferUnderlyingTo
Transfers the underlying asset to target
.
Used by the Pool to transfer assets in borrow(), withdraw() and flashLoan()
Parameters
target
address
tokenId
uint256
The id of the token getting transferred
handleRepayment
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
user
address
The user executing the repayment
amount
uint256
_transfer
Transfers the nTokens between two users. Validates the transfer (ie checks for valid HF after the transfer) if required
Parameters
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
Overrides the parent _transfer to force validated transfer() and transferFrom()
Parameters
from
address
The source address
to
address
The destination address
tokenId
uint256
The token id getting transferred
onERC721Received
onERC1155Received
_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
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
[0]
bytes4
bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
if transfer is allowed
onERC1155BatchReceived
_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
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
[0]
bytes4
bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))
if transfer is allowed
tokenURI
See {IERC721Metadata-tokenURI}.
getAtomicPricingConfig
getXTokenType
return token type`of xToken