Skip to content

server/dex: assign live swap fee rates to dynamic-tx-fee assets#8

Open
peterzen wants to merge 1 commit into
masterfrom
evm-live-swap-feerate
Open

server/dex: assign live swap fee rates to dynamic-tx-fee assets#8
peterzen wants to merge 1 commit into
masterfrom
evm-live-swap-feerate

Conversation

@peterzen

@peterzen peterzen commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Server half of the fee-pipeline fix: EVM matches are now assigned a live fee-rate estimate capped at maxFeeRate, instead of the static maxFeeRate config value verbatim.

This restores maxFeeRate to its documented role as a reserve bound (spec/fundamentals.mediawiki), so operators can set it high as pure insurance without inflating client reserves, order gating, or orphaning resting orders on config changes. Adds a rate-limited operator warning when the live estimate exceeds half of maxFeeRate.

Since 6e18f18, assets supporting dynamic tx fees (EIP-1559) were assigned
the configured maxFeeRate verbatim as the match swap fee rate, on the
grounds that an overshooting fee cap is refunded on-chain and a maximal cap
is immune to fee movement during settlement. But the cap has off-chain
costs that grow with the configured value: clients reserve funds per lot at
this rate, gate order placement on it, and lock it into resting orders. This
pressures operators to configure maxFeeRate low, and a network fee spike
above the configured value renders every swap transaction unminable.

Assign the live market estimate, capped at maxFeeRate, as was already the
case for static-fee assets, restoring maxFeeRate to its documented role as
a reserve bound. Fee movement after match time is handled client-side,
where the wallet may raise its fee cap above the assigned rate up to its
order reserves (ValidateFeeRate only enforces the assigned rate as a
floor).

Also log a rate-limited operator warning when the live estimate exceeds
half of maxFeeRate, signaling that the configured bound is eroding.

Co-Authored-By: Claude Fable 5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the server-side fee pipeline so swap fee rates for dynamic-tx-fee assets (e.g. EIP-1559 chains) are assigned from the live network estimate, capped by maxFeeRate, rather than using maxFeeRate verbatim. This restores maxFeeRate to a true “reserve bound” while reducing unnecessary client-side over-reserving and order gating.

Changes:

  • Assign swap fee rate from FeeRate(ctx) for all assets, including dynamic-tx-fee assets, with capping handled in FeeRate.
  • Add a per-asset, rate-limited operator warning when the live estimate rises above half of maxFeeRate.
  • Add unit coverage validating live-rate assignment, capping behavior, stashed-rate behavior on increases, and error-path behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
server/dex/feemgr.go Switches dynamic-tx-fee swap fee assignment to live fee estimates (capped), and adds a rate-limited operator warning as the estimate approaches maxFeeRate.
server/dex/feemgr_test.go Adds focused tests for the new live swap-fee-rate assignment behavior, including cap and stashed-rate handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants