Repository navigation
do not charge the relayer's gas twice, nor a deduction nobody took - #3154
Merged
Merged
Conversation
Two blockers from the deep audit, both mine. methodVersion 5 exists because v4 added a relayer's gas to the base on sponsored swaps, charging those rows twice by a median of 52 bps. The gross-up walked straight back into it on pump's EVM rows: the relayer signs and pays, its costs come out of the deduction already inside the grossed amount, and the gas was added on top. The audit measured network alone at 161.1 bps on a $2.03 buy. The accounting now follows FOMO's rule, which the spec already states. For a user committing G, pump deducting D, and the relayer paying g out of D: base G rather than G+g, network g, terminal D-g. The two still sum to the deduction, so nothing is invented and nothing is lost. A swap the user sent themselves is untouched, because there the gas is their own outlay on top. And the gross-up had no funding test: it checked the slug alone. The deduction is a property of the router rather than of the bridge path, which is why 6 of the 7 exactly readable spends were not relayer-sent, but that is a reason to believe it, not a reason to skip a test that is cheap and per-swap. If anything arrives at the router in the transaction, its sender funded the trade here and the spend is already what they committed: 4 of 40 looked like that. Grossing one of those adds 62 bps at $25 and 142 at $5, in the direction that makes the product look dearer. The gas test is written against the swap the audit recomputed from the chain, so its figures are the fixture.
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.
Two blockers from the deep audit of bench 268, both introduced by the gross-up.
The gas was charged twice
methodVersion5 exists because v4 did this on Solana: it added the whole network cost, including a relayer's on a sponsored swap, where the user spends no SOL and the terminal takes the gas out of the fee they already paid — charging those rows twice by a median of 52 bps.The gross-up walked back into it on pump's EVM rows. The audit measured network alone at 161.1 bps on a $2.03 buy.
The accounting now follows FOMO's rule, already in the spec. For a user committing G, pump deducting D, the relayer paying g out of D:
The two still sum to the deduction, so nothing is invented and nothing is lost. A swap the user sent themselves is untouched: there the gas is their own outlay on top.
The gross-up had no funding test
It checked the slug alone. The deduction is a property of the router rather than of the bridge path — 6 of the 7 exactly readable spends were not relayer-sent, and a locally funded trade would not land on
level − (0.05 + r·level)to 5e-7 at five different levels — but that is a reason to believe it, not a reason to skip a test that is cheap and per-swap.If anything arrives at the router in the transaction, its sender funded the trade there and the spend is already what they committed. 4 of 40 looked like that. Grossing one adds 62 bps at $25 and 142 at $5, in the direction that makes the product look dearer.
Tests
The gas test is written against the swap the audit recomputed from the chain (40.872485 → 41.097145, deduction 0.224660), so the audit's own figures are the fixture. It asserts that terminal plus network equals the deduction exactly, and that the base did not grow by the gas.