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.

Method

deposit

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.

call params

depositNFTs

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.

call params

withdraw

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.

call params

withdrawNFTs

  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.

call params

borrow

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.

call params

repay

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.

liquidate

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.

call params

View Method

getReserveNormalizedLiquidityScale

  function getReserveNormalizedLiquidityScale(
    address asset
  ) external view virtual override returns (uint256)

Returns the normalized income of the reserve.

getReserveNormalizedDebtScale

  function getReserveNormalizedDebtScale(
    address asset
  ) external view virtual override returns (uint256) 

Returns the normalized variable debt per unit of asset.

getReserveData

  function getReserveData(
    address asset
  ) external view override returns (Reserve.ReserveData memory) 

Returns the state and configuration of the reserve.

return value

getNftReserveData

  function getNftReserveData(
    address asset
  ) external view override returns (NFTReserve.ReserveData memory)

Returns the state and configuration of the NFT reserve.

return value

getReservesList

function getReservesList() external view returns (address[] memory, address[] memory)

Returns the underlying address list of the initialized reserves and the NFT reserves.

getReserveConfiguration

  function getReserveConfig(
    address asset,
    bool isNft
  ) external view override returns (ReserveConfiguration)

Returns the configuration of the reserve.

call params

getUserConfig

  function getUserConfig(
    address user
  ) external view override returns (UserConfiguration, UserNftConfiguration) 

Returns the configuration of the user.

getPoolValues

  function getPoolValues() external view override returns (uint256, uint256, uint256)

Return the borrowable liquidity, NFT liquidity and borrowable debt.

getAssetValues

function getAssetValues(address asset) external view override returns (uint256, uint256)

Return the liquidity in ETH and the debt in ETH.

getUserState

  function getUserState(
    address user
  ) external view override returns (UserVariableCalculator.StateVar memory)

Return the state and Configurator of the user.

return value

getUserAssetValues

  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 updated