IAggregatorExecAdapter
Title: IAggregatorExecAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from LI.FI (https://github.com/lifinance/contracts)
Admin / read / action surface of the generic swap/bridge EXECUTION adapter. It forwards
user-supplied calldata (built off-chain by an aggregator's API/SDK — the LI.FI Diamond being the
canonical first aggregator) to an admin-ALLOW-LISTED (aggregator, selector) pair. This is the most
security-sensitive adapter in the suite: it makes an ARBITRARY external call from a fund-holding
diamond, so the whole design is confused-deputy prevention. It is NOT an ERC-7786 gateway.
TRUST MODEL: the diamond only ever exposes msg.sender-supplied funds plus an EXACT, immediately-reset
approval. The (aggregator, selector) allow-list is the sole authorization primitive; the calldata
body is opaque and untrusted. address(0) and address(this) can never be allow-listed (the latter
would let crafted calldata re-enter privileged facets). After every call the input allowance is reset
to 0 and all leftovers (unspent input, output delta, unspent native) are swept back to msg.sender.
Functions
isAllowedCall
Whether the (aggregator, selector) pair is allow-listed for execute.
function isAllowedCall(address aggregator, bytes4 selector) external view returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| aggregator | address | |
| selector | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
setAllowedCall
Toggles allow-listing of (aggregator, selector). Admin only. Reverts
AggregatorExecInvalidAggregator for address(0) / address(this).
function setAllowedCall(address aggregator, bytes4 selector, bool allowed) external;Parameters
| Name | Type | Description |
|---|---|---|
| aggregator | address | |
| selector | bytes4 | |
| allowed | bool |
execute
Pulls amount of inputToken from msg.sender, approves aggregator for EXACTLY that amount,
forwards callData (its leading selector must be allow-listed for aggregator), then resets the
approval to 0 and sweeps every leftover (unspent input, output delta, unspent native) back to
msg.sender. Strict CEI under a reentrancy guard. Reverts bubble up from the aggregator verbatim.
function execute(
address aggregator,
address inputToken,
uint256 amount,
address outputToken,
bytes calldata callData
) external payable returns (bytes memory ret);Parameters
| Name | Type | Description |
|---|---|---|
| aggregator | address | The allow-listed aggregator target (e.g. the LI.FI Diamond). |
| inputToken | address | The token pulled from the caller and approved to the aggregator (address(0) = native). |
| amount | uint256 | The exact amount of inputToken to pull and approve. |
| outputToken | address | The token the caller expects back; its balance DELTA is swept out (address(0) = none). |
| callData | bytes | The opaque aggregator calldata (built off-chain); bytes4(callData) is the gated selector. |
Returns
| Name | Type | Description |
|---|---|---|
| ret | bytes | The raw return data of the aggregator call. |
Events
AllowedCallSet
Emitted when the admin toggles an (aggregator, selector) allow-list entry.
event AllowedCallSet(address indexed aggregator, bytes4 indexed selector, bool allowed);Parameters
| Name | Type | Description |
|---|---|---|
| aggregator | address | |
| selector | bytes4 | |
| allowed | bool |
AggregatorCall
Emitted when a swap/bridge is executed against an allow-listed aggregator.
event AggregatorCall(
address indexed sender,
address indexed aggregator,
bytes4 indexed selector,
address inputToken,
uint256 amount,
address outputToken
);Parameters
| Name | Type | Description |
|---|---|---|
| sender | address | |
| aggregator | address | |
| selector | bytes4 | |
| inputToken | address | |
| amount | uint256 | |
| outputToken | address |
Errors
AggregatorExecZeroAdmin
The admin was the zero address at init.
error AggregatorExecZeroAdmin();AggregatorExecInvalidAggregator
An aggregator of address(0) or address(this) may never be allow-listed (confused-deputy guard).
error AggregatorExecInvalidAggregator(address aggregator);Parameters
| Name | Type | Description |
|---|---|---|
| aggregator | address |
AggregatorExecEmptyCallData
The supplied calldata was shorter than a 4-byte selector.
error AggregatorExecEmptyCallData();AggregatorExecNotAllowed
The (aggregator, selector) pair is not on the allow-list.
error AggregatorExecNotAllowed(address aggregator, bytes4 selector);Parameters
| Name | Type | Description |
|---|---|---|
| aggregator | address | |
| selector | bytes4 |
AggregatorExecNativeTransferFailed
A native-value transfer to msg.sender (leftover sweep) failed.
error AggregatorExecNativeTransferFailed();