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

uint256 POOL_REVISION

ADDRESSES_PROVIDER

contract IPoolAddressesProvider ADDRESSES_PROVIDER

Returns the PoolAddressesProvider connected to this contract

Return Values

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

constructor

constructor(contract IPoolAddressesProvider provider) public

Constructor.

Parameters

initialize

function initialize(contract IPoolAddressesProvider provider) external virtual

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

supply

function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external virtual

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

supplyERC721

function supplyERC721(address asset, struct DataTypes.ERC721SupplyParams[] tokenData, address onBehalfOf, uint16 referralCode) external virtual

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

supplyERC721FromNToken

function supplyERC721FromNToken(address asset, struct DataTypes.ERC721SupplyParams[] tokenData, address onBehalfOf) external virtual

Same as supplyERC721 but this can only be called by NToken contract and doesn't require sending the underlying asset.

Parameters

supplyWithPermit

function supplyWithPermit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode, uint256 deadline, uint8 permitV, bytes32 permitR, bytes32 permitS) external virtual

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

withdraw

function withdraw(address asset, uint256 amount, address to) external virtual returns (uint256)

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

Return Values

withdrawERC721

function withdrawERC721(address asset, uint256[] tokenIds, address to) external virtual returns (uint256)

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

Return Values

decreaseUniswapV3Liquidity

function decreaseUniswapV3Liquidity(address asset, uint256 tokenId, uint128 liquidityDecrease, uint256 amount0Min, uint256 amount1Min, bool receiveEthAsWeth) external virtual

Decreases liquidity for underlying Uniswap V3 NFT LP and validates that the user respects liquidation checks.

Parameters

borrow

function borrow(address asset, uint256 amount, uint16 referralCode, address onBehalfOf) external virtual

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

repay

function repay(address asset, uint256 amount, address onBehalfOf) external virtual returns (uint256)

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

Return Values

repayWithPTokens

function repayWithPTokens(address asset, uint256 amount) external virtual returns (uint256)

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

Return Values

repayWithPermit

function repayWithPermit(address asset, uint256 amount, address onBehalfOf, uint256 deadline, uint8 permitV, bytes32 permitR, bytes32 permitS) external virtual returns (uint256)

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

Return Values

setUserUseERC20AsCollateral

function setUserUseERC20AsCollateral(address asset, bool useAsCollateral) external virtual

Allows suppliers to enable/disable a specific supplied asset as collateral

Parameters

setUserUseERC721AsCollateral

function setUserUseERC721AsCollateral(address asset, uint256[] tokenIds, bool useAsCollateral) external virtual

Allows suppliers to enable/disable a specific supplied ERC721 asset with a tokenID as collateral

Parameters

liquidateERC20

function liquidateERC20(address collateralAsset, address liquidationAsset, address borrower, uint256 liquidationAmount, bool receivePToken) external payable virtual

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 the collateralAsset plus a bonus to cover market risk

Parameters

liquidateERC721

function liquidateERC721(address collateralAsset, address borrower, uint256 collateralTokenId, uint256 maxLiquidationAmount, bool receiveNToken) external payable virtual

startAuction

function startAuction(address user, address collateralAsset, uint256 collateralTokenId) external

Start the auction on user's specific NFT collateral

Parameters

endAuction

function endAuction(address user, address collateralAsset, uint256 collateralTokenId) external

End specific user's auction

Parameters

flashClaim

function flashClaim(address receiverAddress, address nftAsset, uint256[] nftTokenIds, bytes params) external virtual

_Allows smart contracts to access the tokens within one transaction, as long as the tokens taken is returned.

Requirements:

  • nftTokenIds must exist._

Parameters

getReserveData

function getReserveData(address asset) external view virtual returns (struct DataTypes.ReserveData)

Returns the state and configuration of the reserve

Parameters

Return Values

getConfiguration

function getConfiguration(address asset) external view virtual returns (struct DataTypes.ReserveConfigurationMap)

Returns the configuration of the reserve

Parameters

Return Values

getUserConfiguration

function getUserConfiguration(address user) external view virtual returns (struct DataTypes.UserConfigurationMap)

Returns the configuration of the user across all the reserves

Parameters

Return Values

getReserveNormalizedIncome

function getReserveNormalizedIncome(address asset) external view virtual returns (uint256)

Returns the normalized income normalized income of the reserve

Parameters

Return Values

getReserveNormalizedVariableDebt

function getReserveNormalizedVariableDebt(address asset) external view virtual returns (uint256)

Returns the normalized variable debt per unit of asset

Parameters

Return Values

getReservesList

function getReservesList() external view virtual returns (address[])

Returns the list of the underlying assets of all the initialized reserves

It does not include dropped reserves

Return Values

getReserveAddressById

function getReserveAddressById(uint16 id) external view returns (address)

Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct

Parameters

Return Values

MAX_NUMBER_RESERVES

function MAX_NUMBER_RESERVES() external view virtual returns (uint16)

Returns the maximum number of reserves supported to be listed in this Pool

Return Values

AUCTION_RECOVERY_HEALTH_FACTOR

function AUCTION_RECOVERY_HEALTH_FACTOR() external view virtual returns (uint64)

Returns the auction recovery health factor

Return Values

finalizeTransfer

function finalizeTransfer(address asset, address from, address to, bool usedAsCollateral, uint256 amount, uint256 balanceFromBefore, uint256 balanceToBefore) external virtual

Validates and finalizes an PToken transfer

Only callable by the overlying xToken of the asset

Parameters

finalizeTransferERC721

function finalizeTransferERC721(address asset, uint256 tokenId, address from, address to, bool usedAsCollateral, uint256 balanceFromBefore, uint256 balanceToBefore) external virtual

Validates and finalizes an NToken transfer

Only callable by the overlying xToken of the asset

Parameters

getAuctionData

function getAuctionData(address ntokenAsset, uint256 tokenId) external view virtual returns (struct DataTypes.AuctionData auctionData)

Returns the auction related data of specific asset collection and token id.

Parameters

Return Values

onERC721Received

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

receive

receive() external payable