server/dex: assign live swap fee rates to dynamic-tx-fee assets#8
Open
peterzen wants to merge 1 commit into
Open
server/dex: assign live swap fee rates to dynamic-tx-fee assets#8peterzen wants to merge 1 commit into
peterzen wants to merge 1 commit into
Conversation
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]>
There was a problem hiding this comment.
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 inFeeRate. - 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Server half of the fee-pipeline fix: EVM matches are now assigned a live fee-rate estimate capped at maxFeeRate, instead of the static
maxFeeRateconfig 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.