Skip to content

Commit

Permalink
fix: change rpc method name & round down while calculating premium
Browse files Browse the repository at this point in the history
  • Loading branch information
nakul1010 committed Dec 12, 2023
1 parent 4c1eb93 commit ac4da0e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl<T: Config> Pallet<T> {
///
/// * `amount` - amount in collateral (at current exchange rate)
pub fn get_premium_redeem_fee(amount: &Amount<T>) -> Result<Amount<T>, DispatchError> {
amount.checked_rounded_mul(&<PremiumRedeemFee<T>>::get(), Rounding::NearestPrefUp)
amount.checked_rounded_mul(&<PremiumRedeemFee<T>>::get(), Rounding::Down)
}

/// Get the premium redeem reward rate.
Expand Down
2 changes: 1 addition & 1 deletion crates/redeem/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
#[method(name = "redeem_getVaultRedeemRequests")]
fn get_vault_redeem_requests(&self, vault_id: AccountId, at: Option<BlockHash>) -> RpcResult<Vec<H256>>;

#[method(name = "redeem_getPremiumRedeemVaults")]
#[method(name = "vaultRegistry_getPremiumRedeemVaults")]
fn get_premium_redeem_vaults(&self, at: Option<BlockHash>) -> RpcResult<Vec<(VaultId, BalanceWrapper<Balance>)>>;
}

Expand Down
4 changes: 2 additions & 2 deletions crates/redeem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ impl<T: Config> Pallet<T> {
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::<T>();
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)?
Expand Down

0 comments on commit ac4da0e

Please sign in to comment.