Pool

The Pool contract allows users to:

  • Supply: Deposit an asset into the protocol and receive corresponding liquidity tokens.

  • Withdraw: Redeem the underlying asset by burning liquidity tokens.

  • Borrow: Access a specified amount of an asset, provided there is sufficient collateral.

  • Repay: Repay borrowed assets, thereby burning the corresponding debt tokens.

  • Collateral Management: Enable or disable supplied assets as collateral.

  • Liquidation: Liquidate positions that fall below a healthy collateral threshold.

  • Initialize:

Supply

rustCopyfn supply(
    asset: Address,
    amount: u256,
    on_behalf_of: Address,
    referral_code: u16
) -> Result<(), Error>
  • Description: Supplies a specified amount of an asset to the protocol. This action mints an equivalent amount of liquidity tokens (lTokens) and transfers them to the beneficiary address. Example: Supplying 100 USDC will result in receiving 100 lUSDC.

  • Notes: Before calling this function, the Pool contract must be approved to spend the underlying asset from the sender’s account. Referral integration is currently inactive (pass 0 for the referral code), but this may be activated in the future via Lentum governance proposals.

  • Input Parameters:

    Name
    Type
    Description

    asset

    Address

    The underlying asset’s address being supplied.

    amount

    u256

    The amount of asset to supply.

    on_behalf_of

    Address

    The address that will receive the liquidity tokens; often the same as the sender.

    referral_code

    u16

    Referral code (set to 0 if not using a referral).

withdraw

  • Description: Withdraws a specified amount of the underlying asset from the reserve, burning the corresponding liquidity tokens. Example: If a user holds 100 lUSDC, withdrawing 100 will redeem 100 USDC, burning the 100 lUSDC.

  • Notes: If the user has any outstanding debt backed by the asset, the maximum amount available to withdraw is limited by the requirement to maintain a healthy account status. When withdrawing to another address, the sender must own the liquidity tokens that will be burned.

  • Input Parameters:

    Name
    Type
    Description

    asset

    Address

    The underlying asset’s address (not the liquidity token address).

    amount

    u256

    The amount of the asset to withdraw. Use u256::max_value() to withdraw the entire balance.

    to

    Address

    The recipient address for the withdrawn asset; typically the sender, unless a different beneficiary is specified.

  • Return Value:

    Type
    Description

    u256

    The final amount withdrawn

borrow

  • Description: Borrows a specified amount of an asset, given that the borrower has sufficient collateral or credit delegation approval. Example: Borrowing 100 USDC will transfer 100 USDC to the borrower’s wallet and mint corresponding variable debt tokens.

  • Notes: If borrowing on behalf of another address, that address must have previously supplied sufficient collateral and approved the sender via credit delegation.

  • Input Parameters:

    Name
    Type
    Description

    asset

    Address

    The underlying asset’s address to borrow.

    amount

    u256

    The amount to borrow.

    interest_rate_mode

    u256

    Should be set to 2 (indicating a variable rate mode).

    referral_code

    u16

    Referral code (set to 0 if not using a referral).

    on_behalf_of

    Address

    The address that will receive the borrowed funds or be credited with the debt.


repay

  • Description: Repays a borrowed amount on a specific reserve, burning the equivalent debt tokens. Example: Repaying 100 USDC burns the corresponding 100 variable debt tokens.

  • Notes: The Pool contract must be approved to spend the asset on behalf of the sender. Repeated calls to repay within the same block are not allowed.

  • Input Parameters:

    Name
    Type
    Description

    asset

    Address

    The underlying asset’s address previously borrowed.

    amount

    u256

    The amount to repay. Use u256::max_value() to fully repay the debt (when not repaying on behalf of another user).

    interest_rate_mode

    u256

    Must be 2 (indicating a variable rate mode).

    on_behalf_of

    Address

    The address whose debt is being reduced or removed.

  • Return Value:

    Type
    Description

    u256

    The final amount repaid

liquidationCall

  • Description: Liquidates a non-healthy position (i.e. a position with a health factor below 1). The liquidator repays part or all of the outstanding debt, and in return receives a proportional amount of the collateral asset along with a bonus to cover market risk.

  • Notes:

    • Liquidators can choose whether to receive the collateral as underlying assets or as lTokens.

    • The maximum amount liquidated is capped by a close factor (currently 50%).

    • The debt_to_cover parameter can be set to the maximum value to trigger the highest allowable liquidation.

  • Input Parameters:

    Name
    Type
    Description

    collateral_asset

    Address

    The address of the asset used as collateral.

    debt_asset

    Address

    The address of the borrowed asset to be repaid by the liquidator.

    user

    Address

    The address of the borrower whose position is being liquidated.

    debt_to_cover

    u256

    The amount of debt (in the borrowed asset) that the liquidator will repay.

    receive_ltoken

    bool

    true to receive lTokens equivalent of the collateral; false to receive the underlying asset.

    View Methods

    • getUserAccountData: Returns aggregate data for a user including total collateral, total debt, available borrowing power, current liquidation threshold, LTV, and health factor.

Initialize

  • Description: Initializes the Pool contract. This function is called by the proxy contract when the Pool is added to the addresses provider of the market. The provider’s address is cached to reduce gas consumption on subsequent operations.

  • Input Parameters:

    Name
    Type
    Description

    provider

    Address

    The address of the PoolAddressesProvider

Last updated