LendPoolLoan

LendPoolLoan.sol

The LendPoolLoan is called by the LendPool and does everything related to loans and collaterals.

View Methods

function borrowerOf(uint256 loanId) external view returns (address)

Returns the address of the borrower.

Call Params

Return Values

getCollateralLoanId

function getCollateralLoanId(address nftAsset, uint256 nftTokenId) external view returns (uint256)

Returns the loan id corresponding to a specific nftAsset and nftTokenId

Call Params

Return Values

getLoanIdTracker

function getLoanIdTracker() external view returns (struct CountersUpgradeable.Counter)

Returns the counter tracker for all the loan IDs in the protocol

Return Values

getUserNftCollateralAmount

function getUserNftCollateralAmount(address user, address nftAsset) external view returns (uint256)

Returns the collateral amount for a given user and a specific NFT collection.

Call Params

Return Values

getNftCollateralAmount

function getNftCollateralAmount(address nftAsset) external view returns (uint256)

Returns the collateral amount for a specific collection.

Call Params

Return Values

getLoanHighestBid

function getLoanHighestBid(uint256 loanId) external view returns (address, uint256)

Returns the address and the bid price of the highest bid during an auction.

Call Params

Return Values

getLoanReserveBorrowScaledAmount

function getLoanReserveBorrowScaledAmount(uint256 loanId) external view returns (address, uint256)

Returns the scaled amount and the reserve asset for a specific loan.

Call Params

Return Values

getLoanReserveBorrowAmount

function getLoanReserveBorrowAmount(uint256 loanId) external view returns (address, uint256)

Returns the amount borrowed and the reserve address for a specific loan.

Call Params

Return Values

getLoanCollateralAndReserve

function getLoanCollateralAndReserve(uint256 loanId) external view returns (address nftAsset, uint256 nftTokenId, address reserveAsset, uint256 scaledAmount)

Returns the NFT address, tokenId, reserve address and scaled amount for a specific loan.

Call Params

Return Values

getLoan

function getLoan(uint256 loanId) external view returns (struct DataTypes.LoanData loanData)

Returns the struct containing all the info regarding a specific loan.

Call Params

Return Values

Write Methods

createLoan

function createLoan(address initiator, address onBehalfOf, address nftAsset, uint256 nftTokenId, address uNftAddress, address reserveAsset, uint256 amount, uint256 borrowIndex) external returns (uint256)

Create and store the loan, and mint the uNFT to the user as proof of deposit.

Call Params

Return Values

updateLoan

function updateLoan(address initiator, uint256 loanId, uint256 amountAdded, uint256 amountTaken, uint256 borrowIndex) external

It updates an existing loan.

The caller must be a holder of the loan.

The loan must be in an active state

Call Params

repayLoan

function repayLoan(address initiator, uint256 loanId, address uNftAddress, uint256 amount, uint256 borrowIndex) external

It will repay the given loan, partially or in whole.

The caller must be a holder of the loan.

The caller must send in principal + interest.

The loan must be in an active state.

Call Params

auctionLoan

function auctionLoan(address initiator, uint256 loanId, address onBehalfOf, uint256 bidPrice, uint256 borrowAmount, uint256 borrowIndex) external

It will start and run an auction at a given loan.

The price must be greater than the current highest price.

The loan must be in an active or auction state.

Call Params

redeemLoan

function redeemLoan(address initiator, uint256 loanId, uint256 amountTaken, uint256 borrowIndex) external

If the loan is in an auction state, and the owner wants to pay it back, making the health factor go above 1.

The caller must be a holder of the loan.

The loan must be in an auction state.

redeemLoan = auction state.

repayLoan = active state.

Call Params

liquidateLoan

function liquidateLoan(address initiator, uint256 loanId, address uNftAddress, uint256 borrowAmount, uint256 borrowIndex) external

Liquidate the given loan, sending the NFT to its new owner.

The caller must send in principal + interest.

The loan must be in an active state.

Call Params

buyoutLoan

function buyoutLoan(address initiator, uint256 loanId, address uNftAddress, uint256 borrowAmount, uint256 borrowIndex, uint256 buyoutAmount) external override onlyLendPool

Will clear the borrower's debt, pay the protocol and send the NFT to the new owner.

Call Params

liquidateLoanMarket

function liquidateLoanMarket(uint256 loanId, address uNftAddress, uint256 borrowAmount, uint256 borrowIndex) external override onlyMarketAdapter

It will liquidate the NFTs in case of no bids or not enough amount in bids (compared to the markets using the reservoir adapter) when an auction is created.

Call Params

Last updated