feat: add MetaSwap batch calldata enforcer - #201
Open
hanzel98 wants to merge 1 commit into
Open
Conversation
hanzel98
force-pushed
the
feat/metaswap-batch-calldata-enforcer
branch
from
August 30, 2026 00:13
b9e7058 to
6086455
Compare
Bind swap inputs and approval shape while preserving redeemer-selected route data for limit orders.
hanzel98
force-pushed
the
feat/metaswap-batch-calldata-enforcer
branch
from
August 30, 2026 18:33
6086455 to
579dd26
Compare
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.
Summary
MetaSwapBatchCalldataEnforcerfor canonicalDelegationManagerbatch redemptions.Behavior
Signed terms bind the MetaSwap target, input token, input amount, and approval shape. The enforcer requires
BATCH_DEFAULT_MODEand accepts only:The swap target, value, selector,
tokenFrom, andamountmust match the terms.aggregatorIdand routedataremain flexible.Usage
Add
LimitedCallsEnforcerto make the delegation one-shot. AddERC20BalanceChangeEnforcerorNativeBalanceChangeEnforcerto enforcetokenOutMin.Security
The delegate is trusted to choose safe swap data:
aggregatorIdand routedataare supplied by the redeemer and are not restricted by this enforcer. The enforcer binds the direct input approval and MetaSwap input fields, but it does not validate route side effects, adapter behavior, output amount, or a mutable MetaSwap implementation. A residual allowance may remain if MetaSwap spends less than the approved amount.Deployment and verification
The enforcer is deployed through the existing shared script:
The existing
script/verification/verify-enforcer-contracts.shremains the canonical verification flow after deployed addresses are recorded. No enforcer-specific script or environment variable is introduced.Test plan
approve(amount) + swapapprove(0) + approve(amount) + swapswap{ value: amount }DelegationManagerredemptionaggregatorIdand route dataLimitedCallsEnforcerandERC20BalanceChangeEnforcerNote
Medium Risk
New delegation path can approve up to a signed ERC-20 amount and call a configured MetaSwap contract while route data remains delegate-controlled; output and adapter behavior are not enforced by this caveat alone.
Overview
Adds
MetaSwapBatchCalldataEnforcer, a new caveat enforcer that lets a delegator sign off on a singleBATCH_DEFAULT_MODEredemption with a fixed MetaSwap input story while the redeemer still picks routing.Signed terms pack
metaSwap,tokenIn(address(0)= native),tokenInAmount, and an optional reset-approval flag.beforeHookaccepts only one of three batch shapes: nativeswapwith matchingmsg.value, ERC-20approve+swap, orapprove(0)+approve(amount)+swap. It pins targets, values,approvespender/amounts, and swaptokenFrom/amount;aggregatorIdand routedatastay unconstrained.The shared
DeployCaveatEnforcersscript deploys the new singleton,CaveatEnforcers.mddocuments behavior and trust assumptions (route/output not validated; residual allowance possible; compose withLimitedCallsEnforcerand balance-change enforcers). Tests cover validation edge cases, end-to-endDelegationManagerredemption, and composition withERC20BalanceChangeEnforcer/LimitedCallsEnforcer.Reviewed by Cursor Bugbot for commit 579dd26. Bugbot is set up for automated code reviews on this repo. Configure here.