feat: add MetaSwap batch calldata enforcer - #201
Open
hanzel98 wants to merge 1 commit into
Open
Conversation
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 00:13
b9e7058 to
6086455
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
The enforcer authorizes ERC-20 approvals to MetaSwap within signed bounds while leaving swap route data delegate-controlled, so delegators must trust MetaSwap/adapters and may retain residual allowance; misuse is mitigated by documentation and recommended companion enforcers.
Overview
Adds
MetaSwapBatchCalldataEnforcer, a new caveat that limitsBATCH_DEFAULT_MODEredemptions to fixed MetaSwap swap batches while the redeemer can still pickaggregatorIdand routedata.Signed terms pack MetaSwap address, input token (
address(0)for native), input amount, and whether the batch must useapprove(0)beforeapprove(amount). The hook enforces batch length and pins approval/swap targets, values, selectors, spender, and swaptokenFrom/amount; it does not cap swap output or audit route side effects.Docs describe the allowed shapes and trust assumptions (compose with
LimitedCallsEnforcerand balance-change enforcers). Deploy script deploys the new singleton. Tests cover happy paths, tampering, fullDelegationManagerredemption, and pairing withLimitedCallsEnforcerandERC20BalanceChangeEnforcer.Reviewed by Cursor Bugbot for commit 6086455. Bugbot is set up for automated code reviews on this repo. Configure here.