Pool
Pool
The pool.sol
contract is the main user facing contract of the protocol. It exposes the liquidity management methods that can be invoked using either Solidity or Web3 libraries.
Write Methods
supply
The referralCode
is emitted in Supply event and can be for third party referral integrations. To activate referral feature and obtain a unique referral code, integrators need to submit proposal to Themis Governance.
When supplying, the Pool contract must have** allowance()
to spend funds on behalf of msg.sender ** for at-least** amount ** for the** asset **being supplied. This can be done via the standard ERC20 approve()
method on the underlying token contract
Referral supply is currently inactive, you can pass 0 as referralCode . This program may be activated in the future through an Themis governance proposal
supplyWithPermit
Supply with transfer approval of supplied asset via permit function. This method removes the need for separate approval tx before supplying asset to the pool.
Permit signature must be signed by msg.sender with spender as Pool address.
Referral program is currently inactive, you can pass 0 as referralCode . This program may be activated in the future through an Themis governance proposal
Call Params
withdraw
Withdraws amount
of the underlying asset
, i.e. redeems the underlying token and burns the tTokens.
If user has any existing debt backed by the underlying token, then the maxamountavailable to withdraw is theamount that will not leave user health factor < 1 after withdrawal.
When withdrawing to another address, msg.sender should have aToken that will be burned by Pool .
Call Params
borrow
Borrows amount
of asset
with interestRateMode
, sending the amount to msg.sender
, with the debt being incurred by onBehalfOf
.
Note: If onBehalfOf
is not same as msg.sender , then onBehalfOf
must have supplied enough collateral via supply()
and have delegated credit to msg.sender
via approveDelegation()
.
Referral program is currently inactive, you can pass 0 as referralCode
. This program may be activated in the future through an Aave governance proposal
Call Params
repay
Repays onBehalfOf
's debt amount
of asset
which has a rateMode
.
When repaying, the Pool contract must have** allowance()
to spend funds on behalf of msg.sender
** for at-least** amount ** for the** asset **you are repaying with. This can be done via the standard ERC20 approve()
method on the underlying token contract.
Referral program is currently inactive, you can pass 0 as referralCode
. This program may be activated in the future through an Themis governance proposal
Call Params
repayWithPermit
Repay with transfer approval of borrowed asset via permit function. This method removes the need for separate approval tx before repaying asset to the pool.
Permit signature must be signed by msg.sender
with spender value as Pool address.
Call Params
repayWithtTokens
Allows user to repay with tTokens of the underlying debt asset without any approvals eg. Pay DAI debt using tDAI tokens.
Call Params
swapBorrowRateMode
Swaps msg.sender
's borrow rate mode between stable and variable.
Call Params
rebalanceStableBorrowRate
function rebalanceStableBorrowRate(address asset, address user)
Rebalances stable borrow rate of the user
for given asset
. In case of liquidity crunches on the protocol, stable rate borrows might need to be rebalanced to bring back equilibrium between the borrow and supply rates.
Call Params
setUserUseReserveAsCollateral
Sets the asset of msg.sender
to be used as collateral or not.
An asset in Isolation Mode can be enabled to use as collateral only if no other asset is already enabled to use as collateral.
An asset in Isolation Mode can be enabled to use as collateral only if no other asset is already enabled to use as collateral.
User won’t be able to disable an asset as collateral if they have an outstanding debt position which could be left with Loan risk > 1/HEALTH_FACTOR_LIQUIDATION_THRESHOLD on disabling the given asset as collateral.
Call Params
liquidationCall
When the Loan Risk of a position is greater than 100% (Loan Risk=1/health factor), the liquidator repays part or all of the outstanding loan amount on behalf of the borrower, while the liquidator receives a discounted amount of collateral in return (also known as Liquidation Bonus). In M0, the liquidator can decide whether it wants to receive the relevant amount of tToken instead of the underlying asset. When the liquidation is successfully completed, the Loan Risk of the position is reduced, bringing the Loan Risk below 100%.
Liquidators can only close a certain amount of collateral defined by a close factor. Currently the close factor is 0.5. In other words, liquidators can only liquidate a maximum of 50% of the amount pending to be repaid in a position. The liquidation discount applies to this amount.
Liquidators must approve()
the Pool
contract to use debtToCover
of the underlying ERC20 of theasset
used for the liquidation.
NOTES
In most scenarios, profitable liquidators will choose to liquidate as much as they can (50% of the user position).
debtToCover parameter can be set to
uint(-1)
and the protocol will proceed with the highest possible liquidation allowed by the close factor.To check a user's health factor, use getUserAccountData()
Call Params
flashLoan
Allows users to access liquidity of the pool for givenlist of assets for one transactionas long as the amount taken plus fee is returned or debt position is opened by the end of transaction. If no debt position is opened, receiver must approve thePoolcontract for at least theamount borrowed + fee, else transaction will revert.
Flash loan fee is waived for the approvedflashBorrowers
Referral program is currently inactive, you can pass 0 as referralCode . This program may be activated in the future through an Aave governance proposal
Call Params
flashLoanSimple
Allows users to access liquidity of one reserve or one transaction as long as the amount taken plus fee is returned.
Receiver must approve thePoolcontract for at least the*amount borrowed + fee,*else transaction will revert.
Does not waive few for approvedflashBorrowersnor allow opening a debt position instead of repaying.
Referral program is currently inactive, you can pass 0 as referralCode . This program may be activated in the future through an Aave governance proposal
Call Params
mintToTreasury
Mints reserve income accrued to treasury (as per the reserve factor) for the given list of assets.
Call Params
setUserEMode
Updates the user efficiency mode category. The category id must be a valid id already defined byPool or Risk Admins
Will revert if user is borrowing non-compatible asset or change will drop HF < HEALTH_FACTOR_LIQUIDATION_THRESHOLD
Will revert if user is borrowing non-compatible asset or change will drop HF < HEALTH_FACTOR_LIQUIDATION_THRESHOLD
Call Params
mintUnbacked
Allows contracts, with BRIDGE role permission, to mint unbackedtTokensto the onBehalfOf address. This method is part of the V2 Portal feature.
Only available to the addresses with BRIDGE role. Bridge addresses can be whitelisted by the governance(still in building).
Call Params
backUnbacked
Allows contracts, with BRIDGE role permission, to back the currently unbacked aTokens with amount of underlying asset and pay fee . This method is part of the V2 Portal feature.
Only available to the addresses with BRIDGE role. Bridge addresses can be whitelisted by the governance.
Call Params
rescueTokens
Rescue and transfer tokens locked in this contract.
Only available to POOL_ADMIN role. Pool admin is selected by the governance.
borrowM1
M1's assets will be authorized to borrow assets from the Pool contract when they need to borrow assets. M1's collateral will be pledged directly in the tToken contract. a single class of M1's assets has a maxBorrowLimitInBaseCurrency(eg. Uniswap-V3-POS-wETH/USDC-500 can only borrow $1M value of asset from M0 Pool) . Therefore this class of assets is also limited to the assets that can be borrowed from the Pool contract.
Available only for M1 Pool calls
repayM1
There are different outcomes for users who partially repay or fully repay their debt in M1, with full repayment allowing for direct redemption of the collateral.
Available only for M1 Pool calls
liquidationCallM1
When the Loan Risk of a debit order in M1 is greater than 100% {(loan risk in M1=Outstandingdebtvalue/(assetValue*liquidationThreshold)} . The liquidator repays the entire outstanding amount on behalf of the borrower. At the same time the liquidator gets a discount on the collateral as a return. In M1, there is no LiquidationBonus set, and the liquidator is expected to receive a reward of approximately (1 - liquidationThreshold)*CollateralValue. When the liquidation is completed. The order will be settled.
Available only for M1 Pool calls
NOTES
The discounted collateral which are given to liquidator is usually LP assets or other types of Yield Bearing Token that need to be redeemed on their own.
Earnings from past time in the collateral(fees, yield, reward etc. ) are not calculated into the collateral value, so liquidation may result in a higher than expected award.
View Methods
getReserveData
Returns the state and configuration of the reserve.
Call Params
Return Values
getUserAccountData
Returns the user account data across all the reserves
Call Params
Return Values
getConfiguration
Returns the configuration of the reserve.
Call Params
Return Values
getUserConfiguration
Returns the configuration of the user across all the reserves.
Call Params
Return Values
getReserveNormalizedIncome
Returns the ongoing normalized income for the reserve.
A value of 1e27 means there is no income. As time passes, the yield is accrued. A value of 2/*1e27 means for each unit of asset one unit of income has been accrued.
Return Values
getReserveNormalizedDebt
Returns the ongoing normalized variable debt for the reserve.
A value of 1e27 means there is no debt. As time passes, the debt is accrued. A value of 2/*1e27 means that for each unit of debt, one unit worth of interest has been accumulated.
Return Value
getReservesList
Returns the list of initialized reserves.
getEModeCategoryData
Returns category data for the given eModeCategory id.
Return Values
getUserEMode
Returns eModeCategory Id of the user’s eMode. 0 ⇒ no eMode.
FLASHLOAN_PREMIUM_TOTAL
Returns the percent of total flashloan premium paid by the borrower. A part of this premium is added to reserve's liquidity index i.e. paid to the liquidity provider and the other part is paid to the protocol i.e. accrued to the treasury.
FLASHLOAN_PREMIUM_TO_PROTOCOL
Returns the percent of flashloan premium that is accrued to the treasury.
Last updated