PoolCore
Main point of interaction with an ParaSpace protocol's market
Users can:
Supply
Withdraw
Borrow
Repay
Liquidate positions
To be covered by a proxy contract, owned by the PoolAddressesProvider of the specific market All admin functions are callable by the PoolConfigurator contract defined also in the PoolAddressesProvider
POOL_REVISION
ADDRESSES_PROVIDER
Returns the PoolAddressesProvider connected to this contract
Return Values
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
provider
contract IPoolAddressesProvider
The address of the PoolAddressesProvider contract
initialize
Initializes the Pool.
Function is invoked by the proxy contract when the Pool contract is added to the PoolAddressesProvider of the market. Caching the address of the PoolAddressesProvider in order to reduce gas consumption on subsequent operations
Parameters
provider
contract IPoolAddressesProvider
The address of the PoolAddressesProvider
supply
Supplies an amount
of underlying asset into the reserve, receiving in return overlying xTokens.
E.g. User supplies 100 USDC and gets in return 100 pUSDC
Parameters
asset
address
The address of the underlying asset to supply
amount
uint256
The amount to be supplied
onBehalfOf
address
The address that will receive the xTokens, same as msg.sender if the user wants to receive them on his own wallet, or a different address if the beneficiary of xTokens is a different wallet
referralCode
uint16
Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man
supplyERC721
Supplies multiple tokenIds
of underlying ERC721 asset into the reserve, receiving in return overlying nTokens.
E.g. User supplies 2 BAYC and gets in return 2 nBAYC
Parameters
asset
address
The address of the underlying asset to supply
tokenData
struct DataTypes.ERC721SupplyParams[]
The list of tokenIds and their collateral configs to be supplied
onBehalfOf
address
The address that will receive the xTokens, same as msg.sender if the user wants to receive them on his own wallet, or a different address if the beneficiary of xTokens is a different wallet
referralCode
uint16
Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man
supplyERC721FromNToken
Same as supplyERC721
but this can only be called by NToken contract and doesn't require sending the underlying asset.
Parameters
asset
address
The address of the underlying asset to supply
tokenData
struct DataTypes.ERC721SupplyParams[]
The list of tokenIds and their collateral configs to be supplied
onBehalfOf
address
The address that will receive the xTokens
supplyWithPermit
Supply with transfer approval of asset to be supplied done via permit function see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713
Parameters
asset
address
The address of the underlying asset to supply
amount
uint256
The amount to be supplied
onBehalfOf
address
The address that will receive the xTokens, same as msg.sender if the user wants to receive them on his own wallet, or a different address if the beneficiary of xTokens is a different wallet
referralCode
uint16
Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man
deadline
uint256
The deadline timestamp that the permit is valid
permitV
uint8
The V parameter of ERC712 permit sig
permitR
bytes32
The R parameter of ERC712 permit sig
permitS
bytes32
The S parameter of ERC712 permit sig
withdraw
Withdraws an amount
of underlying asset from the reserve, burning the equivalent xTokens owned E.g. User has 100 pUSDC, calls withdraw() and receives 100 USDC, burning the 100 pUSDC
Parameters
asset
address
The address of the underlying asset to withdraw
amount
uint256
The underlying amount to be withdrawn - Send the value type(uint256).max in order to withdraw the whole xToken balance
to
address
The address that will receive the underlying, same as msg.sender if the user wants to receive it on his own wallet, or a different address if the beneficiary is a different wallet
Return Values
[0]
uint256
The final amount withdrawn
withdrawERC721
Withdraws multiple tokenIds
of underlying ERC721 asset from the reserve, burning the equivalent nTokens owned E.g. User has 2 nBAYC, calls withdraw() and receives 2 BAYC, burning the 2 nBAYC
Parameters
asset
address
The address of the underlying asset to withdraw
tokenIds
uint256[]
The underlying tokenIds to be withdrawn - Send the value type(uint256).max in order to withdraw the whole xToken balance
to
address
The address that will receive the underlying, same as msg.sender if the user wants to receive it on his own wallet, or a different address if the beneficiary is a different wallet
Return Values
[0]
uint256
The final amount withdrawn
decreaseUniswapV3Liquidity
Decreases liquidity for underlying Uniswap V3 NFT LP and validates that the user respects liquidation checks.
Parameters
asset
address
The asset address of uniswapV3
tokenId
uint256
The id of the erc721 token
liquidityDecrease
uint128
The amount of liquidity to remove of LP
amount0Min
uint256
The minimum amount to remove of token0
amount1Min
uint256
The minimum amount to remove of token1
receiveEthAsWeth
bool
If convert weth to ETH
borrow
Allows users to borrow a specific amount
of the reserve underlying asset, provided that the borrower already supplied enough collateral, or he was given enough allowance by a credit delegator on the corresponding debt token (VariableDebtToken)
E.g. User borrows 100 USDC passing as
onBehalfOf
his own address, receiving the 100 USDC in his wallet and 100 stable/variable debt tokens
Parameters
asset
address
The address of the underlying asset to borrow
amount
uint256
The amount to be borrowed
referralCode
uint16
The code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man
onBehalfOf
address
The address of the user who will receive the debt. Should be the address of the borrower itself calling the function if he wants to borrow against his own collateral, or the address of the credit delegator if he has been given credit delegation allowance
repay
Repays a borrowed amount
on a specific reserve, burning the equivalent debt tokens owned
E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the
onBehalfOf
address
Parameters
asset
address
The address of the borrowed underlying asset previously borrowed
amount
uint256
The amount to repay - Send the value type(uint256).max in order to repay the whole debt for asset
on the specific debtMode
onBehalfOf
address
The address of the user who will get his debt reduced/removed. Should be the address of the user calling the function if he wants to reduce/remove his own debt, or the address of any other other borrower whose debt should be removed
Return Values
[0]
uint256
The final amount repaid
repayWithPTokens
Repays a borrowed amount
on a specific reserve using the reserve xTokens, burning the equivalent debt tokens
E.g. User repays 100 USDC using 100 pUSDC, burning 100 variable/stable debt tokens
Passing uint256.max as amount will clean up any residual xToken dust balance, if the user xToken balance is not enough to cover the whole debt
Parameters
asset
address
The address of the borrowed underlying asset previously borrowed
amount
uint256
The amount to repay - Send the value type(uint256).max in order to repay the whole debt for asset
on the specific debtMode
Return Values
[0]
uint256
The final amount repaid
repayWithPermit
Repay with transfer approval of asset to be repaid done via permit function see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713
Parameters
asset
address
The address of the borrowed underlying asset previously borrowed
amount
uint256
The amount to repay - Send the value type(uint256).max in order to repay the whole debt for asset
on the specific debtMode
onBehalfOf
address
Address of the user who will get his debt reduced/removed. Should be the address of the user calling the function if he wants to reduce/remove his own debt, or the address of any other other borrower whose debt should be removed
deadline
uint256
The deadline timestamp that the permit is valid
permitV
uint8
The V parameter of ERC712 permit sig
permitR
bytes32
The R parameter of ERC712 permit sig
permitS
bytes32
The S parameter of ERC712 permit sig
Return Values
[0]
uint256
The final amount repaid
setUserUseERC20AsCollateral
Allows suppliers to enable/disable a specific supplied asset as collateral
Parameters
asset
address
The address of the underlying asset supplied
useAsCollateral
bool
True if the user wants to use the supply as collateral, false otherwise
setUserUseERC721AsCollateral
Allows suppliers to enable/disable a specific supplied ERC721 asset with a tokenID as collateral
Parameters
asset
address
The address of the underlying asset supplied
tokenIds
uint256[]
the ids of the supplied ERC721 token
useAsCollateral
bool
True if the user wants to use the supply as collateral, false otherwise
liquidateERC20
Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1
The caller (liquidator) covers
liquidationAmount
amount of debt of the user getting liquidated, and receives a proportionally amount of thecollateralAsset
plus a bonus to cover market risk
Parameters
collateralAsset
address
The address of the underlying asset used as collateral, to receive as result of the liquidation
liquidationAsset
address
The address of the underlying borrowed asset to be repaid with the liquidation
borrower
address
liquidationAmount
uint256
The debt amount of borrowed asset
the liquidator wants to cover
receivePToken
bool
True if the liquidators wants to receive the collateral xTokens, false
if he wants to receive the underlying collateral asset directly
liquidateERC721
startAuction
Start the auction on user's specific NFT collateral
Parameters
user
address
The address of the user
collateralAsset
address
The address of the NFT collateral
collateralTokenId
uint256
The tokenId of the NFT collateral
endAuction
End specific user's auction
Parameters
user
address
The address of the user
collateralAsset
address
The address of the NFT collateral
collateralTokenId
uint256
The tokenId of the NFT collateral
flashClaim
_Allows smart contracts to access the tokens within one transaction, as long as the tokens taken is returned.
Requirements:
nftTokenIds
must exist._
Parameters
receiverAddress
address
The address of the contract receiving the tokens, implementing the IFlashClaimReceiver interface
nftAsset
address
address of the underlying asset of NFT
nftTokenIds
uint256[]
token ids of the underlying asset
params
bytes
Variadic packed params to pass to the receiver as extra information
getReserveData
Returns the state and configuration of the reserve
Parameters
asset
address
The address of the underlying asset of the reserve
Return Values
[0]
struct DataTypes.ReserveData
The state and configuration data of the reserve
getConfiguration
Returns the configuration of the reserve
Parameters
asset
address
The address of the underlying asset of the reserve
Return Values
[0]
struct DataTypes.ReserveConfigurationMap
The configuration of the reserve
getUserConfiguration
Returns the configuration of the user across all the reserves
Parameters
user
address
The user address
Return Values
[0]
struct DataTypes.UserConfigurationMap
The configuration of the user
getReserveNormalizedIncome
Returns the normalized income normalized income of the reserve
Parameters
asset
address
The address of the underlying asset of the reserve
Return Values
[0]
uint256
The reserve's normalized income
getReserveNormalizedVariableDebt
Returns the normalized variable debt per unit of asset
Parameters
asset
address
The address of the underlying asset of the reserve
Return Values
[0]
uint256
The reserve normalized variable debt
getReservesList
Returns the list of the underlying assets of all the initialized reserves
It does not include dropped reserves
Return Values
[0]
address[]
The addresses of the underlying assets of the initialized reserves
getReserveAddressById
Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct
Parameters
id
uint16
The id of the reserve as stored in the DataTypes.ReserveData struct
Return Values
[0]
address
The address of the reserve associated with id
MAX_NUMBER_RESERVES
Returns the maximum number of reserves supported to be listed in this Pool
Return Values
[0]
uint16
The maximum number of reserves supported
AUCTION_RECOVERY_HEALTH_FACTOR
Returns the auction recovery health factor
Return Values
[0]
uint64
The auction recovery health factor
finalizeTransfer
Validates and finalizes an PToken transfer
Only callable by the overlying xToken of the asset
Parameters
asset
address
The address of the underlying asset of the xToken
from
address
The user from which the xTokens are transferred
to
address
The user receiving the xTokens
usedAsCollateral
bool
amount
uint256
The amount being transferred/withdrawn
balanceFromBefore
uint256
The xToken balance of the from
user before the transfer
balanceToBefore
uint256
The xToken balance of the to
user before the transfer
finalizeTransferERC721
Validates and finalizes an NToken transfer
Only callable by the overlying xToken of the asset
Parameters
asset
address
The address of the underlying asset of the xToken
tokenId
uint256
The tokenId of the ERC721 asset
from
address
The user from which the xTokens are transferred
to
address
The user receiving the xTokens
usedAsCollateral
bool
balanceFromBefore
uint256
The xToken balance of the from
user before the transfer
balanceToBefore
uint256
The xToken balance of the to
user before the transfer
getAuctionData
Returns the auction related data of specific asset collection and token id.
Parameters
ntokenAsset
address
The address of ntoken
tokenId
uint256
The token id which is currently auctioned for liquidation
Return Values
auctionData
struct DataTypes.AuctionData
The auction related data of the corresponding (ntokenAsset, tokenId)