Skip to content

feat: MetaSwap order manager, signed exact windows, and gas baselines - #217

Draft
hanzel98 wants to merge 15 commits into
mainfrom
feat/metaswap-optimized-managers
Draft

hanzel98 wants to merge 15 commits into
mainfrom
feat/metaswap-optimized-managers

Conversation

@hanzel98

@hanzel98 hanzel98 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Gasless swaps and limit orders both redeem through DelegationManager with the production caveat set. That path is what this PR is trying to make cheaper. It adds several managers that sign the same permissions in a packed form, and it measures each one against the code that ships today.

Versions

  • FinalManager (MetaSwapManager.sol). Packed layout. Gasless calls redeemExactBatch with the full batch in calldata. Limit orders send the full approve and swap batch the same way.
  • Eip7710FinalManager (MetaSwapManager.sol). The same packed layout, redeemed through redeemDelegations. The batch sits in executionCallDatas.
  • OrderDelegationManager (MetaSwapOrderDelegationManager.sol). One manager for both flows. Gasless uses an ExactBatch intent. Limit orders use flexible settlement terms.
  • FlexibleSettlementEnforcer (MetaSwapFlexibleSettlementEnforcer.sol). Limit orders only. One delegation on DelegationManager. The enforcer checks the whole order.

Gas for every version is in MetaSwapGasComparisonsNoDirectRoute.md. That doc also links the production code each baseline was copied from.

Gas: FinalManager vs baselines

Flow Cold Later Overall
Gasless vs GaslessExecute 53.6% 61.6% 57.6%
Limit vs LimitOrderBaseline 71.2% 76.7% 74.0%

Cold is the first fill of that shape, in its own transaction. The nonce or id word is still zero, and the user's output-token balance is still zero. The router already holds the input token, and the fee wallet already holds both tokens. The swap route is 512 nonzero bytes. Later is the second fill, sent as the next transaction, with a new signature. The first fill already wrote those slots, so updating them costs less. The number is the gas the receipt charges, after the refund. The refund cannot exceed one fifth of the gas spent.

One manager for gasless swaps and limit orders, with tests, deployment, and verification.
The hash commits the whole batch, including each target and value, so ExactCalldata described only part of it.
Remove the id==0 bitmap skip so every FlexibleSettlement id, including 0,
burns the IdEnforcer-style bitmap and excludes sibling orders that share it.
Keep order-manager flexible gas measurements comparable to the
comparison harness after id 0 started burning the bitmap.
Keep the final, direct-route, and EIP-7710 managers next to the calldata-pinned limit baseline and the gasless exact self-call so later measurements use the same shapes.
Exact gasless batches now sign a timestamp window and a redeemer list
alongside the batch hash. The batch stays exact. The window and the
redeemer list are configurable per order.

- Packed managers (calldata and EIP-7710): the ExactBatch typehash
  includes validAfter, validUntil, and the redeemers. The exact path
  checks the redeemer and the window before it executes.
- MetaSwapOrderDelegationManager: exact terms carry the same window and
  redeemer list.
- Gas comparisons: measure gasless and limit fills against
  GaslessExecute and LimitOrderBaseline, cold and later. Drop
  SwapCalldataPinsInputGas.
- Docs: documents/MetaSwapGasComparisons.md and
  documents/MetaSwapGasComparisonsNoDirectRoute.md.
@hanzel98
hanzel98 requested a review from a team as a code owner November 16, 2026 16:06
@hanzel98 hanzel98 changed the title feat: sign validity window and redeemers on exact MetaSwap batches feat: MetaSwap order manager, signed exact windows, and gas baselines Nov 16, 2026
@hanzel98
hanzel98 marked this pull request as draft November 17, 2026 00:15
@hanzel98
hanzel98 requested a review from McOso November 17, 2026 00:16
…arisons

Keep the measured tables. Remove the three paragraphs that explain the
run conditions, the refund rule, and the isolate flag.
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.

1 participant