From 16da41a66315fe1c4d28dde538b1f7aa3c945f46 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 27 Sep 2023 12:56:33 +0530 Subject: [PATCH 01/19] fix: changed premium fee calculation . --- crates/redeem/src/ext.rs | 12 ++++++++++++ crates/redeem/src/lib.rs | 30 +++++++++++++++++++++--------- crates/vault-registry/src/lib.rs | 18 +++++++++++++++++- crates/vault-registry/src/types.rs | 12 ++++++++++++ 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/crates/redeem/src/ext.rs b/crates/redeem/src/ext.rs index eb82f90acf..41f27bae0e 100644 --- a/crates/redeem/src/ext.rs +++ b/crates/redeem/src/ext.rs @@ -76,6 +76,18 @@ pub(crate) mod vault_registry { >::get_vault_from_id(vault_id) } + pub fn vault_to_be_backed_tokens( + vault_id: &DefaultVaultId, + ) -> Result, DispatchError> { + >::vault_to_be_backed_tokens(vault_id) + } + + pub fn vault_capacity_at_secure_threshold( + vault_id: &DefaultVaultId, + ) -> Result, DispatchError> { + >::vault_capacity_at_secure_threshold(vault_id) + } + pub fn try_increase_to_be_redeemed_tokens( vault_id: &DefaultVaultId, amount: &Amount, diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index 2cbccaf2ec..fbeecf305d 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -501,23 +501,35 @@ impl Pallet { Error::::AmountBelowDustAmount ); - // vault will get rid of the btc + btc_inclusion_fee - ext::vault_registry::try_increase_to_be_redeemed_tokens::(&vault_id, &vault_to_be_burned_tokens)?; - - // lock full amount (inc. fee) - amount_wrapped.lock_on(&redeemer)?; - let redeem_id = ext::security::get_secure_id::(&redeemer); - let below_premium_redeem = ext::vault_registry::is_vault_below_premium_threshold::(&vault_id)?; let currency_id = vault_id.collateral_currency(); let premium_collateral = if below_premium_redeem { - let redeem_amount_wrapped_in_collateral = user_to_be_received_btc.convert_to(currency_id)?; - ext::fee::get_premium_redeem_fee::(&redeem_amount_wrapped_in_collateral)? + // we only award a premium on the amount ok tokens required to bring + // `issued + to_be_issued - to_be_redeemed` back to the secure threshold + + let capacity = ext::vault_registry::vault_capacity_at_secure_threshold(&vault_id)?; + let to_be_backed_tokens = ext::vault_registry::vault_to_be_backed_tokens(&vault_id)?; + + // the amount of tokens that we can give a premium for + let max_premium_tokens = to_be_backed_tokens.saturating_sub(&capacity)?; + // the actual amount of tokens redeemed that we give a premium for + let actual_premium_tokens = max_premium_tokens.min(&user_to_be_received_btc)?; + // converted to collateral.. + let premium_tokens_in_collateral = actual_premium_tokens.convert_to(currency_id)?; + + ext::fee::get_premium_redeem_fee::(&premium_tokens_in_collateral)? } else { Amount::zero(currency_id) }; + // vault will get rid of the btc + btc_inclusion_fee + ext::vault_registry::try_increase_to_be_redeemed_tokens::(&vault_id, &vault_to_be_burned_tokens)?; + + // lock full amount (inc. fee) + amount_wrapped.lock_on(&redeemer)?; + let redeem_id = ext::security::get_secure_id::(&redeemer); + Self::release_replace_collateral(&vault_id, &vault_to_be_burned_tokens)?; Self::insert_redeem_request( diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index e6359400da..9cea7607f8 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -1499,8 +1499,11 @@ impl Pallet { } pub fn is_vault_below_premium_threshold(vault_id: &DefaultVaultId) -> Result { + let vault = Self::get_rich_vault_from_id(&vault_id)?; let threshold = Self::premium_redeem_threshold(&vault_id.currencies).ok_or(Error::::ThresholdNotSet)?; - Self::is_vault_below_threshold(vault_id, threshold) + let collateral = Self::get_backing_collateral(vault_id)?; + + Self::is_collateral_below_threshold(&collateral, &vault.to_be_backed_tokens()?, threshold) } /// check if the vault is below the liquidation threshold. @@ -1886,6 +1889,19 @@ impl Pallet { collateral.convert_to(wrapped_currency)?.checked_div(&threshold) } + pub fn vault_capacity_at_secure_threshold(vault_id: &DefaultVaultId) -> Result, DispatchError> { + let threshold = Self::secure_collateral_threshold(&vault_id.currencies).ok_or(Error::::ThresholdNotSet)?; + let collateral = Self::get_backing_collateral(vault_id)?; + let wrapped_currency = vault_id.wrapped_currency(); + + Self::calculate_max_wrapped_from_collateral_for_threshold(&collateral, wrapped_currency, threshold) + } + + pub fn vault_to_be_backed_tokens(vault_id: &DefaultVaultId) -> Result, DispatchError> { + let vault = Self::get_active_rich_vault_from_id(vault_id)?; + vault.to_be_backed_tokens() + } + pub fn new_vault_deposit_address( vault_id: &DefaultVaultId, secure_id: H256, diff --git a/crates/vault-registry/src/types.rs b/crates/vault-registry/src/types.rs index d96a7760f3..3b3ba860f9 100644 --- a/crates/vault-registry/src/types.rs +++ b/crates/vault-registry/src/types.rs @@ -381,6 +381,18 @@ impl RichVault { Ok(Amount::new(amount, self.wrapped_currency())) } + /// the number of issued tokens if all issues and redeems execute successfully + pub(crate) fn to_be_backed_tokens(&self) -> Result, DispatchError> { + let amount = self + .data + .issued_tokens + .checked_add(&self.data.to_be_issued_tokens) + .ok_or(ArithmeticError::Overflow)? + .checked_sub(&self.data.to_be_redeemed_tokens) + .ok_or(ArithmeticError::Underflow)?; + Ok(Amount::new(amount, self.wrapped_currency())) + } + pub(crate) fn to_be_replaced_tokens(&self) -> Amount { Amount::new(self.data.to_be_replaced_tokens, self.wrapped_currency()) } From ae8256894fdf8147c85953cb6ce32d3297aba258 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 4 Oct 2023 10:57:34 +0530 Subject: [PATCH 02/19] fix: changed premium fee calculation . --- crates/redeem/src/ext.rs | 11 ++ crates/redeem/src/lib.rs | 37 ++-- crates/vault-registry/src/lib.rs | 10 ++ .../runtime-tests/src/parachain/redeem.rs | 158 ++++++++++++++++++ 4 files changed, 206 insertions(+), 10 deletions(-) diff --git a/crates/redeem/src/ext.rs b/crates/redeem/src/ext.rs index 41f27bae0e..bc63b0228b 100644 --- a/crates/redeem/src/ext.rs +++ b/crates/redeem/src/ext.rs @@ -44,6 +44,10 @@ pub(crate) mod vault_registry { use frame_support::dispatch::{DispatchError, DispatchResult}; use vault_registry::types::{CurrencyId, CurrencySource, DefaultVault}; + pub fn get_backing_collateral(vault_id: &DefaultVaultId) -> Result, DispatchError> { + >::get_backing_collateral(vault_id) + } + pub fn get_liquidated_collateral( vault_id: &DefaultVaultId, ) -> Result, DispatchError> { @@ -88,6 +92,13 @@ pub(crate) mod vault_registry { >::vault_capacity_at_secure_threshold(vault_id) } + pub fn vault_capacity_at_secure_threshold_based_on_collateral( + vault_id: &DefaultVaultId, + collateral: Amount, + ) -> Result, DispatchError> { + >::vault_capacity_at_secure_threshold_based_on_collateral(vault_id, collateral) + } + pub fn try_increase_to_be_redeemed_tokens( vault_id: &DefaultVaultId, amount: &Amount, diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index fbeecf305d..f051fd4ed0 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -505,20 +505,37 @@ impl Pallet { let currency_id = vault_id.collateral_currency(); let premium_collateral = if below_premium_redeem { - // we only award a premium on the amount ok tokens required to bring - // `issued + to_be_issued - to_be_redeemed` back to the secure threshold + // Calculate the secure vault capacity + let secure_vault_capacity = ext::vault_registry::vault_capacity_at_secure_threshold(&vault_id)?; + let issued_tokens = ext::vault_registry::vault_to_be_backed_tokens(&vault_id)?; + let difference_in_tokens_to_reach_secure_threshold = + issued_tokens.saturating_sub(&secure_vault_capacity)?; + + // Calculate collateral after paying the premium redeem fee + let backing_collateral = ext::vault_registry::get_backing_collateral(&vault_id)?; + let premium_redeem_fee = ext::fee::get_premium_redeem_fee::( + &difference_in_tokens_to_reach_secure_threshold.convert_to(currency_id)?, + )?; + + let collateral_after_premium_redeem = backing_collateral.saturating_sub(&premium_redeem_fee)?; + + // Calculate the issued tokens that can be backed after paying the premium redeem fee + let issue_backed_after_premium_redeem = + ext::vault_registry::vault_capacity_at_secure_threshold_based_on_collateral( + &vault_id, + collateral_after_premium_redeem.clone(), + )?; - let capacity = ext::vault_registry::vault_capacity_at_secure_threshold(&vault_id)?; - let to_be_backed_tokens = ext::vault_registry::vault_to_be_backed_tokens(&vault_id)?; + let tokens_remaining_after_premium_redeem = + issued_tokens.saturating_sub(&issue_backed_after_premium_redeem)?; - // the amount of tokens that we can give a premium for - let max_premium_tokens = to_be_backed_tokens.saturating_sub(&capacity)?; - // the actual amount of tokens redeemed that we give a premium for - let actual_premium_tokens = max_premium_tokens.min(&user_to_be_received_btc)?; - // converted to collateral.. + // Calculate the actual premium tokens and convert to collateral + let actual_premium_tokens = tokens_remaining_after_premium_redeem.min(&user_to_be_received_btc)?; let premium_tokens_in_collateral = actual_premium_tokens.convert_to(currency_id)?; - ext::fee::get_premium_redeem_fee::(&premium_tokens_in_collateral)? + // Calculate the premium redeem fee for the premium tokens in collateral + let premium_collateral = ext::fee::get_premium_redeem_fee::(&premium_tokens_in_collateral)?; + premium_collateral } else { Amount::zero(currency_id) }; diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 9cea7607f8..7e44e38886 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -1897,6 +1897,16 @@ impl Pallet { Self::calculate_max_wrapped_from_collateral_for_threshold(&collateral, wrapped_currency, threshold) } + pub fn vault_capacity_at_secure_threshold_based_on_collateral( + vault_id: &DefaultVaultId, + collateral: Amount, + ) -> Result, DispatchError> { + let threshold = Self::secure_collateral_threshold(&vault_id.currencies).ok_or(Error::::ThresholdNotSet)?; + let wrapped_currency = vault_id.wrapped_currency(); + + Self::calculate_max_wrapped_from_collateral_for_threshold(&collateral, wrapped_currency, threshold) + } + pub fn vault_to_be_backed_tokens(vault_id: &DefaultVaultId) -> Result, DispatchError> { let vault = Self::get_active_rich_vault_from_id(vault_id)?; vault.to_be_backed_tokens() diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index d6527cf1dc..46a32dd0e2 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -44,6 +44,55 @@ fn test_with(execute: impl Fn(VaultId) -> R) { test_with(LendToken(1), Token(IBTC), None); } +fn test_setup_for_premium_redeem(execute: impl Fn(VaultId) -> R) { + let test_with = |collateral_id, wrapped_id, extra_vault_currency: Option| { + ExtBuilder::build().execute_with(|| { + let secure = FixedU128::checked_from_rational(200, 100).unwrap(); + let premium = FixedU128::checked_from_rational(160, 100).unwrap(); + let liquidation = FixedU128::checked_from_rational(110, 100).unwrap(); + + let vault_id = PrimitiveVaultId::new(account_of(VAULT), collateral_id, wrapped_id); + SecurityPallet::set_active_block_number(1); + for currency_id in iter_collateral_currencies().filter(|c| !c.is_lend_token()) { + assert_ok!(OraclePallet::_set_exchange_rate(currency_id, FixedU128::from(2))); + } + if wrapped_id != DEFAULT_WRAPPED_CURRENCY { + assert_ok!(OraclePallet::_set_exchange_rate(wrapped_id, FixedU128::one())); + } + + activate_lending_and_mint(Token(DOT), LendToken(1)); + + // Set custom thresholds + VaultRegistryPallet::_set_secure_collateral_threshold(vault_id.currencies.clone(), secure); + VaultRegistryPallet::_set_premium_redeem_threshold(vault_id.currencies.clone(), premium); + VaultRegistryPallet::_set_liquidation_collateral_threshold(vault_id.currencies.clone(), liquidation); + + LiquidationVaultData::force_to(default_liquidation_vault_state(&vault_id.currencies)); + UserData::force_to(USER, default_user_state()); + CoreVaultData::force_to(&vault_id, default_vault_state(&vault_id)); + // additional vault in order to prevent the edge case where the fee pool does not + // get additional funds because there are no non-liquidated vaults left + let carol_vault_id = PrimitiveVaultId::new(account_of(CAROL), collateral_id, wrapped_id); + CoreVaultData::force_to(&carol_vault_id, default_vault_state(&carol_vault_id)); + + if let Some(other_currency) = extra_vault_currency { + assert_ok!(OraclePallet::_set_exchange_rate(other_currency, FixedU128::one())); + // check that having other vault with the same account id does not influence tests + let other_vault_id = vault_id_of(VAULT, other_currency); + CoreVaultData::force_to(&other_vault_id, default_vault_state(&other_vault_id)); + } + execute(vault_id) + }) + }; + + test_with(Token(DOT), Token(KBTC), None); + test_with(Token(DOT), Token(IBTC), None); + test_with(Token(DOT), Token(IBTC), Some(Token(KSM))); + test_with(Token(KSM), Token(IBTC), None); + test_with(ForeignAsset(1), Token(IBTC), None); + test_with(LendToken(1), Token(IBTC), None); +} + /// to-be-replaced & replace_collateral are decreased in request_redeem fn consume_to_be_replaced(vault: &mut CoreVaultData, amount_btc: Amount) { let to_be_replaced_decrease = amount_btc.min(&vault.to_be_replaced).unwrap(); @@ -58,6 +107,115 @@ fn consume_to_be_replaced(vault: &mut CoreVaultData, amount_btc: Amount vault.to_be_replaced -= to_be_replaced_decrease; } +mod premium_redeem_tests { + use super::{assert_eq, *}; + + fn setup_vault_below_secure_threshold(vault_id: VaultId) { + // with 2000 collateral and exchange rate at 2, the vault is at: + // - secure threshold (200%) when it has 2000/2/2 = 500 tokens + // - premium threshold (160%) when it has 2000/2/1.6 = 625 tokens + + // we award premium redeem only for the amount needed for (issued + to_be_issued - to_be_redeemed) + // to reach the secure threshold + + // setup the vault such that (issued + to_be_issued - to_be_redeemed) = (450 + 250 - 50) = 650 + // (everything scaled by 1000 to prevent getting dust amount errors) + CoreVaultData::force_to( + &vault_id, + CoreVaultData { + issued: vault_id.wrapped(450_000), + to_be_issued: vault_id.wrapped(250_000), + to_be_redeemed: vault_id.wrapped(50_000), + backing_collateral: vault_id.collateral(2_000_000), + to_be_replaced: vault_id.wrapped(0), + replace_collateral: griefing(0), + ..default_vault_state(&vault_id) + }, + ); + } + + #[test] + fn integration_test_premium_redeem_with_reward_for_only_part_of_the_request() { + test_setup_for_premium_redeem(|vault_id| { + setup_vault_below_secure_threshold(vault_id.clone()); + + assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); + assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + + let redeem_id = setup_redeem(vault_id.wrapped(400_000), USER, &vault_id); + + assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + + let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + // we should get rewarded only for 150_000 + 3750 tokens (that's when we reach nearer to secure threshold) + let expected_premium = FeePallet::get_premium_redeem_fee( + &vault_id + .wrapped(150_000 + 3750) // need to add 0.375 = 153.750 + .convert_to(vault_id.collateral_currency()) + .unwrap(), + ) + .unwrap(); + assert_eq!(vault_id.collateral(redeem.premium), expected_premium); + + // Execute redeem + execute_redeem(redeem_id); + + let compute_collateral = VaultRegistryPallet::compute_collateral(&vault_id).unwrap().amount(); + assert_eq!(compute_collateral, 2000000 - 15375); //15.355 COL tokens lost as premium fees + + // Setup another redeem request + let redeem_id = setup_redeem(vault_id.wrapped(2_000), USER, &vault_id); + + let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + + // No premium should be given for this request + assert_eq!(redeem.premium, 0); + + // Execute redeem + execute_redeem(redeem_id); + + // initially 400 tokens, 1st redeem consumed 398 tokens , 2nd redeem consumed 1.99 tokens, remaining 0.01 + let get_free_redeemable_tokens = VaultRegistryPallet::get_free_redeemable_tokens(&vault_id) + .unwrap() + .amount(); + assert_eq!(get_free_redeemable_tokens, 10); + }); + } + + #[test] + fn integration_test_premium_redeem_with_reward_for_full_request() { + test_setup_for_premium_redeem(|vault_id| { + setup_vault_below_secure_threshold(vault_id.clone()); + + assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); + assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + + let redeem_id = setup_redeem(vault_id.wrapped(100_000), USER, &vault_id); + + assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + + let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + + // we should get rewarded for the full amount, since we did not reach secure threshold + let expected_premium = FeePallet::get_premium_redeem_fee( + &vault_id + .wrapped(redeem.amount_btc) + .convert_to(vault_id.collateral_currency()) + .unwrap(), + ) + .unwrap(); + assert_eq!(vault_id.collateral(redeem.premium), expected_premium); + + let get_free_redeemable_tokens = VaultRegistryPallet::get_free_redeemable_tokens(&vault_id) + .unwrap() + .amount(); + assert_eq!(get_free_redeemable_tokens, 300500); //300.5 + }); + } +} + mod spec_based_tests { use primitives::VaultCurrencyPair; From 20cfc78fe75f63af1b47d63375e3e99bca6527d3 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 4 Oct 2023 11:14:47 +0530 Subject: [PATCH 03/19] fix: added common set up . --- .../runtime-tests/src/parachain/redeem.rs | 108 +++++++++--------- parachain/runtime/runtime-tests/src/utils.rs | 14 +++ 2 files changed, 70 insertions(+), 52 deletions(-) diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index 46a32dd0e2..04e889b778 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -9,29 +9,14 @@ fn test_with(execute: impl Fn(VaultId) -> R) { let test_with = |collateral_id, wrapped_id, extra_vault_currency| { ExtBuilder::build().execute_with(|| { let vault_id = PrimitiveVaultId::new(account_of(VAULT), collateral_id, wrapped_id); - SecurityPallet::set_active_block_number(1); - for currency_id in iter_collateral_currencies().filter(|c| !c.is_lend_token()) { - assert_ok!(OraclePallet::_set_exchange_rate(currency_id, FixedU128::one())); - } - if wrapped_id != DEFAULT_WRAPPED_CURRENCY { - assert_ok!(OraclePallet::_set_exchange_rate(wrapped_id, FixedU128::one())); - } - activate_lending_and_mint(Token(DOT), LendToken(1)); - set_default_thresholds(); - LiquidationVaultData::force_to(default_liquidation_vault_state(&vault_id.currencies)); - UserData::force_to(USER, default_user_state()); - CoreVaultData::force_to(&vault_id, default_vault_state(&vault_id)); - // additional vault in order to prevent the edge case where the fee pool does not - // get additional funds because there are no non-liquidated vaults left - let carol_vault_id = PrimitiveVaultId::new(account_of(CAROL), collateral_id, wrapped_id); - CoreVaultData::force_to(&carol_vault_id, default_vault_state(&carol_vault_id)); - - if let Some(other_currency) = extra_vault_currency { - assert_ok!(OraclePallet::_set_exchange_rate(other_currency, FixedU128::one())); - // check that having other vault with the same account id does not influence tests - let other_vault_id = vault_id_of(VAULT, other_currency); - CoreVaultData::force_to(&other_vault_id, default_vault_state(&other_vault_id)); - } + common_setup::( + wrapped_id, + extra_vault_currency, + collateral_id, + vault_id.clone(), + FixedU128::one(), + None, + ); execute(vault_id) }) }; @@ -52,35 +37,14 @@ fn test_setup_for_premium_redeem(execute: impl Fn(VaultId) -> R) { let liquidation = FixedU128::checked_from_rational(110, 100).unwrap(); let vault_id = PrimitiveVaultId::new(account_of(VAULT), collateral_id, wrapped_id); - SecurityPallet::set_active_block_number(1); - for currency_id in iter_collateral_currencies().filter(|c| !c.is_lend_token()) { - assert_ok!(OraclePallet::_set_exchange_rate(currency_id, FixedU128::from(2))); - } - if wrapped_id != DEFAULT_WRAPPED_CURRENCY { - assert_ok!(OraclePallet::_set_exchange_rate(wrapped_id, FixedU128::one())); - } - - activate_lending_and_mint(Token(DOT), LendToken(1)); - - // Set custom thresholds - VaultRegistryPallet::_set_secure_collateral_threshold(vault_id.currencies.clone(), secure); - VaultRegistryPallet::_set_premium_redeem_threshold(vault_id.currencies.clone(), premium); - VaultRegistryPallet::_set_liquidation_collateral_threshold(vault_id.currencies.clone(), liquidation); - - LiquidationVaultData::force_to(default_liquidation_vault_state(&vault_id.currencies)); - UserData::force_to(USER, default_user_state()); - CoreVaultData::force_to(&vault_id, default_vault_state(&vault_id)); - // additional vault in order to prevent the edge case where the fee pool does not - // get additional funds because there are no non-liquidated vaults left - let carol_vault_id = PrimitiveVaultId::new(account_of(CAROL), collateral_id, wrapped_id); - CoreVaultData::force_to(&carol_vault_id, default_vault_state(&carol_vault_id)); - - if let Some(other_currency) = extra_vault_currency { - assert_ok!(OraclePallet::_set_exchange_rate(other_currency, FixedU128::one())); - // check that having other vault with the same account id does not influence tests - let other_vault_id = vault_id_of(VAULT, other_currency); - CoreVaultData::force_to(&other_vault_id, default_vault_state(&other_vault_id)); - } + common_setup::( + wrapped_id, + extra_vault_currency, + collateral_id, + vault_id.clone(), + FixedU128::from(2), + Some((secure, premium, liquidation)), + ); execute(vault_id) }) }; @@ -93,6 +57,46 @@ fn test_setup_for_premium_redeem(execute: impl Fn(VaultId) -> R) { test_with(LendToken(1), Token(IBTC), None); } +fn common_setup( + wrapped_id: CurrencyId, + extra_vault_currency: Option, + collateral_id: CurrencyId, + vault_id: VaultId, + exchange_rate: FixedU128, + custom_thresholds: Option<(FixedU128, FixedU128, FixedU128)>, +) { + SecurityPallet::set_active_block_number(1); + for currency_id in iter_collateral_currencies().filter(|c| !c.is_lend_token()) { + assert_ok!(OraclePallet::_set_exchange_rate(currency_id, exchange_rate)); + } + if wrapped_id != DEFAULT_WRAPPED_CURRENCY { + assert_ok!(OraclePallet::_set_exchange_rate(wrapped_id, FixedU128::one())); + } + + activate_lending_and_mint(Token(DOT), LendToken(1)); + + if let Some((secure, premium, liquidation)) = custom_thresholds { + set_custom_thresholds(secure, premium, liquidation); + } else { + set_default_thresholds(); + } + + LiquidationVaultData::force_to(default_liquidation_vault_state(&vault_id.currencies)); + UserData::force_to(USER, default_user_state()); + CoreVaultData::force_to(&vault_id, default_vault_state(&vault_id)); + // additional vault in order to prevent the edge case where the fee pool does not + // get additional funds because there are no non-liquidated vaults left + let carol_vault_id = PrimitiveVaultId::new(account_of(CAROL), collateral_id, wrapped_id); + CoreVaultData::force_to(&carol_vault_id, default_vault_state(&carol_vault_id)); + + if let Some(other_currency) = extra_vault_currency { + assert_ok!(OraclePallet::_set_exchange_rate(other_currency, FixedU128::one())); + // check that having other vault with the same account id does not influence tests + let other_vault_id = vault_id_of(VAULT, other_currency); + CoreVaultData::force_to(&other_vault_id, default_vault_state(&other_vault_id)); + } +} + /// to-be-replaced & replace_collateral are decreased in request_redeem fn consume_to_be_replaced(vault: &mut CoreVaultData, amount_btc: Amount) { let to_be_replaced_decrease = amount_btc.min(&vault.to_be_replaced).unwrap(); diff --git a/parachain/runtime/runtime-tests/src/utils.rs b/parachain/runtime/runtime-tests/src/utils.rs index de80c7b33c..b95eba183a 100644 --- a/parachain/runtime/runtime-tests/src/utils.rs +++ b/parachain/runtime/runtime-tests/src/utils.rs @@ -1004,6 +1004,20 @@ pub fn set_default_thresholds() { } } +pub fn set_custom_thresholds(secure: FixedU128, premium: FixedU128, liquidation: FixedU128) { + for collateral_id in iter_collateral_currencies() { + for wrapped_id in iter_wrapped_currencies() { + let currency_pair = VaultCurrencyPair { + collateral: collateral_id, + wrapped: wrapped_id, + }; + VaultRegistryPallet::_set_secure_collateral_threshold(currency_pair.clone(), secure); + VaultRegistryPallet::_set_premium_redeem_threshold(currency_pair.clone(), premium); + VaultRegistryPallet::_set_liquidation_collateral_threshold(currency_pair.clone(), liquidation); + } + } +} + pub fn dummy_public_key() -> BtcPublicKey { BtcPublicKey([ 2, 205, 114, 218, 156, 16, 235, 172, 106, 37, 18, 153, 202, 140, 176, 91, 207, 51, 187, 55, 18, 45, 222, 180, From aeaba1d7c33370272004aa2b41fa99337fa1d3cd Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 4 Oct 2023 13:14:53 +0530 Subject: [PATCH 04/19] fix: benchmarking added . --- crates/redeem/src/benchmarking.rs | 7 + crates/redeem/src/default_weights.rs | 1321 ++++++++--------- .../runtime/interlay/src/weights/redeem.rs | 633 ++++---- .../runtime/kintsugi/src/weights/redeem.rs | 641 ++++---- .../runtime-tests/src/parachain/redeem.rs | 2 +- 5 files changed, 1301 insertions(+), 1303 deletions(-) diff --git a/crates/redeem/src/benchmarking.rs b/crates/redeem/src/benchmarking.rs index afcc7ae50a..fd46579e84 100644 --- a/crates/redeem/src/benchmarking.rs +++ b/crates/redeem/src/benchmarking.rs @@ -158,6 +158,13 @@ pub mod benchmarks { #[extrinsic_call] _(RawOrigin::Signed(caller), amount, btc_address, vault_id.clone()); + let redeem_vault_request = Redeem::::get_redeem_requests_for_vault(vault_id.account_id.clone()); + let redeem_request_hash = redeem_vault_request + .first() + .cloned() + .unwrap_or_else(|| panic!("No redeem request found")); + let redeem_struct = RedeemRequests::::get(redeem_request_hash).unwrap(); + assert!(redeem_struct.premium > 0); } #[benchmark] diff --git a/crates/redeem/src/default_weights.rs b/crates/redeem/src/default_weights.rs index 71ac5e8290..a9a344b47d 100644 --- a/crates/redeem/src/default_weights.rs +++ b/crates/redeem/src/default_weights.rs @@ -49,365 +49,362 @@ pub trait WeightInfo { /// Weights for redeem using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Fee RedeemFee (r:1 w:0) - /// Proof: Fee RedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Redeem RedeemTransactionSize (r:1 w:0) - /// Proof: Redeem RedeemTransactionSize (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:2 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) - /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security Nonce (r:1 w:1) - /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: System ParentHash (r:1 w:0) - /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: VaultRegistry PremiumRedeemThreshold (r:1 w:0) - /// Proof: VaultRegistry PremiumRedeemThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PremiumRedeemFee (r:1 w:0) - /// Proof: Fee PremiumRedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Redeem RedeemRequests (r:0 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - fn request_redeem() -> Weight { + + /// Storage: `Tokens::Accounts` (r:2 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Fee::RedeemFee` (r:1 w:0) + /// Proof: `Fee::RedeemFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemTransactionSize` (r:1 w:0) + /// Proof: `Redeem::RedeemTransactionSize` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:2 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemBtcDustValue` (r:1 w:0) + /// Proof: `Redeem::RedeemBtcDustValue` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PremiumRedeemThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::PremiumRedeemThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `Fee::PremiumRedeemFee` (r:1 w:0) + /// Proof: `Fee::PremiumRedeemFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Security::Nonce` (r:1 w:1) + /// Proof: `Security::Nonce` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `System::ParentHash` (r:1 w:0) + /// Proof: `System::ParentHash` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemRequests` (r:0 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + fn request_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `4672` - // Estimated: `47658` - // Minimum execution time: 311_664_000 picoseconds. - Weight::from_parts(315_792_000, 47658) + // Measured: `3219` + // Estimated: `6260` + // Minimum execution time: 226_000_000 picoseconds. + Weight::from_parts(230_000_000, 6260) .saturating_add(T::DbWeight::get().reads(29_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: VaultRegistry LiquidationVault (r:1 w:1) - /// Proof: VaultRegistry LiquidationVault (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:1 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - fn liquidation_redeem() -> Weight { + /// Storage: `Tokens::Accounts` (r:3 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::LiquidationVault` (r:1 w:1) + /// Proof: `VaultRegistry::LiquidationVault` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:1 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + fn liquidation_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `3861` - // Estimated: `40975` - // Minimum execution time: 279_078_000 picoseconds. - Weight::from_parts(282_886_000, 40975) + // Measured: `2173` + // Estimated: `8760` + // Minimum execution time: 139_000_000 picoseconds. + Weight::from_parts(141_000_000, 8760) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) } - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::DisableInclusionCheck` (r:1 w:0) + /// Proof: `BTCRelay::DisableInclusionCheck` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::Chains` (r:1 w:0) + /// Proof: `BTCRelay::Chains` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BlockHeaders` (r:1 w:0) + /// Proof: `BTCRelay::BlockHeaders` (`max_values`: None, `max_size`: Some(200), added: 2675, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::StableBitcoinConfirmations` (r:1 w:0) + /// Proof: `BTCRelay::StableBitcoinConfirmations` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::StableParachainConfirmations` (r:1 w:0) + /// Proof: `BTCRelay::StableParachainConfirmations` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) /// The range of component `h` is `[2, 10]`. /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[2, 3]`. /// The range of component `b` is `[541, 2048]`. - fn execute_redeem(h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_redeem (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3463` - // Estimated: `18221` - // Minimum execution time: 180_491_000 picoseconds. - Weight::from_parts(156_971_337, 18221) - // Standard Error: 18_912 - .saturating_add(Weight::from_parts(1_667_781, 0).saturating_mul(h.into())) - // Standard Error: 17_010 - .saturating_add(Weight::from_parts(730_184, 0).saturating_mul(i.into())) - // Standard Error: 102_447 - .saturating_add(Weight::from_parts(810_488, 0).saturating_mul(o.into())) - // Standard Error: 103 - .saturating_add(Weight::from_parts(5_905, 0).saturating_mul(b.into())) + // Measured: `2295 + o * (1 ±0)` + // Estimated: `3725` + // Minimum execution time: 89_000_000 picoseconds. + Weight::from_parts(55_152_275, 3725) + // Standard Error: 149_738 + .saturating_add(Weight::from_parts(2_508_576, 0).saturating_mul(h.into())) + // Standard Error: 134_990 + .saturating_add(Weight::from_parts(994_344, 0).saturating_mul(i.into())) + // Standard Error: 818_328 + .saturating_add(Weight::from_parts(3_299_475, 0).saturating_mul(o.into())) + // Standard Error: 824 + .saturating_add(Weight::from_parts(5_210, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:2 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PunishmentFee (r:1 w:0) - /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:0) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:1) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) - /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cancel_redeem_reimburse() -> Weight { + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:1 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:2 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Fee::PunishmentFee` (r:1 w:0) + /// Proof: `Fee::PunishmentFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:1) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::Stake` (r:1 w:1) + /// Proof: `VaultCapacity::Stake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardPerToken` (r:2 w:0) + /// Proof: `VaultCapacity::RewardPerToken` (`max_values`: None, `max_size`: Some(59), added: 2534, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardTally` (r:2 w:2) + /// Proof: `VaultCapacity::RewardTally` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalRewards` (r:2 w:2) + /// Proof: `VaultCapacity::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::Stake` (r:1 w:1) + /// Proof: `VaultRewards::Stake` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardPerToken` (r:2 w:0) + /// Proof: `VaultRewards::RewardPerToken` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardTally` (r:2 w:2) + /// Proof: `VaultRewards::RewardTally` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalRewards` (r:2 w:2) + /// Proof: `VaultRewards::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Fee::Commission` (r:1 w:0) + /// Proof: `Fee::Commission` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::RewardPerToken` (r:2 w:2) + /// Proof: `VaultStaking::RewardPerToken` (`max_values`: None, `max_size`: Some(117), added: 2592, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::SlashPerToken` (r:1 w:1) + /// Proof: `VaultStaking::SlashPerToken` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalStake` (r:1 w:1) + /// Proof: `VaultRewards::TotalStake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultRewards::RewardCurrencies` (`max_values`: None, `max_size`: Some(50), added: 2525, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalStake` (r:1 w:1) + /// Proof: `VaultCapacity::TotalStake` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultCapacity::RewardCurrencies` (`max_values`: None, `max_size`: Some(39), added: 2514, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PunishmentDelay` (r:1 w:0) + /// Proof: `VaultRegistry::PunishmentDelay` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn cancel_redeem_reimburse () -> Weight { // Proof Size summary in bytes: - // Measured: `7166` - // Estimated: `135176` - // Minimum execution time: 798_478_000 picoseconds. - Weight::from_parts(808_188_000, 135176) - .saturating_add(T::DbWeight::get().reads(60_u64)) + // Measured: `5396` + // Estimated: `11350` + // Minimum execution time: 495_000_000 picoseconds. + Weight::from_parts(510_000_000, 11350) + .saturating_add(T::DbWeight::get().reads(59_u64)) .saturating_add(T::DbWeight::get().writes(29_u64)) } - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PunishmentFee (r:1 w:0) - /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:0) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:1) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) - /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cancel_redeem_retry() -> Weight { + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:1 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Fee::PunishmentFee` (r:1 w:0) + /// Proof: `Fee::PunishmentFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:1) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::Stake` (r:1 w:1) + /// Proof: `VaultCapacity::Stake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardPerToken` (r:2 w:0) + /// Proof: `VaultCapacity::RewardPerToken` (`max_values`: None, `max_size`: Some(59), added: 2534, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardTally` (r:2 w:2) + /// Proof: `VaultCapacity::RewardTally` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalRewards` (r:2 w:2) + /// Proof: `VaultCapacity::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::Stake` (r:1 w:1) + /// Proof: `VaultRewards::Stake` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardPerToken` (r:2 w:0) + /// Proof: `VaultRewards::RewardPerToken` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardTally` (r:2 w:2) + /// Proof: `VaultRewards::RewardTally` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalRewards` (r:2 w:2) + /// Proof: `VaultRewards::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Fee::Commission` (r:1 w:0) + /// Proof: `Fee::Commission` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::RewardPerToken` (r:2 w:2) + /// Proof: `VaultStaking::RewardPerToken` (`max_values`: None, `max_size`: Some(117), added: 2592, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::SlashPerToken` (r:1 w:1) + /// Proof: `VaultStaking::SlashPerToken` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalStake` (r:1 w:1) + /// Proof: `VaultRewards::TotalStake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultRewards::RewardCurrencies` (`max_values`: None, `max_size`: Some(50), added: 2525, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalStake` (r:1 w:1) + /// Proof: `VaultCapacity::TotalStake` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultCapacity::RewardCurrencies` (`max_values`: None, `max_size`: Some(39), added: 2514, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PunishmentDelay` (r:1 w:0) + /// Proof: `VaultRegistry::PunishmentDelay` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn cancel_redeem_retry () -> Weight { // Proof Size summary in bytes: - // Measured: `7166` - // Estimated: `132666` - // Minimum execution time: 729_751_000 picoseconds. - Weight::from_parts(738_648_000, 132666) - .saturating_add(T::DbWeight::get().reads(59_u64)) + // Measured: `5396` + // Estimated: `11350` + // Minimum execution time: 406_000_000 picoseconds. + Weight::from_parts(412_000_000, 11350) + .saturating_add(T::DbWeight::get().reads(58_u64)) .saturating_add(T::DbWeight::get().writes(28_u64)) } - /// Storage: Redeem RedeemPeriod (r:0 w:1) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_redeem_period() -> Weight { + /// Storage: `Redeem::RedeemPeriod` (r:0 w:1) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_redeem_period () -> Weight { // Proof Size summary in bytes: - // Measured: `1025` + // Measured: `0` // Estimated: `0` - // Minimum execution time: 28_527_000 picoseconds. - Weight::from_parts(29_970_000, 0) + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(9_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - fn self_redeem() -> Weight { + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + fn self_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `2449` - // Estimated: `7835` - // Minimum execution time: 147_756_000 picoseconds. - Weight::from_parts(149_109_000, 7835) + // Measured: `1427` + // Estimated: `3725` + // Minimum execution time: 71_000_000 picoseconds. + Weight::from_parts(72_000_000, 3725) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -415,365 +412,361 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Fee RedeemFee (r:1 w:0) - /// Proof: Fee RedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Redeem RedeemTransactionSize (r:1 w:0) - /// Proof: Redeem RedeemTransactionSize (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:2 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) - /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security Nonce (r:1 w:1) - /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: System ParentHash (r:1 w:0) - /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: VaultRegistry PremiumRedeemThreshold (r:1 w:0) - /// Proof: VaultRegistry PremiumRedeemThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PremiumRedeemFee (r:1 w:0) - /// Proof: Fee PremiumRedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Redeem RedeemRequests (r:0 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - fn request_redeem() -> Weight { + /// Storage: `Tokens::Accounts` (r:2 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Fee::RedeemFee` (r:1 w:0) + /// Proof: `Fee::RedeemFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemTransactionSize` (r:1 w:0) + /// Proof: `Redeem::RedeemTransactionSize` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:2 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemBtcDustValue` (r:1 w:0) + /// Proof: `Redeem::RedeemBtcDustValue` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PremiumRedeemThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::PremiumRedeemThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `Fee::PremiumRedeemFee` (r:1 w:0) + /// Proof: `Fee::PremiumRedeemFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Security::Nonce` (r:1 w:1) + /// Proof: `Security::Nonce` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `System::ParentHash` (r:1 w:0) + /// Proof: `System::ParentHash` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemRequests` (r:0 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + fn request_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `4672` - // Estimated: `47658` - // Minimum execution time: 311_664_000 picoseconds. - Weight::from_parts(315_792_000, 47658) + // Measured: `3219` + // Estimated: `6260` + // Minimum execution time: 226_000_000 picoseconds. + Weight::from_parts(230_000_000, 6260) .saturating_add(RocksDbWeight::get().reads(29_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: VaultRegistry LiquidationVault (r:1 w:1) - /// Proof: VaultRegistry LiquidationVault (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:1 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - fn liquidation_redeem() -> Weight { + /// Storage: `Tokens::Accounts` (r:3 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::LiquidationVault` (r:1 w:1) + /// Proof: `VaultRegistry::LiquidationVault` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:1 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + fn liquidation_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `3861` - // Estimated: `40975` - // Minimum execution time: 279_078_000 picoseconds. - Weight::from_parts(282_886_000, 40975) + // Measured: `2173` + // Estimated: `8760` + // Minimum execution time: 139_000_000 picoseconds. + Weight::from_parts(141_000_000, 8760) .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(11_u64)) } - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::DisableInclusionCheck` (r:1 w:0) + /// Proof: `BTCRelay::DisableInclusionCheck` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::Chains` (r:1 w:0) + /// Proof: `BTCRelay::Chains` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BlockHeaders` (r:1 w:0) + /// Proof: `BTCRelay::BlockHeaders` (`max_values`: None, `max_size`: Some(200), added: 2675, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::StableBitcoinConfirmations` (r:1 w:0) + /// Proof: `BTCRelay::StableBitcoinConfirmations` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::StableParachainConfirmations` (r:1 w:0) + /// Proof: `BTCRelay::StableParachainConfirmations` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) /// The range of component `h` is `[2, 10]`. /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[2, 3]`. /// The range of component `b` is `[541, 2048]`. - fn execute_redeem(h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_redeem (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3463` - // Estimated: `18221` - // Minimum execution time: 180_491_000 picoseconds. - Weight::from_parts(156_971_337, 18221) - // Standard Error: 18_912 - .saturating_add(Weight::from_parts(1_667_781, 0).saturating_mul(h.into())) - // Standard Error: 17_010 - .saturating_add(Weight::from_parts(730_184, 0).saturating_mul(i.into())) - // Standard Error: 102_447 - .saturating_add(Weight::from_parts(810_488, 0).saturating_mul(o.into())) - // Standard Error: 103 - .saturating_add(Weight::from_parts(5_905, 0).saturating_mul(b.into())) + // Measured: `2295 + o * (1 ±0)` + // Estimated: `3725` + // Minimum execution time: 89_000_000 picoseconds. + Weight::from_parts(55_152_275, 3725) + // Standard Error: 149_738 + .saturating_add(Weight::from_parts(2_508_576, 0).saturating_mul(h.into())) + // Standard Error: 134_990 + .saturating_add(Weight::from_parts(994_344, 0).saturating_mul(i.into())) + // Standard Error: 818_328 + .saturating_add(Weight::from_parts(3_299_475, 0).saturating_mul(o.into())) + // Standard Error: 824 + .saturating_add(Weight::from_parts(5_210, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:2 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PunishmentFee (r:1 w:0) - /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:0) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:1) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) - /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cancel_redeem_reimburse() -> Weight { + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:1 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:2 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Fee::PunishmentFee` (r:1 w:0) + /// Proof: `Fee::PunishmentFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:1) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::Stake` (r:1 w:1) + /// Proof: `VaultCapacity::Stake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardPerToken` (r:2 w:0) + /// Proof: `VaultCapacity::RewardPerToken` (`max_values`: None, `max_size`: Some(59), added: 2534, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardTally` (r:2 w:2) + /// Proof: `VaultCapacity::RewardTally` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalRewards` (r:2 w:2) + /// Proof: `VaultCapacity::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::Stake` (r:1 w:1) + /// Proof: `VaultRewards::Stake` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardPerToken` (r:2 w:0) + /// Proof: `VaultRewards::RewardPerToken` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardTally` (r:2 w:2) + /// Proof: `VaultRewards::RewardTally` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalRewards` (r:2 w:2) + /// Proof: `VaultRewards::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Fee::Commission` (r:1 w:0) + /// Proof: `Fee::Commission` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::RewardPerToken` (r:2 w:2) + /// Proof: `VaultStaking::RewardPerToken` (`max_values`: None, `max_size`: Some(117), added: 2592, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::SlashPerToken` (r:1 w:1) + /// Proof: `VaultStaking::SlashPerToken` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalStake` (r:1 w:1) + /// Proof: `VaultRewards::TotalStake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultRewards::RewardCurrencies` (`max_values`: None, `max_size`: Some(50), added: 2525, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalStake` (r:1 w:1) + /// Proof: `VaultCapacity::TotalStake` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultCapacity::RewardCurrencies` (`max_values`: None, `max_size`: Some(39), added: 2514, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PunishmentDelay` (r:1 w:0) + /// Proof: `VaultRegistry::PunishmentDelay` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn cancel_redeem_reimburse () -> Weight { // Proof Size summary in bytes: - // Measured: `7166` - // Estimated: `135176` - // Minimum execution time: 798_478_000 picoseconds. - Weight::from_parts(808_188_000, 135176) - .saturating_add(RocksDbWeight::get().reads(60_u64)) + // Measured: `5396` + // Estimated: `11350` + // Minimum execution time: 495_000_000 picoseconds. + Weight::from_parts(510_000_000, 11350) + .saturating_add(RocksDbWeight::get().reads(59_u64)) .saturating_add(RocksDbWeight::get().writes(29_u64)) } - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PunishmentFee (r:1 w:0) - /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:0) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:1) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) - /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cancel_redeem_retry() -> Weight { + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:1 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Fee::PunishmentFee` (r:1 w:0) + /// Proof: `Fee::PunishmentFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:1) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::Stake` (r:1 w:1) + /// Proof: `VaultCapacity::Stake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardPerToken` (r:2 w:0) + /// Proof: `VaultCapacity::RewardPerToken` (`max_values`: None, `max_size`: Some(59), added: 2534, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardTally` (r:2 w:2) + /// Proof: `VaultCapacity::RewardTally` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalRewards` (r:2 w:2) + /// Proof: `VaultCapacity::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::Stake` (r:1 w:1) + /// Proof: `VaultRewards::Stake` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardPerToken` (r:2 w:0) + /// Proof: `VaultRewards::RewardPerToken` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardTally` (r:2 w:2) + /// Proof: `VaultRewards::RewardTally` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalRewards` (r:2 w:2) + /// Proof: `VaultRewards::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Fee::Commission` (r:1 w:0) + /// Proof: `Fee::Commission` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::RewardPerToken` (r:2 w:2) + /// Proof: `VaultStaking::RewardPerToken` (`max_values`: None, `max_size`: Some(117), added: 2592, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::SlashPerToken` (r:1 w:1) + /// Proof: `VaultStaking::SlashPerToken` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalStake` (r:1 w:1) + /// Proof: `VaultRewards::TotalStake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultRewards::RewardCurrencies` (`max_values`: None, `max_size`: Some(50), added: 2525, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalStake` (r:1 w:1) + /// Proof: `VaultCapacity::TotalStake` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultCapacity::RewardCurrencies` (`max_values`: None, `max_size`: Some(39), added: 2514, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PunishmentDelay` (r:1 w:0) + /// Proof: `VaultRegistry::PunishmentDelay` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn cancel_redeem_retry () -> Weight { // Proof Size summary in bytes: - // Measured: `7166` - // Estimated: `132666` - // Minimum execution time: 729_751_000 picoseconds. - Weight::from_parts(738_648_000, 132666) - .saturating_add(RocksDbWeight::get().reads(59_u64)) + // Measured: `5396` + // Estimated: `11350` + // Minimum execution time: 406_000_000 picoseconds. + Weight::from_parts(412_000_000, 11350) + .saturating_add(RocksDbWeight::get().reads(58_u64)) .saturating_add(RocksDbWeight::get().writes(28_u64)) } - /// Storage: Redeem RedeemPeriod (r:0 w:1) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_redeem_period() -> Weight { + /// Storage: `Redeem::RedeemPeriod` (r:0 w:1) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_redeem_period () -> Weight { // Proof Size summary in bytes: - // Measured: `1025` + // Measured: `0` // Estimated: `0` - // Minimum execution time: 28_527_000 picoseconds. - Weight::from_parts(29_970_000, 0) + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(9_000_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - fn self_redeem() -> Weight { + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + fn self_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `2449` - // Estimated: `7835` - // Minimum execution time: 147_756_000 picoseconds. - Weight::from_parts(149_109_000, 7835) + // Measured: `1427` + // Estimated: `3725` + // Minimum execution time: 71_000_000 picoseconds. + Weight::from_parts(72_000_000, 3725) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } diff --git a/parachain/runtime/interlay/src/weights/redeem.rs b/parachain/runtime/interlay/src/weights/redeem.rs index 07f30bc059..2b2ced5c79 100644 --- a/parachain/runtime/interlay/src/weights/redeem.rs +++ b/parachain/runtime/interlay/src/weights/redeem.rs @@ -2,31 +2,30 @@ //! Autogenerated weights for redeem //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-04, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-rust-runner-2mz2v-jrrg4`, CPU: `AMD EPYC 7502P 32-Core Processor` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("interlay-dev"), DB CACHE: 1024 +//! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("interlay-dev"), DB CACHE: 1024 // Executed Command: -// target/release/interbtc-parachain +// ./target/release/interbtc-parachain // benchmark // pallet // --pallet -// * +// redeem // --extrinsic // * -// --chain -// interlay-dev -// --execution=wasm // --wasm-execution=compiled // --steps // 50 // --repeat // 10 -// --output -// parachain/runtime/interlay/src/weights/ // --template // .deploy/runtime-weight-template.hbs +// --chain +// interlay-dev +// --output +// interlay_weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -40,122 +39,124 @@ pub struct WeightInfo(PhantomData); impl redeem::WeightInfo for WeightInfo { - /// Storage: Tokens Accounts (r:2 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Fee RedeemFee (r:1 w:0) - /// Proof: Fee RedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Redeem RedeemTransactionSize (r:1 w:0) - /// Proof: Redeem RedeemTransactionSize (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:2 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) - /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security Nonce (r:1 w:1) - /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: System ParentHash (r:1 w:0) - /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: VaultRegistry PremiumRedeemThreshold (r:1 w:0) - /// Proof: VaultRegistry PremiumRedeemThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PremiumRedeemFee (r:1 w:0) - /// Proof: Fee PremiumRedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Redeem RedeemRequests (r:0 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:2 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Fee::RedeemFee` (r:1 w:0) + /// Proof: `Fee::RedeemFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemTransactionSize` (r:1 w:0) + /// Proof: `Redeem::RedeemTransactionSize` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:2 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemBtcDustValue` (r:1 w:0) + /// Proof: `Redeem::RedeemBtcDustValue` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PremiumRedeemThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::PremiumRedeemThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `Fee::PremiumRedeemFee` (r:1 w:0) + /// Proof: `Fee::PremiumRedeemFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Security::Nonce` (r:1 w:1) + /// Proof: `Security::Nonce` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `System::ParentHash` (r:1 w:0) + /// Proof: `System::ParentHash` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemRequests` (r:0 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) fn request_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `3155` + // Measured: `3219` // Estimated: `6260` - // Minimum execution time: 310_652_000 picoseconds. - Weight::from_parts(313_168_000, 6260) - .saturating_add(T::DbWeight::get().reads(28_u64)) + // Minimum execution time: 226_000_000 picoseconds. + Weight::from_parts(230_000_000, 6260) + .saturating_add(T::DbWeight::get().reads(29_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: VaultRegistry LiquidationVault (r:1 w:1) - /// Proof: VaultRegistry LiquidationVault (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:1 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:3 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::LiquidationVault` (r:1 w:1) + /// Proof: `VaultRegistry::LiquidationVault` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:1 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) fn liquidation_redeem () -> Weight { // Proof Size summary in bytes: // Measured: `2173` // Estimated: `8760` - // Minimum execution time: 283_197_000 picoseconds. - Weight::from_parts(284_509_000, 8760) + // Minimum execution time: 139_000_000 picoseconds. + Weight::from_parts(141_000_000, 8760) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) } - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::DisableInclusionCheck` (r:1 w:0) + /// Proof: `BTCRelay::DisableInclusionCheck` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::Chains` (r:1 w:0) + /// Proof: `BTCRelay::Chains` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BlockHeaders` (r:1 w:0) + /// Proof: `BTCRelay::BlockHeaders` (`max_values`: None, `max_size`: Some(200), added: 2675, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::StableBitcoinConfirmations` (r:1 w:0) + /// Proof: `BTCRelay::StableBitcoinConfirmations` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::StableParachainConfirmations` (r:1 w:0) + /// Proof: `BTCRelay::StableParachainConfirmations` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) /// The range of component `h` is `[2, 10]`. /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[2, 3]`. @@ -164,235 +165,235 @@ impl redeem::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2295 + o * (1 ±0)` // Estimated: `3725` - // Minimum execution time: 183_618_000 picoseconds. - Weight::from_parts(155_534_743, 3725) - // Standard Error: 117_935 - .saturating_add(Weight::from_parts(3_687_939, 0).saturating_mul(h.into())) - // Standard Error: 106_320 - .saturating_add(Weight::from_parts(952_959, 0).saturating_mul(i.into())) - // Standard Error: 644_527 - .saturating_add(Weight::from_parts(862_990, 0).saturating_mul(o.into())) - // Standard Error: 649 - .saturating_add(Weight::from_parts(4_928, 0).saturating_mul(b.into())) + // Minimum execution time: 89_000_000 picoseconds. + Weight::from_parts(55_152_275, 3725) + // Standard Error: 149_738 + .saturating_add(Weight::from_parts(2_508_576, 0).saturating_mul(h.into())) + // Standard Error: 134_990 + .saturating_add(Weight::from_parts(994_344, 0).saturating_mul(i.into())) + // Standard Error: 818_328 + .saturating_add(Weight::from_parts(3_299_475, 0).saturating_mul(o.into())) + // Standard Error: 824 + .saturating_add(Weight::from_parts(5_210, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:2 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PunishmentFee (r:1 w:0) - /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:0) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:1) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) - /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:1 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:2 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Fee::PunishmentFee` (r:1 w:0) + /// Proof: `Fee::PunishmentFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:1) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::Stake` (r:1 w:1) + /// Proof: `VaultCapacity::Stake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardPerToken` (r:2 w:0) + /// Proof: `VaultCapacity::RewardPerToken` (`max_values`: None, `max_size`: Some(59), added: 2534, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardTally` (r:2 w:2) + /// Proof: `VaultCapacity::RewardTally` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalRewards` (r:2 w:2) + /// Proof: `VaultCapacity::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::Stake` (r:1 w:1) + /// Proof: `VaultRewards::Stake` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardPerToken` (r:2 w:0) + /// Proof: `VaultRewards::RewardPerToken` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardTally` (r:2 w:2) + /// Proof: `VaultRewards::RewardTally` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalRewards` (r:2 w:2) + /// Proof: `VaultRewards::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Fee::Commission` (r:1 w:0) + /// Proof: `Fee::Commission` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::RewardPerToken` (r:2 w:2) + /// Proof: `VaultStaking::RewardPerToken` (`max_values`: None, `max_size`: Some(117), added: 2592, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::SlashPerToken` (r:1 w:1) + /// Proof: `VaultStaking::SlashPerToken` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalStake` (r:1 w:1) + /// Proof: `VaultRewards::TotalStake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultRewards::RewardCurrencies` (`max_values`: None, `max_size`: Some(50), added: 2525, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalStake` (r:1 w:1) + /// Proof: `VaultCapacity::TotalStake` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultCapacity::RewardCurrencies` (`max_values`: None, `max_size`: Some(39), added: 2514, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PunishmentDelay` (r:1 w:0) + /// Proof: `VaultRegistry::PunishmentDelay` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn cancel_redeem_reimburse () -> Weight { // Proof Size summary in bytes: // Measured: `5396` // Estimated: `11350` - // Minimum execution time: 847_787_000 picoseconds. - Weight::from_parts(851_295_000, 11350) + // Minimum execution time: 495_000_000 picoseconds. + Weight::from_parts(510_000_000, 11350) .saturating_add(T::DbWeight::get().reads(59_u64)) .saturating_add(T::DbWeight::get().writes(29_u64)) } - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PunishmentFee (r:1 w:0) - /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:0) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:1) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) - /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:1 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Fee::PunishmentFee` (r:1 w:0) + /// Proof: `Fee::PunishmentFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:1) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::Stake` (r:1 w:1) + /// Proof: `VaultCapacity::Stake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardPerToken` (r:2 w:0) + /// Proof: `VaultCapacity::RewardPerToken` (`max_values`: None, `max_size`: Some(59), added: 2534, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardTally` (r:2 w:2) + /// Proof: `VaultCapacity::RewardTally` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalRewards` (r:2 w:2) + /// Proof: `VaultCapacity::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::Stake` (r:1 w:1) + /// Proof: `VaultRewards::Stake` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardPerToken` (r:2 w:0) + /// Proof: `VaultRewards::RewardPerToken` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardTally` (r:2 w:2) + /// Proof: `VaultRewards::RewardTally` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalRewards` (r:2 w:2) + /// Proof: `VaultRewards::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Fee::Commission` (r:1 w:0) + /// Proof: `Fee::Commission` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::RewardPerToken` (r:2 w:2) + /// Proof: `VaultStaking::RewardPerToken` (`max_values`: None, `max_size`: Some(117), added: 2592, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::SlashPerToken` (r:1 w:1) + /// Proof: `VaultStaking::SlashPerToken` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalStake` (r:1 w:1) + /// Proof: `VaultRewards::TotalStake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultRewards::RewardCurrencies` (`max_values`: None, `max_size`: Some(50), added: 2525, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalStake` (r:1 w:1) + /// Proof: `VaultCapacity::TotalStake` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultCapacity::RewardCurrencies` (`max_values`: None, `max_size`: Some(39), added: 2514, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PunishmentDelay` (r:1 w:0) + /// Proof: `VaultRegistry::PunishmentDelay` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn cancel_redeem_retry () -> Weight { // Proof Size summary in bytes: // Measured: `5396` // Estimated: `11350` - // Minimum execution time: 775_122_000 picoseconds. - Weight::from_parts(783_890_000, 11350) + // Minimum execution time: 406_000_000 picoseconds. + Weight::from_parts(412_000_000, 11350) .saturating_add(T::DbWeight::get().reads(58_u64)) .saturating_add(T::DbWeight::get().writes(28_u64)) } - /// Storage: Redeem RedeemPeriod (r:0 w:1) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemPeriod` (r:0 w:1) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn set_redeem_period () -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 18_136_000 picoseconds. - Weight::from_parts(18_727_000, 0) + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(9_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) fn self_redeem () -> Weight { // Proof Size summary in bytes: // Measured: `1427` // Estimated: `3725` - // Minimum execution time: 149_329_000 picoseconds. - Weight::from_parts(152_415_000, 3725) + // Minimum execution time: 71_000_000 picoseconds. + Weight::from_parts(72_000_000, 3725) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } diff --git a/parachain/runtime/kintsugi/src/weights/redeem.rs b/parachain/runtime/kintsugi/src/weights/redeem.rs index ca3aee803b..65a6a95a0a 100644 --- a/parachain/runtime/kintsugi/src/weights/redeem.rs +++ b/parachain/runtime/kintsugi/src/weights/redeem.rs @@ -2,31 +2,30 @@ //! Autogenerated weights for redeem //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-04, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-rust-runner-2mz2v-kcxvd`, CPU: `AMD EPYC 7502P 32-Core Processor` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 +//! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 // Executed Command: -// target/release/interbtc-parachain +// ./target/release/interbtc-parachain // benchmark // pallet // --pallet -// * +// redeem // --extrinsic // * -// --chain -// kintsugi-dev -// --execution=wasm // --wasm-execution=compiled // --steps // 50 // --repeat // 10 -// --output -// parachain/runtime/kintsugi/src/weights/ // --template // .deploy/runtime-weight-template.hbs +// --chain +// kintsugi-dev +// --output +// kintsugi_weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -40,359 +39,357 @@ pub struct WeightInfo(PhantomData); impl redeem::WeightInfo for WeightInfo { - /// Storage: Tokens Accounts (r:2 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Fee RedeemFee (r:1 w:0) - /// Proof: Fee RedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Redeem RedeemTransactionSize (r:1 w:0) - /// Proof: Redeem RedeemTransactionSize (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:2 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) - /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security Nonce (r:1 w:1) - /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: System ParentHash (r:1 w:0) - /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: VaultRegistry PremiumRedeemThreshold (r:1 w:0) - /// Proof: VaultRegistry PremiumRedeemThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PremiumRedeemFee (r:1 w:0) - /// Proof: Fee PremiumRedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Redeem RedeemRequests (r:0 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:2 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Fee::RedeemFee` (r:1 w:0) + /// Proof: `Fee::RedeemFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemTransactionSize` (r:1 w:0) + /// Proof: `Redeem::RedeemTransactionSize` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:2 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemBtcDustValue` (r:1 w:0) + /// Proof: `Redeem::RedeemBtcDustValue` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PremiumRedeemThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::PremiumRedeemThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `Fee::PremiumRedeemFee` (r:1 w:0) + /// Proof: `Fee::PremiumRedeemFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Security::Nonce` (r:1 w:1) + /// Proof: `Security::Nonce` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `System::ParentHash` (r:1 w:0) + /// Proof: `System::ParentHash` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemRequests` (r:0 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) fn request_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `3189` + // Measured: `3307` // Estimated: `6260` - // Minimum execution time: 311_614_000 picoseconds. - Weight::from_parts(319_349_000, 6260) - .saturating_add(T::DbWeight::get().reads(28_u64)) + // Minimum execution time: 237_000_000 picoseconds. + Weight::from_parts(242_000_000, 6260) + .saturating_add(T::DbWeight::get().reads(29_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: VaultRegistry LiquidationVault (r:1 w:1) - /// Proof: VaultRegistry LiquidationVault (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:1 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:3 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::LiquidationVault` (r:1 w:1) + /// Proof: `VaultRegistry::LiquidationVault` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:1 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) fn liquidation_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `2173` + // Measured: `2193` // Estimated: `8760` - // Minimum execution time: 287_687_000 picoseconds. - Weight::from_parts(292_145_000, 8760) + // Minimum execution time: 145_000_000 picoseconds. + Weight::from_parts(147_000_000, 8760) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) } - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::DisableInclusionCheck` (r:1 w:0) + /// Proof: `BTCRelay::DisableInclusionCheck` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::Chains` (r:1 w:0) + /// Proof: `BTCRelay::Chains` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BlockHeaders` (r:1 w:0) + /// Proof: `BTCRelay::BlockHeaders` (`max_values`: None, `max_size`: Some(200), added: 2675, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::StableBitcoinConfirmations` (r:1 w:0) + /// Proof: `BTCRelay::StableBitcoinConfirmations` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::StableParachainConfirmations` (r:1 w:0) + /// Proof: `BTCRelay::StableParachainConfirmations` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) /// The range of component `h` is `[2, 10]`. /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[2, 3]`. /// The range of component `b` is `[541, 2048]`. - fn execute_redeem (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_redeem (h: u32, i: u32, _o: u32, _b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2295 + o * (1 ±0)` + // Measured: `2315 + o * (1 ±0)` // Estimated: `3725` - // Minimum execution time: 184_800_000 picoseconds. - Weight::from_parts(149_034_719, 3725) - // Standard Error: 137_585 - .saturating_add(Weight::from_parts(3_833_551, 0).saturating_mul(h.into())) - // Standard Error: 124_035 - .saturating_add(Weight::from_parts(1_176_171, 0).saturating_mul(i.into())) - // Standard Error: 751_913 - .saturating_add(Weight::from_parts(1_964_806, 0).saturating_mul(o.into())) - // Standard Error: 757 - .saturating_add(Weight::from_parts(5_490, 0).saturating_mul(b.into())) + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(98_367_431, 3725) + // Standard Error: 105_687 + .saturating_add(Weight::from_parts(1_774_333, 0).saturating_mul(h.into())) + // Standard Error: 95_278 + .saturating_add(Weight::from_parts(64_310, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:2 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PunishmentFee (r:1 w:0) - /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:0) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:1) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) - /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:1 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:2 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Fee::PunishmentFee` (r:1 w:0) + /// Proof: `Fee::PunishmentFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:1) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::Stake` (r:1 w:1) + /// Proof: `VaultCapacity::Stake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardPerToken` (r:2 w:0) + /// Proof: `VaultCapacity::RewardPerToken` (`max_values`: None, `max_size`: Some(59), added: 2534, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardTally` (r:2 w:2) + /// Proof: `VaultCapacity::RewardTally` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalRewards` (r:2 w:2) + /// Proof: `VaultCapacity::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::Stake` (r:1 w:1) + /// Proof: `VaultRewards::Stake` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardPerToken` (r:2 w:0) + /// Proof: `VaultRewards::RewardPerToken` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardTally` (r:2 w:2) + /// Proof: `VaultRewards::RewardTally` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalRewards` (r:2 w:2) + /// Proof: `VaultRewards::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Fee::Commission` (r:1 w:0) + /// Proof: `Fee::Commission` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::RewardPerToken` (r:2 w:2) + /// Proof: `VaultStaking::RewardPerToken` (`max_values`: None, `max_size`: Some(117), added: 2592, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::SlashPerToken` (r:1 w:1) + /// Proof: `VaultStaking::SlashPerToken` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalStake` (r:1 w:1) + /// Proof: `VaultRewards::TotalStake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultRewards::RewardCurrencies` (`max_values`: None, `max_size`: Some(50), added: 2525, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalStake` (r:1 w:1) + /// Proof: `VaultCapacity::TotalStake` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultCapacity::RewardCurrencies` (`max_values`: None, `max_size`: Some(39), added: 2514, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PunishmentDelay` (r:1 w:0) + /// Proof: `VaultRegistry::PunishmentDelay` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn cancel_redeem_reimburse () -> Weight { // Proof Size summary in bytes: - // Measured: `5430` + // Measured: `5450` // Estimated: `11350` - // Minimum execution time: 850_042_000 picoseconds. - Weight::from_parts(865_223_000, 11350) + // Minimum execution time: 437_000_000 picoseconds. + Weight::from_parts(444_000_000, 11350) .saturating_add(T::DbWeight::get().reads(59_u64)) .saturating_add(T::DbWeight::get().writes(29_u64)) } - /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - /// Storage: Redeem RedeemPeriod (r:1 w:0) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Loans UnderlyingAssetId (r:1 w:0) - /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Loans Markets (r:2 w:0) - /// Proof: Loans Markets (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Loans LastAccruedInterestTime (r:1 w:1) - /// Proof: Loans LastAccruedInterestTime (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Loans TotalBorrows (r:1 w:0) - /// Proof: Loans TotalBorrows (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans TotalReserves (r:1 w:0) - /// Proof: Loans TotalReserves (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans MinExchangeRate (r:1 w:0) - /// Proof: Loans MinExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Loans MaxExchangeRate (r:1 w:0) - /// Proof: Loans MaxExchangeRate (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Fee PunishmentFee (r:1 w:0) - /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:0) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:1) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplyState (r:1 w:1) - /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplySpeed (r:1 w:0) - /// Proof: Loans RewardSupplySpeed (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Loans RewardSupplierIndex (r:2 w:2) - /// Proof: Loans RewardSupplierIndex (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Loans RewardAccrued (r:2 w:2) - /// Proof: Loans RewardAccrued (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) - /// Storage: Loans AccountDeposits (r:1 w:0) - /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) - /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemRequests` (r:1 w:1) + /// Proof: `Redeem::RedeemRequests` (`max_values`: None, `max_size`: Some(245), added: 2720, mode: `MaxEncodedLen`) + /// Storage: `Redeem::RedeemPeriod` (r:1 w:0) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Security::ActiveBlockCount` (r:1 w:0) + /// Proof: `Security::ActiveBlockCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `BTCRelay::BestBlockHeight` (r:1 w:0) + /// Proof: `BTCRelay::BestBlockHeight` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Loans::UnderlyingAssetId` (r:1 w:0) + /// Proof: `Loans::UnderlyingAssetId` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Aggregate` (r:1 w:0) + /// Proof: `Oracle::Aggregate` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `Loans::Markets` (r:2 w:0) + /// Proof: `Loans::Markets` (`max_values`: None, `max_size`: Some(160), added: 2635, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Loans::LastAccruedInterestTime` (r:1 w:1) + /// Proof: `Loans::LastAccruedInterestTime` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalBorrows` (r:1 w:0) + /// Proof: `Loans::TotalBorrows` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::TotalReserves` (r:1 w:0) + /// Proof: `Loans::TotalReserves` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::MinExchangeRate` (r:1 w:0) + /// Proof: `Loans::MinExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Loans::MaxExchangeRate` (r:1 w:0) + /// Proof: `Loans::MaxExchangeRate` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Fee::PunishmentFee` (r:1 w:0) + /// Proof: `Fee::PunishmentFee` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::Nonce` (r:1 w:0) + /// Proof: `VaultStaking::Nonce` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalCurrentStake` (r:1 w:1) + /// Proof: `VaultStaking::TotalCurrentStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::TotalUserVaultCollateral` (r:1 w:1) + /// Proof: `VaultRegistry::TotalUserVaultCollateral` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::Stake` (r:1 w:1) + /// Proof: `VaultCapacity::Stake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardPerToken` (r:2 w:0) + /// Proof: `VaultCapacity::RewardPerToken` (`max_values`: None, `max_size`: Some(59), added: 2534, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardTally` (r:2 w:2) + /// Proof: `VaultCapacity::RewardTally` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalRewards` (r:2 w:2) + /// Proof: `VaultCapacity::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::Stake` (r:1 w:1) + /// Proof: `VaultRewards::Stake` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardPerToken` (r:2 w:0) + /// Proof: `VaultRewards::RewardPerToken` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardTally` (r:2 w:2) + /// Proof: `VaultRewards::RewardTally` (`max_values`: None, `max_size`: Some(124), added: 2599, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalRewards` (r:2 w:2) + /// Proof: `VaultRewards::TotalRewards` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Fee::Commission` (r:1 w:0) + /// Proof: `Fee::Commission` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::RewardPerToken` (r:2 w:2) + /// Proof: `VaultStaking::RewardPerToken` (`max_values`: None, `max_size`: Some(117), added: 2592, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::TotalStake` (r:1 w:0) + /// Proof: `VaultStaking::TotalStake` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultStaking::SlashPerToken` (r:1 w:1) + /// Proof: `VaultStaking::SlashPerToken` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::SecureCollateralThreshold` (r:1 w:0) + /// Proof: `VaultRegistry::SecureCollateralThreshold` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::TotalStake` (r:1 w:1) + /// Proof: `VaultRewards::TotalStake` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `VaultRewards::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultRewards::RewardCurrencies` (`max_values`: None, `max_size`: Some(50), added: 2525, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::TotalStake` (r:1 w:1) + /// Proof: `VaultCapacity::TotalStake` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `VaultCapacity::RewardCurrencies` (r:1 w:0) + /// Proof: `VaultCapacity::RewardCurrencies` (`max_values`: None, `max_size`: Some(39), added: 2514, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplyState` (r:1 w:1) + /// Proof: `Loans::RewardSupplyState` (`max_values`: None, `max_size`: Some(47), added: 2522, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplySpeed` (r:1 w:0) + /// Proof: `Loans::RewardSupplySpeed` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardSupplierIndex` (r:2 w:2) + /// Proof: `Loans::RewardSupplierIndex` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Loans::RewardAccrued` (r:2 w:2) + /// Proof: `Loans::RewardAccrued` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Loans::AccountDeposits` (r:1 w:0) + /// Proof: `Loans::AccountDeposits` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `VaultRegistry::PunishmentDelay` (r:1 w:0) + /// Proof: `VaultRegistry::PunishmentDelay` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn cancel_redeem_retry () -> Weight { // Proof Size summary in bytes: - // Measured: `5430` + // Measured: `5450` // Estimated: `11350` - // Minimum execution time: 773_779_000 picoseconds. - Weight::from_parts(789_120_000, 11350) + // Minimum execution time: 399_000_000 picoseconds. + Weight::from_parts(401_000_000, 11350) .saturating_add(T::DbWeight::get().reads(58_u64)) .saturating_add(T::DbWeight::get().writes(28_u64)) } - /// Storage: Redeem RedeemPeriod (r:0 w:1) - /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Redeem::RedeemPeriod` (r:0 w:1) + /// Proof: `Redeem::RedeemPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn set_redeem_period () -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 18_106_000 picoseconds. - Weight::from_parts(18_667_000, 0) + // Minimum execution time: 8_000_000 picoseconds. + Weight::from_parts(9_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) + /// Storage: `VaultRegistry::Vaults` (r:1 w:1) + /// Proof: `VaultRegistry::Vaults` (`max_values`: None, `max_size`: Some(260), added: 2735, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(35), added: 2510, mode: `MaxEncodedLen`) fn self_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `1427` + // Measured: `1447` // Estimated: `3725` - // Minimum execution time: 150_121_000 picoseconds. - Weight::from_parts(151_013_000, 3725) + // Minimum execution time: 70_000_000 picoseconds. + Weight::from_parts(72_000_000, 3725) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index 04e889b778..ecc382fe0b 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -215,7 +215,7 @@ mod premium_redeem_tests { let get_free_redeemable_tokens = VaultRegistryPallet::get_free_redeemable_tokens(&vault_id) .unwrap() .amount(); - assert_eq!(get_free_redeemable_tokens, 300500); //300.5 + assert_eq!(get_free_redeemable_tokens, 300500); }); } } From 3dfeb00772b2bcee5d2fba104743f422c552c840 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Mon, 4 Dec 2023 11:52:17 +0530 Subject: [PATCH 05/19] fix: change premium calculation formula. --- crates/fee/src/lib.rs | 15 +++++++ crates/fee/src/types.rs | 2 +- crates/redeem/src/ext.rs | 22 ++++++---- crates/redeem/src/lib.rs | 43 +++++++++---------- crates/vault-registry/src/lib.rs | 24 ++++++----- crates/vault-registry/src/types.rs | 2 +- .../runtime-tests/src/parachain/redeem.rs | 6 +-- 7 files changed, 68 insertions(+), 46 deletions(-) diff --git a/crates/fee/src/lib.rs b/crates/fee/src/lib.rs index 321efd28d4..96523f0149 100644 --- a/crates/fee/src/lib.rs +++ b/crates/fee/src/lib.rs @@ -111,6 +111,8 @@ pub mod pallet { TryIntoIntError, /// Value exceeds the expected upper bound for storage fields in this pallet. AboveMaxExpectedValue, + /// Subtraction of the premium redeem fee from a value failed. + PremiumRedeemSubtractionFailed, } #[pallet::hooks] @@ -427,6 +429,19 @@ impl Pallet { amount.checked_rounded_mul(&>::get(), Rounding::NearestPrefUp) } + /// Apply a premium redeem discount to the given unsigned fixed-point value + /// + /// # Arguments + /// + /// * `amount` - amount in collateral (at current exchange rate) + pub fn apply_premium_redeem_discount( + amount: &UnsignedFixedPoint, + ) -> Result, DispatchError> { + Ok(amount + .checked_sub(&>::get()) + .ok_or(Error::::PremiumRedeemSubtractionFailed)?) + } + /// Calculate punishment fee for a Vault that fails to execute a redeem /// request before the expiry. /// diff --git a/crates/fee/src/types.rs b/crates/fee/src/types.rs index f7bdfccd87..e9e71ce3fb 100644 --- a/crates/fee/src/types.rs +++ b/crates/fee/src/types.rs @@ -5,7 +5,7 @@ use scale_info::TypeInfo; pub(crate) type BalanceOf = ::Balance; -pub(crate) type UnsignedFixedPoint = ::UnsignedFixedPoint; +pub type UnsignedFixedPoint = ::UnsignedFixedPoint; pub(crate) type DefaultVaultId = VaultId<::AccountId, CurrencyId>; diff --git a/crates/redeem/src/ext.rs b/crates/redeem/src/ext.rs index bc63b0228b..9d9cc1f7ba 100644 --- a/crates/redeem/src/ext.rs +++ b/crates/redeem/src/ext.rs @@ -42,7 +42,7 @@ pub(crate) mod vault_registry { use crate::DefaultVaultId; use currency::Amount; use frame_support::dispatch::{DispatchError, DispatchResult}; - use vault_registry::types::{CurrencyId, CurrencySource, DefaultVault}; + use vault_registry::types::{CurrencyId, CurrencySource, DefaultVault, UnsignedFixedPoint}; pub fn get_backing_collateral(vault_id: &DefaultVaultId) -> Result, DispatchError> { >::get_backing_collateral(vault_id) @@ -92,13 +92,6 @@ pub(crate) mod vault_registry { >::vault_capacity_at_secure_threshold(vault_id) } - pub fn vault_capacity_at_secure_threshold_based_on_collateral( - vault_id: &DefaultVaultId, - collateral: Amount, - ) -> Result, DispatchError> { - >::vault_capacity_at_secure_threshold_based_on_collateral(vault_id, collateral) - } - pub fn try_increase_to_be_redeemed_tokens( vault_id: &DefaultVaultId, amount: &Amount, @@ -190,6 +183,12 @@ pub(crate) mod vault_registry { ) -> Result<(Amount, Amount), DispatchError> { >::decrease_to_be_replaced_tokens(vault_id, tokens) } + + pub fn get_secure_threshold( + vault_id: &DefaultVaultId, + ) -> Result, DispatchError> { + >::get_secure_threshold(vault_id) + } } #[cfg_attr(test, mockable)] @@ -230,6 +229,7 @@ pub(crate) mod oracle { #[cfg_attr(test, mockable)] pub(crate) mod fee { use currency::Amount; + use fee::types::UnsignedFixedPoint; use frame_support::dispatch::{DispatchError, DispatchResult}; pub fn fee_pool_account_id() -> T::AccountId { @@ -251,4 +251,10 @@ pub(crate) mod fee { pub fn get_premium_redeem_fee(amount: &Amount) -> Result, DispatchError> { >::get_premium_redeem_fee(amount) } + + pub fn apply_premium_redeem_discount( + amount: &UnsignedFixedPoint, + ) -> Result, DispatchError> { + >::apply_premium_redeem_discount(amount) + } } diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index f051fd4ed0..f0e2c50396 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -32,7 +32,7 @@ pub use crate::types::{DefaultRedeemRequest, RedeemRequest, RedeemRequestStatus} use crate::types::{BalanceOf, RedeemRequestExt, Version}; use bitcoin::types::FullTransactionProof; use btc_relay::BtcAddress; -use currency::Amount; +use currency::{Amount, Rounding}; use frame_support::{ dispatch::{DispatchError, DispatchResult}, ensure, @@ -456,6 +456,7 @@ mod self_redeem { Ok(()) } } + // "Internal" functions, callable by code. #[cfg_attr(test, mockable)] impl Pallet { @@ -507,35 +508,31 @@ impl Pallet { let premium_collateral = if below_premium_redeem { // Calculate the secure vault capacity let secure_vault_capacity = ext::vault_registry::vault_capacity_at_secure_threshold(&vault_id)?; - let issued_tokens = ext::vault_registry::vault_to_be_backed_tokens(&vault_id)?; + let to_be_backed_tokens = ext::vault_registry::vault_to_be_backed_tokens(&vault_id)?; let difference_in_tokens_to_reach_secure_threshold = - issued_tokens.saturating_sub(&secure_vault_capacity)?; + to_be_backed_tokens.saturating_sub(&secure_vault_capacity)?; - // Calculate collateral after paying the premium redeem fee - let backing_collateral = ext::vault_registry::get_backing_collateral(&vault_id)?; - let premium_redeem_fee = ext::fee::get_premium_redeem_fee::( - &difference_in_tokens_to_reach_secure_threshold.convert_to(currency_id)?, - )?; + if difference_in_tokens_to_reach_secure_threshold.gt(&user_to_be_received_btc)? { + let premium_tokens_in_collateral = user_to_be_received_btc.convert_to(currency_id)?; - let collateral_after_premium_redeem = backing_collateral.saturating_sub(&premium_redeem_fee)?; + ext::fee::get_premium_redeem_fee::(&premium_tokens_in_collateral)? + } else { + // Formula = max_premium_collateral = (FEE * (oldTokens * EXCH * SECURE - oldCol)) / (SECURE - FEE) - // Calculate the issued tokens that can be backed after paying the premium redeem fee - let issue_backed_after_premium_redeem = - ext::vault_registry::vault_capacity_at_secure_threshold_based_on_collateral( - &vault_id, - collateral_after_premium_redeem.clone(), - )?; + let backing_collateral = ext::vault_registry::get_backing_collateral(&vault_id)?; - let tokens_remaining_after_premium_redeem = - issued_tokens.saturating_sub(&issue_backed_after_premium_redeem)?; + let secure_threshold = ext::vault_registry::get_secure_threshold::(&vault_id)?; - // Calculate the actual premium tokens and convert to collateral - let actual_premium_tokens = tokens_remaining_after_premium_redeem.min(&user_to_be_received_btc)?; - let premium_tokens_in_collateral = actual_premium_tokens.convert_to(currency_id)?; + let issued_tokens_in_collateral = to_be_backed_tokens.convert_to(currency_id)?; // oldTokens * EXCH - // Calculate the premium redeem fee for the premium tokens in collateral - let premium_collateral = ext::fee::get_premium_redeem_fee::(&premium_tokens_in_collateral)?; - premium_collateral + let token_exchange_value = + issued_tokens_in_collateral.checked_rounded_mul(&secure_threshold, Rounding::NearestPrefUp)?; // oldTokens * EXCH * SECURE + + ext::fee::get_premium_redeem_fee::( + &token_exchange_value.saturating_sub(&backing_collateral)?, // (oldCol - oldTokens * EXCH * SECURE) + )? // FEE * (oldTokens * EXCH * SECURE - oldCol)) + .checked_div(&ext::fee::apply_premium_redeem_discount::(&secure_threshold)?)? // (SECURE - FEE) + } } else { Amount::zero(currency_id) }; diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 7e44e38886..e04e53f91c 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -1089,6 +1089,20 @@ impl Pallet { Ok(()) } + /// Get the secure threshold for a specified vault. + /// # Arguments + /// * `vault_id` - the id of the vault from which to issue tokens + /// + /// # Returns + /// Returns the secure threshold of the specified vault or an error if the vault retrieval fails. + /// + /// # Errors + /// * `VaultNotFound` - if no vault exists for the given `vault_id` + pub fn get_secure_threshold(vault_id: &DefaultVaultId) -> Result, DispatchError> { + let vault = Self::get_rich_vault_from_id(&vault_id)?; + vault.get_secure_threshold() + } + /// Adds an amount tokens to the to-be-redeemed tokens balance of a vault. /// This function serves as a prevention against race conditions in the /// redeem and replace procedures. If, for example, a vault would receive @@ -1897,16 +1911,6 @@ impl Pallet { Self::calculate_max_wrapped_from_collateral_for_threshold(&collateral, wrapped_currency, threshold) } - pub fn vault_capacity_at_secure_threshold_based_on_collateral( - vault_id: &DefaultVaultId, - collateral: Amount, - ) -> Result, DispatchError> { - let threshold = Self::secure_collateral_threshold(&vault_id.currencies).ok_or(Error::::ThresholdNotSet)?; - let wrapped_currency = vault_id.wrapped_currency(); - - Self::calculate_max_wrapped_from_collateral_for_threshold(&collateral, wrapped_currency, threshold) - } - pub fn vault_to_be_backed_tokens(vault_id: &DefaultVaultId) -> Result, DispatchError> { let vault = Self::get_active_rich_vault_from_id(vault_id)?; vault.to_be_backed_tokens() diff --git a/crates/vault-registry/src/types.rs b/crates/vault-registry/src/types.rs index 3b3ba860f9..cb57a18cf6 100644 --- a/crates/vault-registry/src/types.rs +++ b/crates/vault-registry/src/types.rs @@ -102,7 +102,7 @@ impl CurrencySource { pub(crate) type BalanceOf = ::Balance; -pub(crate) type UnsignedFixedPoint = ::UnsignedFixedPoint; +pub type UnsignedFixedPoint = ::UnsignedFixedPoint; pub type CurrencyId = ::CurrencyId; diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index ecc382fe0b..8ac17cc4bc 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -152,10 +152,10 @@ mod premium_redeem_tests { assert!(!VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); - // we should get rewarded only for 150_000 + 3750 tokens (that's when we reach nearer to secure threshold) + // we should get rewarded only for 150_000 + 3840 tokens (that's when we reach nearer to secure threshold) let expected_premium = FeePallet::get_premium_redeem_fee( &vault_id - .wrapped(150_000 + 3750) // need to add 0.375 = 153.750 + .wrapped(150_000 + 3840) // need to add 0.384 = 153.84 .convert_to(vault_id.collateral_currency()) .unwrap(), ) @@ -166,7 +166,7 @@ mod premium_redeem_tests { execute_redeem(redeem_id); let compute_collateral = VaultRegistryPallet::compute_collateral(&vault_id).unwrap().amount(); - assert_eq!(compute_collateral, 2000000 - 15375); //15.355 COL tokens lost as premium fees + assert_eq!(compute_collateral, 2000000 - 15384); //15.384 COL tokens lost as premium fees // Setup another redeem request let redeem_id = setup_redeem(vault_id.wrapped(2_000), USER, &vault_id); From 5a00bac8bfccb7704954873fe1ca0bbfebd7c633 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 6 Dec 2023 19:03:49 +0530 Subject: [PATCH 06/19] fix: change premium calculation flow --- crates/fee/src/lib.rs | 17 +-- crates/issue/src/ext.rs | 2 +- crates/redeem/src/ext.rs | 38 ++----- crates/redeem/src/lib.rs | 32 ++---- crates/replace/src/ext.rs | 2 +- crates/vault-registry/src/ext.rs | 5 + crates/vault-registry/src/lib.rs | 101 +++++++++++++++--- crates/vault-registry/src/tests.rs | 38 ++++--- .../runtime-tests/src/parachain/redeem.rs | 6 +- 9 files changed, 138 insertions(+), 103 deletions(-) diff --git a/crates/fee/src/lib.rs b/crates/fee/src/lib.rs index 96523f0149..c172324475 100644 --- a/crates/fee/src/lib.rs +++ b/crates/fee/src/lib.rs @@ -111,8 +111,6 @@ pub mod pallet { TryIntoIntError, /// Value exceeds the expected upper bound for storage fields in this pallet. AboveMaxExpectedValue, - /// Subtraction of the premium redeem fee from a value failed. - PremiumRedeemSubtractionFailed, } #[pallet::hooks] @@ -429,17 +427,12 @@ impl Pallet { amount.checked_rounded_mul(&>::get(), Rounding::NearestPrefUp) } - /// Apply a premium redeem discount to the given unsigned fixed-point value + /// Get the premium redeem reward rate. /// - /// # Arguments - /// - /// * `amount` - amount in collateral (at current exchange rate) - pub fn apply_premium_redeem_discount( - amount: &UnsignedFixedPoint, - ) -> Result, DispatchError> { - Ok(amount - .checked_sub(&>::get()) - .ok_or(Error::::PremiumRedeemSubtractionFailed)?) + /// # Returns + /// Returns the premium redeem reward rate. + pub fn premium_redeem_reward_rate() -> UnsignedFixedPoint { + >::get() } /// Calculate punishment fee for a Vault that fails to execute a redeem diff --git a/crates/issue/src/ext.rs b/crates/issue/src/ext.rs index d548bb6b9f..9a149a236a 100644 --- a/crates/issue/src/ext.rs +++ b/crates/issue/src/ext.rs @@ -95,7 +95,7 @@ pub(crate) mod vault_registry { } pub fn ensure_not_banned(vault_id: &DefaultVaultId) -> DispatchResult { - >::_ensure_not_banned(vault_id) + >::ensure_not_banned(vault_id) } pub fn decrease_to_be_issued_tokens( diff --git a/crates/redeem/src/ext.rs b/crates/redeem/src/ext.rs index 9d9cc1f7ba..32a0f25ff7 100644 --- a/crates/redeem/src/ext.rs +++ b/crates/redeem/src/ext.rs @@ -42,10 +42,12 @@ pub(crate) mod vault_registry { use crate::DefaultVaultId; use currency::Amount; use frame_support::dispatch::{DispatchError, DispatchResult}; - use vault_registry::types::{CurrencyId, CurrencySource, DefaultVault, UnsignedFixedPoint}; + use vault_registry::types::{CurrencyId, CurrencySource, DefaultVault}; - pub fn get_backing_collateral(vault_id: &DefaultVaultId) -> Result, DispatchError> { - >::get_backing_collateral(vault_id) + pub fn get_vault_max_premium_redeem( + vault_id: &DefaultVaultId, + ) -> Result, DispatchError> { + >::get_vault_max_premium_redeem(vault_id) } pub fn get_liquidated_collateral( @@ -80,18 +82,6 @@ pub(crate) mod vault_registry { >::get_vault_from_id(vault_id) } - pub fn vault_to_be_backed_tokens( - vault_id: &DefaultVaultId, - ) -> Result, DispatchError> { - >::vault_to_be_backed_tokens(vault_id) - } - - pub fn vault_capacity_at_secure_threshold( - vault_id: &DefaultVaultId, - ) -> Result, DispatchError> { - >::vault_capacity_at_secure_threshold(vault_id) - } - pub fn try_increase_to_be_redeemed_tokens( vault_id: &DefaultVaultId, amount: &Amount, @@ -136,7 +126,7 @@ pub(crate) mod vault_registry { } pub fn ensure_not_banned(vault_id: &DefaultVaultId) -> DispatchResult { - >::_ensure_not_banned(vault_id) + >::ensure_not_banned(vault_id) } pub fn is_vault_below_premium_threshold( @@ -183,12 +173,6 @@ pub(crate) mod vault_registry { ) -> Result<(Amount, Amount), DispatchError> { >::decrease_to_be_replaced_tokens(vault_id, tokens) } - - pub fn get_secure_threshold( - vault_id: &DefaultVaultId, - ) -> Result, DispatchError> { - >::get_secure_threshold(vault_id) - } } #[cfg_attr(test, mockable)] @@ -248,13 +232,7 @@ pub(crate) mod fee { >::get_punishment_fee(amount) } - pub fn get_premium_redeem_fee(amount: &Amount) -> Result, DispatchError> { - >::get_premium_redeem_fee(amount) - } - - pub fn apply_premium_redeem_discount( - amount: &UnsignedFixedPoint, - ) -> Result, DispatchError> { - >::apply_premium_redeem_discount(amount) + pub fn premium_redeem_reward_rate() -> UnsignedFixedPoint { + >::premium_redeem_reward_rate() } } diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index f0e2c50396..34f4568d84 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -506,33 +506,13 @@ impl Pallet { let currency_id = vault_id.collateral_currency(); let premium_collateral = if below_premium_redeem { - // Calculate the secure vault capacity - let secure_vault_capacity = ext::vault_registry::vault_capacity_at_secure_threshold(&vault_id)?; - let to_be_backed_tokens = ext::vault_registry::vault_to_be_backed_tokens(&vault_id)?; - let difference_in_tokens_to_reach_secure_threshold = - to_be_backed_tokens.saturating_sub(&secure_vault_capacity)?; + let redeem_amount_wrapped_in_collateral = user_to_be_received_btc.convert_to(currency_id)?; + let premium_redeem_rate = ext::fee::premium_redeem_reward_rate::(); + let premium_for_redeem_amount = redeem_amount_wrapped_in_collateral + .checked_rounded_mul(&premium_redeem_rate, Rounding::NearestPrefUp)?; - if difference_in_tokens_to_reach_secure_threshold.gt(&user_to_be_received_btc)? { - let premium_tokens_in_collateral = user_to_be_received_btc.convert_to(currency_id)?; - - ext::fee::get_premium_redeem_fee::(&premium_tokens_in_collateral)? - } else { - // Formula = max_premium_collateral = (FEE * (oldTokens * EXCH * SECURE - oldCol)) / (SECURE - FEE) - - let backing_collateral = ext::vault_registry::get_backing_collateral(&vault_id)?; - - let secure_threshold = ext::vault_registry::get_secure_threshold::(&vault_id)?; - - let issued_tokens_in_collateral = to_be_backed_tokens.convert_to(currency_id)?; // oldTokens * EXCH - - let token_exchange_value = - issued_tokens_in_collateral.checked_rounded_mul(&secure_threshold, Rounding::NearestPrefUp)?; // oldTokens * EXCH * SECURE - - ext::fee::get_premium_redeem_fee::( - &token_exchange_value.saturating_sub(&backing_collateral)?, // (oldCol - oldTokens * EXCH * SECURE) - )? // FEE * (oldTokens * EXCH * SECURE - oldCol)) - .checked_div(&ext::fee::apply_premium_redeem_discount::(&secure_threshold)?)? // (SECURE - FEE) - } + let max_premium = ext::vault_registry::get_vault_max_premium_redeem(&vault_id)?; + max_premium.min(&premium_for_redeem_amount)? } else { Amount::zero(currency_id) }; diff --git a/crates/replace/src/ext.rs b/crates/replace/src/ext.rs index 730d59c8cb..62457cfeba 100644 --- a/crates/replace/src/ext.rs +++ b/crates/replace/src/ext.rs @@ -81,7 +81,7 @@ pub(crate) mod vault_registry { } pub fn ensure_not_banned(vault_id: &DefaultVaultId) -> DispatchResult { - >::_ensure_not_banned(vault_id) + >::ensure_not_banned(vault_id) } pub fn try_increase_to_be_issued_tokens( diff --git a/crates/vault-registry/src/ext.rs b/crates/vault-registry/src/ext.rs index 72a3571cf4..83494f4675 100644 --- a/crates/vault-registry/src/ext.rs +++ b/crates/vault-registry/src/ext.rs @@ -113,9 +113,14 @@ pub(crate) mod capacity { #[cfg_attr(test, mockable)] pub(crate) mod fee { use crate::DefaultVaultId; + use fee::types::UnsignedFixedPoint; use frame_support::dispatch::DispatchResult; pub fn distribute_all_vault_rewards(vault_id: &DefaultVaultId) -> DispatchResult { >::distribute_all_vault_rewards(vault_id) } + + pub fn premium_redeem_reward_rate() -> UnsignedFixedPoint { + >::premium_redeem_reward_rate() + } } diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index e04e53f91c..98a6f2a7f7 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -774,6 +774,52 @@ impl Pallet { ext::staking::total_current_stake::(vault_id) } + /// Calculate the maximum premium that can be given by a vault. + /// + /// # Arguments + /// * `vault_id` - The identifier of the vault for which the maximum premium is being calculated. + /// + /// # Returns + /// Returns a `Result` containing the calculated maximum premium as an `Amount`. + pub fn get_vault_max_premium_redeem(vault_id: &DefaultVaultId) -> Result, DispatchError> { + // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, + // we only award a premium for the amount of tokens required to get the vault back to secure threshold. + + // The CollateralizationRate is defined as `totalCollateral / convertToCollateral(totalTokens)` + // When paying a premium, the collateralization rate gets updated according to the following formula: + // `NewCollateralization = (oldCol - awardedPremium) / ( oldTokens*EXCH - awardedPremium/FEE)` + + // To calculate the maximum premium we are willing to pay, we set the newCollateralization to + // the global secure threshold, which gives: + // `SECURE = (oldCol - awardedPremium) / (oldTokens*EXCH - awardedPremium/FEE)`` + // We can rewrite this formula to calculate the `premium` amount that would get us to the secure + // threshold: `maxPremium = (oldTokens * EXCH * SECURE - oldCol) * (FEE / (SECURE - + // FEE))` Which can be interpreted as: + // `maxPremium = missingCollateral * (FEE / (SECURE - FEE)) + + // Note that to prevent repeated premium redeems while waiting for execution, we use to_be_backed_tokens + // for `oldCol`, which takes into account pending issues and redeems + let to_be_backed_tokens = Self::vault_to_be_backed_tokens(&vault_id)?; + let global_secure_threshold = Self::get_global_secure_threshold(&vault_id.currencies)?; + let premium_redeem_rate = ext::fee::premium_redeem_reward_rate::(); + + let required_collateral = Self::required_collateral(&vault_id, &to_be_backed_tokens, global_secure_threshold)?; + + let current_collateral = Self::get_backing_collateral(&vault_id)?; + let missing_collateral = required_collateral.checked_sub(¤t_collateral)?; + + let factor = premium_redeem_rate + .checked_div( + &global_secure_threshold + .checked_sub(&premium_redeem_rate) + .ok_or(ArithmeticError::Underflow)?, + ) + .ok_or(ArithmeticError::DivisionByZero)?; + + let max_premium = missing_collateral.checked_mul(&factor)?; + Ok(max_premium) + } + pub fn get_liquidated_collateral(vault_id: &DefaultVaultId) -> Result, DispatchError> { let vault = Self::get_vault_from_id(vault_id)?; Ok(Amount::new(vault.liquidated_collateral, vault_id.currencies.collateral)) @@ -1089,18 +1135,40 @@ impl Pallet { Ok(()) } - /// Get the secure threshold for a specified vault. + /// Get the global secure threshold for a specified currency pair. + /// /// # Arguments - /// * `vault_id` - the id of the vault from which to issue tokens + /// * `currency_pair` - The currency pair for which to retrieve the global secure threshold. /// /// # Returns - /// Returns the secure threshold of the specified vault or an error if the vault retrieval fails. + /// Returns the global secure threshold for the specified currency pair or an error if the threshold is not set. /// /// # Errors - /// * `VaultNotFound` - if no vault exists for the given `vault_id` - pub fn get_secure_threshold(vault_id: &DefaultVaultId) -> Result, DispatchError> { - let vault = Self::get_rich_vault_from_id(&vault_id)?; - vault.get_secure_threshold() + /// * `ThresholdNotSet` - If the secure collateral threshold for the given `currency_pair` is not set. + pub fn get_global_secure_threshold( + currency_pair: &VaultCurrencyPair>, + ) -> Result, DispatchError> { + let global_secure_threshold = + Self::secure_collateral_threshold(¤cy_pair).ok_or(Error::::ThresholdNotSet)?; + Ok(global_secure_threshold) + } + + /// Calculate the required collateral for a vault given the specified parameters. + /// + /// # Arguments + /// * `vault_id` - The identifier of the vault for which to calculate the required collateral. + /// * `to_be_backed_tokens` - The amount of tokens to be backed by collateral. + /// * `secure_threshold` - The secure collateral threshold to be applied in the calculation. + /// + /// # Returns + /// Returns the required collateral amount or an error if the calculation fails. + pub fn required_collateral( + vault_id: &DefaultVaultId, + to_be_backed_tokens: &Amount, + secure_threshold: UnsignedFixedPoint, + ) -> Result, DispatchError> { + let issued_tokens_in_collateral = to_be_backed_tokens.convert_to(vault_id.collateral_currency())?; // oldTokens * EXCH + issued_tokens_in_collateral.checked_rounded_mul(&secure_threshold, Rounding::NearestPrefUp) } /// Adds an amount tokens to the to-be-redeemed tokens balance of a vault. @@ -1496,7 +1564,7 @@ impl Pallet { Ok(()) } - pub fn _ensure_not_banned(vault_id: &DefaultVaultId) -> DispatchResult { + pub fn ensure_not_banned(vault_id: &DefaultVaultId) -> DispatchResult { let vault = Self::get_active_rich_vault_from_id(&vault_id)?; vault.ensure_not_banned() } @@ -1614,13 +1682,16 @@ impl Pallet { /// The redeemable tokens are the currently vault.issued_tokens - the vault.to_be_redeemed_tokens pub fn get_premium_redeem_vaults() -> Result, Amount)>, DispatchError> { let mut suitable_vaults = Vaults::::iter() - .filter_map(|(vault_id, vault)| { - let rich_vault: RichVault = vault.into(); - - let redeemable_tokens = rich_vault.redeemable_tokens().ok()?; - - if !redeemable_tokens.is_zero() && Self::is_vault_below_premium_threshold(&vault_id).unwrap_or(false) { - Some((vault_id, redeemable_tokens)) + .filter_map(|(vault_id, _vault)| { + let max_premium_in_collateral = Self::get_vault_max_premium_redeem(&vault_id).ok()?; + let premium_redeemable_tokens = + max_premium_in_collateral.convert_to(vault_id.wrapped_currency()).ok()?; + + if Self::ensure_not_banned(&vault_id).is_ok() + && !premium_redeemable_tokens.is_zero() + && Self::is_vault_below_premium_threshold(&vault_id).unwrap_or(false) + { + Some((vault_id, premium_redeemable_tokens)) } else { None } diff --git a/crates/vault-registry/src/tests.rs b/crates/vault-registry/src/tests.rs index cd1dd05cc2..bb1defa353 100644 --- a/crates/vault-registry/src/tests.rs +++ b/crates/vault-registry/src/tests.rs @@ -987,12 +987,14 @@ fn get_settled_collateralization_from_vault_succeeds() { mod get_vaults_below_premium_collaterlization_tests { use super::{assert_eq, *}; + use crate::ext; /// sets premium_redeem threshold to 1 pub fn run_test(test: impl FnOnce()) { super::run_test(|| { VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, FixedU128::from_float(0.001)); VaultRegistry::_set_premium_redeem_threshold(DEFAULT_CURRENCY_PAIR, FixedU128::one()); + ext::fee::premium_redeem_reward_rate::.mock_safe(move || MockResult::Return(1.into())); test() }) @@ -1013,6 +1015,9 @@ mod get_vaults_below_premium_collaterlization_tests { #[test] fn get_vaults_below_premium_collateralization_fails() { run_test(|| { + // set back to default threshold + set_default_thresholds(); + add_vault(vault_id(4), 50, 100); assert_err!( @@ -1036,9 +1041,12 @@ mod get_vaults_below_premium_collaterlization_tests { add_vault(id1.clone(), issue_tokens1, collateral1); add_vault(id2.clone(), issue_tokens2, collateral2); + // set back to default threshold so that vaults fall under premium redeem + set_default_thresholds(); + assert_eq!( VaultRegistry::get_premium_redeem_vaults(), - Ok(vec![(id1, wrapped(issue_tokens1)), (id2, wrapped(issue_tokens2))]) + Ok(vec![(id2, wrapped(52)), (id1, wrapped(51))]) ); }) } @@ -1046,30 +1054,30 @@ mod get_vaults_below_premium_collaterlization_tests { #[test] fn get_vaults_below_premium_collateralization_filters_banned_and_sufficiently_collateralized_vaults() { run_test(|| { - // not returned, because is is not under premium threshold (which is set to 100% for this test) + // returned let id1 = vault_id(3); let issue_tokens1: u128 = 50; let collateral1 = 50; add_vault(id1.clone(), issue_tokens1, collateral1); - // returned - let id2 = vault_id(4); - let issue_tokens2: u128 = 50; - let collateral2 = 49; - add_vault(id2.clone(), issue_tokens2, collateral2); - // not returned because it's banned - let id3 = vault_id(5); + let id2 = vault_id(5); let issue_tokens3: u128 = 50; let collateral3 = 49; - add_vault(id3.clone(), issue_tokens3, collateral3); - let mut vault3 = VaultRegistry::get_active_rich_vault_from_id(&id3).unwrap(); + add_vault(id2.clone(), issue_tokens3, collateral3); + let mut vault3 = VaultRegistry::get_active_rich_vault_from_id(&id2).unwrap(); vault3.ban_until(1000); - assert_eq!( - VaultRegistry::get_premium_redeem_vaults(), - Ok(vec!((id2, wrapped(issue_tokens2)))) - ); + // set back to default threshold so that vaults fall under premium redeem + set_default_thresholds(); + + // not returned + let id3 = vault_id(4); + let issue_tokens2: u128 = 50; + let collateral2 = 150; + add_vault(id3.clone(), issue_tokens2, collateral2); + + assert_eq!(VaultRegistry::get_premium_redeem_vaults(), Ok(vec!((id1, wrapped(50))))); }) } } diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index 8ac17cc4bc..533746af51 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -872,7 +872,7 @@ mod spec_based_tests { ); check_redeem_status(USER, RedeemRequestStatus::Reimbursed(true)); assert_noop!( - VaultRegistryPallet::_ensure_not_banned(&vault_id), + VaultRegistryPallet::ensure_not_banned(&vault_id), VaultRegistryError::VaultBanned ); }); @@ -1005,7 +1005,7 @@ mod spec_based_tests { }) ); assert_noop!( - VaultRegistryPallet::_ensure_not_banned(&vault_id), + VaultRegistryPallet::ensure_not_banned(&vault_id), VaultRegistryError::VaultBanned ); }); @@ -1347,7 +1347,7 @@ fn integration_test_execute_redeem_on_banned_vault_succeeds() { // should now be banned assert_noop!( - VaultRegistryPallet::_ensure_not_banned(&vault_id), + VaultRegistryPallet::ensure_not_banned(&vault_id), VaultRegistryError::VaultBanned ); From a81259a02582e610822a5ba8896e7ca915f11769 Mon Sep 17 00:00:00 2001 From: Nakul Date: Thu, 7 Dec 2023 01:20:23 +0530 Subject: [PATCH 07/19] fix: comments Co-authored-by: sander2 --- crates/vault-registry/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 98a6f2a7f7..467c82cbd2 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -785,16 +785,17 @@ impl Pallet { // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, // we only award a premium for the amount of tokens required to get the vault back to secure threshold. + // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, + // we only award a premium for the amount of tokens required to get the vault back to secure threshold. // The CollateralizationRate is defined as `totalCollateral / convertToCollateral(totalTokens)` // When paying a premium, the collateralization rate gets updated according to the following formula: // `NewCollateralization = (oldCol - awardedPremium) / ( oldTokens*EXCH - awardedPremium/FEE)` - // To calculate the maximum premium we are willing to pay, we set the newCollateralization to - // the global secure threshold, which gives: + // the secure threshold, which gives: // `SECURE = (oldCol - awardedPremium) / (oldTokens*EXCH - awardedPremium/FEE)`` - // We can rewrite this formula to calculate the `premium` amount that would get us to the secure - // threshold: `maxPremium = (oldTokens * EXCH * SECURE - oldCol) * (FEE / (SECURE - - // FEE))` Which can be interpreted as: + // We can rewrite this formula to calculate the `premium` amount that would get us to the secure threshold: + // `maxPremium = (oldTokens * EXCH * SECURE - oldCol) * (FEE / (SECURE - FEE))` + // Which can be interpreted as: // `maxPremium = missingCollateral * (FEE / (SECURE - FEE)) // Note that to prevent repeated premium redeems while waiting for execution, we use to_be_backed_tokens From 8e2a28e5c6d55159ed31aeee26da7001f737e77f Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Thu, 7 Dec 2023 01:41:24 +0530 Subject: [PATCH 08/19] fix: fmt and subtraction bug. --- crates/vault-registry/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 467c82cbd2..7420225524 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -785,7 +785,7 @@ impl Pallet { // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, // we only award a premium for the amount of tokens required to get the vault back to secure threshold. - // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, + // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, // we only award a premium for the amount of tokens required to get the vault back to secure threshold. // The CollateralizationRate is defined as `totalCollateral / convertToCollateral(totalTokens)` // When paying a premium, the collateralization rate gets updated according to the following formula: @@ -807,7 +807,7 @@ impl Pallet { let required_collateral = Self::required_collateral(&vault_id, &to_be_backed_tokens, global_secure_threshold)?; let current_collateral = Self::get_backing_collateral(&vault_id)?; - let missing_collateral = required_collateral.checked_sub(¤t_collateral)?; + let missing_collateral = required_collateral.saturating_sub(¤t_collateral)?; let factor = premium_redeem_rate .checked_div( From 6e65b86955747194a779413e1b14863840fccbb8 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Thu, 7 Dec 2023 01:43:32 +0530 Subject: [PATCH 09/19] fix: remove unused helper fn. --- crates/vault-registry/src/lib.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 7420225524..8e22089fd1 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -1975,14 +1975,6 @@ impl Pallet { collateral.convert_to(wrapped_currency)?.checked_div(&threshold) } - pub fn vault_capacity_at_secure_threshold(vault_id: &DefaultVaultId) -> Result, DispatchError> { - let threshold = Self::secure_collateral_threshold(&vault_id.currencies).ok_or(Error::::ThresholdNotSet)?; - let collateral = Self::get_backing_collateral(vault_id)?; - let wrapped_currency = vault_id.wrapped_currency(); - - Self::calculate_max_wrapped_from_collateral_for_threshold(&collateral, wrapped_currency, threshold) - } - pub fn vault_to_be_backed_tokens(vault_id: &DefaultVaultId) -> Result, DispatchError> { let vault = Self::get_active_rich_vault_from_id(vault_id)?; vault.to_be_backed_tokens() From 4c1eb93d03856aaf6496cad6559e0070d6150b95 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Mon, 11 Dec 2023 13:31:25 +0530 Subject: [PATCH 10/19] fix: change premium redeem calculation flow --- Cargo.lock | 2 + crates/fee/src/lib.rs | 7 ++ crates/redeem/rpc/Cargo.toml | 3 + crates/redeem/rpc/runtime-api/Cargo.toml | 4 + crates/redeem/rpc/runtime-api/src/lib.rs | 9 +- crates/redeem/rpc/src/lib.rs | 41 +++++++-- crates/redeem/src/benchmarking.rs | 4 +- crates/redeem/src/ext.rs | 25 +++--- crates/redeem/src/lib.rs | 19 ++--- .../vault-registry/rpc/runtime-api/src/lib.rs | 3 - crates/vault-registry/rpc/src/lib.rs | 16 ---- crates/vault-registry/src/ext.rs | 14 +++ crates/vault-registry/src/lib.rs | 85 +++++++++++-------- crates/vault-registry/src/tests.rs | 19 +++-- parachain/runtime/interlay/src/lib.rs | 12 +-- parachain/runtime/kintsugi/src/lib.rs | 13 +-- .../runtime-tests/src/parachain/redeem.rs | 67 ++++++++++++++- parachain/src/service.rs | 4 + rpc/src/lib.rs | 2 + 19 files changed, 249 insertions(+), 100 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index face9e081b..01ca6a2a91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11607,6 +11607,7 @@ name = "redeem-rpc" version = "1.2.0" dependencies = [ "jsonrpsee", + "oracle-rpc-runtime-api", "parity-scale-codec", "redeem-rpc-runtime-api", "sp-api", @@ -11619,6 +11620,7 @@ name = "redeem-rpc-runtime-api" version = "1.2.0" dependencies = [ "frame-support", + "oracle-rpc-runtime-api", "parity-scale-codec", "sp-api", "sp-std", diff --git a/crates/fee/src/lib.rs b/crates/fee/src/lib.rs index c172324475..d98f8dfa4e 100644 --- a/crates/fee/src/lib.rs +++ b/crates/fee/src/lib.rs @@ -435,6 +435,13 @@ impl Pallet { >::get() } + /// Get the fee share that users need to pay to redeem tokens. + /// + /// # Returns + /// Returns the redeem fee. + pub fn get_redeem_fee_value() -> UnsignedFixedPoint { + >::get() + } /// Calculate punishment fee for a Vault that fails to execute a redeem /// request before the expiry. /// diff --git a/crates/redeem/rpc/Cargo.toml b/crates/redeem/rpc/Cargo.toml index fa03559d88..523683e9ea 100644 --- a/crates/redeem/rpc/Cargo.toml +++ b/crates/redeem/rpc/Cargo.toml @@ -11,3 +11,6 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkad sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } redeem-rpc-runtime-api = { path = "runtime-api" } + +[dependencies.oracle-rpc-runtime-api] +path = '../../oracle/rpc/runtime-api' diff --git a/crates/redeem/rpc/runtime-api/Cargo.toml b/crates/redeem/rpc/runtime-api/Cargo.toml index be10d50822..a3ba7f6253 100644 --- a/crates/redeem/rpc/runtime-api/Cargo.toml +++ b/crates/redeem/rpc/runtime-api/Cargo.toml @@ -10,6 +10,10 @@ frame-support = { git = "https://github.com/paritytech/substrate", branch = "pol sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +[dependencies.oracle-rpc-runtime-api] +default-features = false +path = '../../../oracle/rpc/runtime-api' + [features] default = ["std"] std = [ diff --git a/crates/redeem/rpc/runtime-api/src/lib.rs b/crates/redeem/rpc/runtime-api/src/lib.rs index cdcc70a605..0b3dd1c080 100644 --- a/crates/redeem/rpc/runtime-api/src/lib.rs +++ b/crates/redeem/rpc/runtime-api/src/lib.rs @@ -3,10 +3,14 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::Codec; +use frame_support::dispatch::DispatchError; +use oracle_rpc_runtime_api::BalanceWrapper; use sp_std::vec::Vec; sp_api::decl_runtime_apis! { - pub trait RedeemApi where + pub trait RedeemApi where + VaultId: Codec, + Balance: Codec, AccountId: Codec, H256: Codec, RedeemRequest: Codec, @@ -16,5 +20,8 @@ sp_api::decl_runtime_apis! { /// Get all redeem requests for a particular vault fn get_vault_redeem_requests(vault_id: AccountId) -> Vec; + + /// Get all vaults below the premium redeem threshold, ordered in descending order of this amount + fn get_premium_redeem_vaults() -> Result)>, DispatchError>; } } diff --git a/crates/redeem/rpc/src/lib.rs b/crates/redeem/rpc/src/lib.rs index 6e0e2c1146..0003008009 100644 --- a/crates/redeem/rpc/src/lib.rs +++ b/crates/redeem/rpc/src/lib.rs @@ -6,20 +6,36 @@ use jsonrpsee::{ proc_macros::rpc, types::error::{CallError, ErrorCode, ErrorObject}, }; +use oracle_rpc_runtime_api::BalanceWrapper; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; -use sp_runtime::traits::Block as BlockT; +use sp_runtime::{ + traits::{Block as BlockT, MaybeDisplay, MaybeFromStr}, + DispatchError, +}; use std::sync::Arc; pub use redeem_rpc_runtime_api::RedeemApi as RedeemRuntimeApi; +fn handle_response(result: Result, E>, msg: String) -> RpcResult { + result + .map_err(|err| internal_err(format!("Runtime error: {:?}: {:?}", msg, err)))? + .map_err(|err| internal_err(format!("Execution error: {:?}: {:?}", msg, err))) +} + #[rpc(client, server)] -pub trait RedeemApi { +pub trait RedeemApi +where + Balance: Codec + MaybeDisplay + MaybeFromStr, +{ #[method(name = "redeem_getRedeemRequests")] fn get_redeem_requests(&self, account_id: AccountId, at: Option) -> RpcResult>; #[method(name = "redeem_getVaultRedeemRequests")] fn get_vault_redeem_requests(&self, vault_id: AccountId, at: Option) -> RpcResult>; + + #[method(name = "redeem_getPremiumRedeemVaults")] + fn get_premium_redeem_vaults(&self, at: Option) -> RpcResult)>>; } fn internal_err(message: T) -> JsonRpseeError { @@ -47,12 +63,14 @@ impl Redeem { } #[async_trait] -impl RedeemApiServer<::Hash, AccountId, H256, RedeemRequest> - for Redeem +impl + RedeemApiServer<::Hash, VaultId, Balance, AccountId, H256, RedeemRequest> for Redeem where Block: BlockT, C: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, - C::Api: RedeemRuntimeApi, + C::Api: RedeemRuntimeApi, + VaultId: Codec, + Balance: Codec + MaybeDisplay + MaybeFromStr, AccountId: Codec, H256: Codec, RedeemRequest: Codec, @@ -76,4 +94,17 @@ where api.get_vault_redeem_requests(at, vault_id) .map_err(|e| internal_err(format!("Unable to fetch redeem requests: {:?}", e))) } + + fn get_premium_redeem_vaults( + &self, + at: Option<::Hash>, + ) -> RpcResult)>> { + let api = self.client.runtime_api(); + let at = at.unwrap_or_else(|| self.client.info().best_hash); + + handle_response( + api.get_premium_redeem_vaults(at), + "Unable to find a vault below the premium redeem threshold".into(), + ) + } } diff --git a/crates/redeem/src/benchmarking.rs b/crates/redeem/src/benchmarking.rs index fd46579e84..c6a58c2453 100644 --- a/crates/redeem/src/benchmarking.rs +++ b/crates/redeem/src/benchmarking.rs @@ -18,10 +18,10 @@ use vault_registry::{ // Pallets use crate::Pallet as Redeem; use btc_relay::Pallet as BtcRelay; -use oracle::Pallet as Oracle; +use oracle::{OracleKey, Pallet as Oracle}; use security::Pallet as Security; +use sp_runtime::FixedPointNumber; use vault_registry::Pallet as VaultRegistry; - type UnsignedFixedPoint = ::UnsignedFixedPoint; fn collateral(amount: u32) -> Amount { diff --git a/crates/redeem/src/ext.rs b/crates/redeem/src/ext.rs index 32a0f25ff7..ecc3eaf666 100644 --- a/crates/redeem/src/ext.rs +++ b/crates/redeem/src/ext.rs @@ -42,8 +42,22 @@ pub(crate) mod vault_registry { use crate::DefaultVaultId; use currency::Amount; use frame_support::dispatch::{DispatchError, DispatchResult}; + use sp_std::vec::Vec; use vault_registry::types::{CurrencyId, CurrencySource, DefaultVault}; + pub fn calculate_inclusion_fee( + wrapped_currency: CurrencyId, + redeem_transaction_size: u32, + ) -> Result, DispatchError> { + >::calculate_inclusion_fee(wrapped_currency, redeem_transaction_size) + } + + pub fn get_premium_redeem_vaults( + redeem_transaction_size: u32, + ) -> Result, Amount)>, DispatchError> { + >::get_premium_redeem_vaults(redeem_transaction_size) + } + pub fn get_vault_max_premium_redeem( vault_id: &DefaultVaultId, ) -> Result, DispatchError> { @@ -199,17 +213,6 @@ pub(crate) mod security { } } -#[cfg_attr(test, mockable)] -pub(crate) mod oracle { - use crate::OracleKey; - use frame_support::dispatch::DispatchError; - use oracle::types::UnsignedFixedPoint; - - pub fn get_price(key: OracleKey) -> Result, DispatchError> { - >::get_price(key) - } -} - #[cfg_attr(test, mockable)] pub(crate) mod fee { use currency::Amount; diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index 34f4568d84..d93c05ccea 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -40,9 +40,7 @@ use frame_support::{ transactional, }; use frame_system::{ensure_root, ensure_signed}; -use oracle::OracleKey; use sp_core::H256; -use sp_runtime::{ArithmeticError, FixedPointNumber}; use sp_std::{convert::TryInto, vec::Vec}; use types::DefaultVaultId; use vault_registry::{ @@ -456,7 +454,6 @@ mod self_redeem { Ok(()) } } - // "Internal" functions, callable by code. #[cfg_attr(test, mockable)] impl Pallet { @@ -505,6 +502,9 @@ impl Pallet { let below_premium_redeem = ext::vault_registry::is_vault_below_premium_threshold::(&vault_id)?; let currency_id = vault_id.collateral_currency(); + // Calculate the premium collateral amount based on whether the redemption is below the premium redeem + // threshold. This should come before increasing the `to_be_redeemed` tokens and locking the amount to + // ensure accurate premium redeem calculations. let premium_collateral = if below_premium_redeem { let redeem_amount_wrapped_in_collateral = user_to_be_received_btc.convert_to(currency_id)?; let premium_redeem_rate = ext::fee::premium_redeem_reward_rate::(); @@ -797,13 +797,7 @@ impl Pallet { /// the inclusion fee rate reported by the oracle pub fn get_current_inclusion_fee(wrapped_currency: CurrencyId) -> Result, DispatchError> { let size: u32 = Self::redeem_transaction_size(); - let satoshi_per_bytes = ext::oracle::get_price::(OracleKey::FeeEstimation)?; - - let fee = satoshi_per_bytes - .checked_mul_int(size) - .ok_or(ArithmeticError::Overflow)?; - let amount = fee.try_into().map_err(|_| Error::::TryIntoIntError)?; - Ok(Amount::new(amount, wrapped_currency)) + ext::vault_registry::calculate_inclusion_fee::(wrapped_currency, size) } pub fn get_dust_value(currency_id: CurrencyId) -> Amount { @@ -821,6 +815,11 @@ impl Pallet { .collect::>() } + pub fn get_premium_redeem_vaults() -> Result, Amount)>, DispatchError> { + let size: u32 = Self::redeem_transaction_size(); + ext::vault_registry::get_premium_redeem_vaults::(size) + } + /// Fetch all redeem requests for the specified vault. /// /// # Arguments diff --git a/crates/vault-registry/rpc/runtime-api/src/lib.rs b/crates/vault-registry/rpc/runtime-api/src/lib.rs index 838142f72d..b752770357 100644 --- a/crates/vault-registry/rpc/runtime-api/src/lib.rs +++ b/crates/vault-registry/rpc/runtime-api/src/lib.rs @@ -24,9 +24,6 @@ sp_api::decl_runtime_apis! { /// Get the vault's collateral (including nomination) fn get_vault_total_collateral(vault_id: VaultId) -> Result, DispatchError>; - /// Get all vaults below the premium redeem threshold, ordered in descending order of this amount - fn get_premium_redeem_vaults() -> Result)>, DispatchError>; - /// Get all vaults with non-zero issuable tokens, ordered in descending order of this amount fn get_vaults_with_issuable_tokens() -> Result)>, DispatchError>; diff --git a/crates/vault-registry/rpc/src/lib.rs b/crates/vault-registry/rpc/src/lib.rs index c538d9284c..b3e479c5ac 100644 --- a/crates/vault-registry/rpc/src/lib.rs +++ b/crates/vault-registry/rpc/src/lib.rs @@ -38,9 +38,6 @@ where at: Option, ) -> RpcResult>; - #[method(name = "vaultRegistry_getPremiumRedeemVaults")] - fn get_premium_redeem_vaults(&self, at: Option) -> RpcResult)>>; - #[method(name = "vaultRegistry_getVaultsWithIssuableTokens")] fn get_vaults_with_issuable_tokens( &self, @@ -179,19 +176,6 @@ where ) } - fn get_premium_redeem_vaults( - &self, - at: Option<::Hash>, - ) -> RpcResult)>> { - let api = self.client.runtime_api(); - let at = at.unwrap_or_else(|| self.client.info().best_hash); - - handle_response( - api.get_premium_redeem_vaults(at), - "Unable to find a vault below the premium redeem threshold".into(), - ) - } - fn get_vaults_with_issuable_tokens( &self, at: Option<::Hash>, diff --git a/crates/vault-registry/src/ext.rs b/crates/vault-registry/src/ext.rs index 83494f4675..0bf4f5de5b 100644 --- a/crates/vault-registry/src/ext.rs +++ b/crates/vault-registry/src/ext.rs @@ -110,6 +110,16 @@ pub(crate) mod capacity { } } +#[cfg_attr(test, mockable)] +pub(crate) mod oracle { + use frame_support::dispatch::DispatchError; + use oracle::{types::UnsignedFixedPoint, OracleKey}; + + pub fn get_price(key: OracleKey) -> Result, DispatchError> { + >::get_price(key) + } +} + #[cfg_attr(test, mockable)] pub(crate) mod fee { use crate::DefaultVaultId; @@ -123,4 +133,8 @@ pub(crate) mod fee { pub fn premium_redeem_reward_rate() -> UnsignedFixedPoint { >::premium_redeem_reward_rate() } + + pub fn get_redeem_fee_value() -> UnsignedFixedPoint { + >::get_redeem_fee_value() + } } diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 8e22089fd1..14fe02bd7f 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -52,11 +52,12 @@ use frame_system::{ ensure_signed, offchain::{SendTransactionTypes, SubmitTransaction}, }; +use oracle::OracleKey; use sp_core::{H256, U256}; use sp_runtime::{ traits::*, transaction_validity::{InvalidTransaction, TransactionSource, TransactionValidity, ValidTransaction}, - ArithmeticError, + ArithmeticError, FixedPointNumber, }; use sp_std::{convert::TryInto, vec::Vec}; use traits::NominationApi; @@ -782,9 +783,6 @@ impl Pallet { /// # Returns /// Returns a `Result` containing the calculated maximum premium as an `Amount`. pub fn get_vault_max_premium_redeem(vault_id: &DefaultVaultId) -> Result, DispatchError> { - // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, - // we only award a premium for the amount of tokens required to get the vault back to secure threshold. - // The goal of premium redeems is to get the vault back the a healthy collateralization ratio. As such, // we only award a premium for the amount of tokens required to get the vault back to secure threshold. // The CollateralizationRate is defined as `totalCollateral / convertToCollateral(totalTokens)` @@ -804,7 +802,8 @@ impl Pallet { let global_secure_threshold = Self::get_global_secure_threshold(&vault_id.currencies)?; let premium_redeem_rate = ext::fee::premium_redeem_reward_rate::(); - let required_collateral = Self::required_collateral(&vault_id, &to_be_backed_tokens, global_secure_threshold)?; + let required_collateral = + Self::get_required_collateral_for_wrapped(&to_be_backed_tokens, vault_id.collateral_currency())?; let current_collateral = Self::get_backing_collateral(&vault_id)?; let missing_collateral = required_collateral.saturating_sub(¤t_collateral)?; @@ -1146,7 +1145,8 @@ impl Pallet { /// /// # Errors /// * `ThresholdNotSet` - If the secure collateral threshold for the given `currency_pair` is not set. - pub fn get_global_secure_threshold( + #[cfg_attr(feature = "integration-tests", visibility::make(pub))] + fn get_global_secure_threshold( currency_pair: &VaultCurrencyPair>, ) -> Result, DispatchError> { let global_secure_threshold = @@ -1154,24 +1154,6 @@ impl Pallet { Ok(global_secure_threshold) } - /// Calculate the required collateral for a vault given the specified parameters. - /// - /// # Arguments - /// * `vault_id` - The identifier of the vault for which to calculate the required collateral. - /// * `to_be_backed_tokens` - The amount of tokens to be backed by collateral. - /// * `secure_threshold` - The secure collateral threshold to be applied in the calculation. - /// - /// # Returns - /// Returns the required collateral amount or an error if the calculation fails. - pub fn required_collateral( - vault_id: &DefaultVaultId, - to_be_backed_tokens: &Amount, - secure_threshold: UnsignedFixedPoint, - ) -> Result, DispatchError> { - let issued_tokens_in_collateral = to_be_backed_tokens.convert_to(vault_id.collateral_currency())?; // oldTokens * EXCH - issued_tokens_in_collateral.checked_rounded_mul(&secure_threshold, Rounding::NearestPrefUp) - } - /// Adds an amount tokens to the to-be-redeemed tokens balance of a vault. /// This function serves as a prevention against race conditions in the /// redeem and replace procedures. If, for example, a vault would receive @@ -1574,7 +1556,7 @@ impl Pallet { pub fn is_vault_below_secure_threshold(vault_id: &DefaultVaultId) -> Result { let vault = Self::get_rich_vault_from_id(&vault_id)?; let threshold = vault.get_secure_threshold()?; - Self::is_vault_below_threshold(vault_id, threshold) + Self::is_vault_below_certain_threshold(vault_id, threshold) } pub fn is_vault_liquidated(vault_id: &DefaultVaultId) -> Result { @@ -1674,25 +1656,59 @@ impl Pallet { .collect(); Ok(vaults) } + + /// Calculates the inclusion fee for a redeem transaction based on the provided parameters. + pub fn calculate_inclusion_fee( + wrapped_currency: CurrencyId, + redeem_tx_size: u32, + ) -> Result, DispatchError> { + let satoshi_per_bytes = ext::oracle::get_price::(OracleKey::FeeEstimation)?; + + let fee = satoshi_per_bytes + .checked_mul_int(redeem_tx_size) + .ok_or(ArithmeticError::Overflow)?; + let amount = fee.try_into().map_err(|_| Error::::TryIntoIntError)?; + Ok(Amount::new(amount, wrapped_currency)) + } + /// Get all vaults that: /// - are below the premium redeem threshold, and /// - have a non-zero amount of redeemable tokens, and thus /// - are not banned /// - /// Maybe returns a tuple of (VaultId, RedeemableTokens) - /// The redeemable tokens are the currently vault.issued_tokens - the vault.to_be_redeemed_tokens - pub fn get_premium_redeem_vaults() -> Result, Amount)>, DispatchError> { + /// Return a tuple of (VaultId, RedeemTokens to get `max_premium` from vault) + pub fn get_premium_redeem_vaults( + redeem_transaction_size: u32, + ) -> Result, Amount)>, DispatchError> { + let premium_reward_rate = ext::fee::premium_redeem_reward_rate::(); + let mut suitable_vaults = Vaults::::iter() .filter_map(|(vault_id, _vault)| { + // The calculation to calculate redeem tokens to get `max_premium` is referenced from + // redeem pallet `request_redeem` method. + // BurnTokensForReachingPremiumThreshold = BurnWrap + InclusionFee + // RedeemTokens = BurnTokensForReachingPremiumThreshold / (1 - RedeemFee) let max_premium_in_collateral = Self::get_vault_max_premium_redeem(&vault_id).ok()?; - let premium_redeemable_tokens = - max_premium_in_collateral.convert_to(vault_id.wrapped_currency()).ok()?; + let redeem_amount_wrapped_in_collateral = + max_premium_in_collateral.checked_div(&premium_reward_rate).ok()?; + let burn_wrap = redeem_amount_wrapped_in_collateral + .convert_to(vault_id.wrapped_currency()) + .ok()?; + let inclusion_fee = + Self::calculate_inclusion_fee(vault_id.wrapped_currency(), redeem_transaction_size).ok()?; + + let vault_to_burn_tokens = burn_wrap.checked_add(&inclusion_fee).ok()?; + + let redeem_fee = ext::fee::get_redeem_fee_value::(); + let amount_wrapped = UnsignedFixedPoint::::one().saturating_sub(redeem_fee); + + let request_redeem_tokens_for_max_premium = vault_to_burn_tokens.checked_div(&amount_wrapped).ok()?; if Self::ensure_not_banned(&vault_id).is_ok() - && !premium_redeemable_tokens.is_zero() + && !request_redeem_tokens_for_max_premium.is_zero() && Self::is_vault_below_premium_threshold(&vault_id).unwrap_or(false) { - Some((vault_id, premium_redeemable_tokens)) + Some((vault_id, request_redeem_tokens_for_max_premium)) } else { None } @@ -1927,7 +1943,8 @@ impl Pallet { collateral_in_wrapped.ratio(&issued_tokens) } - fn is_vault_below_threshold( + #[cfg_attr(feature = "integration-tests", visibility::make(pub))] + fn is_vault_below_certain_threshold( vault_id: &DefaultVaultId, threshold: UnsignedFixedPoint, ) -> Result { @@ -1975,7 +1992,7 @@ impl Pallet { collateral.convert_to(wrapped_currency)?.checked_div(&threshold) } - pub fn vault_to_be_backed_tokens(vault_id: &DefaultVaultId) -> Result, DispatchError> { + fn vault_to_be_backed_tokens(vault_id: &DefaultVaultId) -> Result, DispatchError> { let vault = Self::get_active_rich_vault_from_id(vault_id)?; vault.to_be_backed_tokens() } diff --git a/crates/vault-registry/src/tests.rs b/crates/vault-registry/src/tests.rs index bb1defa353..fc53a25329 100644 --- a/crates/vault-registry/src/tests.rs +++ b/crates/vault-registry/src/tests.rs @@ -1015,13 +1015,15 @@ mod get_vaults_below_premium_collaterlization_tests { #[test] fn get_vaults_below_premium_collateralization_fails() { run_test(|| { + ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); + // set back to default threshold set_default_thresholds(); add_vault(vault_id(4), 50, 100); assert_err!( - VaultRegistry::get_premium_redeem_vaults(), + VaultRegistry::get_premium_redeem_vaults(400_u32), TestError::NoVaultUnderThePremiumRedeemThreshold ); }) @@ -1030,6 +1032,8 @@ mod get_vaults_below_premium_collaterlization_tests { #[test] fn get_vaults_below_premium_collateralization_succeeds() { run_test(|| { + ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); + let id1 = vault_id(3); let issue_tokens1: u128 = 50; let collateral1 = 49; @@ -1045,8 +1049,8 @@ mod get_vaults_below_premium_collaterlization_tests { set_default_thresholds(); assert_eq!( - VaultRegistry::get_premium_redeem_vaults(), - Ok(vec![(id2, wrapped(52)), (id1, wrapped(51))]) + VaultRegistry::get_premium_redeem_vaults(400_u32), + Ok(vec![(id2, wrapped(452)), (id1, wrapped(451))]) ); }) } @@ -1054,6 +1058,8 @@ mod get_vaults_below_premium_collaterlization_tests { #[test] fn get_vaults_below_premium_collateralization_filters_banned_and_sufficiently_collateralized_vaults() { run_test(|| { + ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); + // returned let id1 = vault_id(3); let issue_tokens1: u128 = 50; @@ -1071,13 +1077,16 @@ mod get_vaults_below_premium_collaterlization_tests { // set back to default threshold so that vaults fall under premium redeem set_default_thresholds(); - // not returned + // not returned, since default threshold applied so vault is now not under premium threshold let id3 = vault_id(4); let issue_tokens2: u128 = 50; let collateral2 = 150; add_vault(id3.clone(), issue_tokens2, collateral2); - assert_eq!(VaultRegistry::get_premium_redeem_vaults(), Ok(vec!((id1, wrapped(50))))); + assert_eq!( + VaultRegistry::get_premium_redeem_vaults(400_u32), + Ok(vec!((id1, wrapped(450)))) + ); }) } } diff --git a/parachain/runtime/interlay/src/lib.rs b/parachain/runtime/interlay/src/lib.rs index 04a38c600e..90daff86dd 100644 --- a/parachain/runtime/interlay/src/lib.rs +++ b/parachain/runtime/interlay/src/lib.rs @@ -1812,11 +1812,6 @@ impl_runtime_apis! { Ok(BalanceWrapper{amount:result.amount()}) } - fn get_premium_redeem_vaults() -> Result)>, DispatchError> { - let result = VaultRegistry::get_premium_redeem_vaults()?; - Ok(result.iter().map(|v| (v.0.clone(), BalanceWrapper{amount:v.1.amount()})).collect()) - } - fn get_vaults_with_issuable_tokens() -> Result)>, DispatchError> { let result = VaultRegistry::get_vaults_with_issuable_tokens()?; Ok(result.into_iter().map(|v| (v.0, BalanceWrapper{amount:v.1.amount()})).collect()) @@ -1943,6 +1938,8 @@ impl_runtime_apis! { impl redeem_rpc_runtime_api::RedeemApi< Block, + VaultId, + Balance, AccountId, H256, RedeemRequest @@ -1954,6 +1951,11 @@ impl_runtime_apis! { fn get_vault_redeem_requests(account_id: AccountId) -> Vec { Redeem::get_redeem_requests_for_vault(account_id) } + + fn get_premium_redeem_vaults() -> Result)>, DispatchError> { + let result = Redeem::get_premium_redeem_vaults()?; + Ok(result.iter().map(|v| (v.0.clone(), BalanceWrapper{amount:v.1.amount()})).collect()) + } } impl replace_rpc_runtime_api::ReplaceApi< diff --git a/parachain/runtime/kintsugi/src/lib.rs b/parachain/runtime/kintsugi/src/lib.rs index 5c92592bbe..e689706719 100644 --- a/parachain/runtime/kintsugi/src/lib.rs +++ b/parachain/runtime/kintsugi/src/lib.rs @@ -1683,11 +1683,6 @@ impl_runtime_apis! { Ok(BalanceWrapper{amount:result.amount()}) } - fn get_premium_redeem_vaults() -> Result)>, DispatchError> { - let result = VaultRegistry::get_premium_redeem_vaults()?; - Ok(result.iter().map(|v| (v.0.clone(), BalanceWrapper{amount:v.1.amount()})).collect()) - } - fn get_vaults_with_issuable_tokens() -> Result)>, DispatchError> { let result = VaultRegistry::get_vaults_with_issuable_tokens()?; Ok(result.into_iter().map(|v| (v.0, BalanceWrapper{amount:v.1.amount()})).collect()) @@ -1814,6 +1809,8 @@ impl_runtime_apis! { impl redeem_rpc_runtime_api::RedeemApi< Block, + VaultId, + Balance, AccountId, H256, RedeemRequest @@ -1825,6 +1822,12 @@ impl_runtime_apis! { fn get_vault_redeem_requests(account_id: AccountId) -> Vec { Redeem::get_redeem_requests_for_vault(account_id) } + + + fn get_premium_redeem_vaults() -> Result)>, DispatchError> { + let result = Redeem::get_premium_redeem_vaults()?; + Ok(result.iter().map(|v| (v.0.clone(), BalanceWrapper{amount:v.1.amount()})).collect()) + } } impl replace_rpc_runtime_api::ReplaceApi< diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index 533746af51..4e9a361f19 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -114,7 +114,7 @@ fn consume_to_be_replaced(vault: &mut CoreVaultData, amount_btc: Amount mod premium_redeem_tests { use super::{assert_eq, *}; - fn setup_vault_below_secure_threshold(vault_id: VaultId) { + fn setup_vault_below_premium_threshold(vault_id: VaultId) { // with 2000 collateral and exchange rate at 2, the vault is at: // - secure threshold (200%) when it has 2000/2/2 = 500 tokens // - premium threshold (160%) when it has 2000/2/1.6 = 625 tokens @@ -141,7 +141,7 @@ mod premium_redeem_tests { #[test] fn integration_test_premium_redeem_with_reward_for_only_part_of_the_request() { test_setup_for_premium_redeem(|vault_id| { - setup_vault_below_secure_threshold(vault_id.clone()); + setup_vault_below_premium_threshold(vault_id.clone()); assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); @@ -187,10 +187,71 @@ mod premium_redeem_tests { }); } + #[test] + fn integration_test_redeem_max_premium_redeemable_token() { + test_setup_for_premium_redeem(|vault_id| { + setup_vault_below_premium_threshold(vault_id.clone()); + + let global_secure = VaultRegistryPallet::get_global_secure_threshold(&vault_id.currencies).unwrap(); // 200% + + // secure > premium > liquidation threshold + // at start vault should be below premium threshold, while above global secure & secure threshold + assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); + assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::is_vault_below_certain_threshold(&vault_id, global_secure).unwrap()); + + // Change vault secure threshold, + // now secure > global secure > premium > liquidation threshold + let vault_custom_secure_threshold = UnsignedFixedPoint::checked_from_rational(300, 100); + assert_ok!( + RuntimeCall::VaultRegistry(VaultRegistryCall::set_custom_secure_threshold { + currency_pair: vault_id.currencies.clone(), + custom_threshold: vault_custom_secure_threshold, + }) + .dispatch(origin_of(vault_id.account_id.clone())) + ); + + // vault should be below premium & secure threshold, while above global secure threshold + assert!(VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); + assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::is_vault_below_certain_threshold(&vault_id, global_secure).unwrap()); + + let max_premium_for_vault = VaultRegistryPallet::get_vault_max_premium_redeem(&vault_id).unwrap(); + // get premium redeem vaults + let premium_redeem_vaults = RedeemPallet::get_premium_redeem_vaults() + .unwrap() + .get(0) + .unwrap() + .clone(); + + // request redeem tokens given by RPC + let redeem_id_1 = setup_redeem(premium_redeem_vaults.1, USER, &vault_id); + + let redeem_1 = RedeemPallet::get_open_redeem_request_from_id(&redeem_id_1).unwrap(); + // recv premium should be equal to max premium + assert_eq!(redeem_1.premium, max_premium_for_vault.amount()); + assert!(!redeem_1.premium.is_zero()); + + // max premium for vault should be zero + let max_premium_for_vault = VaultRegistryPallet::get_vault_max_premium_redeem(&vault_id).unwrap(); + assert!(max_premium_for_vault.amount().is_zero()); + + // redeeming the max premium amount put backs vault above premium threshold + // vault should be below secure threshold, while above global secure & premium threshold + assert!(VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::is_vault_below_certain_threshold(&vault_id, global_secure).unwrap()); + + let redeem_id_2 = setup_redeem(vault_id.wrapped(800_00), USER, &vault_id); + let redeem_2 = RedeemPallet::get_open_redeem_request_from_id(&redeem_id_2).unwrap(); + // no premium is given out for new redeems + assert!(redeem_2.premium.is_zero()); + }); + } #[test] fn integration_test_premium_redeem_with_reward_for_full_request() { test_setup_for_premium_redeem(|vault_id| { - setup_vault_below_secure_threshold(vault_id.clone()); + setup_vault_below_premium_threshold(vault_id.clone()); assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); diff --git a/parachain/src/service.rs b/parachain/src/service.rs index 13eb51c1ca..03da257eec 100644 --- a/parachain/src/service.rs +++ b/parachain/src/service.rs @@ -109,6 +109,8 @@ pub trait RuntimeApiCollection: issue::IssueRequest, > + redeem_rpc_runtime_api::RedeemApi< Block, + VaultId, + Balance, AccountId, H256, redeem::RedeemRequest, @@ -157,6 +159,8 @@ where issue::IssueRequest, > + redeem_rpc_runtime_api::RedeemApi< Block, + VaultId, + Balance, AccountId, H256, redeem::RedeemRequest, diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 764a7f69e8..d86b3037da 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -87,6 +87,8 @@ where issue_rpc::IssueRuntimeApi>, C::Api: redeem_rpc::RedeemRuntimeApi< Block, + VaultId, + Balance, AccountId, H256, RedeemRequest, From ac4da0e7af4581e4a3e0eab9e8a80d9e64c588cd Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Tue, 12 Dec 2023 10:03:10 +0530 Subject: [PATCH 11/19] fix: change rpc method name & round down while calculating premium --- crates/fee/src/lib.rs | 2 +- crates/redeem/rpc/src/lib.rs | 2 +- crates/redeem/src/lib.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/fee/src/lib.rs b/crates/fee/src/lib.rs index d98f8dfa4e..0153065ad4 100644 --- a/crates/fee/src/lib.rs +++ b/crates/fee/src/lib.rs @@ -424,7 +424,7 @@ impl Pallet { /// /// * `amount` - amount in collateral (at current exchange rate) pub fn get_premium_redeem_fee(amount: &Amount) -> Result, DispatchError> { - amount.checked_rounded_mul(&>::get(), Rounding::NearestPrefUp) + amount.checked_rounded_mul(&>::get(), Rounding::Down) } /// Get the premium redeem reward rate. diff --git a/crates/redeem/rpc/src/lib.rs b/crates/redeem/rpc/src/lib.rs index 0003008009..b4c5171bf4 100644 --- a/crates/redeem/rpc/src/lib.rs +++ b/crates/redeem/rpc/src/lib.rs @@ -34,7 +34,7 @@ where #[method(name = "redeem_getVaultRedeemRequests")] fn get_vault_redeem_requests(&self, vault_id: AccountId, at: Option) -> RpcResult>; - #[method(name = "redeem_getPremiumRedeemVaults")] + #[method(name = "vaultRegistry_getPremiumRedeemVaults")] fn get_premium_redeem_vaults(&self, at: Option) -> RpcResult)>>; } diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index d93c05ccea..fddc491996 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -508,8 +508,8 @@ impl Pallet { let premium_collateral = if below_premium_redeem { let redeem_amount_wrapped_in_collateral = user_to_be_received_btc.convert_to(currency_id)?; let premium_redeem_rate = ext::fee::premium_redeem_reward_rate::(); - let premium_for_redeem_amount = redeem_amount_wrapped_in_collateral - .checked_rounded_mul(&premium_redeem_rate, Rounding::NearestPrefUp)?; + let premium_for_redeem_amount = + redeem_amount_wrapped_in_collateral.checked_rounded_mul(&premium_redeem_rate, Rounding::Down)?; let max_premium = ext::vault_registry::get_vault_max_premium_redeem(&vault_id)?; max_premium.min(&premium_for_redeem_amount)? From 31556f24b1e459596593c3ce0423751e0b482faa Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 13 Dec 2023 01:40:22 +0530 Subject: [PATCH 12/19] fix: premium collateralization test case & RPC --- crates/redeem/rpc/src/lib.rs | 2 +- crates/vault-registry/rpc/src/lib.rs | 5 +++- crates/vault-registry/src/tests.rs | 42 ++++++++++++---------------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/crates/redeem/rpc/src/lib.rs b/crates/redeem/rpc/src/lib.rs index b4c5171bf4..0003008009 100644 --- a/crates/redeem/rpc/src/lib.rs +++ b/crates/redeem/rpc/src/lib.rs @@ -34,7 +34,7 @@ where #[method(name = "redeem_getVaultRedeemRequests")] fn get_vault_redeem_requests(&self, vault_id: AccountId, at: Option) -> RpcResult>; - #[method(name = "vaultRegistry_getPremiumRedeemVaults")] + #[method(name = "redeem_getPremiumRedeemVaults")] fn get_premium_redeem_vaults(&self, at: Option) -> RpcResult)>>; } diff --git a/crates/vault-registry/rpc/src/lib.rs b/crates/vault-registry/rpc/src/lib.rs index b3e479c5ac..30d0233199 100644 --- a/crates/vault-registry/rpc/src/lib.rs +++ b/crates/vault-registry/rpc/src/lib.rs @@ -82,7 +82,10 @@ where at: Option, ) -> RpcResult>; - #[method(name = "vaultRegistry_getRequiredCollateralForVault")] + #[method( + name = "vaultRegistry_getRequiredCollateralForVault", + aliases = ["redeem_getPremiumRedeemVaults"] + )] fn get_required_collateral_for_vault( &self, vault_id: VaultId, diff --git a/crates/vault-registry/src/tests.rs b/crates/vault-registry/src/tests.rs index fc53a25329..aa34564d18 100644 --- a/crates/vault-registry/src/tests.rs +++ b/crates/vault-registry/src/tests.rs @@ -995,6 +995,7 @@ mod get_vaults_below_premium_collaterlization_tests { VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, FixedU128::from_float(0.001)); VaultRegistry::_set_premium_redeem_threshold(DEFAULT_CURRENCY_PAIR, FixedU128::one()); ext::fee::premium_redeem_reward_rate::.mock_safe(move || MockResult::Return(1.into())); + ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); test() }) @@ -1015,11 +1016,6 @@ mod get_vaults_below_premium_collaterlization_tests { #[test] fn get_vaults_below_premium_collateralization_fails() { run_test(|| { - ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); - - // set back to default threshold - set_default_thresholds(); - add_vault(vault_id(4), 50, 100); assert_err!( @@ -1032,8 +1028,6 @@ mod get_vaults_below_premium_collaterlization_tests { #[test] fn get_vaults_below_premium_collateralization_succeeds() { run_test(|| { - ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); - let id1 = vault_id(3); let issue_tokens1: u128 = 50; let collateral1 = 49; @@ -1045,8 +1039,9 @@ mod get_vaults_below_premium_collaterlization_tests { add_vault(id1.clone(), issue_tokens1, collateral1); add_vault(id2.clone(), issue_tokens2, collateral2); - // set back to default threshold so that vaults fall under premium redeem - set_default_thresholds(); + // set back secure threshold + let secure = UnsignedFixedPoint::checked_from_rational(200, 100).unwrap(); // 200% + VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, secure); assert_eq!( VaultRegistry::get_premium_redeem_vaults(400_u32), @@ -1058,34 +1053,33 @@ mod get_vaults_below_premium_collaterlization_tests { #[test] fn get_vaults_below_premium_collateralization_filters_banned_and_sufficiently_collateralized_vaults() { run_test(|| { - ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); - - // returned + // not returned, because is is not under premium threshold (which is set to 100% for this test) let id1 = vault_id(3); let issue_tokens1: u128 = 50; let collateral1 = 50; add_vault(id1.clone(), issue_tokens1, collateral1); + // returned + let id2 = vault_id(4); + let issue_tokens2: u128 = 50; + let collateral2 = 49; + add_vault(id2.clone(), issue_tokens2, collateral2); + // not returned because it's banned - let id2 = vault_id(5); + let id3 = vault_id(5); let issue_tokens3: u128 = 50; let collateral3 = 49; - add_vault(id2.clone(), issue_tokens3, collateral3); - let mut vault3 = VaultRegistry::get_active_rich_vault_from_id(&id2).unwrap(); + add_vault(id3.clone(), issue_tokens3, collateral3); + let mut vault3 = VaultRegistry::get_active_rich_vault_from_id(&id3).unwrap(); vault3.ban_until(1000); - // set back to default threshold so that vaults fall under premium redeem - set_default_thresholds(); - - // not returned, since default threshold applied so vault is now not under premium threshold - let id3 = vault_id(4); - let issue_tokens2: u128 = 50; - let collateral2 = 150; - add_vault(id3.clone(), issue_tokens2, collateral2); + // set back secure threshold + let secure = UnsignedFixedPoint::checked_from_rational(200, 100).unwrap(); // 200% + VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, secure); assert_eq!( VaultRegistry::get_premium_redeem_vaults(400_u32), - Ok(vec!((id1, wrapped(450)))) + Ok(vec!((id2, wrapped(451)))) ); }) } From c3edd9a32576e8a4023b439402974badcef06e3e Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 13 Dec 2023 01:43:11 +0530 Subject: [PATCH 13/19] fix: add alias --- crates/redeem/rpc/src/lib.rs | 2 +- crates/vault-registry/rpc/src/lib.rs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/redeem/rpc/src/lib.rs b/crates/redeem/rpc/src/lib.rs index 0003008009..ac4afcef83 100644 --- a/crates/redeem/rpc/src/lib.rs +++ b/crates/redeem/rpc/src/lib.rs @@ -34,7 +34,7 @@ where #[method(name = "redeem_getVaultRedeemRequests")] fn get_vault_redeem_requests(&self, vault_id: AccountId, at: Option) -> RpcResult>; - #[method(name = "redeem_getPremiumRedeemVaults")] + #[method(name = "redeem_getPremiumRedeemVaults", aliases = ["redeem_getPremiumRedeemVaults"])] fn get_premium_redeem_vaults(&self, at: Option) -> RpcResult)>>; } diff --git a/crates/vault-registry/rpc/src/lib.rs b/crates/vault-registry/rpc/src/lib.rs index 30d0233199..b3e479c5ac 100644 --- a/crates/vault-registry/rpc/src/lib.rs +++ b/crates/vault-registry/rpc/src/lib.rs @@ -82,10 +82,7 @@ where at: Option, ) -> RpcResult>; - #[method( - name = "vaultRegistry_getRequiredCollateralForVault", - aliases = ["redeem_getPremiumRedeemVaults"] - )] + #[method(name = "vaultRegistry_getRequiredCollateralForVault")] fn get_required_collateral_for_vault( &self, vault_id: VaultId, From e03b3dfd49d0bd760ef859c16903cb62f365c265 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 13 Dec 2023 11:24:56 +0530 Subject: [PATCH 14/19] fix: test case --- crates/redeem/rpc/src/lib.rs | 2 +- crates/vault-registry/src/tests.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/redeem/rpc/src/lib.rs b/crates/redeem/rpc/src/lib.rs index ac4afcef83..3a65641a9e 100644 --- a/crates/redeem/rpc/src/lib.rs +++ b/crates/redeem/rpc/src/lib.rs @@ -34,7 +34,7 @@ where #[method(name = "redeem_getVaultRedeemRequests")] fn get_vault_redeem_requests(&self, vault_id: AccountId, at: Option) -> RpcResult>; - #[method(name = "redeem_getPremiumRedeemVaults", aliases = ["redeem_getPremiumRedeemVaults"])] + #[method(name = "redeem_getPremiumRedeemVaults", aliases = ["vaultRegistry_getPremiumRedeemVaults"])] fn get_premium_redeem_vaults(&self, at: Option) -> RpcResult)>>; } diff --git a/crates/vault-registry/src/tests.rs b/crates/vault-registry/src/tests.rs index aa34564d18..99c47abae0 100644 --- a/crates/vault-registry/src/tests.rs +++ b/crates/vault-registry/src/tests.rs @@ -996,6 +996,7 @@ mod get_vaults_below_premium_collaterlization_tests { VaultRegistry::_set_premium_redeem_threshold(DEFAULT_CURRENCY_PAIR, FixedU128::one()); ext::fee::premium_redeem_reward_rate::.mock_safe(move || MockResult::Return(1.into())); ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); + ext::fee::get_redeem_fee_value::.mock_safe(move || MockResult::Return(FixedU128::from_float(0.005))); test() }) @@ -1019,7 +1020,7 @@ mod get_vaults_below_premium_collaterlization_tests { add_vault(vault_id(4), 50, 100); assert_err!( - VaultRegistry::get_premium_redeem_vaults(400_u32), + VaultRegistry::get_premium_redeem_vaults(0_u32), TestError::NoVaultUnderThePremiumRedeemThreshold ); }) @@ -1044,8 +1045,8 @@ mod get_vaults_below_premium_collaterlization_tests { VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, secure); assert_eq!( - VaultRegistry::get_premium_redeem_vaults(400_u32), - Ok(vec![(id2, wrapped(452)), (id1, wrapped(451))]) + VaultRegistry::get_premium_redeem_vaults(0_u32), + Ok(vec![(id2, wrapped(52)), (id1, wrapped(51))]) ); }) } @@ -1078,8 +1079,8 @@ mod get_vaults_below_premium_collaterlization_tests { VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, secure); assert_eq!( - VaultRegistry::get_premium_redeem_vaults(400_u32), - Ok(vec!((id2, wrapped(451)))) + VaultRegistry::get_premium_redeem_vaults(0_u32), + Ok(vec!((id2, wrapped(51)))) ); }) } From bb9960efcc060092ff71c0fa39668aef126b59e8 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Wed, 13 Dec 2023 11:47:59 +0530 Subject: [PATCH 15/19] fix: test case --- crates/vault-registry/src/tests.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/vault-registry/src/tests.rs b/crates/vault-registry/src/tests.rs index 99c47abae0..8db94062c7 100644 --- a/crates/vault-registry/src/tests.rs +++ b/crates/vault-registry/src/tests.rs @@ -994,8 +994,9 @@ mod get_vaults_below_premium_collaterlization_tests { super::run_test(|| { VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, FixedU128::from_float(0.001)); VaultRegistry::_set_premium_redeem_threshold(DEFAULT_CURRENCY_PAIR, FixedU128::one()); - ext::fee::premium_redeem_reward_rate::.mock_safe(move || MockResult::Return(1.into())); - ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(1.into()))); + ext::fee::premium_redeem_reward_rate:: + .mock_safe(move || MockResult::Return(FixedU128::from_float(0.05))); + ext::oracle::get_price::.mock_safe(move |_| MockResult::Return(Ok(3.into()))); ext::fee::get_redeem_fee_value::.mock_safe(move || MockResult::Return(FixedU128::from_float(0.005))); test() @@ -1020,7 +1021,7 @@ mod get_vaults_below_premium_collaterlization_tests { add_vault(vault_id(4), 50, 100); assert_err!( - VaultRegistry::get_premium_redeem_vaults(0_u32), + VaultRegistry::get_premium_redeem_vaults(10_u32), TestError::NoVaultUnderThePremiumRedeemThreshold ); }) @@ -1045,8 +1046,8 @@ mod get_vaults_below_premium_collaterlization_tests { VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, secure); assert_eq!( - VaultRegistry::get_premium_redeem_vaults(0_u32), - Ok(vec![(id2, wrapped(52)), (id1, wrapped(51))]) + VaultRegistry::get_premium_redeem_vaults(10_u32), + Ok(vec![(id1, wrapped(issue_tokens1)), (id2, wrapped(issue_tokens2))]) ); }) } @@ -1079,8 +1080,8 @@ mod get_vaults_below_premium_collaterlization_tests { VaultRegistry::_set_secure_collateral_threshold(DEFAULT_CURRENCY_PAIR, secure); assert_eq!( - VaultRegistry::get_premium_redeem_vaults(0_u32), - Ok(vec!((id2, wrapped(51)))) + VaultRegistry::get_premium_redeem_vaults(10_u32), + Ok(vec!((id2, wrapped(issue_tokens2)))) ); }) } From 0f67fd9677008c9521b87550a50a9c21b3b57a3f Mon Sep 17 00:00:00 2001 From: Sander Bosma Date: Fri, 15 Dec 2023 11:44:41 +0100 Subject: [PATCH 16/19] refactor: change is_below_premium_threshold function and change tests --- crates/redeem/src/ext.rs | 6 - crates/redeem/src/lib.rs | 5 +- crates/redeem/src/tests.rs | 5 - crates/vault-registry/src/lib.rs | 12 +- .../runtime-tests/src/parachain/redeem.rs | 130 ++++++++++-------- 5 files changed, 83 insertions(+), 75 deletions(-) diff --git a/crates/redeem/src/ext.rs b/crates/redeem/src/ext.rs index ecc3eaf666..bb4e42f09a 100644 --- a/crates/redeem/src/ext.rs +++ b/crates/redeem/src/ext.rs @@ -143,12 +143,6 @@ pub(crate) mod vault_registry { >::ensure_not_banned(vault_id) } - pub fn is_vault_below_premium_threshold( - vault_id: &DefaultVaultId, - ) -> Result { - >::is_vault_below_premium_threshold(vault_id) - } - pub fn is_vault_below_secure_threshold( vault_id: &DefaultVaultId, ) -> Result { diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index fddc491996..d374cd9ad0 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -499,13 +499,12 @@ impl Pallet { Error::::AmountBelowDustAmount ); - let below_premium_redeem = ext::vault_registry::is_vault_below_premium_threshold::(&vault_id)?; let currency_id = vault_id.collateral_currency(); // Calculate the premium collateral amount based on whether the redemption is below the premium redeem // threshold. This should come before increasing the `to_be_redeemed` tokens and locking the amount to // ensure accurate premium redeem calculations. - let premium_collateral = if below_premium_redeem { + let premium_collateral = { let redeem_amount_wrapped_in_collateral = user_to_be_received_btc.convert_to(currency_id)?; let premium_redeem_rate = ext::fee::premium_redeem_reward_rate::(); let premium_for_redeem_amount = @@ -513,8 +512,6 @@ impl Pallet { let max_premium = ext::vault_registry::get_vault_max_premium_redeem(&vault_id)?; max_premium.min(&premium_for_redeem_amount)? - } else { - Amount::zero(currency_id) }; // vault will get rid of the btc + btc_inclusion_fee diff --git a/crates/redeem/src/tests.rs b/crates/redeem/src/tests.rs index c31a0afd15..17f522fd3b 100644 --- a/crates/redeem/src/tests.rs +++ b/crates/redeem/src/tests.rs @@ -182,7 +182,6 @@ fn test_request_redeem_succeeds_with_normal_redeem() { }); ext::security::get_secure_id::.mock_safe(move |_| MockResult::Return(H256([0; 32]))); - ext::vault_registry::is_vault_below_premium_threshold::.mock_safe(move |_| MockResult::Return(Ok(false))); ext::fee::get_redeem_fee::.mock_safe(move |_| MockResult::Return(Ok(wrapped(redeem_fee)))); let btc_fee = Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY).unwrap(); @@ -286,7 +285,6 @@ fn test_request_redeem_succeeds_with_self_redeem() { }); ext::security::get_secure_id::.mock_safe(move |_| MockResult::Return(H256::zero())); - ext::vault_registry::is_vault_below_premium_threshold::.mock_safe(move |_| MockResult::Return(Ok(false))); let btc_fee = Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY).unwrap(); assert_ok!(Redeem::request_redeem( @@ -760,8 +758,6 @@ mod spec_based_tests { ext::vault_registry::ensure_not_banned::.mock_safe(move |_vault_id| MockResult::Return(Ok(()))); ext::vault_registry::try_increase_to_be_redeemed_tokens:: .mock_safe(move |_vault_id, _amount| MockResult::Return(Ok(()))); - ext::vault_registry::is_vault_below_premium_threshold:: - .mock_safe(move |_vault_id| MockResult::Return(Ok(false))); let redeem_fee = Fee::get_redeem_fee(&wrapped(amount_to_redeem)).unwrap(); let burned_tokens = wrapped(amount_to_redeem) - redeem_fee; @@ -919,7 +915,6 @@ mod spec_based_tests { inject_redeem_request(H256([0u8; 32]), redeem_request.clone()); ext::btc_relay::has_request_expired::.mock_safe(|_, _, _| MockResult::Return(Ok(true))); - ext::vault_registry::is_vault_below_secure_threshold::.mock_safe(|_| MockResult::Return(Ok(false))); ext::vault_registry::ban_vault::.mock_safe(move |vault| { assert_eq!(vault, &VAULT); MockResult::Return(Ok(())) diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 14fe02bd7f..280abe73df 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -804,10 +804,10 @@ impl Pallet { let required_collateral = Self::get_required_collateral_for_wrapped(&to_be_backed_tokens, vault_id.collateral_currency())?; - let current_collateral = Self::get_backing_collateral(&vault_id)?; let missing_collateral = required_collateral.saturating_sub(¤t_collateral)?; + // factor = fee / (secure - fee) let factor = premium_redeem_rate .checked_div( &global_secure_threshold @@ -1563,7 +1563,10 @@ impl Pallet { Ok(Self::get_vault_from_id(&vault_id)?.is_liquidated()) } - pub fn is_vault_below_premium_threshold(vault_id: &DefaultVaultId) -> Result { + #[cfg(feature = "integration-tests")] + // note: unlike `is_vault_below_secure_threshold` and `is_vault_below_liquidation_threshold`, + // this function uses to_be_backed tokens + pub fn will_be_below_premium_threshold(vault_id: &DefaultVaultId) -> Result { let vault = Self::get_rich_vault_from_id(&vault_id)?; let threshold = Self::premium_redeem_threshold(&vault_id.currencies).ok_or(Error::::ThresholdNotSet)?; let collateral = Self::get_backing_collateral(vault_id)?; @@ -1704,10 +1707,7 @@ impl Pallet { let request_redeem_tokens_for_max_premium = vault_to_burn_tokens.checked_div(&amount_wrapped).ok()?; - if Self::ensure_not_banned(&vault_id).is_ok() - && !request_redeem_tokens_for_max_premium.is_zero() - && Self::is_vault_below_premium_threshold(&vault_id).unwrap_or(false) - { + if Self::ensure_not_banned(&vault_id).is_ok() && !request_redeem_tokens_for_max_premium.is_zero() { Some((vault_id, request_redeem_tokens_for_max_premium)) } else { None diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index 4e9a361f19..0e04954cf3 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -127,15 +127,21 @@ mod premium_redeem_tests { CoreVaultData::force_to( &vault_id, CoreVaultData { - issued: vault_id.wrapped(450_000), - to_be_issued: vault_id.wrapped(250_000), - to_be_redeemed: vault_id.wrapped(50_000), - backing_collateral: vault_id.collateral(2_000_000), + issued: vault_id.wrapped(450_000_000), + to_be_issued: vault_id.wrapped(250_000_000), + to_be_redeemed: vault_id.wrapped(50_000_000), + backing_collateral: vault_id.collateral(2_000_000_000), to_be_replaced: vault_id.wrapped(0), replace_collateral: griefing(0), ..default_vault_state(&vault_id) }, ); + + // make sure user has enough tokens to redeem + let mut user_state = UserData::get(USER); + (*user_state.balances.get_mut(&vault_id.wrapped_currency()).unwrap()).free = + (*user_state.balances.get_mut(&vault_id.wrapped_currency()).unwrap()).free * 1000; + UserData::force_to(USER, user_state); } #[test] @@ -144,46 +150,53 @@ mod premium_redeem_tests { setup_vault_below_premium_threshold(vault_id.clone()); assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); - assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + assert!(VaultRegistryPallet::will_be_below_premium_threshold(&vault_id).unwrap()); - let redeem_id = setup_redeem(vault_id.wrapped(400_000), USER, &vault_id); + let compute_collateral = VaultRegistryPallet::compute_collateral(&vault_id).unwrap().amount(); + assert_eq!(compute_collateral, 2_000_000_000); - assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); - assert!(!VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + let initial_state = ParachainState::get(&vault_id); + let redeem_id = setup_redeem(vault_id.wrapped(400_000_000), USER, &vault_id); let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); - // we should get rewarded only for 150_000 + 3840 tokens (that's when we reach nearer to secure threshold) - let expected_premium = FeePallet::get_premium_redeem_fee( - &vault_id - .wrapped(150_000 + 3840) // need to add 0.384 = 153.84 - .convert_to(vault_id.collateral_currency()) - .unwrap(), - ) - .unwrap(); - assert_eq!(vault_id.collateral(redeem.premium), expected_premium); - // Execute redeem - execute_redeem(redeem_id); + assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::will_be_below_premium_threshold(&vault_id).unwrap()); - let compute_collateral = VaultRegistryPallet::compute_collateral(&vault_id).unwrap().amount(); - assert_eq!(compute_collateral, 2000000 - 15384); //15.384 COL tokens lost as premium fees + dry_run(|| { + // further redeems will have no rewards, even though the premium redeem + // has not executed yet + let redeem_id = setup_redeem(vault_id.wrapped(2_000_000), USER, &vault_id); + let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + assert_eq!(redeem.premium, 0); + }); - // Setup another redeem request - let redeem_id = setup_redeem(vault_id.wrapped(2_000), USER, &vault_id); + execute_redeem(redeem_id); - let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + assert_eq!( + ParachainState::get(&vault_id), + initial_state.with_changes(|user, vault, _, fee_pool| { + // premium transferred to user + // we should get rewarded only for 15.3846153846 *10^6 tokens (that's when we reach nearer to secure + // threshold) + let expected_premium = vault_id.collateral(15_384_615); + vault.backing_collateral -= expected_premium; + (*user.balances.get_mut(&vault_id.collateral_currency()).unwrap()).free += expected_premium; + + // bitcoin balance update as usual + (*user.balances.get_mut(&vault_id.wrapped_currency()).unwrap()).free -= + redeem.amount_btc() + redeem.fee() + redeem.transfer_fee_btc(); + vault.issued -= redeem.amount_btc() + redeem.transfer_fee_btc(); + *fee_pool.rewards_for(&vault_id) += redeem.fee(); + }) + ); - // No premium should be given for this request + // We already checked that redeems have no more rewards after requesting the + // premium redeem. Here we do a sanity check that it's still the case after + // execution + let redeem_id = setup_redeem(vault_id.wrapped(2_000_000), USER, &vault_id); + let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); assert_eq!(redeem.premium, 0); - - // Execute redeem - execute_redeem(redeem_id); - - // initially 400 tokens, 1st redeem consumed 398 tokens , 2nd redeem consumed 1.99 tokens, remaining 0.01 - let get_free_redeemable_tokens = VaultRegistryPallet::get_free_redeemable_tokens(&vault_id) - .unwrap() - .amount(); - assert_eq!(get_free_redeemable_tokens, 10); }); } @@ -195,13 +208,14 @@ mod premium_redeem_tests { let global_secure = VaultRegistryPallet::get_global_secure_threshold(&vault_id.currencies).unwrap(); // 200% // secure > premium > liquidation threshold - // at start vault should be below premium threshold, while above global secure & secure threshold + // at start the vault is above the custom&global secure threshold, but due to the to_be_issued + // tokens it is already eligible for premium redeem assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); - assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); assert!(!VaultRegistryPallet::is_vault_below_certain_threshold(&vault_id, global_secure).unwrap()); + assert!(VaultRegistryPallet::will_be_below_premium_threshold(&vault_id).unwrap()); // Change vault secure threshold, - // now secure > global secure > premium > liquidation threshold + // now custom secure > global secure > premium > liquidation threshold let vault_custom_secure_threshold = UnsignedFixedPoint::checked_from_rational(300, 100); assert_ok!( RuntimeCall::VaultRegistry(VaultRegistryCall::set_custom_secure_threshold { @@ -213,23 +227,24 @@ mod premium_redeem_tests { // vault should be below premium & secure threshold, while above global secure threshold assert!(VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); - assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); assert!(!VaultRegistryPallet::is_vault_below_certain_threshold(&vault_id, global_secure).unwrap()); + assert!(VaultRegistryPallet::will_be_below_premium_threshold(&vault_id).unwrap()); let max_premium_for_vault = VaultRegistryPallet::get_vault_max_premium_redeem(&vault_id).unwrap(); // get premium redeem vaults - let premium_redeem_vaults = RedeemPallet::get_premium_redeem_vaults() - .unwrap() - .get(0) - .unwrap() - .clone(); + let premium_redeem_vaults = RedeemPallet::get_premium_redeem_vaults().unwrap()[0].clone(); + // non-zero amount of tokens that are elible for premium redeem + assert!(!premium_redeem_vaults.1.is_zero()); // request redeem tokens given by RPC let redeem_id_1 = setup_redeem(premium_redeem_vaults.1, USER, &vault_id); let redeem_1 = RedeemPallet::get_open_redeem_request_from_id(&redeem_id_1).unwrap(); - // recv premium should be equal to max premium - assert_eq!(redeem_1.premium, max_premium_for_vault.amount()); + // premium should be equal to max premium, but allow rounding error in this check. + assert!( + redeem_1.premium >= max_premium_for_vault.amount() - 1 + && redeem_1.premium <= max_premium_for_vault.amount() + 1 + ); assert!(!redeem_1.premium.is_zero()); // max premium for vault should be zero @@ -239,9 +254,21 @@ mod premium_redeem_tests { // redeeming the max premium amount put backs vault above premium threshold // vault should be below secure threshold, while above global secure & premium threshold assert!(VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); - assert!(!VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::will_be_below_premium_threshold(&vault_id).unwrap()); assert!(!VaultRegistryPallet::is_vault_below_certain_threshold(&vault_id, global_secure).unwrap()); + execute_redeem(redeem_id_1); + // We should be almost exactly at the secure threshold (there should only be minor + // rounding errors) + let vault = CoreVaultData::vault(vault_id.clone()); + let future_tokens = vault.to_be_issued + vault.issued - vault.to_be_redeemed; + let collateral = vault.backing_collateral; + let future_ratio = collateral + .ratio(&future_tokens.convert_to(vault_id.collateral_currency()).unwrap()) + .unwrap(); + // actual collateralization rate: 2.000004822104648639. Allow small rounding changes + assert!(future_ratio - global_secure < FixedU128::from_float(0.00001)); + let redeem_id_2 = setup_redeem(vault_id.wrapped(800_00), USER, &vault_id); let redeem_2 = RedeemPallet::get_open_redeem_request_from_id(&redeem_id_2).unwrap(); // no premium is given out for new redeems @@ -254,12 +281,12 @@ mod premium_redeem_tests { setup_vault_below_premium_threshold(vault_id.clone()); assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); - assert!(VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + assert!(VaultRegistryPallet::will_be_below_premium_threshold(&vault_id).unwrap()); - let redeem_id = setup_redeem(vault_id.wrapped(100_000), USER, &vault_id); + let redeem_id = setup_redeem(vault_id.wrapped(100_000_000), USER, &vault_id); assert!(!VaultRegistryPallet::is_vault_below_secure_threshold(&vault_id).unwrap()); - assert!(!VaultRegistryPallet::is_vault_below_premium_threshold(&vault_id).unwrap()); + assert!(!VaultRegistryPallet::will_be_below_premium_threshold(&vault_id).unwrap()); let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); @@ -272,11 +299,6 @@ mod premium_redeem_tests { ) .unwrap(); assert_eq!(vault_id.collateral(redeem.premium), expected_premium); - - let get_free_redeemable_tokens = VaultRegistryPallet::get_free_redeemable_tokens(&vault_id) - .unwrap() - .amount(); - assert_eq!(get_free_redeemable_tokens, 300500); }); } } From 339bfa78836db6ed797acc4732bb1551c2ff8e4e Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Thu, 21 Dec 2023 13:15:50 +0530 Subject: [PATCH 17/19] fix: redeem test cases + add back --- crates/redeem/src/tests.rs | 3 +++ crates/vault-registry/src/lib.rs | 6 ++++-- .../runtime/runtime-tests/src/parachain/redeem.rs | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/redeem/src/tests.rs b/crates/redeem/src/tests.rs index 17f522fd3b..22ad2b24bb 100644 --- a/crates/redeem/src/tests.rs +++ b/crates/redeem/src/tests.rs @@ -766,6 +766,8 @@ mod spec_based_tests { assert_eq!(tokens, &burned_tokens); MockResult::Return(Ok((wrapped(0), griefing(0)))) }); + ext::vault_registry::get_vault_max_premium_redeem:: + .mock_safe(|_| MockResult::Return(Ok(collateral(0)))); // The returned `replaceCollateral` MUST be released currency::Amount::unlock_on.mock_safe(move |collateral_amount, vault_id| { @@ -919,6 +921,7 @@ mod spec_based_tests { assert_eq!(vault, &VAULT); MockResult::Return(Ok(())) }); + ext::vault_registry::is_vault_below_secure_threshold::.mock_safe(|_| MockResult::Return(Ok(false))); Amount::::unlock_on.mock_safe(|_, _| MockResult::Return(Ok(()))); Amount::::transfer.mock_safe(|_, _, _| MockResult::Return(Ok(()))); ext::vault_registry::transfer_funds_saturated:: diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 280abe73df..dda7892e74 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -1563,7 +1563,6 @@ impl Pallet { Ok(Self::get_vault_from_id(&vault_id)?.is_liquidated()) } - #[cfg(feature = "integration-tests")] // note: unlike `is_vault_below_secure_threshold` and `is_vault_below_liquidation_threshold`, // this function uses to_be_backed tokens pub fn will_be_below_premium_threshold(vault_id: &DefaultVaultId) -> Result { @@ -1707,7 +1706,10 @@ impl Pallet { let request_redeem_tokens_for_max_premium = vault_to_burn_tokens.checked_div(&amount_wrapped).ok()?; - if Self::ensure_not_banned(&vault_id).is_ok() && !request_redeem_tokens_for_max_premium.is_zero() { + if Self::ensure_not_banned(&vault_id).is_ok() && !request_redeem_tokens_for_max_premium.is_zero() + // need the check as `inclusion_fee` will be a non zero amount, hence `request_redeem_tokens_for_max_premium` will also be a non zero amount + && Self::will_be_below_premium_threshold(&vault_id).unwrap_or(false) + { Some((vault_id, request_redeem_tokens_for_max_premium)) } else { None diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index 0e04954cf3..de11a4972a 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -200,6 +200,20 @@ mod premium_redeem_tests { }); } + #[test] + fn integration_test_try_get_premium_vaults_which_is_sufficiently_collateralized_then_under_collateralized() { + test_setup_for_premium_redeem(|vault_id| { + assert_noop!( + RedeemPallet::get_premium_redeem_vaults(), + VaultRegistryError::NoVaultUnderThePremiumRedeemThreshold + ); + + // put vault under premium redeem threshold + setup_vault_below_premium_threshold(vault_id.clone()); + assert_eq!(RedeemPallet::get_premium_redeem_vaults().unwrap().len(), 1); + }); + } + #[test] fn integration_test_redeem_max_premium_redeemable_token() { test_setup_for_premium_redeem(|vault_id| { From b9b547d0260179b7e2adf46958ffd0b88e519580 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Thu, 21 Dec 2023 13:20:52 +0530 Subject: [PATCH 18/19] fix: comment modified. --- crates/vault-registry/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index dda7892e74..6d749510ca 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -1707,7 +1707,7 @@ impl Pallet { let request_redeem_tokens_for_max_premium = vault_to_burn_tokens.checked_div(&amount_wrapped).ok()?; if Self::ensure_not_banned(&vault_id).is_ok() && !request_redeem_tokens_for_max_premium.is_zero() - // need the check as `inclusion_fee` will be a non zero amount, hence `request_redeem_tokens_for_max_premium` will also be a non zero amount + // need `will_be_below_premium_threshold` check as `inclusion_fee` will be a non zero amount, hence `request_redeem_tokens_for_max_premium` will also be a non zero amount && Self::will_be_below_premium_threshold(&vault_id).unwrap_or(false) { Some((vault_id, request_redeem_tokens_for_max_premium)) From 386737953deb793ddd57607ddc11adfc5e06e926 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Mon, 1 Jan 2024 10:49:15 +0530 Subject: [PATCH 19/19] fix: code comments --- crates/vault-registry/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index 6d749510ca..c89e03ad51 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -1706,9 +1706,12 @@ impl Pallet { let request_redeem_tokens_for_max_premium = vault_to_burn_tokens.checked_div(&amount_wrapped).ok()?; - if Self::ensure_not_banned(&vault_id).is_ok() && !request_redeem_tokens_for_max_premium.is_zero() - // need `will_be_below_premium_threshold` check as `inclusion_fee` will be a non zero amount, hence `request_redeem_tokens_for_max_premium` will also be a non zero amount - && Self::will_be_below_premium_threshold(&vault_id).unwrap_or(false) + if Self::ensure_not_banned(&vault_id).is_ok() + && !request_redeem_tokens_for_max_premium.is_zero() + // Need to check `will_be_below_premium_threshold` to handle a corner case + // where the vault is above PremiumThreshold, but `request_redeem_tokens_for_max_premium` is being calculated as a non-zero amount + // since the `inclusion_fee` is a non-zero amount. + && Self::will_be_below_premium_threshold(&vault_id).unwrap_or(false) { Some((vault_id, request_redeem_tokens_for_max_premium)) } else {