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

Trade fee optimisation (make explicit refund fee) for swaps v1 #2124

Open
dimxy opened this issue May 21, 2024 · 0 comments
Open

Trade fee optimisation (make explicit refund fee) for swaps v1 #2124

dimxy opened this issue May 21, 2024 · 0 comments

Comments

@dimxy
Copy link
Collaborator

dimxy commented May 21, 2024

For swaps MM2 maintains trade fee variable calculated both for the taker and maker. It indicates tx fee to spend on swap payment and refund transactions (see maker_payment_trade_fee and taker_payment_trade_fee vars).
The trade fee vars contain sum of both payment tx and refund tx fee. However it may not be always accurate.
Consider where trade fee is used:

  • to generate a trade_preimage transaction returned to user to review and sign, see taker_swap_trade_preimage(). Seems it's not good to ask the user to allocate total fee for payment tx only.
  • to calculate max total value available for swap (see calc_max_maker_vol and calc_max_taker_vol fn) and check balance for swap (see check_balance_for_maker_swap and check_balance_for_taker_swap).
  • to get locked_amount for the swap.

Before PR #2051 swap trade fee always included refund fee.
In the PR #2051 the trade_preimage rpcs now return trade fee w/o the refund fee. But inside those rpcs check balance is called for which refund fee is needed. So it's better to have both payment and refund fee values separate.
Above is for swaps v1.

(For swaps v2, in currently implemented utxo case, trade fee var is used to check max balance for the swap. Actual tx fee is auto estimated in tx creation process, so no need to break trade fee into payment and refund tx fee.)

A related issue is #1848 with a more general task to reduce tx fees.

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

No branches or pull requests

1 participant