Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool
@title Pool Module @author Aave @notice Main module for the Aave protocol, managing the state of all reserves and users
- Resource
ReserveExtendConfiguration
- Resource
ReserveData
- Struct
ReserveInfo
- Resource
Reserves
- Resource
UsersConfig
- Function
get_reserve_data
- Function
number_of_active_reserves
- Function
number_of_active_and_dropped_reserves
- Function
get_reserve_configuration
- Function
get_reserve_configuration_by_reserve_data
- Function
get_reserve_last_update_timestamp
- Function
get_reserve_id
- Function
get_reserve_a_token_address
- Function
get_reserve_accrued_to_treasury
- Function
get_reserve_variable_borrow_index
- Function
get_reserve_liquidity_index
- Function
get_reserve_current_liquidity_rate
- Function
get_reserve_current_variable_borrow_rate
- Function
get_reserve_variable_debt_token_address
- Function
get_reserve_isolation_mode_total_debt
- Function
get_reserve_virtual_underlying_balance
- Function
get_liquidation_grace_period
- Function
get_reserve_deficit
- Function
get_user_configuration
- Function
get_reserve_normalized_income
- Function
get_normalized_income_by_reserve_data
- Function
get_reserve_normalized_variable_debt
- Function
get_normalized_debt_by_reserve_data
- Function
get_reserves_list
- Function
get_reserve_address_by_id
- Function
get_flashloan_premium_total
- Function
get_flashloan_premium_to_protocol
- Function
max_number_reserves
- Function
asset_exists
- Function
get_isolation_mode_state
- Function
get_siloed_borrowing_state
- Function
set_reserve_configuration_with_guard
- Function
init_pool
- Function
new_reserve_data
- Function
delete_reserve_data
- Function
set_reserve_last_update_timestamp
- Function
set_reserve_accrued_to_treasury
- Function
set_reserve_variable_borrow_index
- Function
set_reserve_liquidity_index
- Function
set_reserve_current_liquidity_rate
- Function
set_reserve_current_variable_borrow_rate
- Function
set_reserve_isolation_mode_total_debt
- Function
set_reserve_virtual_underlying_balance
- Function
set_liquidation_grace_period
- Function
set_reserve_deficit
- Function
set_reserve_configuration
- Function
set_user_configuration
- Function
cumulate_to_liquidity_index
- Function
reset_isolation_mode_total_debt
- Function
update_flashloan_premiums
use 0x1::object;
use 0x1::signer;
use 0x1::smart_table;
use 0x1::table_with_length;
use 0x1::timestamp;
use 0x24e01fa503119e76bf9eea69eec59884fc3da82f5ea23bf5f20f8ce358a4606::acl_manage;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::reserve_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::user_config;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::events;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::math_utils;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::wad_ray_math;
Resource ReserveExtendConfiguration
@notice Configuration for reserve extensions like flashloan premiums
struct ReserveExtendConfiguration has drop, store, key
Resource ReserveData
@notice Stateful information about a reserve
#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
struct ReserveData has key
Struct ReserveInfo
@notice A wrapper over the ReserveData
object with its associated delete ref
struct ReserveInfo has store
Resource Reserves
@notice Information of all reserves
struct Reserves has key
Resource UsersConfig
@notice Map of users address and their configuration data (user_address => UserConfigurationMap)
struct UsersConfig has key
Function get_reserve_data
@notice Get an object that points to the state of the reserve @param asset The address of the underlying asset of the reserve @return The object that refers to the state of the reserve
#[view]
public fun get_reserve_data(asset: address): object::Object<pool::ReserveData>
Function number_of_active_reserves
@notice Return the number of active reserves @return The number of active reserves
#[view]
public fun number_of_active_reserves(): u256
Function number_of_active_and_dropped_reserves
@notice Return the number of active and dropped reserves @return The number of active and dropped reserves
#[view]
public fun number_of_active_and_dropped_reserves(): u256
Function get_reserve_configuration
@notice Returns the configuration of the reserve @param asset The address of the underlying asset of the reserve @return The configuration of the reserve
#[view]
public fun get_reserve_configuration(asset: address): reserve_config::ReserveConfigurationMap
Function get_reserve_configuration_by_reserve_data
@notice Returns the configuration of the reserve by reserve data @param reserve_data The reserve data object @return The configuration of the reserve
#[view]
public fun get_reserve_configuration_by_reserve_data(reserve_data: object::Object<pool::ReserveData>): reserve_config::ReserveConfigurationMap
Function get_reserve_last_update_timestamp
@notice Returns the last update timestamp of the reserve @param reserve_data The reserve data object @return The last update timestamp
#[view]
public fun get_reserve_last_update_timestamp(reserve_data: object::Object<pool::ReserveData>): u64
Function get_reserve_id
@notice Returns the ID of the reserve @param reserve_data The reserve data object @return The ID of the reserve
#[view]
public fun get_reserve_id(reserve_data: object::Object<pool::ReserveData>): u16
Function get_reserve_a_token_address
@notice Returns the aToken address of the reserve @param reserve_data The reserve data object @return The aToken address
#[view]
public fun get_reserve_a_token_address(reserve_data: object::Object<pool::ReserveData>): address
Function get_reserve_accrued_to_treasury
@notice Returns the accrued to treasury amount of the reserve @param reserve_data The reserve data object @return The accrued to treasury amount
#[view]
public fun get_reserve_accrued_to_treasury(reserve_data: object::Object<pool::ReserveData>): u256
Function get_reserve_variable_borrow_index
@notice Returns the variable borrow index of the reserve @param reserve_data The reserve data object @return The variable borrow index
#[view]
public fun get_reserve_variable_borrow_index(reserve_data: object::Object<pool::ReserveData>): u128
Function get_reserve_liquidity_index
@notice Returns the liquidity index of the reserve @param reserve_data The reserve data object @return The liquidity index
#[view]
public fun get_reserve_liquidity_index(reserve_data: object::Object<pool::ReserveData>): u128
Function get_reserve_current_liquidity_rate
@notice Returns the current liquidity rate of the reserve @param reserve_data The reserve data object @return The current liquidity rate
#[view]
public fun get_reserve_current_liquidity_rate(reserve_data: object::Object<pool::ReserveData>): u128
Function get_reserve_current_variable_borrow_rate
@notice Returns the current variable borrow rate of the reserve @param reserve_data The reserve data object @return The current variable borrow rate
#[view]
public fun get_reserve_current_variable_borrow_rate(reserve_data: object::Object<pool::ReserveData>): u128
Function get_reserve_variable_debt_token_address
@notice Returns the variable debt token address of the reserve @param reserve_data The reserve data object @return The variable debt token address
#[view]
public fun get_reserve_variable_debt_token_address(reserve_data: object::Object<pool::ReserveData>): address
Function get_reserve_isolation_mode_total_debt
@notice Returns the isolation mode total debt of the reserve @param reserve_data The reserve data object @return The isolation mode total debt
#[view]
public fun get_reserve_isolation_mode_total_debt(reserve_data: object::Object<pool::ReserveData>): u128
Function get_reserve_virtual_underlying_balance
@notice Returns the virtual underlying balance of the reserve @param reserve_data The reserve data object @return The virtual underlying balance
#[view]
public fun get_reserve_virtual_underlying_balance(reserve_data: object::Object<pool::ReserveData>): u128
Function get_liquidation_grace_period
@notice Returns the liquidation grace period of the given asset @param reserve_data The reserve data object @return Timestamp when the liquidation grace period will end
#[view]
public fun get_liquidation_grace_period(reserve_data: object::Object<pool::ReserveData>): u64
Function get_reserve_deficit
@notice Returns the current deficit of a reserve @param reserve_data The reserve data object @return The current deficit of the reserve
#[view]
public fun get_reserve_deficit(reserve_data: object::Object<pool::ReserveData>): u128
Function get_user_configuration
@notice Returns the user configuration @param user The address of the user @return The user configuration
#[view]
public fun get_user_configuration(user: address): user_config::UserConfigurationMap
Function get_reserve_normalized_income
@notice Returns the normalized income of the reserve @param asset The address of the underlying asset of the reserve @return The reserve's normalized income
#[view]
public fun get_reserve_normalized_income(asset: address): u256
Function get_normalized_income_by_reserve_data
@notice Returns the ongoing normalized income for the reserve @dev A value of 1e27 means there is no income. As time passes, the income is accrued @dev A value of 2*1e27 means for each unit of asset one unit of income has been accrued @param reserve The reserve data object @return The normalized income, expressed in ray
#[view]
public fun get_normalized_income_by_reserve_data(reserve_data: object::Object<pool::ReserveData>): u256
Function get_reserve_normalized_variable_debt
@notice Returns the normalized variable debt per unit of asset @dev WARNING: This function is intended to be used primarily by the protocol itself to get a "dynamic" variable index based on time, current stored index and virtual rate at the current moment (approx. a borrower would get if opening a position). This means that is always used in combination with variable debt supply/balances. If using this function externally, consider that is possible to have an increasing normalized variable debt that is not equivalent to how the variable debt index would be updated in storage (e.g. only updates with non-zero variable debt supply) @param asset The address of the underlying asset of the reserve @return The reserve normalized variable debt
#[view]
public fun get_reserve_normalized_variable_debt(asset: address): u256
Function get_normalized_debt_by_reserve_data
@notice Returns the ongoing normalized variable debt for the reserve @dev A value of 1e27 means there is no debt. As time passes, the debt is accrued @dev A value of 2*1e27 means that for each unit of debt, one unit worth of interest has been accumulated @param reserve The reserve data object @return The normalized variable debt, expressed in ray
#[view]
public fun get_normalized_debt_by_reserve_data(reserve_data: object::Object<pool::ReserveData>): u256
Function get_reserves_list
@notice Returns the list of the underlying assets of all the initialized reserves @dev It does not include dropped reserves @return The addresses of the underlying assets of the initialized reserves
#[view]
public fun get_reserves_list(): vector<address>
Function get_reserve_address_by_id
@notice Returns the address of the underlying asset of a reserve by the reserve id as stored in the ReserveData struct @param id The id of the reserve as stored in the ReserveData struct @return The address of the reserve associated with id
#[view]
public fun get_reserve_address_by_id(id: u256): address
Function get_flashloan_premium_total
@notice Returns the total flashloan premium @return The total flashloan premium
#[view]
public fun get_flashloan_premium_total(): u128
Function get_flashloan_premium_to_protocol
@notice Returns the flashloan premium to protocol @return The flashloan premium to protocol
#[view]
public fun get_flashloan_premium_to_protocol(): u128
Function max_number_reserves
@notice Returns the maximum number of reserves supported to be listed in this Pool @return The maximum number of reserves supported
#[view]
public fun max_number_reserves(): u16
Function asset_exists
@notice Checks if a specified asset exists in the reserve list @dev Ensures the reserve list is initialized before checking for the asset's presence @param asset The address of the asset to check in the reserve list @return A boolean indicating whether the asset exists in the reserve list
#[view]
public fun asset_exists(asset: address): bool
Function get_isolation_mode_state
@notice Returns the Isolation Mode state of the user @param user_config_map The configuration of the user @return True if the user is in isolation mode, false otherwise @return The address of the only asset used as collateral @return The debt ceiling of the reserve
public fun get_isolation_mode_state(user_config_map: &user_config::UserConfigurationMap): (bool, address, u256)
Function get_siloed_borrowing_state
@notice Returns the siloed borrowing state for the user @param account The address of the user @return True if the user has borrowed a siloed asset, false otherwise @return The address of the only borrowed asset
#[view]
public fun get_siloed_borrowing_state(account: address): (bool, address)
Function set_reserve_configuration_with_guard
@notice Sets the reserve configuration with guard @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param reserve_config_map The new configuration bitmap
public fun set_reserve_configuration_with_guard(account: &signer, asset: address, reserve_config_map: reserve_config::ReserveConfigurationMap)
Function init_pool
@notice Initializes the pool @dev Only callable by the pool_configurator module @param account The account signer of the caller
public(friend) fun init_pool(account: &signer)
Function new_reserve_data
@notice Constructor for the ReserveData
struct
@param owner The owner of the reserve
@param underlying_asset The address of the underlying asset of the reserve
@param a_token_address The address of the aToken
@param variable_debt_token_address The address of the variable debt token
@param configuration The configuration of the reserve
@return The object that refers to the state of the reserve
public(friend) fun new_reserve_data(owner: &signer, underlying_asset: address, a_token_address: address, variable_debt_token_address: address, configuration: reserve_config::ReserveConfigurationMap): object::Object<pool::ReserveData>
Function delete_reserve_data
@notice This function is used to delete the reserve data for a specified asset @dev Only callable by the pool_token_logic module @param asset The address of the underlying asset of the reserve
public(friend) fun delete_reserve_data(asset: address)
Function set_reserve_last_update_timestamp
@notice This function sets the last update timestamp for a specified asset's reserve data @dev Only callable by the pool_logic module @param reserve_data The reserve data object to update @param last_update_timestamp The new last update timestamp to set, expressed as a u64 value
public(friend) fun set_reserve_last_update_timestamp(reserve_data: object::Object<pool::ReserveData>, last_update_timestamp: u64)
Function set_reserve_accrued_to_treasury
@notice Update accrued_to_treasury of the reserve @dev Only callable by the pool and flashloan_logic module @param reserve_data The reserve data object to update @param accrued_to_treasury The new accrued_to_treasury value
public(friend) fun set_reserve_accrued_to_treasury(reserve_data: object::Object<pool::ReserveData>, accrued_to_treasury: u256)
Function set_reserve_variable_borrow_index
@notice This function sets the variable borrow index for a specified asset's reserve data @dev Only callable by the pool_logic module @param reserve_data The reserve data object to update @param variable_borrow_index The new variable borrow index to set, expressed as a u128 value
public(friend) fun set_reserve_variable_borrow_index(reserve_data: object::Object<pool::ReserveData>, variable_borrow_index: u128)
Function set_reserve_liquidity_index
@notice This function sets the liquidity index for a specified asset's reserve data @dev Only callable by the pool, pool_logic module @param reserve_data The reserve data object to update @param liquidity_index The new liquidity index to set, expressed as a u128 value
public(friend) fun set_reserve_liquidity_index(reserve_data: object::Object<pool::ReserveData>, liquidity_index: u128)
Function set_reserve_current_liquidity_rate
@notice This function sets the current liquidity rate for a specified asset's reserve data @dev Only callable by the pool_logic module @param reserve_data The reserve data object to update @param current_liquidity_rate The new current liquidity rate to set, expressed as a u128 value
public(friend) fun set_reserve_current_liquidity_rate(reserve_data: object::Object<pool::ReserveData>, current_liquidity_rate: u128)
Function set_reserve_current_variable_borrow_rate
@notice This function sets the current variable borrow rate for a specified asset's reserve data @dev Only callable by the pool_logic module @param reserve_data The reserve data object to update @param current_variable_borrow_rate The new current variable borrow rate to set, expressed as a u128 value
public(friend) fun set_reserve_current_variable_borrow_rate(reserve_data: object::Object<pool::ReserveData>, current_variable_borrow_rate: u128)
Function set_reserve_isolation_mode_total_debt
@notice Updates isolation_mode_total_debt of the reserve @dev Only callable by the borrow_logic and isolation_mode_logic module @param reserve_data The reserve data object to update @param isolation_mode_total_debt The new isolation_mode_total_debt value
public(friend) fun set_reserve_isolation_mode_total_debt(reserve_data: object::Object<pool::ReserveData>, isolation_mode_total_debt: u128)
Function set_reserve_virtual_underlying_balance
@notice Sets the virtual underlying balance of the reserve @param reserve_data The reserve data object to update @param balance The new virtual underlying balance
public(friend) fun set_reserve_virtual_underlying_balance(reserve_data: object::Object<pool::ReserveData>, balance: u128)
Function set_liquidation_grace_period
@notice Sets the liquidation grace period of the given asset @dev To enable a liquidation grace period, a timestamp in the future should be set, To disable a liquidation grace period, any timestamp in the past works, like 0 @dev Only callable by the pool_configurator module @param reserve_data The reserve data object to update @param until Timestamp when the liquidation grace period will end
public(friend) fun set_liquidation_grace_period(reserve_data: object::Object<pool::ReserveData>, until: u64)
Function set_reserve_deficit
@notice Sets the deficit of the reserve @dev Only callable by the liquidation_logic module @param reserve_data The reserve data object to update @param deficit The new deficit of the reserve
public(friend) fun set_reserve_deficit(reserve_data: object::Object<pool::ReserveData>, deficit: u128)
Function set_reserve_configuration
@notice Sets the configuration bitmap of the reserve as a whole @dev Only callable by the pool_configurator and pool module @param asset The address of the underlying asset of the reserve @param reserve_config_map The new configuration bitmap
public(friend) fun set_reserve_configuration(asset: address, reserve_config_map: reserve_config::ReserveConfigurationMap)
Function set_user_configuration
@notice Sets the configuration bitmap of the user @dev Only callable by the supply_logic, borrow_logic and liquidation_logic module @param user The address of the user @param user_config_map The new configuration bitmap
public(friend) fun set_user_configuration(user: address, user_config_map: user_config::UserConfigurationMap)
Function cumulate_to_liquidity_index
@notice Accumulates a predefined amount of asset to the reserve as a fixed, instantaneous income. Used for example to accumulate the flashloan fee to the reserve, and spread it between all the suppliers @dev Only callable by the flashloan_logic module @param reserve_data The reserve data object to update @param total_liquidity The total liquidity available in the reserve @param amount The amount to accumulate @return The next liquidity index of the reserve
public(friend) fun cumulate_to_liquidity_index(reserve_data: object::Object<pool::ReserveData>, total_liquidity: u256, amount: u256): u256
Function reset_isolation_mode_total_debt
@notice Resets the isolation mode total debt of the given asset to zero @dev Only callable by the pool_configurator module @dev It requires the given asset has zero debt ceiling @param asset The address of the underlying asset to reset the isolation_mode_total_debt
public(friend) fun reset_isolation_mode_total_debt(asset: address)
Function update_flashloan_premiums
@notice Updates flash loan premiums. Flash loan premium consists of two parts:
- A part is sent to aToken holders as extra, one time accumulated interest
- A part is collected by the protocol treasury
@dev The total premium is calculated on the total borrowed amount
@dev The premium to protocol is calculated on the total premium, being a percentage of flash_loan_premium_total
@dev Only callable by the pool_configurator module
@param flash_loan_premium_total The total premium, expressed in bps
@param flash_loan_premium_to_protocol The part of the premium sent to the protocol treasury, expressed in bps
public(friend) fun update_flashloan_premiums(flash_loan_premium_total: u128, flash_loan_premium_to_protocol: u128)