Pool
The pool is the core contract through which users will interact with the protocol. It allows for all the funding operations.
Package Name: pool
Source Code: pool on GitHub
pool.move
Contract API reference
Write Methods
function deposit
function depositDeposits amount of an asset into the protocol, minting the same amount of corresponding nTokens
function withdraw
function withdrawWithdraws amount of the underlying asset, i.e. redeems the underlying token and burns the aTokens.
function borrow
function borrowBorrows amount of asset with, sending the amount to msg.sender
function repay
function repayRepays a debt amount of asset
function enable_as_collateral
function enable_as_collateralLets a user sets the asset of to be allowed to be used as collateral or not.
function execute_liquidation
function execute_liquidationWhat needs to be know:
The collateral asset
The debt asset
User
The amount of debt that needs to be covered by the liquidator
Example Liquidation Scenario
A user deposits $100 worth of SUI (70% LTV), and borrows $50 worth of BTC.
Supply Balance: $100
Borrow Balance: $50
Health Factor = 100 * 0,7 / 50 = 1.4
BTC price goes up by 50%
Supply Balance: $100
Borrow Balance: $75
Health Factor = 100 * 0,7 / 75 = 0,9333
User is now liquidate-able
Liquidate positions with a health factor below 1. Also see our Liquidations guide.
When the health factor of a position is below 1, liquidators repay part or all of the outstanding borrowed amount on behalf of the borrower, while receiving a discounted amount of collateral in return (also known as a liquidation "bonus"). Liquidators can decide if they want to receive an equivalent amount of collateral aTokens, or the underlying asset directly. When the liquidation is completed successfully, the health factor of the position is increased, bringing the health factor above 1.
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.
function flash_loan
function flash_loanSee Sui Example flash loan here.
View Methods
function get_market_reserve_data
function get_market_reserve_dataReturns the state of the reserve of a specific market
Liquidity Index
Current Supply / Liquidity in Ray
Current Interest Rate
Last Update Timestamp
nToken address
Underlying address
Interest Rate Strategy Address
function get_user_account_data
function get_user_account_dataReturns the user account data across all the reserves
Total Collateral (in Sui)
Total Debt (in Sui)
LTV
Health Factor
Liquidation Threshold
Borrowing power left
function get_market_configuration
function get_market_configurationReturns the configuration of the market
LTV
Liquidation Threshold
Liquidation Bonus
Reserve Factor
Borrowing enabled
Decimals of the market
function get_market_normalised_income
function get_market_normalised_incomeReturns the normalized income per unit of asset of a specific market
function get_market_normalised_debt
function get_market_normalised_debtReturns the normalized variable debt per unit of asset of a specific market
function paused
function pausedReturns true if the LendingPool is paused.
function get_market_list
function get_market_listReturns the list of markets.
Error Codes
TODO
Last updated