Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool_configurator

@title Pool Configurator Module @author Aave @notice Implements functionality to configure the Aave protocol pool parameters

use 0x1::event;
use 0x1::object;
use 0x1::option;
use 0x1::signer;
use 0x1::smart_table;
use 0x1::string;
use 0x1::timestamp;
use 0x24e01fa503119e76bf9eea69eec59884fc3da82f5ea23bf5f20f8ce358a4606::acl_manage;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::reserve_config;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::a_token_factory;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::default_reserve_interest_rate_strategy;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::emode_logic;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool_fee_manager;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool_logic;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool_token_logic;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::variable_debt_token_factory;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::math_utils;

Resource InternalData

@notice Internal module data

struct InternalData has key

Struct ReserveInterestRateDataChanged

@notice Emitted when reserve interest rate strategy configuration is updated @param asset The address of the underlying asset of the reserve @param optimal_usage_ratio Optimal utilization ratio used in the interest rate calculation @param base_variable_borrow_rate Base variable borrow rate when usage rate is 0 (expressed in ray) @param variable_rate_slope1 Slope of the variable rate curve when usage <= optimal (expressed in ray) @param variable_rate_slope2 Slope of the variable rate curve when usage > optimal (expressed in ray)

#[event]
struct ReserveInterestRateDataChanged has drop, store

Struct ReserveBorrowing

@notice Emitted when borrowing is enabled or disabled on a reserve @param asset The address of the underlying asset of the reserve @param enabled True if borrowing is enabled, false otherwise

#[event]
struct ReserveBorrowing has drop, store

Struct ReserveFlashLoaning

@notice Emitted when flashloans are enabled or disabled on a reserve @param asset The address of the underlying asset of the reserve @param enabled True if flashloans are enabled, false otherwise

#[event]
struct ReserveFlashLoaning has drop, store

Struct CollateralConfigurationChanged

@notice Emitted when the collateralization risk parameters for the specified asset are updated @param asset The address of the underlying asset of the reserve @param ltv The loan to value of the asset when used as collateral @param liquidation_threshold The threshold at which loans using this asset as collateral will be considered undercollateralized @param liquidation_bonus The bonus liquidators receive to liquidate this asset

#[event]
struct CollateralConfigurationChanged has drop, store

Struct PendingLtvChanged

@notice Emitted when the pending ltv has changed during reserve freezing @param asset The address of the underlying asset of the reserve @param pending_ltv_set The pending loan to value of the asset when used as collateral

#[event]
struct PendingLtvChanged has drop, store

Struct ReserveActive

@notice Emitted when a reserve is activated or deactivated @param asset The address of the underlying asset of the reserve @param active True if reserve is active, false otherwise

#[event]
struct ReserveActive has drop, store

Struct ReserveFrozen

@notice Emitted when a reserve is frozen or unfrozen @param asset The address of the underlying asset of the reserve @param frozen True if reserve is frozen, false otherwise

#[event]
struct ReserveFrozen has drop, store

Struct ReservePaused

@notice Emitted when a reserve is paused or unpaused @param asset The address of the underlying asset of the reserve @param paused True if reserve is paused, false otherwise

#[event]
struct ReservePaused has drop, store

Struct ReserveDropped

@notice Emitted when a reserve is dropped @param asset The address of the underlying asset of the reserve

#[event]
struct ReserveDropped has drop, store

Struct ReserveFactorChanged

@notice Emitted when a reserve factor is updated @param asset The address of the underlying asset of the reserve @param old_reserve_factor The old reserve factor, expressed in bps @param new_reserve_factor The new reserve factor, expressed in bps

#[event]
struct ReserveFactorChanged has drop, store

Struct BorrowCapChanged

@notice Emitted when the borrow cap of a reserve is updated @param asset The address of the underlying asset of the reserve @param old_borrow_cap The old borrow cap @param new_borrow_cap The new borrow cap

#[event]
struct BorrowCapChanged has drop, store

Struct SupplyCapChanged

@notice Emitted when the supply cap of a reserve is updated @param asset The address of the underlying asset of the reserve @param old_supply_cap The old supply cap @param new_supply_cap The new supply cap

#[event]
struct SupplyCapChanged has drop, store

Struct LiquidationProtocolFeeChanged

@notice Emitted when the liquidation protocol fee of a reserve is updated @param asset The address of the underlying asset of the reserve @param old_fee The old liquidation protocol fee, expressed in bps @param new_fee The new liquidation protocol fee, expressed in bps

#[event]
struct LiquidationProtocolFeeChanged has drop, store

Struct LiquidationGracePeriodChanged

@notice Emitted when the liquidation grace period is updated @param asset The address of the underlying asset of the reserve @param grace_period_until Timestamp until when liquidations will not be allowed post-unpause

#[event]
struct LiquidationGracePeriodChanged has drop, store

Struct LiquidationGracePeriodDisabled

@notice Emitted when the liquidation grace period is disabled @param asset The address of the underlying asset of the reserve

#[event]
struct LiquidationGracePeriodDisabled has drop, store

Struct EModeAssetCategoryChanged

@notice Emitted when the category of an asset in eMode is changed @param asset The address of the underlying asset of the reserve @param old_category_id The old eMode asset category @param new_category_id The new eMode asset category

#[event]
struct EModeAssetCategoryChanged has drop, store

Struct EModeCategoryAdded

@notice Emitted when a new eMode category is added @param category_id The new eMode category id @param ltv The ltv for the asset category in eMode @param liquidation_threshold The liquidationThreshold for the asset category in eMode @param liquidation_bonus The liquidationBonus for the asset category in eMode @param oracle The optional address of the price oracle specific for this category @param label A human readable identifier for the category

#[event]
struct EModeCategoryAdded has drop, store

Struct DebtCeilingChanged

@notice Emitted when the debt ceiling of an asset is set @param asset The address of the underlying asset of the reserve @param old_debt_ceiling The old debt ceiling @param new_debt_ceiling The new debt ceiling

#[event]
struct DebtCeilingChanged has drop, store

Struct SiloedBorrowingChanged

@notice Emitted when the the siloed borrowing state for an asset is changed @param asset The address of the underlying asset of the reserve @param old_state The old siloed borrowing state @param new_state The new siloed borrowing state

#[event]
struct SiloedBorrowingChanged has drop, store

Struct FlashloanPremiumTotalUpdated

@notice Emitted when the total premium on flashloans is updated @param old_flashloan_premium_total The old premium, expressed in bps @param new_flashloan_premium_total The new premium, expressed in bps

#[event]
struct FlashloanPremiumTotalUpdated has drop, store

Struct FlashloanPremiumToProtocolUpdated

@notice Emitted when the part of the premium that goes to protocol is updated @param old_flashloan_premium_to_protocol The old premium, expressed in bps @param new_flashloan_premium_to_protocol The new premium, expressed in bps

#[event]
struct FlashloanPremiumToProtocolUpdated has drop, store

Struct BorrowableInIsolationChanged

@notice Emitted when the reserve is set as borrowable/non borrowable in isolation mode @param asset The address of the underlying asset of the reserve @param borrowable True if the reserve is borrowable in isolation, false otherwise

#[event]
struct BorrowableInIsolationChanged has drop, store

Function get_pending_ltv

@notice Returns the pending Loan-to-Value (LTV) ratio for the given asset @dev Reads from the InternalData resource but does not modify state @param asset The address of the underlying asset @return The pending LTV value as a u256, or 0 if not set

#[view]
public fun get_pending_ltv(asset: address): u256

Function init_reserves

@notice Initializes multiple reserves @param account The account signer of the caller @param underlying_asset The list of the underlying assets of the reserves @param treasury The list of the treasury addresses of the reserves @param a_token_name The list of the aToken names of the reserves @param a_token_symbol The list of the aToken symbols of the reserves @param variable_debt_token_name The list of the variable debt token names of the reserves @param variable_debt_token_symbol The list of the variable debt token symbols of the reserves @param incentives_controller The list of incentives controllers for the reserves @param optimal_usage_ratio The optimal usage ratio, in bps @param base_variable_borrow_rate The base variable borrow rate, in bps @param variable_rate_slope1 The slope of the variable interest curve, before hitting the optimal ratio, in bps @param variable_rate_slope2 The slope of the variable interest curve, after hitting the optimal ratio, in bps @dev The caller needs to be an asset listing or pool admin

public entry fun init_reserves(account: &signer, underlying_asset: vector<address>, treasury: vector<address>, a_token_name: vector<string::String>, a_token_symbol: vector<string::String>, variable_debt_token_name: vector<string::String>, variable_debt_token_symbol: vector<string::String>, incentives_controller: vector<option::Option<address>>, optimal_usage_ratio: vector<u256>, base_variable_borrow_rate: vector<u256>, variable_rate_slope1: vector<u256>, variable_rate_slope2: vector<u256>)

Function drop_reserve

@notice Drops a reserve entirely @dev Emits the ReserveDropped event @param account The account signer of the caller @param asset The address of the reserve to drop

public entry fun drop_reserve(account: &signer, asset: address)

Function set_reserve_borrowing

@notice Configures borrowing on a reserve @dev Emits the ReserveBorrowing event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param enabled True if borrowing needs to be enabled, false otherwise

public entry fun set_reserve_borrowing(account: &signer, asset: address, enabled: bool)

Function update_interest_rate_strategy

@notice Forcefully updates the interest rate strategy of the pool reserve @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param optimal_usage_ratio The optimal usage ratio, in bps @param base_variable_borrow_rate The base variable borrow rate, in bps @param variable_rate_slope1 The slope of the variable interest curve, before hitting the optimal ratio, in bps @param variable_rate_slope2 The slope of the variable interest curve, after hitting the optimal ratio, in bps

public entry fun update_interest_rate_strategy(account: &signer, asset: address, optimal_usage_ratio: u256, base_variable_borrow_rate: u256, variable_rate_slope1: u256, variable_rate_slope2: u256)

Function configure_reserve_as_collateral

@notice Configures the reserve collateralization parameters @dev Emits the CollateralConfigurationChanged event @dev All the values are expressed in bps. A value of 10000, results in 100.00% @dev The liquidation_bonus is always above 100%. A value of 105% means the liquidator will receive a 5% bonus @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param ltv The loan to value of the asset when used as collateral @param liquidation_threshold The threshold at which loans using this asset as collateral will be considered undercollateralized @param liquidation_bonus The bonus liquidators receive to liquidate this asset

public entry fun configure_reserve_as_collateral(account: &signer, asset: address, ltv: u256, liquidation_threshold: u256, liquidation_bonus: u256)

Function set_reserve_flash_loaning

@notice Enable or disable flashloans on a reserve @dev Emits the ReserveFlashLoaning event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param enabled True if flashloans need to be enabled, false otherwise

public entry fun set_reserve_flash_loaning(account: &signer, asset: address, enabled: bool)

Function set_reserve_active

@notice Activate or deactivate a reserve @dev Emits the ReserveActive event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param active True if the reserve needs to be active, false otherwise

public entry fun set_reserve_active(account: &signer, asset: address, active: bool)

Function set_reserve_freeze

@notice Freeze or unfreeze a reserve. A frozen reserve doesn't allow any new supply, borrow or rate swap but allows repayments, liquidations, rate rebalances and withdrawals @dev Emits the ReserveFrozen event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param freeze True if the reserve needs to be frozen, false otherwise

public entry fun set_reserve_freeze(account: &signer, asset: address, freeze: bool)

Function set_borrowable_in_isolation

@notice Sets the borrowable in isolation flag for the reserve @dev When this flag is set to true, the asset will be borrowable against isolated collaterals and the borrowed amount will be accumulated in the isolated collateral's total debt exposure @dev Only assets of the same family (e.g. USD stablecoins) should be borrowable in isolation mode to keep consistency in the debt ceiling calculations @dev Emits the BorrowableInIsolationChanged event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param borrowable True if the asset should be borrowable in isolation, false otherwise

public entry fun set_borrowable_in_isolation(account: &signer, asset: address, borrowable: bool)

Function set_reserve_pause

@notice Pauses a reserve. A paused reserve does not allow any interaction (supply, borrow, repay, swap interest rate, liquidate, atoken transfers) @dev Emits the ReservePaused event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param paused True if pausing the reserve, false if unpausing @param grace_period Count of seconds after unpause during which liquidations will not be available - Only applicable whenever unpausing (paused as false) - Passing 0 means no grace period - Capped to maximum MAX_GRACE_PERIOD

public entry fun set_reserve_pause(account: &signer, asset: address, paused: bool, grace_period: u64)

Function set_reserve_pause_no_grace_period

@notice Pauses/unpauses a reserve with no grace period @dev Emits the ReservePaused event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param paused True if pausing the reserve, false if unpausing

public entry fun set_reserve_pause_no_grace_period(account: &signer, asset: address, paused: bool)

Function disable_liquidation_grace_period

@notice Disables liquidation grace period for the asset. The liquidation grace period is set in the past so that liquidations are allowed for the asset @param account The account signer of the caller @param asset The address of the underlying asset of the reserve

public entry fun disable_liquidation_grace_period(account: &signer, asset: address)

Function set_reserve_factor

@notice Updates the reserve factor of a reserve @dev Emits the ReserveFactorChanged event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param new_reserve_factor The new reserve factor of the reserve

public entry fun set_reserve_factor(account: &signer, asset: address, new_reserve_factor: u256)

Function set_debt_ceiling

@notice Sets the debt ceiling for an asset @dev Emits the DebtCeilingChanged event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param new_debt_ceiling The new debt ceiling

public entry fun set_debt_ceiling(account: &signer, asset: address, new_debt_ceiling: u256)

Function set_siloed_borrowing

@notice Sets siloed borrowing for an asset @dev Emits the SiloedBorrowingChanged event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param new_siloed The new siloed borrowing state

public entry fun set_siloed_borrowing(account: &signer, asset: address, new_siloed: bool)

Function set_borrow_cap

@notice Updates the borrow cap of a reserve @dev Emits the BorrowCapChanged event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param new_borrow_cap The new borrow cap of the reserve

public entry fun set_borrow_cap(account: &signer, asset: address, new_borrow_cap: u256)

Function set_supply_cap

@notice Updates the supply cap of a reserve @dev Emits the SupplyCapChanged event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param new_supply_cap The new supply cap of the reserve

public entry fun set_supply_cap(account: &signer, asset: address, new_supply_cap: u256)

Function set_liquidation_protocol_fee

@notice Updates the liquidation protocol fee of reserve @dev Emits the LiquidationProtocolFeeChanged event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param new_fee The new liquidation protocol fee of the reserve, expressed in bps

public entry fun set_liquidation_protocol_fee(account: &signer, asset: address, new_fee: u256)

Function set_emode_category

@notice Adds a new efficiency mode (eMode) category or alters an existing one. @dev The new ltv and liquidation threshold must be greater than the base ltvs and liquidation thresholds of all assets within the eMode category @dev Emits the EModeCategoryAdded event @param account The account signer of the caller @param category_id The id of the category to be configured @param ltv The ltv associated with the category @param liquidation_threshold The liquidation threshold associated with the category @param liquidation_bonus The liquidation bonus associated with the category @param label A label identifying the category

public entry fun set_emode_category(account: &signer, category_id: u8, ltv: u16, liquidation_threshold: u16, liquidation_bonus: u16, label: string::String)

Function set_asset_emode_category

@notice Assign an efficiency mode (eMode) category to asset @dev Emits the EModeAssetCategoryChanged event @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param new_category_id The new category id of the asset

public entry fun set_asset_emode_category(account: &signer, asset: address, new_category_id: u8)

Function set_pool_pause

@notice Pauses or unpauses all the protocol reserves. In the paused state all the protocol interactions are suspended @dev Emits the ReservePaused event for each reserve @param account The account signer of the caller @param paused True if protocol needs to be paused, false otherwise @param grace_period Count of seconds after unpause during which liquidations will not be available - Only applicable whenever unpausing (paused as false) - Passing 0 means no grace period - Capped to maximum MAX_GRACE_PERIOD

public entry fun set_pool_pause(account: &signer, paused: bool, grace_period: u64)

Function set_pool_pause_no_grace_period

@notice Pauses or unpauses all the protocol reserves with no grace period. In the paused state all the protocol interactions are suspended @dev Emits the ReservePaused event for each reserve @param account The account signer of the caller @param paused True if protocol needs to be paused, false otherwise

public entry fun set_pool_pause_no_grace_period(account: &signer, paused: bool)

Function update_flashloan_premium_total

@notice Updates the total flash loan premium. Total flash loan premium consists of two parts: - A part is sent to aToken holders as extra balance - A part is collected by the protocol reserves @dev Expressed in bps @dev The premium is calculated on the total amount borrowed @dev Emits the FlashloanPremiumTotalUpdated event @param account The account signer of the caller @param new_flashloan_premium_total The total flashloan premium

public entry fun update_flashloan_premium_total(account: &signer, new_flashloan_premium_total: u128)

Function update_flashloan_premium_to_protocol

@notice Updates the flash loan premium collected by protocol reserves @dev Expressed in bps @dev The premium to protocol is calculated on the total flashloan premium @dev Emits the FlashloanPremiumToProtocolUpdated event @param account The account signer of the caller @param new_flashloan_premium_to_protocol The part of the flashloan premium sent to the protocol treasury

public entry fun update_flashloan_premium_to_protocol(account: &signer, new_flashloan_premium_to_protocol: u128)

Function set_apt_fee

@notice Updates the global APT fee rate (in micro APT units) @dev The new apt fee must be less than or equal to MAX_APT_FEE (10 APT) @dev Emits a FeeChanged event on successful update @param account The account signer of the caller @param asset The address of the underlying asset of the reserve @param new_apt_fee The new fee value in micro APT

public entry fun set_apt_fee(account: &signer, asset: address, new_apt_fee: u64)