Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump boltz-client, fix fee calculation #68

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ crate-type = ["staticlib", "cdylib", "lib"]
[dependencies]
anyhow = "1.0.80"
bip39 = { version = "2.0.0", features = ["serde"] }
#boltz-client = "0.1.2"
#boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust", rev = "61592bcf0ad2e9bd68c593bc87c5a487805b6d00" }
boltz-client = { git = "https://github.com/hydra-yse/boltz-rust", branch = "yse-breez-latest" }
boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust", rev = "e55b8439f3311be7fcd18ec14a5747d0f3dbd74f" }
log = "0.4.20"
lwk_common = "0.3.0"
lwk_signer = "0.3.0"
Expand Down
14 changes: 6 additions & 8 deletions lib/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,15 @@ 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;

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, onchain_amount_sat + fees_total))
Ok((onchain_amount_sat, invoice_amount_sat))
}
(None, Some(invoice_amount_sat)) => {
let fees_boltz = lbtc_pair.fees.reverse_boltz(invoice_amount_sat);
Expand Down
Loading