Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::emode_logic
@title Emode Logic Module @author Aave @notice Implements the base logic for all the actions related to the eMode
- Struct
UserEModeSet
- Struct
EModeCategory
- Resource
EModeCategoryList
- Resource
UsersEmodeCategory
- Constants
- Function
get_user_emode
- Function
get_emode_configuration
- Function
get_emode_e_mode_label
- Function
get_emode_e_mode_liquidation_bonus
- Function
is_in_emode_category
- Function
get_emode_category_data
- Function
set_user_emode
- Function
get_emode_category_ltv
- Function
get_emode_category_liquidation_threshold
- Function
get_emode_category_liquidation_bonus
- Function
get_emode_category_label
- Function
init_emode
- Function
configure_emode_category
use 0x1::event;
use 0x1::signer;
use 0x1::smart_table;
use 0x1::string;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::user_config;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::validation_logic;
Struct UserEModeSet
@dev Emitted when the user selects a certain asset category for eMode @param user The address of the user @param category_id The category id
#[event]
struct UserEModeSet has drop, store
Struct EModeCategory
struct EModeCategory has copy, drop, store
Resource EModeCategoryList
List of eMode categories as a map (emode_category_id => EModeCategory).
struct EModeCategoryList has key
Resource UsersEmodeCategory
Map of users address and their eMode category (user_address => emode_category_id)
struct UsersEmodeCategory has key
Constants
const EMPTY_STRING: vector<u8> = [];
Function get_user_emode
@notice Returns the eMode the user is using @param user The address of the user @return The eMode id
#[view]
public fun get_user_emode(user: address): u8
Function get_emode_configuration
@notice Gets the eMode configuration and calculates the eMode asset price if a custom oracle is configured @param user_emode_category The user eMode category @return The eMode ltv @return The eMode liquidation threshold
#[view]
public fun get_emode_configuration(user_emode_category: u8): (u256, u256)
Function get_emode_e_mode_label
@notice Gets the eMode category label @param user_emode_category The user eMode category @return The label of the eMode category
#[view]
public fun get_emode_e_mode_label(user_emode_category: u8): string::String
Function get_emode_e_mode_liquidation_bonus
@notice Gets the eMode category liquidation_bonus @param user_emode_category The user eMode category @return The liquidation bonus of the eMode category
#[view]
public fun get_emode_e_mode_liquidation_bonus(user_emode_category: u8): u16
Function is_in_emode_category
@notice Checks if eMode is active for a user and if yes, if the asset belongs to the eMode category chosen @param emode_user_category The user eMode category @param emode_asset_category The asset eMode category @return True if eMode is active and the asset belongs to the eMode category chosen by the user, false otherwise
#[view]
public fun is_in_emode_category(emode_user_category: u8, emode_asset_category: u8): bool
Function get_emode_category_data
@notice Returns the data of an eMode category @param id The id of the category @return The configuration data of the category
#[view]
public fun get_emode_category_data(id: u8): emode_logic::EModeCategory
Function set_user_emode
@notice Updates the user efficiency mode category
@dev Will revert if user is borrowing non-compatible asset or change will drop HF < HEALTH_FACTOR_LIQUIDATION_THRESHOLD
@dev Emits the UserEModeSet
event
@param account The account signer of the caller
@param category_id The state of all users efficiency mode category
public entry fun set_user_emode(account: &signer, category_id: u8)
Function get_emode_category_ltv
@notice Get the ltv of the eMode category @param emode_category The eMode category @return The ltv of the eMode category
public fun get_emode_category_ltv(emode_category: &emode_logic::EModeCategory): u16
Function get_emode_category_liquidation_threshold
@notice Get the liquidation threshold of the eMode category @param emode_category The eMode category @return The liquidation threshold of the eMode category
public fun get_emode_category_liquidation_threshold(emode_category: &emode_logic::EModeCategory): u16
Function get_emode_category_liquidation_bonus
@notice Get the liquidation bonus of the eMode category @param emode_category The eMode category @return The liquidation bonus of the eMode category
public fun get_emode_category_liquidation_bonus(emode_category: &emode_logic::EModeCategory): u16
Function get_emode_category_label
@notice Get the label of the eMode category @param emode_category The eMode category @return The label of the eMode category
public fun get_emode_category_label(emode_category: &emode_logic::EModeCategory): string::String
Function init_emode
@notice Initializes the eMode @dev Only callable by the pool_configurator module @param account The account signer of the caller
public(friend) fun init_emode(account: &signer)
Function configure_emode_category
@notice Configures a new category for the eMode. @dev Only callable by the pool_configurator module @dev In eMode, the protocol allows very high borrowing power to borrow assets of the same category. The category 0 is reserved as it's the default for volatile assets @param id The id of the category @param ltv The loan to value ratio @param liquidation_threshold The liquidation threshold @param liquidation_bonus The liquidation bonus @param label The label of the category
public(friend) fun configure_emode_category(id: u8, ltv: u16, liquidation_threshold: u16, liquidation_bonus: u16, label: string::String)