Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::validation_logic
@title Validation Logic Module @author Aave @notice Implements the validation logic for the various actions of the protocol
- Function
validate_flashloan_complex
- Function
validate_flashloan_simple
- Function
validate_supply
- Function
validate_withdraw
- Function
validate_transfer
- Function
validate_set_use_reserve_as_collateral
- Function
validate_borrow
- Function
validate_repay
- Function
validate_liquidation_call
- Function
validate_hf_and_ltv
- Function
validate_automatic_use_as_collateral
- Function
validate_use_as_collateral
- Function
validate_health_factor
- Function
validate_set_user_emode
use 0x1::object;
use 0x1::timestamp;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::reserve_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::user_config;
use 0xc1b23ac8ce67df6361b241bfa30a22c9b177fe39c471334a514eea977e6673a9::oracle;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::a_token_factory;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::generic_logic;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool_logic;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::math_utils;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::wad_ray_math;
Function validate_flashloan_complex
@notice Validates a flashloan action. @param assets The assets being flash-borrowed @param amounts The amounts for each asset being borrowed @param interest_rate_modes The interest rate modes for each asset
public fun validate_flashloan_complex(assets: &vector<address>, amounts: &vector<u256>, interest_rate_modes: &vector<u8>)
Function validate_flashloan_simple
@notice Validates a flashloan action. @param reserve_data The reserve data the reserve @param amount The amount being flash-borrowed
public fun validate_flashloan_simple(reserve_data: object::Object<pool::ReserveData>, amount: u256)
Function validate_supply
@notice Validates a supply action. @param reserve_cache The reserve cache of the reserve @param reserve_data The reserve data of the reserve @param amount The amount to be supplied @param on_behalf_of The account on which behalf the amount is being supplied
public fun validate_supply(reserve_cache: &pool_logic::ReserveCache, reserve_data: object::Object<pool::ReserveData>, amount: u256, on_behalf_of: address)
Function validate_withdraw
@notice Validates a withdraw action. @param reserve_cache The reserve cache of the reserve @param amount The amount to be withdrawn @param user_balance The balance of the user
public fun validate_withdraw(reserve_cache: &pool_logic::ReserveCache, amount: u256, user_balance: u256)
Function validate_transfer
@notice Validates a transfer action. @param reserve_data The reserve data the reserve
public fun validate_transfer(reserve_data: object::Object<pool::ReserveData>)
Function validate_set_use_reserve_as_collateral
@notice Validates the action of setting an asset as collateral. @param reserve_cache The reserve cache of the reserve @param user_balance The balance of the user @param is_collateral Indicates whether the asset is currently used as collateral in the user config @param use_as_collateral True if the user wants to use the supply as collateral, false otherwise
public fun validate_set_use_reserve_as_collateral(reserve_cache: &pool_logic::ReserveCache, user_balance: u256, is_collateral: bool, use_as_collateral: bool)
Function validate_borrow
@notice Validates a borrow action. @param reserve_cache The reserve cache of the reserve @param user_config_map The UserConfigurationMap object @param asset The address of the asset to be borrowed @param user_address The address of the user @param amount The amount to be borrowed @param interest_rate_mode The interest rate mode @param reserves_count The number of reserves @param user_emode_category The user's eMode category @param emode_ltv The eMode LTV @param emode_liq_threshold The eMode liquidation threshold @param isolation_mode_active The isolation mode state @param isolation_mode_collateral_address The address of the collateral reserve in isolation mode @param isolation_mode_debt_ceiling The debt ceiling in isolation mode
public fun validate_borrow(reserve_cache: &pool_logic::ReserveCache, user_config_map: &user_config::UserConfigurationMap, asset: address, user_address: address, amount: u256, interest_rate_mode: u8, reserves_count: u256, user_emode_category: u8, emode_ltv: u256, emode_liq_threshold: u256, isolation_mode_active: bool, isolation_mode_collateral_address: address, isolation_mode_debt_ceiling: u256)
Function validate_repay
@notice Validates a repay action. @param account_address The address of the user repaying the debt @param reserve_cache The reserve cache of the reserve @param amount_sent The amount sent for the repayment. Can be an actual value or uint(-1) @param interest_rate_mode The interest rate mode of the debt being repaid @param on_behalf_of The address of the user account_address is repaying for @param variable_debt The borrow balance of the user
public fun validate_repay(account_address: address, reserve_cache: &pool_logic::ReserveCache, amount_sent: u256, interest_rate_mode: u8, on_behalf_of: address, variable_debt: u256)
Function validate_liquidation_call
@notice Validates the liquidation action. @param user_config_map The user configuration mapping @param collateral_reserve_data The reserve data of the collateral @param debt_reserve_data The reserve data of the debt @param debt_reserve_cache The reserve cache of the debt reserve @param total_debt The total debt of the user @param health_factor The health factor of the user
public fun validate_liquidation_call(user_config_map: &user_config::UserConfigurationMap, collateral_reserve_data: object::Object<pool::ReserveData>, debt_reserve_data: object::Object<pool::ReserveData>, debt_reserve_cache: &pool_logic::ReserveCache, total_debt: u256, health_factor: u256)
Function validate_hf_and_ltv
@notice Validates the health factor of a user and the ltv of the asset being withdrawn. @param user_config_map the user configuration map @param asset The address of the underlying asset of the reserve @param from The user from which the aTokens are being transferred @param reserves_count The number of available reserves @param user_emode_category The users active efficiency mode category @param emode_ltv The ltv of the efficiency mode category @param emode_liq_threshold The liquidation threshold of the efficiency mode category
public fun validate_hf_and_ltv(user_config_map: &user_config::UserConfigurationMap, asset: address, from: address, reserves_count: u256, user_emode_category: u8, emode_ltv: u256, emode_liq_threshold: u256)
Function validate_automatic_use_as_collateral
@notice Validates if an asset should be automatically activated as collateral in the following actions: supply, transfer, mint unbacked, and liquidate @dev This is used to ensure that isolated assets are not enabled as collateral automatically @param user_config_map the user configuration map @param reserve_config_map The reserve configuration map @return True if the asset can be activated as collateral, false otherwise
public fun validate_automatic_use_as_collateral(user_config_map: &user_config::UserConfigurationMap, reserve_config_map: &reserve_config::ReserveConfigurationMap): bool
Function validate_use_as_collateral
@notice Validates the action of activating the asset as collateral. @dev Only possible if the asset has non-zero LTV and the user is not in isolation mode @param user_config_map the user configuration map @param reserve_config_map The reserve configuration map @return True if the asset can be activated as collateral, false otherwise
public fun validate_use_as_collateral(user_config_map: &user_config::UserConfigurationMap, reserve_config_map: &reserve_config::ReserveConfigurationMap): bool
Function validate_health_factor
@notice Validates the health factor of a user. @param user_config_map the user configuration map @param user The user to validate health factor of @param user_emode_category The users active efficiency mode category @param reserves_count The number of available reserves @param emode_ltv The ltv of the efficiency mode category @param emode_liq_threshold The liquidation threshold of the efficiency mode category @return The health factor and whether the user has a zero-LTV collateral
public fun validate_health_factor(user_config_map: &user_config::UserConfigurationMap, user: address, user_emode_category: u8, reserves_count: u256, emode_ltv: u256, emode_liq_threshold: u256): (u256, bool)
Function validate_set_user_emode
@notice Validates the action of setting efficiency mode. @param user_config_map the user configuration map @param reserves_count The total number of valid reserves @param category_id The id of the category @param liquidation_threshold The liquidation threshold
public fun validate_set_user_emode(user_config_map: &user_config::UserConfigurationMap, reserves_count: u256, category_id: u8, liquidation_threshold: u16)