-
Notifications
You must be signed in to change notification settings - Fork 40
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
Maker ignores premium set in SwapInAgreement message #151
Comments
One other question; why is "locktime" set in |
Good catch! I guess you found something that we put in the spec a long time ago which we haven't thought through nor implemented by now. This was some kind of placeholder for us to not forget to talk about this eventually. Do you think the way the premium is negotiated right now is the way to go or should we have a discussion about how to design the premium and the negotiation for it? |
This probably deserves some discussion. A good default goal is that the swap proposer pays the on-chain fees for the swap receiver. It gets tricky if the sender and receiver disagree on how to compute those fees. We can look to how on-chain fees in Lightning work for how to approach this problem. Calculating the weights of a nominal transaction should be easier for PeerSwap since there are no HTLCs or other variables to consider. The fee environment is also less likely to change within the period of time the swap is in progress. For example, when a maker proposes a swap-in to a taker, they should add to the swap amount in the opening transaction output the premium requested by the taker in the swap-in-agreement message. This premium should equal the amount of on-chain fees the taker expects to spend for the claim-by-invoice tx. By accepting the swap, the taker should get the amount promised on-chain, after fees. Likewise, if the taker proposes a swap-out to the maker, then the maker should include the on-chain fees for the opening tx and pay-by-csv tx in the off-chain premium they expect for their fee invoice. This prevents them from being out-of-pocket on fees even if the swap-out proposer does not conclude the swap. I'm currently using the following values for nominal transaction sizes, but these should be verified: val claimByInvoiceTxWeight = 593 // TODO: add test to confirm this is the actual weight of the claimByInvoice tx in vBytes
val openingTxWeight = 610 // TODO: compute and add test to confirm this is the actual weight of the opening tx in vBytes I realize now that I am not including a Each party should perform the same calculation as their counter party to verify that the requested fee/premium is not unreasonable. I think there should be a setting for the maximum percent the feeRatePerKw can exceed what is expected when calculating these values. If the counter party asks for a higher amount, the swap is canceled with a message to indicate the fee mismatch. To be extra adversarial, you just fail the swap without saying why - otherwise your counter party will always increase fees to just below your threshold. Until we get something sorted out, I'll just set these fees to 0 so I can continue integration testing. |
A more meta part of this discussion includes the question: "why would anyone propose a swap if they have to pay the on-chain fees?" . The answer should be that after the swap, they expect to earn in transaction fees more then they paid in swap premium. Or perhaps because this is the lowest cost way to buy inbound (or outbound) liquidity. |
I'm doing integration testing between PeerSwap CLN commit d1d88e4 and Eclair Swap Plugin SNAPSHOT 49823db. This testing was done with regtest.
Setup: Alice = Eclair node, Carol = CLN node
Repo:
Negotiation proceeds to point where Alice validates the OpeningTx and fails because the output amount is 100001, even though Alice requested a premium of 22237 sats, which is computed by Alice as
feeRatePerKw * claimByInvoiceTxWeight / 1000
.The opening tx sent by CLN was:
The text was updated successfully, but these errors were encountered: