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

Fix fees shown for send chain swaps #641

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

danielgranhao
Copy link
Contributor

No description provided.

// overpayments, we use the actual claim value as the final received amount
// for fee calculation.
PaymentType::Receive => s.payer_amount_sat - tx.amount_sat,
PaymentType::Send => s.payer_amount_sat - s.receiver_amount_sat,
Copy link
Member

Choose a reason for hiding this comment

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

Should we take the (tx.amount_sat + tx.feez_sat) instead of payer_amount_sat in the case of Send? Or you think the current approach is cleaner and more clear? I am tending to think the current code is clearer, just looking for another opinion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The tx fees_sat would only cover the lockup fee, not the boltz fees also

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the amount_sat is also incorrect in the send cases. It should reflect the amount received and the fees_sat the total fees to send that amount

Copy link
Member

Choose a reason for hiding this comment

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

@dangeross In the case of send isn't the tx is the lockup tx? In that case isn't the tx.amount_sat + tx.fee_sat is the total amount sent out of the wallet (e.g payer amount)? The boltz fees should be part of the amount_sat IIUC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we take the (tx.amount_sat + tx.feez_sat) instead of payer_amount_sat in the case of Send? Or you think the current approach is cleaner and more clear? I am tending to think the current code is clearer, just looking for another opinion.

@roeierez The values of tx.amount_sat and s.payer_amount_sat are the same (the tx.amount_sat includes the fees IIUC), so adding the tx fees on top would be incorrect. But yes, we could use tx.amount_sat instead of s.payer_amount_sat. I don't have a strong preference. We can keep it like this.

I think the amount_sat is also incorrect in the send cases. It should reflect the amount received and the fees_sat the total fees to send that amount

@dangeross I was thinking about this, and it depends on how we define the amount_sat field. Is it the amount a user decided to receive/send? Or the amount that a user actually receives/spends? Because of fees, for sending, these options are different. Our current approach is the latter. We can discuss if we want to change to the former. Regardless, as long as the meaning of the field is clear to the SDK integrators, it doesn't make any difference, as they can easily calculate the alternative value.

Copy link
Member

Choose a reason for hiding this comment

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

@danielgranhao I am not sure tx.amount_sat (in the case of sending) contains the onchain fees for the lockup transaction which actually is expressed in the fee_sat.
So IIUC the total amount sent out of the user wallet (e.g payer_amount_sat) should be tx.amount_sat (which includes the tx output amount and the boltz service fees) plus the fee_sat which is the tx lockup onchain fees.
Nevertheless I think the current approach is clean and IMO we can leave it as is.

@roeierez roeierez added this to the v0.6.0 milestone Jan 6, 2025
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

@danielgranhao danielgranhao merged commit eadcdbf into main Jan 7, 2025
9 checks passed
@danielgranhao danielgranhao deleted the fix-chain-swap-fee-display branch January 7, 2025 10:13
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.

3 participants