Bump boltz-client, fix fee calculation (#68)

* Bump boltz-client, fix fee calculation

* Cargo fmt
This commit is contained in:
ok300
2024-04-04 14:01:33 +00:00
committed by GitHub
parent 76278ac1b6
commit 091c0ced8b
4 changed files with 10 additions and 13 deletions

View File

@@ -305,17 +305,16 @@ impl Wallet {
let (onchain_amount_sat, invoice_amount_sat) =
match (req.onchain_amount_sat, req.invoice_amount_sat) {
(Some(onchain_amount_sat), None) => {
// TODO Calculate correct fees, once these PRs are merged and published
// https://github.com/SatoshiPortal/boltz-rust/pull/31
// https://github.com/SatoshiPortal/boltz-rust/pull/32
// TODO Until above is fixed, this is only an approximation (using onchain instead of invoice amount to calc. fees)
let fees_boltz = lbtc_pair.fees.reverse_boltz(onchain_amount_sat);
let fees_lockup = lbtc_pair.fees.reverse_lockup();
let fees_claim = CLAIM_ABSOLUTE_FEES; // lbtc_pair.fees.reverse_claim_estimate();
let fees_total = fees_boltz + fees_lockup + fees_claim;
let p = lbtc_pair.fees.percentage;
Ok((onchain_amount_sat, onchain_amount_sat + fees_total))
let temp_recv_amt = onchain_amount_sat;
let invoice_amt_minus_service_fee = temp_recv_amt + fees_lockup + fees_claim;
let invoice_amount_sat =
(invoice_amt_minus_service_fee as f64 * 100.0 / (100.0 - p)).ceil() as u64;
Ok((onchain_amount_sat, invoice_amount_sat))
}
(None, Some(invoice_amount_sat)) => {
let fees_boltz = lbtc_pair.fees.reverse_boltz(invoice_amount_sat);