-
Notifications
You must be signed in to change notification settings - Fork 23
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
Pay order-matching fee on the app #863
Conversation
e0a05e2
to
528ad6c
Compare
With 4a18708 it looks like this: (Ignore the overflow warnings, those are already happening on native.) |
Not sure we have to - we can never really guarantee this completely because:
I think the better solution will be:
|
In my opinion we should do this before we release this feature, otherwise it's not transparent enough. |
Thanks for your thoughts on this. I agree that we won't be able to fully guarantee that the taker (app) will be able to pay for both executing the trade and the fee invoice. Since we want this to be atomic anyway and we know that we will eventually do so, I would advocate for keeping it as simple as possible for this non-atomic version. As such I would hesitate to add any complex logic around the current flow. Given the current state of the project, I still advocate for a very crude check before letting the user place the order because:
|
[snip]
I'm happy with the crude check for now; given that we want to display the fee it should be part of the calculation anyway. (sorry, could have pointed that out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comment, I am OK with merging this version, hence the approval, but I think changing it to pay after Finalized
(upon updating the order to Filled
) would be better.
We can also opt to experiment how often the user is charge without the execution succeeding, and if users actually complain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
864: feat: charge fee when opening a jit channel r=holzeis a=holzeis fixes #577 - The payment of the fee is not yet depicted as a special payment. This will be covered in a follow up PR after aligning with #863 - The funding transaction is only cached in memory TODOs that will be covered in follow up tickets. - [ ] https://github.com/get10101/meta/issues/172 - [ ] #873 - [ ] #883 ![Simulator Screenshot - iPhone 14 Pro - 2023-06-30 at 11 34 28](https://github.com/get10101/10101/assets/382048/d22e680c-889a-4dd4-9e3f-c6d0d84a53ea) Co-authored-by: Richard Holzeis <[email protected]>
863: Pay order-matching fee on the app r=luckysori a=luckysori Fixes #838[^1]. Fixes https://github.com/get10101/meta/issues/170. Fixes https://github.com/get10101/meta/issues/171. Fixes #884. We keep it simple for now: the coordinator returns an invoice and we trust the app to pay for it. Invoice generation rationale ---------------------------- We choose to let the coordinator generate an invoice rather than send an spontaneous payment from the app so that we can more easily update the coordinator fees without having to release a new version of the app. Payment timing rationale ------------------------ In patch 7c6a4bb the app was paying the invoice as soon as possible, but this had two downsides: 1. The app could end up paying for a trade that didn't come to fruition. 2. Updating the LN-DLC channel from the `rust-dlc` side and `rust-lightning` side simultaneously is not currently supported, so we could run into channel-breaking issues. As such, we eventually opted for the simple 74a0acf. The solution is not perfect and it assumes that the app will not be rebooted until the payment is sent, but it should be good enough for now. Other thoughts -------------- Eventually, the order-matching fee could be included in the payout curve or, perhaps even better, as a separate static output on the buffer transaction (this is currently not supported). --- These are some TODOs that could be tackled here or in follow-ups: - [x] Verify that the app can actually pay for both executing the trade and the order-matching fee _before_ executing the trade. - [x] Only claim the order-matching fee once the trade has been executed. #884 - [x] Tell the user about the estimated fee to be charged before they create the order. https://github.com/get10101/meta/issues/170 - [x] Show the user the charged fee on the success screen after executing the order. https://github.com/get10101/meta/issues/171 [^1]: Given that we can only charge taker fees for now. We should create a separate ticket for the maker once it's possible to do so. Co-authored-by: Lucas Soriano del Pino <[email protected]>
We keep it simple for now: the coordinator returns an invoice and we trust the app to pay for it. Invoice generation rationale ---------------------------- We choose to let the coordinator generate an invoice rather than send an spontaneous payment from the app so that we can more easily update the coordinator fees without having to release a new version of the app. Payment timing rationale ------------------------ The app pays the invoice as soon as the coordinator responds to the trade request successfully. For now we let the coordinator claim the payment immediately, but we could wait until the trade has actually been executed to _claim_ the payment. Claiming the payment later should be simple enough: let the coordinator remember the `PaymentHash` of the order-matching fee invoice when generating it and do not claim it automatically when receiving the corresponding `PaymentClaimable` event (store the preimage instead). Once the trade has been executed, look for the invoice in storage and finally claim the funds. Other thoughts -------------- Eventually, the order-matching fee could be included in the payout curve or, perhaps even better, as a separate static output on the buffer transaction (this is currently not supported).
This patch includes an explicit sleep that should be removed once we understand why we can fail to emit the `PaymentClaimable` event in the coordinator and we implement a fix. Another caveat is that the order-matching fee invoice is stored in memory, so we could theoretically end up closing the app before the payment goes through.
Canceled. |
bors r+ |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Fixes #8381.
Fixes https://github.com/get10101/meta/issues/170.
Fixes https://github.com/get10101/meta/issues/171.
Fixes #884.
We keep it simple for now: the coordinator returns an invoice and we trust the app to pay for it.
Invoice generation rationale
We choose to let the coordinator generate
an invoice rather than send an spontaneous payment from the app so that we can more easily update the coordinator fees without having to release a new version of the app.
Payment timing rationale
In patch 7c6a4bb the app was paying the invoice as soon as possible, but this had two downsides:
rust-dlc
side andrust-lightning
side simultaneously is not currently supported, so we could run into channel-breaking issues.As such, we eventually opted for the simple 74a0acf. The solution is not perfect and it assumes that the app will not be rebooted until the payment is sent, but it should be good enough for now.
Other thoughts
Eventually, the order-matching fee could be included in the payout curve or, perhaps even better, as a separate static output on the buffer transaction (this is currently not supported).
These are some TODOs that could be tackled here or in follow-ups:
Footnotes
Given that we can only charge taker fees for now. We should create a separate ticket for the maker once it's possible to do so. ↩