Lending

Overview

Lending on Fulcrum is powered by iTokens, which are global lending pools. Each asset has a single iToken equivalent (ETH as iETH, DAI has iDAI, etc.), and has an independent interest rate paid to lenders who have deposited funds to the contract. The interest earned is proportional to the amount of iToken held by each lender. iTokens are minted by transferring the underlying asset to the contract, calling mint, and receiving back an equivalent amount of the iToken (ERC20) at the current iToken price. iTokens have an on-chain API to query current "redemption value" (tokenPrice()), as well the interest rates paid by borrowers and paid to lenders.

State-Changing Functions

mint(address,uint256)

1
function mint(
2
address receiver,
3
uint256 depositAmount)
4
external
5
returns (uint256 mintAmount);
Copied!
Called to deposit assets to the iToken, which in turn mints iTokens to the lender’s wallet at the current tokenPrice() rate. A prior ERC20 “approve” transaction should have been sent to the asset token for an amount greater than or equal to depositAmount. The receiver address specifies the address that will receive the minted iTokens. Note: The asset token address for an iToken is returned by the loanTokenAddress() function. For iETH contracts, the expected underlying asset is WETH.

mintWithEther(address)

1
function mintWithEther(
2
address receiver)
3
external
4
payable
5
returns (uint256 mintAmount);
Copied!
(iETH only) This accepts ETH sent directly to the iETH contract for minting iETH tokens.

burn(address,uint256)

1
function burn(
2
address receiver,
3
uint256 burnAmount)
4
external
5
returns (uint256 loanAmountPaid);
Copied!
Called to redeem owned iTokens for an equivalent amount of the underlying asset, at the current tokenPrice() rate. The receiver address specifies the address that will receive the asset proceeds.

burnToEther(address)

1
function burnToEther(
2
address payable receiver,
3
uint256 burnAmount)
4
external
5
returns (uint256 loanAmountPaid);
Copied!
(iETH only) Called to redeem owned iTokens similar to the above, but for an equivalent amount of ETH.

claimLoanToken()

1
function claimLoanToken()
2
external
3
returns (uint256 claimedAmount);
Copied!
In the event that there isn't available (un-borrowed) liquidity after a burn() function is called, the lender is entered into a "reserve" queue to be automatically paid back as liquidity becomes freed from borrowers, when borrowers close their positions or a position gets liquidated. At anytime, a lender can call this function to claim any available funds owed to them, and to put them in the front of the reserve queue.

Coming soon: New and improved functions for borrowing

Read-Only Functions

tokenPrice()

1
function tokenPrice()
2
public
3
view
4
returns (uint256 price);
Copied!
Returns the current price of the iToken. Example 1000000000000000000 = 1 ETH per iToken.

checkpointPrice(address)

1
function checkpointPrice(
2
address _user)
3
public
4
view
5
returns (uint256 price);
Copied!
Returns the token price recorded during the last checkpoint for the user. Checkpoints occur whenever there is a token balance changing action taken by the user (minting, burning, transferring, or claiming). A user profit since last checkpoint would be calculated like so: (tokenPrice()-checkpointPrice(user)) * balanceOf(user) / 10^36

totalReservedSupply()

1
function totalReservedSupply()
2
public
3
view
4
returns (uint256);
Copied!
Returns amount of assets that are reserved for redemption by lenders and unavailable for future borrowing. Some or all of these funds may still be locked in current loans.

marketLiquidity()

1
function marketLiquidity()
2
public
3
view
4
returns (uint256);
Copied!
Returns amount of assets available for borrowing from the iToken lending pool (totalAssetSupply()-totalAssetBorrow())

borrowInterestRate()

1
function borrowInterestRate()
2
public
3
view
4
returns (uint256);
Copied!
Returns the minimum rate the next borrower will receive for variable-rate loans.

nextBorrowInterestRate(uint256)

1
function nextBorrowInterestRate(
2
uint256 borrowAmount)
3
public
4
view
5
returns (uint256);
Copied!
Returns the rate the next borrower will receive for variable-rate loans, based on amount borrowed.

nextBorrowInterestRateWithOption(uint256,bool)

1
function nextBorrowInterestRateWithOption(
2
uint256 borrowAmount,
3
bool useFixedInterestModel)
4
public
5
view
6
returns (uint256);
Copied!
Returns the rate the next borrower will receive for variable or fixed-rate loans, based on amount borrowed,

avgBorrowInterestRate()

1
function avgBorrowInterestRate()
2
public
3
view
4
returns (uint256);
Copied!
Returns the aggregate rate that all borrowers are paying to lenders.

supplyInterestRate()

1
function supplyInterestRate()
2
public
3
view
4
returns (uint256);
Copied!
Returns the aggregate rate that all lenders are receiving from borrowers. The supplyInterestRate() will always be less than the avgBorrowInterestRate(). Please refer to the Interest Determination section of the Fulcrum announcement article for additional information.

nextSupplyInterestRate(uint265)

1
function nextSupplyInterestRate(
2
uint256 supplyAmount)
3
public
4
view
5
returns (uint256);
Copied!
Returns the interest rate that lenders will be paying after a lender makes a new deposit.

totalAssetSupply()

1
function totalAssetSupply()
2
public
3
view
4
returns (uint256);
Copied!
Returns the total amount assets currently being supplied for lending, which includes earned interest.

totalAssetBorrow()

1
function totalAssetBorrow()
2
public
3
view
4
returns (uint256);
Copied!
Returns the total amount assets currently borrowed in active loans.

getMaxEscrowAmount(uint256)

1
function getMaxEscrowAmount(
2
uint256 leverageAmount)
3
public
4
view
5
returns (uint256);
Copied!
Returns the maximum amount of escrow the borrower can submit to open a loan for a given leverageAmount.

getBorrowAmount(uint256,uint256,bool)

1
function getBorrowAmount(
2
uint256 escrowAmount,
3
uint256 leverageAmount,
4
bool withdrawOnOpen)
5
public
6
view
7
returns (uint256);
Copied!
Returns the amount of loan principal received for a given borrower escrow amount and leverageAmount. A TRUE value for withdrawOnOpen indicates the loan will be over-collateralized and withdrawable to the borrower’s private wallet.

getLoanData(uint256)

1
struct LoanData {
2
bytes32 loanOrderHash;
3
uint256 leverageAmount;
4
uint256 initialMarginAmount;
5
uint256 maintenanceMarginAmount;
6
uint256 index;
7
}
8
9
function getLoanData(
10
uint256 levergeAmount)
11
public
12
view
13
returns (LoanData memory);
Copied!
Returns a LoanData object with data for a given leverageAmount.

getLeverageList()

1
function getLeverageList()
2
public
3
view
4
returns (uint256[] memory);
Copied!
Returns a list of leverage amounts supported by the iToken. An example leverage: 2000000000000000000 = 2x leverage

assetBalanceOf(address)

1
function assetBalanceOf(
2
address _owner)
3
public
4
view
5
returns (uint256);
Copied!
Returns the user’s balance of the underlying asset. This is the same as multiplying the user’s token balance by the token price.
Last modified 2yr ago