From b42efaa7d7a1e93989ab9f89679ffcd074ad5a6f Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 11 Mar 2021 18:23:45 +0000 Subject: [PATCH] fix: use correct vault amount in auction replace check Signed-off-by: Gregory Hill --- vault/src/replace.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vault/src/replace.rs b/vault/src/replace.rs index d6a51a52e..398b6614c 100644 --- a/vault/src/replace.rs +++ b/vault/src/replace.rs @@ -245,7 +245,7 @@ pub async fn check_collateral_of_vaults( .get_all_vaults() .await? .into_iter() - .filter(|vault| vault.id != vault_id && matches!(vault.status, VaultStatus::Active)); + .filter(|vault| vault.id != vault_id); for vault in vaults { trace!("Checking collateral of {}", vault.id); if provider @@ -275,7 +275,12 @@ async fn auction_replace< btc_rpc: &Arc, vault: &PolkaBtcVault, ) -> Result<(), Error> { - let btc_amount = vault.issued_tokens; + let btc_amount = vault + .issued_tokens + .checked_sub(vault.to_be_redeemed_tokens) + .ok_or(Error::ArithmeticUnderflow)? + .checked_sub(vault.to_be_replaced_tokens) + .ok_or(Error::ArithmeticUnderflow)?; let collateral = provider .get_required_collateral_for_polkabtc(btc_amount) .await?;