@@ -18,11 +18,6 @@ import { CALLTYPE_SINGLE, EXECTYPE_DEFAULT } from "../utils/Constants.sol";
1818/**
1919 * @title DelegationMetaSwapAdapter
2020 * @notice Acts as a middleman to orchestrate token swaps using delegations and an aggregator (MetaSwap).
21- * @dev This contract depends on an ArgsEqualityCheckEnforcer. The root delegation must include a caveat
22- * with this enforcer as its first element. Its arguments indicate whether the swap should enforce the token
23- * whitelist ("Token-Whitelist-Enforced") or not ("Token-Whitelist-Not-Enforced"). The root delegator is
24- * responsible for including this enforcer to signal the desired behavior.
25- *
2621 * @dev This adapter is intended to be used with the Swaps API. Accordingly, all API requests must include a valid
2722 * signature that incorporates an expiration timestamp. The signature is verified during swap execution to ensure
2823 * that it is still valid.
@@ -40,30 +35,18 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
4035
4136 ////////////////////////////// State //////////////////////////////
4237
43- /// @dev Constant value used to enforce the token whitelist
44- string public constant WHITELIST_ENFORCED = "Token-Whitelist-Enforced " ;
45-
46- /// @dev Constant value used to avoid enforcing the token whitelist
47- string public constant WHITELIST_NOT_ENFORCED = "Token-Whitelist-Not-Enforced " ;
48-
4938 /// @dev The DelegationManager contract that has root access to this contract
5039 IDelegationManager public immutable delegationManager;
5140
5241 /// @dev The MetaSwap contract used to swap tokens
5342 IMetaSwap public immutable metaSwap;
5443
55- /// @dev The enforcer used to compare args and terms
56- address public immutable argsEqualityCheckEnforcer;
57-
5844 /// @dev Address of the API signer account.
5945 address public swapApiSigner;
6046
6147 /// @dev Indicates if a token is allowed to be used in the swaps
6248 mapping (IERC20 token = > bool allowed ) public isTokenAllowed;
6349
64- /// @dev A mapping indicating if an aggregator ID hash is allowed.
65- mapping (bytes32 aggregatorIdHash = > bool allowed ) public isAggregatorAllowed;
66-
6750 ////////////////////////////// Events //////////////////////////////
6851
6952 /// @dev Emitted when the DelegationManager contract address is set.
@@ -72,18 +55,12 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
7255 /// @dev Emitted when the MetaSwap contract address is set.
7356 event SetMetaSwap (IMetaSwap indexed newMetaSwap );
7457
75- /// @dev Emitted when the Args Equality Check Enforcer contract address is set.
76- event SetArgsEqualityCheckEnforcer (address indexed newArgsEqualityCheckEnforcer );
77-
7858 /// @dev Emitted when the contract sends tokens (or native tokens) to a recipient.
7959 event SentTokens (IERC20 indexed token , address indexed recipient , uint256 amount );
8060
8161 /// @dev Emitted when the allowed token status changes for a token.
8262 event ChangedTokenStatus (IERC20 token , bool status );
8363
84- /// @dev Emitted when the allowed aggregator ID status changes.
85- event ChangedAggregatorIdStatus (bytes32 indexed aggregatorIdHash , string aggregatorId , bool status );
86-
8764 /// @dev Emitted when the Signer API is updated.
8865 event SwapApiSignerUpdated (address indexed newSigner );
8966
@@ -119,9 +96,6 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
11996 /// @dev Error when the tokenTo is not in the allow list.
12097 error TokenToIsNotAllowed (IERC20 token );
12198
122- /// @dev Error when the aggregator ID is not in the allow list.
123- error AggregatorIdIsNotAllowed (string aggregatorId );
124-
12599 /// @dev Error when the input arrays of a function have different lengths.
126100 error InputLengthsMismatch ();
127101
@@ -137,9 +111,6 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
137111 /// @dev Error when the amountFrom in the api data and swap data do not match.
138112 error AmountFromMismatch ();
139113
140- /// @dev Error when the delegations do not include the ArgsEqualityCheckEnforcer
141- error MissingArgsEqualityCheckEnforcer ();
142-
143114 /// @dev Error thrown when API signature is invalid.
144115 error InvalidApiSignature ();
145116
@@ -176,30 +147,25 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
176147 * @param _delegationManager The address of the trusted DelegationManager contract has privileged access to call
177148 * executeByExecutor based on a given delegation.
178149 * @param _metaSwap The address of the trusted MetaSwap contract.
179- * @param _argsEqualityCheckEnforcer The address of the ArgsEqualityCheckEnforcer contract.
180150 */
181151 constructor (
182152 address _owner ,
183153 address _swapApiSigner ,
184154 IDelegationManager _delegationManager ,
185- IMetaSwap _metaSwap ,
186- address _argsEqualityCheckEnforcer
155+ IMetaSwap _metaSwap
187156 )
188157 Ownable (_owner)
189158 {
190- if (
191- _swapApiSigner == address (0 ) || address (_delegationManager) == address (0 ) || address (_metaSwap) == address (0 )
192- || _argsEqualityCheckEnforcer == address (0 )
193- ) revert InvalidZeroAddress ();
159+ if (_swapApiSigner == address (0 ) || address (_delegationManager) == address (0 ) || address (_metaSwap) == address (0 )) {
160+ revert InvalidZeroAddress ();
161+ }
194162
195163 swapApiSigner = _swapApiSigner;
196164 delegationManager = _delegationManager;
197165 metaSwap = _metaSwap;
198- argsEqualityCheckEnforcer = _argsEqualityCheckEnforcer;
199166 emit SwapApiSignerUpdated (_swapApiSigner);
200167 emit SetDelegationManager (_delegationManager);
201168 emit SetMetaSwap (_metaSwap);
202- emit SetArgsEqualityCheckEnforcer (_argsEqualityCheckEnforcer);
203169 }
204170
205171 ////////////////////////////// External Methods //////////////////////////////
@@ -218,15 +184,8 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
218184 * - expiration Timestamp after which the signature is invalid.
219185 * - signature Signature validating the provided apiData.
220186 * @param _delegations Array of Delegation objects containing delegation-specific data, sorted leaf to root.
221- * @param _useTokenWhitelist Indicates whether the tokens must be validated or not.
222187 */
223- function swapByDelegation (
224- SignatureData calldata _signatureData ,
225- Delegation[] memory _delegations ,
226- bool _useTokenWhitelist
227- )
228- external
229- {
188+ function swapByDelegation (SignatureData calldata _signatureData , Delegation[] memory _delegations ) external {
230189 _validateSignature (_signatureData);
231190
232191 (string memory aggregatorId_ , IERC20 tokenFrom_ , IERC20 tokenTo_ , uint256 amountFrom_ , bytes memory swapData_ ) =
@@ -235,10 +194,6 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
235194
236195 if (delegationsLength_ == 0 ) revert InvalidEmptyDelegations ();
237196 if (tokenFrom_ == tokenTo_) revert InvalidIdenticalTokens ();
238-
239- _validateTokens (tokenFrom_, tokenTo_, _delegations, _useTokenWhitelist);
240-
241- if (! isAggregatorAllowed[keccak256 (abi.encode (aggregatorId_))]) revert AggregatorIdIsNotAllowed (aggregatorId_);
242197 if (_delegations[0 ].delegator != msg .sender ) revert NotLeafDelegator ();
243198
244199 // Prepare the call that will be executed internally via onlySelf
@@ -399,27 +354,6 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
399354 }
400355 }
401356
402- /**
403- * @notice Updates the allowed (whitelist) status of multiple aggregator IDs in a single call.
404- * @dev Only callable by the contract owner.
405- * @param _aggregatorIds Array of aggregator ID strings.
406- * @param _statuses Corresponding array of booleans (true = allowed, false = disallowed).
407- */
408- function updateAllowedAggregatorIds (string [] calldata _aggregatorIds , bool [] calldata _statuses ) external onlyOwner {
409- uint256 aggregatorsLength_ = _aggregatorIds.length ;
410- if (aggregatorsLength_ != _statuses.length ) revert InputLengthsMismatch ();
411-
412- for (uint256 i = 0 ; i < aggregatorsLength_; ++ i) {
413- bytes32 aggregatorIdHash_ = keccak256 (abi.encode (_aggregatorIds[i]));
414- bool status_ = _statuses[i];
415- if (isAggregatorAllowed[aggregatorIdHash_] != status_) {
416- isAggregatorAllowed[aggregatorIdHash_] = status_;
417-
418- emit ChangedAggregatorIdStatus (aggregatorIdHash_, _aggregatorIds[i], status_);
419- }
420- }
421- }
422-
423357 ////////////////////////////// Private/Internal Methods //////////////////////////////
424358
425359 /**
@@ -455,42 +389,6 @@ contract DelegationMetaSwapAdapter is ExecutionHelper, Ownable2Step {
455389 emit SentTokens (_token, _recipient, _amount);
456390 }
457391
458- /**
459- * @dev Validates that the tokens are whitelisted or not based on the _useTokenWhitelist flag.
460- * @dev Adds the argsCheckEnforcer args to later validate if the token whitelist must be have been used or not.
461- * @param _tokenFrom The input token of the swap.
462- * @param _tokenTo The output token of the swap.
463- * @param _delegations The delegation chain; the last delegation must include the ArgsEqualityCheckEnforcer.
464- * @param _useTokenWhitelist Flag indicating whether token whitelist checks should be enforced.
465- */
466- function _validateTokens (
467- IERC20 _tokenFrom ,
468- IERC20 _tokenTo ,
469- Delegation[] memory _delegations ,
470- bool _useTokenWhitelist
471- )
472- private
473- view
474- {
475- // The Args Enforcer must be the first caveat in the root delegation
476- uint256 lastIndex_ = _delegations.length - 1 ;
477- if (
478- _delegations[lastIndex_].caveats.length == 0
479- || _delegations[lastIndex_].caveats[0 ].enforcer != argsEqualityCheckEnforcer
480- ) {
481- revert MissingArgsEqualityCheckEnforcer ();
482- }
483-
484- // The args are set by this contract depending on the useTokenWhitelist flag
485- if (_useTokenWhitelist) {
486- if (! isTokenAllowed[_tokenFrom]) revert TokenFromIsNotAllowed (_tokenFrom);
487- if (! isTokenAllowed[_tokenTo]) revert TokenToIsNotAllowed (_tokenTo);
488- _delegations[lastIndex_].caveats[0 ].args = abi.encode (WHITELIST_ENFORCED);
489- } else {
490- _delegations[lastIndex_].caveats[0 ].args = abi.encode (WHITELIST_NOT_ENFORCED);
491- }
492- }
493-
494392 /**
495393 * @dev Internal helper to decode aggregator data from `apiData`.
496394 * @param _apiData Bytes that includes aggregatorId, tokenFrom, amountFrom, and the aggregator swap data.
0 commit comments