From ac4da0e7af4581e4a3e0eab9e8a80d9e64c588cd Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Tue, 12 Dec 2023 10:03:10 +0530 Subject: [PATCH] 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)?