LendingPool

The LendingPool contract is the main contract for user interaction. It exposes all user-oriented actions and can be invoked by Solidity or web3 libraries.

Methods

initReserve()​

function initReserve(ConfigTypes.InitReserveInput input, address fToken, address stableDebtToken, address variableDebtToken)​

Initialises a reserve.

Parameter Name
Type
Description

input

ConfigTypes.InitReserveInput

The init reserve input parameters

fToken

address

fToken proxy address

stableDebtToken

address

stableDebtToken proxy address

variableDebtToken

address

variableDebtToken proxy address

deposit()

function deposit(uint256 amount, uint256 reserveId, address onBehalfOf, uint16 referralCode)​

Deposits assets into the lending pool.

Parameter Name
Type
Description

amount

uint256

amount deposited, expressed in wei units

reserveId

uint256

id of the targeted reserve

onBehalfOf

address

address whom will receive the fTokens. Use msg.sender when the fTokens should be sent to the caller.

referralCode

uint256

referral code for our referral program. 0 for no referral.

batchDeposit()

function batchDeposit(uint256[] calldata amounts, uint256[] reserveIds, address[] calldata onBehalfOfs, uint16[] referralCodes)

Batches deposits of assets across lending pools.

Parameter Name
Type
Description

amounts

uint256[] calldata

amounts deposited, expressed in wei units

reserveIds

uint256[] calldata

ids of the targeted reserves

onBehalfOfs

address[] calldata

addresses whom will receive the fTokens

referralCodes

uint256[] calldata

referral codes for our referral program

withdraw()

function withdraw(uint256 amount, uint256 reserveId, address to)

Withdraws assets from the lending pool.

Parameter Name
Type
Description

amount

uint256

amount withdrawn, expressed in wei units

reserveId

uint256

id of the targeted reserve

to

address

address to receive the underlying asset tokens

batchWithdraw()

function batchWithdraw(uint256[] calldata amounts, uint256[] calldata reserveIds, address[] calldata tos)

Batches withdraws of assets across lending pools.

Parameter Name
Type
Description

amounts

uint256[] calldata

amounts withdrawn, expressed in wei units

reserveIds

uint256[] calldata

ids of the targeted reserves

tos

address[] calldata

addresses to receive the underlying asset tokens

borrow()

function borrow(uint256 amount, uint256 tokenId, uint256 tokenValue, uint256 reserveId, uint256 duration, address onBehalfOf, uint16 referralCode)​

Creates a borrow position.

Parameter Name
Type
Description

amount

uint256

amount borrowed, expressed in wei units

tokenId

uint256

tokenId of the NFT to be deposited

tokenValue

uint256

number of ERC1155 tokens supplied, 0 implies ERC721

reserveId

uint256

id of the targeted reserve

duration

uint256

duration of the loan, 0 implies open-ended

onBehalfOf

address

address to receive the loan

referralCode

uint16

referral codes for our referral program

batchBorrow()

function batchBorrow(uint256[] calldata amounts, uint256[] calldata tokenIds, uint256[] calldata tokenValues, uint256[] calldata reserveIds, uint256 duration, address onBehalfOf, uint16 referralCode)​

Batches borrow position execution. Note, only single duration batches are supported.

Parameter Name
Type
Description

amounts

uint256[] calldata

amounts borrowed, expressed in wei units

tokenIds

uint256[] calldata

tokenId sof the NFTs to be deposited

tokenValues

uint256[] calldata

numbers of ERC1155 tokens supplied, 0 implies ERC721

reserveIds

uint256[] calldata

ids of the targeted reserves

duration

uint256

duration of the loan, 0 implies open-ended

onBehalfOf

address

address to receive the loan

referralCode

uint16

referral codes for our referral program

repay()

function repay(uint256 borrowId, uint256 amount)​

Repays a borrow position.

Parameter Name
Type
Description

borrowId

uint256

id of the targeted borrow

amount

uint256

amount to be repaid, expressed in wei

batchRepay()

function batchRepay(uint256[] calldata borrowIds, uint256[] calldata amounts)​

Batch repays borrow positions.

Parameter Name
Type
Description

borrowIds

uint256[] calldata

ids of the targeted borrows

amounts

uint256[] calldata

amounts to be repaid, expressed in wei

refinance()

function refinance(uint256 borrowId, uint256 amount, uint256 duration)​

Refinances a borrow position.

If the refinance amount is less than the current loan amount this is treated as a partial repayment with the difference being requested for transfer from the borrower's wallet.

If the refinance amount is more than the current loan amount then this debt is added to their balance and the additional funds are sent to their wallet.

Parameter Name
Type
Description

borrowId

uint256

id of the targeted borrow

amount

uint256

refinanced loan amount, expressed in wei

duration

uint256

duration of the refinanced loan, 0 for open-ended

batchRefinance()

function batchRefinance(uint256[]calldata borrowIds, uint256[]calldata amounts, uint256[]calldata durations)​

Batches refinancing of borrow positions.

Parameter Name
Type
Description

borrowIds

uint256[] calldata

ids of the targeted borrows

amounts

uint256[] calldata

refinanced loan amounts, expressed in wei

durations

uint256[] calldata

duration of the refinanced loan, 0 for open-ended

auction()

function auction(uint256 borrowId, address onBehalfOf)​

Triggers a liquidation auction on a loan in default.

Parameter Name
Type
Description

borrowId

uint256

id of the targeted borrow

onBehalfOf

address

address to receive the auction caller bonus

batchAuction()

function batchAuction(uint256[] calldata borrowIds, address[] calldata onBehalfOfs)​

Batch triggers liquidation auctions on loans in default.

Parameter Name
Type
Description

borrowIds

uint256[] calldata

ids of the targeted borrows

onBehalfOfs

address[] calldata

addresses to receive the auction caller bonuses

bid()

function bid(uint256 borrowId, address onBehalfOf)​

Purchases the underlying NFT of a loan under auction.

Parameter Name
Type
Description

asset

address

address of the asset used for payment

amount

uint256

amount to be paid, expressed in wei

borrowId

uint256

id of the targeted borrow

onBehalfOf

address

address to receive the underlying NFT

batchBid()

function batchBid(uint256[] calldata borrowIds, address[] calldata onBehalfOfs)​

Batch purchases the underlying NFTs of loans under auction.

Parameter Name
Type
Description

assets

address[] calldata

addresses of the assets used for payment

amounts

uint256[] calldata

amounts to be paid, expressed in wei

borrowIds

uint256[] calldata

ids of the targeted borrows

onBehalfOfs

address[] calldata

addresses to receive the underlying NFTs

setMaxNumberOfReserves()

function setMaxNumberOfReserves(uint256 val)​

Sets the max number of reserves.

Parameter Name
Type
Description

val

uint256

max number of reserves

setReserveMaxSupply()

function setReserveMaxSupply(uint256 reserveId, uint256 maxTokenSupply)​

Sets the max number of NFTs that can be used as collateral within a reserve.

Parameter Name
Type
Description

reserveId

uint256

id of the targeted reserve

maxTokenSupply

uint256

max number of NFTs that can be used as collateral

setReserveInterestRateAddress()

function setReserveInterestRateAddress(uint256 reserveId, address rateAddress)​

Sets the interest rate model strategy for a reserve.

Parameter Name
Type
Description

reserveId

uint256

id of the targeted reserve

rateAddress

address

address of the interest rate model strategy

setReserveConfiguration()

function setReserveConfiguration(uint256 reserveId, uint256 reserveConfiguration)​

Sets the configuration bitmap of a reserve.

Parameter Name
Type
Description

reserveId

uint256

id of the targeted reserve

configuration

uint256

new configuration bitmap

setReserveCreatorAddress()

function setReserveCreatorAddress(uint256 reserveId, address creator)​

Sets the creator address for a reserve

Parameter Name
Type
Description

reserveId

uint256

id of the targeted reserve

creator

address

address for the creator

setReserveCreatorPercentage()

function setReserveCreatorPercentage(uint256 reserveId, uint256 percentage)​

Sets the percentage of protocol fees that go to the creator.

Parameter Name
Type
Description

reserveId

uint256

id of the targeted reserve

percentage

uint256

percentage in percentage-maths: e.g. 5000 for 50%

setPause()

function setPause(bool val)​

Sets the pause state of the lending pool

Parameter Name
Type
Description

val

bool

true if paused

setPausedTime()

function setPausedTime(uint256 startTime, uint256 duration)​

Sets the pause state of the lending pool for a given start time and duration.

Parameter Name
Type
Description

startTime

uint256

pause start time

duration

uint256

pause duration

View Methods

paused()

function paused()

Returns true if the lending pool is paused.

getPausedTime()

function getPausedTime()

Returns the start and duration of the lending pool pause time.

Return values

Parameter Name
Type
Description

startTime

uint256

Paused start time

duration

uint256

Paused duration

getAddressProvider()

function getAddressProvider()

Returns the address provider.

getMaxNumberOfReserves()

function getMaxNumberOfReserves()

Returns the maximum number of reserves

getReserve()

function getReserve(uint256 reserveId)

Returns the state and configuration of the reserve.

Return values

Parameter Name
Type
Description

configuration

uint256

Uses a bitmask. bit 16-31: Liq. threshold

bit 32-47: Liq. bonus

bit 48-55: Decimals

bit 56: Reserve is active

bit 57: reserve is frozen

bit 58: borrowing is enabled

bit 59: variable rate borrowing enabled

bit 60-63: reserved

bit 64-79: reserve factor

bit 80-95: grace period

bit 96-111: auction duration

bit 112-127: auction start price multiple *All % are 1e4, ie. percentage plus two decimals

collateral

address

address of NFT permitted as collateral

asset

address

address of asset avaiable to be borrowed

fTokenAddress

address

address of fToken proxy contract

stableDebtTokenAddress

address

address of stableDebtToken proxy contract

variableDebtTokenAddress

address

address of variableDebtToken proxy contract

interestRateAddress

address

address of interest rate strategy model

assetPriceFeed

string

name of Chainlink Oracle price feed

id

uint256

id of the reserve

maxTokenSupply

uint256

max token supply that can be used as collateral

maxTokenId

uint256

max token id that can be used as collateral

minTokenId

uint256

min tokne id that can be used as collateral

liquidityIndex

uint128

liquidity index in ray

variableBorrowIndex

uint128

variable borrow index in ray

currentLiquidityRate

uint128

current supply / liquidity / deposit rate in ray

currentVariableBorrowRate

uint128

current variable borrow rate in ray

lastUpdateTimestamp

uint40

timestamp of when reserve data was last updated

getReserveId()

function getReserveId(address collateral, address asset, uint256 maxTokenId, uint256 minTokenId)

Returns the id of the associated reserve.

Return values

getReserveConfiguration()

function getReserveConfiguration(uint256 reserveId)

Returns the configuration of a reserve.

Return values

Parameter Name
Type
Description

configuration

DataTypes.ReserveConfigurationMap memory

configuration of the reserve

getReserveNormalizedIncome()

function getReserveNormalizedIncome(uint256 reserveId)

Returns the normalised income of a reserve.

getReserveNormalizedVariableDebt()

function getReserveNormalizedVariableDebt(uint256 reserveId)

Returns the normalised variable debt of a reserve.

getReserveUserStableRate()

function getReserveUserStableRate(uint256 reserveId, address user)

Returns a reserve user stable rate.

getReserveFlags()

function getReserveFlags(uint256 reserveId)

Returns the reserve flags.

Return values

Parameter Name
Type
Description

activeReserve

bool

true if reserve is active

frozenReserve

bool

true if reserve is frozen

borrowingEnabled

bool

true if borrowing is enabled on the reserve

variableBorrowEnabled

bool

true if variable rate borrowing is enabled

getReservesList()

function getReservesList()

Returns a list of reserve ids.

getInitializedCollaterals()

function getInitializedCollaterals()

Returns a list of addresses of initialized collaterals.

getInitializedAssets()

function getInitializedAssets()

Returns a list of addresses of initialized assets.

getBorrowHealthFactor()

function getborrowHealthFactor(uint256 borrowId)

Returns the collateral price, borrow amount and health factor for a given borrow id.

Return values

Parameter Name
Type
Description

collateralPrice

uint256

the current appraised price of the collateral

borrowAmount

uint256

the amount borrowed against the collateral

healthFactor

uint256

the current health factor of the borrow

getAuctionConfiguration()

function getAuctionConfiguration(uint256 reserveId)

Returns the auction liquidation bonus and duration.

Return values

Parameter Name
Type
Description

liquidationBonus

uint256

the percentage of the auction going to stakeholders, e.g. 1000 for 10%

duration

uint256

the auction duration in days

finalizeTransfer()

function finalizeTransfer(uint256 reserveId, address from, address to, uint256 amount, uint256 balanceFromBefore, uint256 balanceToBefore)

Validates and finalises an fToken transfer.

Storage

Inherited contract LendingPoolStorage.sol is used to maintain state, separating this from the Lending Pool contract. This follows specific guidelines for the process of adding new variables; to ensure compatibility and upgradability.

Error Codes

In order to reduce gas usage and code size, FluidNFT contracts return numbered errors. If you are making calls to the protocol and receive numb

ABI

LendingPool ABI

Last updated