TokenSwapAdapter
Title: TokenSwapAdapter
Abstract contract for token swap adapters
Functions
executeTokenSwap
Executes series of token swaps and returns the hashes of the orders submitted/executed
function executeTokenSwap(ExternalTrade[] calldata externalTrades, bytes calldata data) external payable virtual;
Parameters
| Name | Type | Description |
|---|---|---|
externalTrades | ExternalTrade[] | The external trades to execute |
data | bytes |
completeTokenSwap
Completes the token swaps by confirming each order settlement and claiming the resulting tokens (if necessary).
This function must return the exact amounts of sell tokens and buy tokens claimed per trade. If the adapter operates asynchronously (e.g., CoWSwap), this function should handle the following:
- Cancel any unsettled trades to prevent further execution.
- Claim the remaining tokens from the unsettled trades.
function completeTokenSwap(ExternalTrade[] calldata externalTrades)
external
payable
virtual
returns (uint256[2][] memory claimedAmounts);
Parameters
| Name | Type | Description |
|---|---|---|
externalTrades | ExternalTrade[] | The external trades that were executed and need to be settled. |
Returns
| Name | Type | Description |
|---|---|---|
claimedAmounts | uint256[2][] | A 2D array where each element contains the claimed amounts of sell tokens and buy tokens for each corresponding trade in externalTrades. The first element of each sub-array is the claimed sell amount, and the second element is the claimed buy amount. |