diff --git a/aave-core/aave-data/sources/v1.move b/aave-core/aave-data/sources/v1.move index 27d3467..1cd0d43 100644 --- a/aave-core/aave-data/sources/v1.move +++ b/aave-core/aave-data/sources/v1.move @@ -54,6 +54,14 @@ module aave_data::v1 { oracle_configs_testnet: smart_table::SmartTable>, /// @dev Oracle configuration for mainnet oracle_configs_mainnet: smart_table::SmartTable>, + /// @dev Flashloan premiums to protocol configuration for testnet + flashloan_premium_to_protocol_testnet: smart_table::SmartTable, + /// @dev Flashloan premiums to protocol configuration for mainnet + flashloan_premium_to_protocol_mainnet: smart_table::SmartTable, + /// @dev Flashloan premium totals for testnet + flashloan_premium_premium_totals_testnet: smart_table::SmartTable, + /// @dev Flashloan premium totals for mainnet + flashloan_premium_premium_totals_mainnet: smart_table::SmartTable, /// @dev Pool admins addresses for testnet pool_admins_testnet: vector
, @@ -136,7 +144,11 @@ module aave_data::v1 { admin_controlled_ecosystem_reserve_funds_admins_mainnet: aave_data::v1_values::build_admin_controlled_ecosystem_reserve_funds_admins_mainnet(), rewards_controller_admins_mainnet: aave_data::v1_values::build_rewards_controller_admins_mainnet(), oracle_configs_testnet: aave_data::v1_values::build_oracle_configs_testnet(), - oracle_configs_mainnet: aave_data::v1_values::build_oracle_configs_mainnet() + oracle_configs_mainnet: aave_data::v1_values::build_oracle_configs_mainnet(), + flashloan_premium_to_protocol_testnet: aave_data::v1_values::build_flashloan_premium_to_protocol_testnet(), + flashloan_premium_to_protocol_mainnet: aave_data::v1_values::build_flashloan_premium_to_protocol_mainnet(), + flashloan_premium_premium_totals_testnet: aave_data::v1_values::build_flashloan_premium_totals_testnet(), + flashloan_premium_premium_totals_mainnet: aave_data::v1_values::build_flashloan_premium_totals_mainnet() } ); } @@ -491,4 +503,82 @@ module aave_data::v1 { global_data.rewards_controller_admins_mainnet ) } + + /// @notice Gets the flashloan_premium_premium_totals for mainnet in normalized format (keys and values as separate vectors) + /// @return Tuple of (asset symbols, values) + public fun get_flashloan_premium_totals_mainnet_normalized(): + (vector, vector) acquires Data { + let table = + &borrow_global(@aave_data).flashloan_premium_premium_totals_mainnet; + let keys = smart_table::keys(table); + let views = vector::empty(); + + let i = 0; + while (i < vector::length(&keys)) { + let key = *vector::borrow(&keys, i); + let val = *smart_table::borrow(table, key); + vector::push_back(&mut views, val); + i = i + 1; + }; + (keys, views) + } + + /// @notice Gets the flashloan_premium_premium_totals for testnet in normalized format (keys and values as separate vectors) + /// @return Tuple of (asset symbols, values) + public fun get_flashloan_premium_totals_testnet_normalized(): + (vector, vector) acquires Data { + let table = + &borrow_global(@aave_data).flashloan_premium_premium_totals_testnet; + let keys = smart_table::keys(table); + let views = vector::empty(); + + let i = 0; + while (i < vector::length(&keys)) { + let key = *vector::borrow(&keys, i); + let val = *smart_table::borrow(table, key); + vector::push_back(&mut views, val); + i = i + 1; + }; + (keys, views) + } + + /// @notice Gets the flashloan_premium_to_protocol for mainnet in normalized format (keys and values as separate vectors) + /// @return Tuple of (asset symbols, values) + public fun get_flashloan_premium_to_protocol_mainnet_normalized(): ( + vector, vector + ) acquires Data { + let table = + &borrow_global(@aave_data).flashloan_premium_to_protocol_mainnet; + let keys = smart_table::keys(table); + let views = vector::empty(); + + let i = 0; + while (i < vector::length(&keys)) { + let key = *vector::borrow(&keys, i); + let val = *smart_table::borrow(table, key); + vector::push_back(&mut views, val); + i = i + 1; + }; + (keys, views) + } + + /// @notice Gets the flashloan_premium_to_protocol for testnet in normalized format (keys and values as separate vectors) + /// @return Tuple of (asset symbols, values) + public fun get_flashloan_premium_to_protocol_testnet_normalized(): ( + vector, vector + ) acquires Data { + let table = + &borrow_global(@aave_data).flashloan_premium_to_protocol_testnet; + let keys = smart_table::keys(table); + let views = vector::empty(); + + let i = 0; + while (i < vector::length(&keys)) { + let key = *vector::borrow(&keys, i); + let val = *smart_table::borrow(table, key); + vector::push_back(&mut views, val); + i = i + 1; + }; + (keys, views) + } } diff --git a/aave-core/aave-data/sources/v1_deployment.move b/aave-core/aave-data/sources/v1_deployment.move index 02b1374..a754cc2 100644 --- a/aave-core/aave-data/sources/v1_deployment.move +++ b/aave-core/aave-data/sources/v1_deployment.move @@ -491,6 +491,32 @@ module aave_data::v1_deployment { aave_data::v1::get_reserves_config_testnet_normalized() }; + // Fetch all flashloan premium values based on the specified network + let (_reserve_config_keys, flashloan_premium_totals) = + if (network == utf8(APTOS_MAINNET)) { + aave_data::v1::get_flashloan_premium_totals_mainnet_normalized() + } else if (network == utf8(APTOS_TESTNET)) { + aave_data::v1::get_flashloan_premium_totals_testnet_normalized() + } else { + print( + &format1(&b"Unsupported network - {}. Using testnet values", network) + ); + aave_data::v1::get_flashloan_premium_totals_testnet_normalized() + }; + + // Fetch all flashloan premium to protocol values based on the specified network + let (_reserve_config_keys, flashloan_premiums_to_protocol) = + if (network == utf8(APTOS_MAINNET)) { + aave_data::v1::get_flashloan_premium_to_protocol_mainnet_normalized() + } else if (network == utf8(APTOS_TESTNET)) { + aave_data::v1::get_flashloan_premium_to_protocol_testnet_normalized() + } else { + print( + &format1(&b"Unsupported network - {}. Using testnet values", network) + ); + aave_data::v1::get_flashloan_premium_to_protocol_testnet_normalized() + }; + // Configure each reserve with its specific parameters print(&format1(&b"Configuring reserves ... {}", 1)); for (i in 0..vector::length(&underlying_assets_addresses)) { @@ -501,6 +527,9 @@ module aave_data::v1_deployment { object::address_to_object(underlying_asset_address); let underlying_asset_decimals = fungible_asset::decimals(underlying_asset_metadata); + let flashloan_premium_total = *vector::borrow(&flashloan_premium_totals, i); + let flashloan_premium_to_protocol = + *vector::borrow(&flashloan_premiums_to_protocol, i); // Extract configuration parameters for this reserve let reserve_config = vector::borrow(&reserve_configs, i); @@ -583,6 +612,14 @@ module aave_data::v1_deployment { ); }; + // set flashloan premiums + pool_configurator::update_flashloan_premium_total( + account, flashloan_premium_total as u128 + ); + pool_configurator::update_flashloan_premium_to_protocol( + account, flashloan_premium_to_protocol as u128 + ); + // Apply the configuration to the reserve aave_pool::pool::set_reserve_configuration_with_guard( account, underlying_asset_address, reserve_config_new diff --git a/aave-core/aave-data/sources/v1_values.move b/aave-core/aave-data/sources/v1_values.move index dc8d29e..cf98a23 100644 --- a/aave-core/aave-data/sources/v1_values.move +++ b/aave-core/aave-data/sources/v1_values.move @@ -1143,4 +1143,112 @@ module aave_data::v1_values { ); interest_rate_config } + + /// @notice Build flashloan premium totals for mainnet + /// @return SmartTable mapping asset symbols to flashloan premium totals + public fun build_flashloan_premium_totals_mainnet(): SmartTable { + let flashloan_premium_totals = smart_table::new(); + smart_table::upsert( + &mut flashloan_premium_totals, + utf8(APT_ASSET), + (5 * math_utils::get_percentage_factor()) / 10000 // 0.05% + ); + smart_table::upsert( + &mut flashloan_premium_totals, + utf8(USDC_ASSET), + (5 * math_utils::get_percentage_factor()) / 10000 // 0.05% + ); + smart_table::upsert( + &mut flashloan_premium_totals, + utf8(USDT_ASSET), + (5 * math_utils::get_percentage_factor()) / 10000 // 0.05% + ); + smart_table::upsert( + &mut flashloan_premium_totals, + utf8(SUSDE_ASSET), + (5 * math_utils::get_percentage_factor()) / 10000 // 0.05% + ); + flashloan_premium_totals + } + + /// @notice Build flashloan premium totals for testnet + /// @return SmartTable mapping asset symbols to flashloan premium totals + public fun build_flashloan_premium_totals_testnet(): SmartTable { + let flashloan_premium_totals = smart_table::new(); + smart_table::upsert( + &mut flashloan_premium_totals, + utf8(APT_ASSET), + (5 * math_utils::get_percentage_factor()) / 10000 // 0.05% + ); + smart_table::upsert( + &mut flashloan_premium_totals, + utf8(USDC_ASSET), + (5 * math_utils::get_percentage_factor()) / 10000 // 0.05% + ); + smart_table::upsert( + &mut flashloan_premium_totals, + utf8(USDT_ASSET), + (5 * math_utils::get_percentage_factor()) / 10000 // 0.05% + ); + smart_table::upsert( + &mut flashloan_premium_totals, + utf8(SUSDE_ASSET), + (5 * math_utils::get_percentage_factor()) / 10000 // 0.05% + ); + flashloan_premium_totals + } + + /// @notice Build flashloan premium to protocol for mainnet + /// @return SmartTable mapping asset symbols to flashloan premium to protocol + public fun build_flashloan_premium_to_protocol_mainnet(): SmartTable { + let flashloan_premium_to_protocol = smart_table::new(); + smart_table::upsert( + &mut flashloan_premium_to_protocol, + utf8(APT_ASSET), + 0 // 0% + ); + smart_table::upsert( + &mut flashloan_premium_to_protocol, + utf8(USDC_ASSET), + 0 // 0% + ); + smart_table::upsert( + &mut flashloan_premium_to_protocol, + utf8(USDT_ASSET), + 0 // 0% + ); + smart_table::upsert( + &mut flashloan_premium_to_protocol, + utf8(SUSDE_ASSET), + 0 // 0% + ); + flashloan_premium_to_protocol + } + + /// @notice Build flashloan premium to protocol for testnet + /// @return SmartTable mapping asset symbols to flashloan premium to protocol + public fun build_flashloan_premium_to_protocol_testnet(): SmartTable { + let flashloan_premium_to_protocol = smart_table::new(); + smart_table::upsert( + &mut flashloan_premium_to_protocol, + utf8(APT_ASSET), + 0 // 0% + ); + smart_table::upsert( + &mut flashloan_premium_to_protocol, + utf8(USDC_ASSET), + 0 // 0% + ); + smart_table::upsert( + &mut flashloan_premium_to_protocol, + utf8(USDT_ASSET), + 0 // 0% + ); + smart_table::upsert( + &mut flashloan_premium_to_protocol, + utf8(SUSDE_ASSET), + 0 // 0% + ); + flashloan_premium_to_protocol + } }