LendingPool
The LendingPool contract is the main contract of the protocol. It exposes all the user-oriented actions that can be invoked using either Solidity or web3 libraries.
LendingPool methods deposit, depositNFTs, borrow, withdraw, withdrawNFTs, repay and liquidate are only for ERC20 and ERC721, if you want to deposit, depositNFTs, borrow, withdraw, withdrawNFTs or liquidate using native ETH use WETHGateway instead, and if you want to borrow or repay using CryptoPunks as collaterals use PunkGateway.
function deposit(
address asset,
uint256 amount,
address to
)
Deposits an
amount
of underlying asset into the reserve, receiving in return overlying TTokens. E.g. User deposits 10 ETH and gets in return 10 ETH_TTOKEN.Name | Type | Description |
---|---|---|
asset | address | The address of the underlying asset to deposit |
amount | uint256 | The underlying amount to be deposited, expressed in underlying asset decimals units |
to | address | address whom will receive the TTokens. |
function depositNFTs(
address[] calldata nfts,
uint256[] calldata tokenIds,
uint256[] calldata amounts,
address to
)
Deposits a underlying NFT asset into the NFT reserve, receiving in return overlying TERC721. E.g. User deposit 1 Azuki and gets in return 1 Azuki_TNFT.
Name | Type | Description |
---|---|---|
nfts | address[] | the address of the NFTs to be deposited. |
tokenIds | uint256[] | the token ids to be deposited. |
amounts | uint256[] | the amounts to be deposited. if it is ERC721, amount is 1. |
to | address | the address that will receive tNFT. |
function withdraw(
address asset,
uint256 amount,
address to
)
Withdraws an amount of underlying asset from the reserve, burning the equivalent TTokens owned. E.g. User withdraws 10 ETH and burns 10 ETH_TTOKEN.
Name | Type | Description |
---|---|---|
asset | address | The address of the underlying asset to deposit |
amount | uint256 | The underlying amount to be withdrawn, expressed in underlying asset decimals units |
to | address | 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. |
function withdrawNFTs(
address[] calldata nfts,
uint256[] calldata tokenIds,
uint256[] calldata amounts,
address to
)
Withdraws an underlying NFT asset from the NFT reserve, burning the overlying TERC721 owned. E.g. User withdraws 1 Azuki and burns 1 Azuki_TNFT.
Name | Type | Description |
---|---|---|
nfts | address[] | the address of the NFTs to be withdrawn. |
tokenIds | uint256[] | the token ids to be withdrawn. |
amounts | uint256[] | the amounts to be withdrawn. if it is ERC721, amount is 1. |
to | address | the address that will receive the underlying. |
function borrow(
address asset,
uint256 amount,
address from
)
Allows users to borrow a specific amount of the reserve underlying asset. E.g. User borrows 10 ETH, receiving the 10 ETH in his wallet and lock collateral asset in contract.
Name | Type | Description |
---|---|---|
asset | address | The address of the underlying asset to borrow |
amount | uint256 | The underlying amount to be borrowed, expressed in underlying asset decimals units |
from | address | the address that executes borrow |
function repay(address asset, uint256 amount, address to) external override returns (uint256)
Repays a borrowed amount on a specific reserve, burning the equivalent loan owned. E.g. User repays 10 ETH, burning loan.
Name | type | description |
---|---|---|
asset | address | the address of the underlying asset to repay. |
amount | uint256 | the amount to repay. |
to | address | the address that will receive the underlying. |
function liquidate(
address nft,
uint256 tokenId,
address debt,
address user,
address to,
bool receiveTNFT
)
Function to liquidate a non-healthy NFT loan. The caller (liquidator) buys collateral asset of the user getting liquidated and receives the collateral asset.
Name | Type | Description |
---|---|---|
nft | address | the address of the underlying NFT used as collateral. The nft to liquidate. |
tokenId | uint256 | the token ID of the underlying NFT used as collateral. The token id to liquidate. |
debt | address | the address of the underlying asset for debt. |
user | address | the address of borrower. |
to | address | the address that will receive the collateral. |
receiveTNFT | address | receive the TNFT or the underlying NFT. |
function getReserveNormalizedLiquidityScale(
address asset
) external view virtual override returns (uint256)
Returns the normalized income of the reserve.
function getReserveNormalizedDebtScale(
address asset
) external view virtual override returns (uint256)
Returns the normalized variable debt per unit of asset.
function getReserveData(
address asset
) external view override returns (Reserve.ReserveData memory)
Returns the state and configuration of the reserve.
Name | Type | Description |
---|---|---|
configuration | ReserveConfiguration | the reserve configuration |
liquidityIndex | uint128 | the liquidity index. Expressed in ray |
debtIndex | uint128 | variable borrow index. Expressed in ray |
depositRate | uint128 | the current supply rate. Expressed in ray |
borrowRate | uint128 | the current variable borrow rate. Expressed in ray |
lastUpdateTimestamp | uint40 | |
tTokenAddress | address | TToken addresses of reserve |
debtTokenAddress | address | debtToken addresses of reserve |
interestRateCalculatorAddress | address | address of the interest rate calculator |
treasury | address | address of the treasury |
id | uin8 | the id of the reserve. Represents the position in the list of the active reserves. |
function getNftReserveData(
address asset
) external view override returns (NFTReserve.ReserveData memory)
Returns the state and configuration of the NFT reserve.
Parameter | Type | Description |
---|---|---|
configuration | ReserveConfiguration | the nft reserve configuration |
tNFTAddress | address | address for tNFT. |
id | uint8 | the id of the nft reserve. |
function getReservesList() external view returns (address[] memory, address[] memory)
Returns the underlying address list of the initialized reserves and the NFT reserves.
function getReserveConfig(
address asset,
bool isNft
) external view override returns (ReserveConfiguration)
Returns the configuration of the reserve.
Name | type | description |
---|---|---|
asset | address | the underlying address of the reserve. |
isNft | bool | a nft assert or not. |
function getUserConfig(
address user
) external view override returns (UserConfiguration, UserNftConfiguration)
Returns the configuration of the user.
function getPoolValues() external view override returns (uint256, uint256, uint256)
Return the borrowable liquidity, NFT liquidity and borrowable debt.
function getAssetValues(address asset) external view override returns (uint256, uint256)
Return the liquidity in ETH and the debt in ETH.
function getUserState(
address user
) external view override returns (UserVariableCalculator.StateVar memory)
Return the state and Configurator of the user.
Name | type | description |
---|---|---|
borrowableLiq | uint256 | the borrowing power left in ETH of these NFTs. |
nftLiq | uint256 | the nft liquidity in ETH. |
totalCollateralInETH | uint256 | the total collateral in ETH of these NFTs. |
totalDebtInETH | uint256 | the current borrowed debt of these NFTs. |
ltv | uint256 | the loan to value of the user, that is collateral ration. |
function getUserAssetValues(
address user,
address asset
) external view override returns (uint256, uint256, uint256)
Return the current supply, the current borrowed debt and the total collateral in ETH of these NFTs.
Last modified 4mo ago