Skip to content

feat: add MetaSwap delegation manager for gasless swaps and limit orders - #207

Open
hanzel98 wants to merge 1 commit into
mainfrom
feat/metaswap-order-delegation-manager
Open

hanzel98 wants to merge 1 commit into
mainfrom
feat/metaswap-order-delegation-manager

Conversation

@hanzel98

@hanzel98 hanzel98 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds MetaSwapOrderDelegationManager for the two MetaSwap flows: gasless swaps and limit orders.
  • A gasless swap signs the exact batch hash, so the redeemer cannot change the calls. A limit order signs the settlement bounds, and the redeemer supplies the route.
  • Redemption costs less because these flows no longer go through the generic delegation loop and external caveat hooks. The checks those flows need are enforced by the manager.
Flow User signs Redeemer may change
Gasless swap The batch hash Nothing
Limit order Tokens, amounts, approval shape, recipient, redeemers, optional timestamp and id The route and aggregator id

A limit order still requires a listed redeemer, checks the approval and swap shape, and requires the signed minimum output. disabledDelegations remains the one-shot for both flows. A failed fill rolls back.

Gas

Estimated transaction gas: 21,000 plus calldata plus execution. Each row is the same swap.

Gasless swaps

Today the signed call is a self-call into the 7702 account, and that call runs the batch. The order manager signs the batch hash and runs the batch directly.

Swap Delegation Manager self-call Order manager Saved
Native ETH in, token out 207,406 119,846 87,560 (42.2%)
Token in, native ETH out 244,371 150,307 94,064 (38.5%)
Token in, token out 267,138 172,834 94,304 (35.3%)
Token in, token out, with reset 280,704 179,889 100,815 (35.9%)

Limit orders

Today this is separate root delegations on DelegationManager: an approval, then a swap. The flexible settlement enforcer collapses that into one delegation. This manager does too, and it is cheaper than both.

Swap Separate roots Delegation Manager + flexible settlement enforcer Order manager
Native ETH in, token out 400,781 180,323 154,924
Token in, native ETH out 547,368 230,757 185,275
Token in, token out 553,429 235,372 209,780
Token in, token out, with reset 578,824 244,078 218,447

Saved against the separate roots:

Swap Enforcer Order manager
Native ETH in, token out 220,458 (55.0%) 245,857 (61.3%)
Token in, native ETH out 316,611 (57.8%) 362,093 (66.2%)
Token in, token out 318,057 (57.5%) 343,649 (62.1%)
Token in, token out, with reset 334,746 (57.8%) 360,377 (62.3%)

The order manager is also cheaper than the enforcer on every shape:

Swap Saved Percent
Native ETH in, token out 25,399 14.1%
Token in, native ETH out 45,482 19.7%
Token in, token out 25,592 10.9%
Token in, token out, with reset 25,631 10.5%

Scope

  • One root delegation, one caveat, batch mode
  • Gasless expiry stays off-chain. A limit order can set a timestamp window
  • id == 0 is one-shot by delegation hash. A non-zero id also blocks sibling orders that share it. Cancelling does not burn the id
  • No delegation chains, try mode, pause, or enableDelegation
  • An EIP-7702 account that uses this manager redeems through it instead of DelegationManager

Test plan

  • MetaSwapOrderDelegationManagerTest passes, including both flows and the redemption guards
  • Dry-run script/DeployMetaSwapOrderDelegationManager.s.sol
  • Confirm the verify script reads META_SWAP_ORDER_DELEGATION_MANAGER_ADDRESS

@hanzel98
hanzel98 requested a review from a team as a code owner September 11, 2026 01:50

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8e74755. Configure here.

Comment thread src/enforcers/MetaSwapPrefundEnforcer.sol Outdated
@hanzel98
hanzel98 force-pushed the feat/metaswap-order-delegation-manager branch from fa2e317 to 68a79cb Compare October 1, 2026 20:21
@hanzel98 hanzel98 changed the title feat: experimental MetaSwap order delegation manager feat: MetaSwap Order Delegation Manager Oct 1, 2026
One manager for gasless swaps and limit orders, with tests, deployment, and verification.
@hanzel98
hanzel98 force-pushed the feat/metaswap-order-delegation-manager branch from 68a79cb to 28c3d2e Compare October 1, 2026 20:25
@hanzel98 hanzel98 changed the title feat: MetaSwap Order Delegation Manager feat: add MetaSwap delegation manager for gasless swaps and limit orders Oct 1, 2026
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