mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-07-04 18:41:38 +00:00
Show the actual BTC amount and fee to be swapped
This commit is contained in:
parent
113a29839f
commit
668d34080d
|
@ -327,7 +327,7 @@ async fn determine_btc_to_swap(
|
||||||
// TODO: Also wait for more funds if balance < dust
|
// TODO: Also wait for more funds if balance < dust
|
||||||
let initial_balance = initial_balance.await?;
|
let initial_balance = initial_balance.await?;
|
||||||
|
|
||||||
if initial_balance == Amount::ZERO {
|
let balance = if initial_balance == Amount::ZERO {
|
||||||
info!(
|
info!(
|
||||||
"Please deposit the BTC you want to swap to {} (max {})",
|
"Please deposit the BTC you want to swap to {} (max {})",
|
||||||
get_new_address.await?,
|
get_new_address.await?,
|
||||||
|
@ -339,23 +339,23 @@ async fn determine_btc_to_swap(
|
||||||
.context("Failed to wait for Bitcoin deposit")?;
|
.context("Failed to wait for Bitcoin deposit")?;
|
||||||
|
|
||||||
info!("Received {}", new_balance);
|
info!("Received {}", new_balance);
|
||||||
|
new_balance
|
||||||
} else {
|
} else {
|
||||||
info!("Found {} in wallet", initial_balance);
|
info!("Found {} in wallet", initial_balance);
|
||||||
}
|
initial_balance
|
||||||
|
};
|
||||||
|
|
||||||
let max_giveable = max_giveable
|
let max_giveable = max_giveable
|
||||||
.await
|
.await
|
||||||
.context("Failed to compute max 'giveable' Bitcoin amount")?;
|
.context("Failed to compute max 'giveable' Bitcoin amount")?;
|
||||||
|
let fees = balance - max_giveable;
|
||||||
|
|
||||||
let max_accepted = bid_quote.max_quantity;
|
let max_accepted = bid_quote.max_quantity;
|
||||||
|
|
||||||
if max_giveable > max_accepted {
|
let btc_swap_amount = min(max_giveable, max_accepted);
|
||||||
info!(
|
info!("Swapping {} with {} fees", btc_swap_amount, fees);
|
||||||
"Max giveable amount {} exceeds max accepted amount {}!",
|
|
||||||
max_giveable, max_accepted
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(min(max_giveable, max_accepted))
|
Ok(btc_swap_amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user