Module 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::reserve_config
@title ReserveConfiguration module @author Aave @notice Implements the bitmap logic to handle the reserve configuration
- Struct
ReserveConfigurationMap
- Constants
- Function
init
- Function
get_ltv
- Function
get_liquidation_threshold
- Function
get_liquidation_bonus
- Function
get_decimals
- Function
get_active
- Function
get_frozen
- Function
get_paused
- Function
get_borrowable_in_isolation
- Function
get_siloed_borrowing
- Function
get_borrowing_enabled
- Function
get_reserve_factor
- Function
get_borrow_cap
- Function
get_supply_cap
- Function
get_debt_ceiling
- Function
get_liquidation_protocol_fee
- Function
get_emode_category
- Function
get_flash_loan_enabled
- Function
get_flags
- Function
get_params
- Function
get_caps
- Function
get_debt_ceiling_decimals
- Function
get_max_reserves_count
- Function
get_min_reserve_asset_decimals
- Function
get_max_valid_liquidation_grace_period
- Function
set_ltv
- Function
set_liquidation_threshold
- Function
set_liquidation_bonus
- Function
set_decimals
- Function
set_active
- Function
set_frozen
- Function
set_paused
- Function
set_borrowable_in_isolation
- Function
set_siloed_borrowing
- Function
set_borrowing_enabled
- Function
set_reserve_factor
- Function
set_borrow_cap
- Function
set_supply_cap
- Function
set_debt_ceiling
- Function
set_liquidation_protocol_fee
- Function
set_emode_category
- Function
set_flash_loan_enabled
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::helper;
Struct ReserveConfigurationMap
@notice Main structure for storing reserve configuration as a bitmap
struct ReserveConfigurationMap has copy, drop, store
Constants
const ACTIVE_MASK: u256 = 115792089237316195423570985008687907853269984665640564039457511950319091711999;
const BORROWABLE_IN_ISOLATION_MASK: u256 = 115792089237316195423570985008687907853269984665640564039455278164903915945983;
const BORROWABLE_IN_ISOLATION_START_BIT_POSITION: u8 = 61;
const BORROWING_ENABLED_START_BIT_POSITION: u8 = 58;
const BORROWING_MASK: u256 = 115792089237316195423570985008687907853269984665640564039457295777536977928191;
const BORROW_CAP_MASK: u256 = 115792089237316195423570985008687907853269901588890828691141347134601036824575;
const BORROW_CAP_START_BIT_POSITION: u8 = 80;
const DEBT_CEILING_DECIMALS: u256 = 2;
const DEBT_CEILING_MASK: u256 = 108555083659990515227827083269813533489170840026057959730454019326871953473535;
const DEBT_CEILING_START_BIT_POSITION: u8 = 212;
const DECIMALS_MASK: u256 = 115792089237316195423570985008687907853269984665640564039457512231794068422655;
const EMODE_CATEGORY_MASK: u256 = 115792089237316195423570889601861022891927484329094684320502060868636724166655;
const EMODE_CATEGORY_START_BIT_POSITION: u8 = 168;
const FLASHLOAN_ENABLED_MASK: u256 = 115792089237316195423570985008687907853269984665640564039448360635876274864127;
const FLASHLOAN_ENABLED_START_BIT_POSITION: u8 = 63;
const FROZEN_MASK: u256 = 115792089237316195423570985008687907853269984665640564039457439892725053784063;
const IS_ACTIVE_START_BIT_POSITION: u8 = 56;
const IS_FROZEN_START_BIT_POSITION: u8 = 57;
const IS_PAUSED_START_BIT_POSITION: u8 = 60;
const LIQUIDATION_BONUS_MASK: u256 = 115792089237316195423570985008687907853269984665640564039457583726442447896575;
const LIQUIDATION_BONUS_START_BIT_POSITION: u8 = 32;
const LIQUIDATION_PROTOCOL_FEE_MASK: u256 = 115792089237316195423570984634549197687329661445021480007966928956539929624575;
const LIQUIDATION_PROTOCOL_FEE_START_BIT_POSITION: u8 = 152;
const LIQUIDATION_THRESHOLD_MASK: u256 = 115792089237316195423570985008687907853269984665640564039457584007908834738175;
@notice For the LTV, the start bit is 0 (up to 15), hence no bitshifting is needed
const LIQUIDATION_THRESHOLD_START_BIT_POSITION: u8 = 16;
const LTV_MASK: u256 = 115792089237316195423570985008687907853269984665640564039457584007913129574400;
const MAX_RESERVES_COUNT: u256 = 128;
const MAX_VALID_BORROW_CAP: u256 = 68719476735;
const MAX_VALID_DEBT_CEILING: u256 = 1099511627775;
const MAX_VALID_DECIMALS: u256 = 255;
const MAX_VALID_EMODE_CATEGORY: u256 = 255;
const MAX_VALID_LIQUIDATION_BONUS: u256 = 65535;
const MAX_VALID_LIQUIDATION_GRACE_PERIOD: u256 = 14400;
const MAX_VALID_LIQUIDATION_PROTOCOL_FEE: u256 = 65535;
const MAX_VALID_LIQUIDATION_THRESHOLD: u256 = 65535;
const MAX_VALID_LTV: u256 = 65535;
const MAX_VALID_RESERVE_FACTOR: u256 = 65535;
const MAX_VALID_SUPPLY_CAP: u256 = 68719476735;
const MIN_RESERVE_ASSET_DECIMALS: u256 = 6;
@notice there is an unoccupied hole of 1 bit at position 59 from pre 3.2 stableBorrowRateEnabled
const PAUSED_MASK: u256 = 115792089237316195423570985008687907853269984665640564039456431086408522792959;
const RESERVE_DECIMALS_START_BIT_POSITION: u8 = 48;
const RESERVE_FACTOR_MASK: u256 = 115792089237316195423570985008687907853269984665640562830550211137357664485375;
const RESERVE_FACTOR_START_BIT_POSITION: u8 = 64;
const SILOED_BORROWING_MASK: u256 = 115792089237316195423570985008687907853269984665640564039452972321894702252031;
const SILOED_BORROWING_START_BIT_POSITION: u8 = 62;
const SUPPLY_CAP_MASK: u256 = 115792089237316195423570985008682198862499243902866067452821842515308866174975;
const SUPPLY_CAP_START_BIT_POSITION: u8 = 116;
Function init
@notice Initialize the reserve configuration @return A new ReserveConfigurationMap with zero data
public fun init(): reserve_config::ReserveConfigurationMap
Function get_ltv
@notice Gets the Loan to Value of the reserve @param self The reserve configuration @return The loan to value
public fun get_ltv(self: &reserve_config::ReserveConfigurationMap): u256
Function get_liquidation_threshold
@notice Gets the liquidation threshold of the reserve @param self The reserve configuration @return The liquidation threshold
public fun get_liquidation_threshold(self: &reserve_config::ReserveConfigurationMap): u256
Function get_liquidation_bonus
@notice Gets the liquidation bonus of the reserve @param self The reserve configuration @return The liquidation bonus
public fun get_liquidation_bonus(self: &reserve_config::ReserveConfigurationMap): u256
Function get_decimals
@notice Gets the decimals of the underlying asset of the reserve @param self The reserve configuration @return The decimals
public fun get_decimals(self: &reserve_config::ReserveConfigurationMap): u256
Function get_active
@notice Gets the active state of the reserve @param self The reserve configuration @return The active state
public fun get_active(self: &reserve_config::ReserveConfigurationMap): bool
Function get_frozen
@notice Gets the frozen state of the reserve @param self The reserve configuration @return The frozen state
public fun get_frozen(self: &reserve_config::ReserveConfigurationMap): bool
Function get_paused
@notice Gets the paused state of the reserve @param self The reserve configuration @return The paused state
public fun get_paused(self: &reserve_config::ReserveConfigurationMap): bool
Function get_borrowable_in_isolation
@notice Gets the borrowable in isolation flag for the reserve. @dev If the returned flag is true, the asset is borrowable against isolated collateral. Assets borrowed with isolated collateral is accounted for in the isolated collateral's total debt exposure. @dev Only assets of the same family (eg USD stablecoins) should be borrowable in isolation mode to keep consistency in the debt ceiling calculations. @param self The reserve configuration @return The borrowable in isolation flag
public fun get_borrowable_in_isolation(self: &reserve_config::ReserveConfigurationMap): bool
Function get_siloed_borrowing
@notice Gets the siloed borrowing flag for the reserve. @dev When this flag is set to true, users borrowing this asset will not be allowed to borrow any other asset. @param self The reserve configuration @return The siloed borrowing flag
public fun get_siloed_borrowing(self: &reserve_config::ReserveConfigurationMap): bool
Function get_borrowing_enabled
@notice Gets the borrowing state of the reserve @param self The reserve configuration @return The borrowing state
public fun get_borrowing_enabled(self: &reserve_config::ReserveConfigurationMap): bool
Function get_reserve_factor
@notice Gets the reserve factor of the reserve @param self The reserve configuration @return The reserve factor
public fun get_reserve_factor(self: &reserve_config::ReserveConfigurationMap): u256
Function get_borrow_cap
@notice Gets the borrow cap of the reserve @param self The reserve configuration @return The borrow cap
public fun get_borrow_cap(self: &reserve_config::ReserveConfigurationMap): u256
Function get_supply_cap
@notice Gets the supply cap of the reserve @param self The reserve configuration @return The supply cap
public fun get_supply_cap(self: &reserve_config::ReserveConfigurationMap): u256
Function get_debt_ceiling
@notice Gets the debt ceiling for the asset if the asset is in isolation mode @param self The reserve configuration @return The debt ceiling (0 = isolation mode disabled)
public fun get_debt_ceiling(self: &reserve_config::ReserveConfigurationMap): u256
Function get_liquidation_protocol_fee
@notice Gets the liquidation protocol fee @param self The reserve configuration @return The liquidation protocol fee
public fun get_liquidation_protocol_fee(self: &reserve_config::ReserveConfigurationMap): u256
Function get_emode_category
@notice Gets the eMode asset category @param self The reserve configuration @return The eMode category for the asset
public fun get_emode_category(self: &reserve_config::ReserveConfigurationMap): u256
Function get_flash_loan_enabled
@notice Gets the flashloanable flag for the reserve @param self The reserve configuration @return The flashloanable flag
public fun get_flash_loan_enabled(self: &reserve_config::ReserveConfigurationMap): bool
Function get_flags
@notice Gets the configuration flags of the reserve @param self The reserve configuration @return The state flag representing active @return The state flag representing frozen @return The state flag representing borrowing enabled @return The state flag representing paused
public fun get_flags(self: &reserve_config::ReserveConfigurationMap): (bool, bool, bool, bool)
Function get_params
@notice Gets the configuration parameters of the reserve from storage @param self The reserve configuration @return The state param representing ltv @return The state param representing liquidation threshold @return The state param representing liquidation bonus @return The state param representing reserve decimals @return The state param representing reserve factor @return The state param representing eMode category
public fun get_params(self: &reserve_config::ReserveConfigurationMap): (u256, u256, u256, u256, u256, u256)
Function get_caps
@notice Gets the caps parameters of the reserve from storage @param self The reserve configuration @return The state param representing borrow cap @return The state param representing supply cap.
public fun get_caps(self: &reserve_config::ReserveConfigurationMap): (u256, u256)
Function get_debt_ceiling_decimals
@notice Gets the debt ceiling decimals @return The debt ceiling decimals
public fun get_debt_ceiling_decimals(): u256
Function get_max_reserves_count
@notice Gets the maximum number of reserves @return The maximum number of reserves allowed
public fun get_max_reserves_count(): u256
Function get_min_reserve_asset_decimals
@notice Gets the minimum number of reserve asset decimals @return The minimum decimals required for reserve assets
public fun get_min_reserve_asset_decimals(): u256
Function get_max_valid_liquidation_grace_period
@notice Gets the maximum valid liquidation grace period @return The maximum allowed liquidation grace period
public fun get_max_valid_liquidation_grace_period(): u256
Function set_ltv
@notice Sets the Loan to Value of the reserve @param self The reserve configuration @param ltv The new ltv
public fun set_ltv(self: &mut reserve_config::ReserveConfigurationMap, ltv: u256)
Function set_liquidation_threshold
@notice Sets the liquidation threshold of the reserve @param self The reserve configuration @param liquidation_threshold The new liquidation threshold
public fun set_liquidation_threshold(self: &mut reserve_config::ReserveConfigurationMap, liquidation_threshold: u256)
Function set_liquidation_bonus
@notice Sets the liquidation bonus of the reserve @param self The reserve configuration @param liquidation_bonus The new liquidation bonus
public fun set_liquidation_bonus(self: &mut reserve_config::ReserveConfigurationMap, liquidation_bonus: u256)
Function set_decimals
@notice Sets the decimals of the underlying asset of the reserve @param self The reserve configuration @param decimals The decimals
public fun set_decimals(self: &mut reserve_config::ReserveConfigurationMap, decimals: u256)
Function set_active
@notice Sets the active state of the reserve @param self The reserve configuration @param active The new active state
public fun set_active(self: &mut reserve_config::ReserveConfigurationMap, active: bool)
Function set_frozen
@notice Sets the frozen state of the reserve @param self The reserve configuration @param frozen The new frozen state
public fun set_frozen(self: &mut reserve_config::ReserveConfigurationMap, frozen: bool)
Function set_paused
@notice Sets the paused state of the reserve @param self The reserve configuration @param paused The new paused state
public fun set_paused(self: &mut reserve_config::ReserveConfigurationMap, paused: bool)
Function set_borrowable_in_isolation
@notice Sets the borrowing in isolation state of 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 (eg USD stablecoins) should be borrowable in isolation mode to keep consistency in the debt ceiling calculations. @param self The reserve configuration @param borrowable The new borrowing in isolation state
public fun set_borrowable_in_isolation(self: &mut reserve_config::ReserveConfigurationMap, borrowable: bool)
Function set_siloed_borrowing
@notice Sets the siloed borrowing flag for the reserve. @dev When this flag is set to true, users borrowing this asset will not be allowed to borrow any other asset. @param self The reserve configuration @param siloed_borrowing True if the asset is siloed
public fun set_siloed_borrowing(self: &mut reserve_config::ReserveConfigurationMap, siloed_borrowing: bool)
Function set_borrowing_enabled
@notice Enables or disables borrowing on the reserve @param self The reserve configuration @param borrowing_enabled True if the borrowing needs to be enabled, false otherwise
public fun set_borrowing_enabled(self: &mut reserve_config::ReserveConfigurationMap, borrowing_enabled: bool)
Function set_reserve_factor
@notice Sets the reserve factor of the reserve @param self The reserve configuration @param reserve_factor The reserve factor
public fun set_reserve_factor(self: &mut reserve_config::ReserveConfigurationMap, reserve_factor: u256)
Function set_borrow_cap
@notice Sets the borrow cap of the reserve @param self The reserve configuration @param borrow_cap The borrow cap
public fun set_borrow_cap(self: &mut reserve_config::ReserveConfigurationMap, borrow_cap: u256)
Function set_supply_cap
@notice Sets the supply cap of the reserve @param self The reserve configuration @param supply_cap The supply cap
public fun set_supply_cap(self: &mut reserve_config::ReserveConfigurationMap, supply_cap: u256)
Function set_debt_ceiling
@notice Sets the debt ceiling in isolation mode for the asset @param self The reserve configuration @param debt_ceiling The maximum debt ceiling for the asset
public fun set_debt_ceiling(self: &mut reserve_config::ReserveConfigurationMap, debt_ceiling: u256)
Function set_liquidation_protocol_fee
@notice Sets the liquidation protocol fee of the reserve @param self The reserve configuration @param liquidation_protocol_fee The liquidation protocol fee
public fun set_liquidation_protocol_fee(self: &mut reserve_config::ReserveConfigurationMap, liquidation_protocol_fee: u256)
Function set_emode_category
@notice Sets the eMode asset category @param self The reserve configuration @param emode_category The asset category when the user selects the eMode
public fun set_emode_category(self: &mut reserve_config::ReserveConfigurationMap, emode_category: u256)
Function set_flash_loan_enabled
@notice Sets the flashloanable flag for the reserve @param self The reserve configuration @param flash_loan_enabled True if the asset is flashloanable, false otherwise
public fun set_flash_loan_enabled(self: &mut reserve_config::ReserveConfigurationMap, flash_loan_enabled: bool)