Skip to content

Commit

Permalink
Merge pull request #46 from interlay/greg/fix/auction-amount
Browse files Browse the repository at this point in the history
fix: use correct vault amount in auction replace check
  • Loading branch information
gregdhill authored Mar 11, 2021
2 parents 5b2a53b + b42efaa commit 4f23f0f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vault/src/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub async fn check_collateral_of_vaults<B: BitcoinCoreApi>(
.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
Expand Down Expand Up @@ -275,7 +275,12 @@ async fn auction_replace<
btc_rpc: &Arc<B>,
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?;
Expand Down

0 comments on commit 4f23f0f

Please sign in to comment.