Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool_logic

@title Pool Logic Module @author Aave @notice Implements core logic for Aave protocol pool operations including state updates and interest rate calculations

use 0x1::event;
use 0x1::object;
use 0x1::timestamp;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::reserve_config;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::default_reserve_interest_rate_strategy;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::variable_debt_token_factory;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::math_utils;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::wad_ray_math;

Struct ReserveDataUpdated

@notice Emitted when the state of a reserve is updated @param reserve The address of the underlying asset of the reserve @param liquidity_rate The next liquidity rate @param variable_borrow_rate The next variable borrow rate @param liquidity_index The next liquidity index @param variable_borrow_index The next variable borrow index

#[event]
struct ReserveDataUpdated has drop, store

Struct ReserveCache

@notice Cache for pool reserve data to avoid repeated storage reads

struct ReserveCache has drop

Function update_state

@notice Updates the liquidity cumulative index and the variable borrow index @dev Only callable by the supply_logic, borrow_logic, flashloan_logic and liquidation_logic module @param reserve_data The reserve data @param reserve_cache The mutable reference of the reserve cache

public(friend) fun update_state(reserve_data: object::Object<pool::ReserveData>, reserve_cache: &mut pool_logic::ReserveCache)

Function update_interest_rates_and_virtual_balance

@notice Updates the reserve the current variable borrow rate and the current liquidity rate @dev Only callable by the supply_logic, borrow_logic, flashloan_logic, liquidation_logic and pool_configurator module @param reserve_data The reserve data @param reserve_cache The reserve cache @param reserve_address The address of the reserve to be updated @param liquidity_added The amount of liquidity added to the protocol (supply or repay) in the previous action @param liquidity_taken The amount of liquidity taken from the protocol (redeem or borrow)

public(friend) fun update_interest_rates_and_virtual_balance(reserve_data: object::Object<pool::ReserveData>, reserve_cache: &pool_logic::ReserveCache, reserve_address: address, liquidity_added: u256, liquidity_taken: u256)

Function cache

@notice Creates a cache of the reserve data to avoid repeated storage reads @param reserve_data The reserve data @return A new ReserveCache containing the reserve data

public fun cache(reserve_data: object::Object<pool::ReserveData>): pool_logic::ReserveCache

Function get_reserve_cache_configuration

@notice Gets the reserve configuration from cache @param reserve_cache The reserve cache @return The reserve configuration

public fun get_reserve_cache_configuration(reserve_cache: &pool_logic::ReserveCache): reserve_config::ReserveConfigurationMap

Function get_reserve_factor

@notice Gets the reserve factor from cache @param reserve_cache The reserve cache @return The reserve factor

public fun get_reserve_factor(reserve_cache: &pool_logic::ReserveCache): u256

Function get_curr_liquidity_index

@notice Gets the current liquidity index from cache @param reserve_cache The reserve cache @return The current liquidity index

public fun get_curr_liquidity_index(reserve_cache: &pool_logic::ReserveCache): u256

Function set_curr_liquidity_index

@notice Sets the current liquidity index in cache @param reserve_cache The reserve cache @param index The index to set

public fun set_curr_liquidity_index(reserve_cache: &mut pool_logic::ReserveCache, index: u256)

Function get_next_liquidity_index

@notice Gets the next liquidity index from cache @param reserve_cache The reserve cache @return The next liquidity index

public fun get_next_liquidity_index(reserve_cache: &pool_logic::ReserveCache): u256

Function set_next_liquidity_index

@notice Sets the next liquidity index in cache @param reserve_cache The reserve cache @param index The index to set

public fun set_next_liquidity_index(reserve_cache: &mut pool_logic::ReserveCache, index: u256)

Function get_curr_variable_borrow_index

@notice Gets the current variable borrow index from cache @param reserve_cache The reserve cache @return The current variable borrow index

public fun get_curr_variable_borrow_index(reserve_cache: &pool_logic::ReserveCache): u256

Function get_reserve_cache_last_update_timestamp

@notice Gets the last update timestamp from cache @param reserve_cache The reserve cache @return The last update timestamp

public fun get_reserve_cache_last_update_timestamp(reserve_cache: &pool_logic::ReserveCache): u64

Function get_next_variable_borrow_index

@notice Gets the next variable borrow index from cache @param reserve_cache The reserve cache @return The next variable borrow index

public fun get_next_variable_borrow_index(reserve_cache: &pool_logic::ReserveCache): u256

Function set_next_variable_borrow_index

@notice Sets the next variable borrow index in cache @param reserve_cache The reserve cache @param index The index to set

public fun set_next_variable_borrow_index(reserve_cache: &mut pool_logic::ReserveCache, index: u256)

Function get_curr_liquidity_rate

@notice Gets the current liquidity rate from cache @param reserve_cache The reserve cache @return The current liquidity rate

public fun get_curr_liquidity_rate(reserve_cache: &pool_logic::ReserveCache): u256

Function set_curr_liquidity_rate

@notice Sets the current liquidity rate in cache @param reserve_cache The reserve cache @param rate The rate to set

public fun set_curr_liquidity_rate(reserve_cache: &mut pool_logic::ReserveCache, rate: u256)

Function get_curr_variable_borrow_rate

@notice Gets the current variable borrow rate from cache @param reserve_cache The reserve cache @return The current variable borrow rate

public fun get_curr_variable_borrow_rate(reserve_cache: &pool_logic::ReserveCache): u256

Function set_curr_variable_borrow_rate

@notice Sets the current variable borrow rate in cache @param reserve_cache The reserve cache @param rate The rate to set

public fun set_curr_variable_borrow_rate(reserve_cache: &mut pool_logic::ReserveCache, rate: u256)

Function set_reserve_cache_last_update_timestamp

@notice Sets the last update timestamp in cache @param reserve_cache The reserve cache @param timestamp The timestamp to set

public fun set_reserve_cache_last_update_timestamp(reserve_cache: &mut pool_logic::ReserveCache, timestamp: u64)

Function get_a_token_address

@notice Gets the aToken address from cache @param reserve_cache The reserve cache @return The aToken address

public fun get_a_token_address(reserve_cache: &pool_logic::ReserveCache): address

Function get_variable_debt_token_address

@notice Gets the variable debt token address from cache @param reserve_cache The reserve cache @return The variable debt token address

public fun get_variable_debt_token_address(reserve_cache: &pool_logic::ReserveCache): address

Function get_curr_scaled_variable_debt

@notice Gets the current scaled variable debt from cache @param reserve_cache The reserve cache @return The current scaled variable debt

public fun get_curr_scaled_variable_debt(reserve_cache: &pool_logic::ReserveCache): u256

Function get_next_scaled_variable_debt

@notice Gets the next scaled variable debt from cache @param reserve_cache The reserve cache @return The next scaled variable debt

public fun get_next_scaled_variable_debt(reserve_cache: &pool_logic::ReserveCache): u256

Function set_next_scaled_variable_debt

@notice Sets the next scaled variable debt in cache @param reserve_cache The reserve cache @param scaled_debt The scaled debt to set

public fun set_next_scaled_variable_debt(reserve_cache: &mut pool_logic::ReserveCache, scaled_debt: u256)