AggregatorExecAdapter
Inherits: IAggregatorExecAdapter
Title: AggregatorExecAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from LI.FI (https://github.com/lifinance/contracts)
Generic swap/bridge EXECUTION facet: forwards user-supplied, off-chain-built calldata to an
admin-ALLOW-LISTED (aggregator, selector) pair (the LI.FI Diamond is the canonical first
aggregator). 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. NOT an ERC-7786 gateway.
Stateless delegator — logic/storage live in AggregatorExecAdapterLib. execute is nonReentrant with
strict CEI: funds come only from msg.sender, the aggregator gets an EXACT, immediately-reset approval,
and every leftover (unspent input, output delta, unspent native) is swept back to the caller.
Notes:
- lattice-version: 0.1.0
- lattice-source: LI.FI
Functions
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 virtual;Parameters
| Name | Type | Description |
|---|---|---|
| aggregator | address | |
| selector | bytes4 | |
| allowed | bool |
isAllowedCall
Whether the (aggregator, selector) pair is allow-listed for execute.
function isAllowedCall(address aggregator, bytes4 selector) external view virtual returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| aggregator | address | |
| selector | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | 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 virtual 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. |
exportSelectors
ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).
Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches
forge inspect AggregatorExecAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
execute(address,address,uint256,address,bytes) 0x8e845c30
isAllowedCall(address,bytes4) 0x4cecd2a5
setAllowedCall(address,bytes4,bool) 0x2b370b67
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |