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

Add zero-amount Receive Chain Swap #538

Merged
merged 25 commits into from
Dec 9, 2024
Merged

Conversation

ok300
Copy link
Contributor

@ok300 ok300 commented Oct 25, 2024

Fixes #519

Open questions:

  • Proper way to show fees during prepare/pay: "X sat + Y% of the sent amount" ?
  • Include min/max in prepare_response? How else to communicate them to caller, as they are now essential?
    • Also: it's important they exactly match the ones for the pair hash used in creating the swap
  • Should such a (refundable) swap require user interaction to "try to claim"?
    • Or should the SDK try to claim automatically when a lockup is detected (or on lockupFailed event)?
  • How to reflect in DB: set payer_amount_sat to 0 for zero-amount swaps? Or NULL (DB migration)?

@ok300 ok300 force-pushed the ok300-fix-u32-conversion branch 2 times, most recently from 55937a5 to 9a82900 Compare October 28, 2024 13:51
Base automatically changed from ok300-fix-u32-conversion to main October 28, 2024 14:36
@ok300 ok300 force-pushed the ok300-amountless-chain-swaps branch from 9f41dab to 89e20d4 Compare October 29, 2024 10:24
@dangeross
Copy link
Collaborator

Should such a (refundable) swap require user interaction to "try to claim"?

  • Or should the SDK try to claim automatically when a lockup is detected (or on lockupFailed event)?

The SDK user has to provide a fee rate for these refunds, so they need to be manually handled

@ok300
Copy link
Contributor Author

ok300 commented Nov 4, 2024

It's not about refunds per se. The zero-amount swaps get the TransactionLockupFailed event when the user locks up funds. At this point, it would be indistinguishable from a refundable.

However it will not become an actual refundable when the user locks up funds, because when the zero-amount swap gets this event, we are getting and confirming the so-called quote from Boltz. By confirming it, we tell Boltz they should proceed with this swap (e.g. create the server lockup tx, etc). My question above was about this "getting and confirming" the quote. However we clarified in an earlier call that no user interaction should be needed to claim, so therefore we get and auto-confirm the quote.

Hopefully this clarifies the confusion.

@ok300 ok300 marked this pull request as ready for review November 4, 2024 16:59
Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. some comments about the interface.

lib/bindings/src/breez_sdk_liquid.udl Outdated Show resolved Hide resolved
lib/core/src/chain_swap.rs Outdated Show resolved Hide resolved
lib/core/src/chain_swap.rs Outdated Show resolved Hide resolved
cli/src/commands.rs Outdated Show resolved Hide resolved
lib/core/src/sdk.rs Show resolved Hide resolved
lib/core/src/persist/chain.rs Outdated Show resolved Hide resolved
lib/core/src/chain_swap.rs Outdated Show resolved Hide resolved
@ok300 ok300 requested review from dangeross and roeierez November 27, 2024 15:55
lib/core/src/model.rs Outdated Show resolved Hide resolved
lib/core/src/persist/chain.rs Outdated Show resolved Hide resolved
lib/core/src/chain_swap.rs Outdated Show resolved Hide resolved
@ok300 ok300 force-pushed the ok300-amountless-chain-swaps branch from 0002af6 to 183c828 Compare December 6, 2024 18:59
@ok300 ok300 requested review from dangeross and roeierez December 6, 2024 19:03
Copy link
Collaborator

@dangeross dangeross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a couple of comments

@@ -14,7 +14,8 @@ frb = ["dep:flutter_rust_bridge"]
[dependencies]
anyhow = { workspace = true }
bip39 = "2.0.0"
boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust", branch = "trunk" }
#boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust", branch = "trunk" }
boltz-client = { git = "https://github.com/ok300/boltz-rust", branch = "ok300-support-quote" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is your rust-boltz PR merged yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: e8ac979

/// The percentage of the sent amount that will count towards the service fee.
///
/// When the method is [PaymentMethod::LiquidAddress], this is empty.
pub service_feerate: Option<f64>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe to be consistent with the previous PR, this could be swapper_feerate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: addde46

Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

lib/core/src/chain_swap.rs Outdated Show resolved Hide resolved
@ok300 ok300 requested review from roeierez and dangeross December 9, 2024 12:49
Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM one comment regarding docs.

let min = prepare_response.min_payer_amount_sat;
let max = prepare_response.max_payer_amount_sat;
let service_feerate = prepare_response.service_feerate;
format!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we will need to document the fact that in amountless swap applications need to add the service fee on top of the fees_sat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: 542dec7

@ok300 ok300 requested a review from roeierez December 9, 2024 14:15
@ok300 ok300 merged commit cfc883a into main Dec 9, 2024
7 of 8 checks passed
@ok300 ok300 deleted the ok300-amountless-chain-swaps branch December 9, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support amountless BTC -> Liquid swap
3 participants