Layerbank Block
Overview
The layerbank_block::layerbank_block
module contains the block implementation for LayerBank's Aave integration. This module provides convenience functions to interact with Aave's lending protocol, handling supply operations, withdrawals, and rewards claiming. These block functions are used by concrete strategy implementations to interact with the Aave protocol, instead of interacting with it directly.
Constants
MAX_U64:
u256 = 18446744073709551615u256
- Maximum value for a u64, used in rewards claiming operations
Public Functions
Lending Operations
supply(account: &signer, asset: address, amount: u256, recipient: address, referral_code: u16)
: Wraps the Aavesupply_logic::supply
function. Supplies an asset to the Aave lending pool and mints aTokens to the specified recipient. The account must have sufficient balance of the asset.withdraw(account: &signer, asset: address, amount: u256, recipient: address)
: Wraps the Aavesupply_logic::withdraw
function. Withdraws an asset from the Aave lending pool. The account must have sufficient aToken balance. The withdrawn assets are sent to the specified recipient. Note: This function does not claim rewards - reward claiming should be handled separately.
Rewards Operations
claim_all_rewards(caller: &signer, asset: Object<Metadata>, rewards_controller_address: address)
: Claims all available rewards for a supplied asset. Claims rewards for a single supplied asset and sends rewards to the caller's address.claim_all_non_base_asset_rewards(caller: &signer, base_asset: Object<Metadata>, rewards_controller_address: address)
: Claims all rewards except those denominated in the base asset. Retrieves the list of all reward assets, claims rewards for each reward asset except the base asset, and sends all claimed rewards to the caller's address.claim_base_asset_rewards(caller: &signer, base_asset: Object<Metadata>, rewards_controller_address: address): u256
: Claims only the rewards denominated in the base asset. Returns the total amount of base asset rewards claimed. The claimed rewards are sent to the caller's address. Returns 0 if no base asset rewards are available.
View Functions
get_user_supply_with_interest(user: address, asset: address): u256
: Returns the total amount of underlying asset supplied by a user including accrued interest. Calculated by multiplying the user's scaled aToken balance by the normalized income (liquidity index). Returns the total supply balance in the underlying asset's decimals.reserve_exists(asset: address)
: Verifies if a reserve exists for the specified asset by attempting to get its reserve data. Aborts if the reserve doesn't exist.
Last updated