Skip to content

ISwapper

Git Source

Interface for token swapping functionality

This interface defines the standard for swapping one token for another. Implementations of this interface handle the actual swap logic and routing, which may involve DEX integrations, aggregators, or other swap mechanisms.

Functions

swap

Swaps one token for another

This function performs a token swap from assetIn to assetOut. The caller must transfer amountIn of assetIn to the swapper contract before calling this function. The swapper will then send the resulting assetOut tokens to the specified recipient.

function swap(
    address assetIn,
    uint256 amountIn,
    address assetOut,
    uint256 minAmountOut,
    address recipient,
    bytes calldata swapperParams
)
    external
    returns (uint256 amountOut);
Parameters
NameTypeDescription
assetInaddressThe address of the input token to be swapped
amountInuint256The amount of input tokens to swap
assetOutaddressThe address of the output token to receive
minAmountOutuint256The minimum amount of output tokens expected (slippage protection)
recipientaddressThe address that will receive the output tokens
swapperParamsbytesAdditional data specific to the swap implementation (e.g., DEX router data, paths)
Returns
NameTypeDescription
amountOutuint256The actual amount of output tokens received from the swap

Events

Swap

Emitted after a successful token swap

event Swap(address indexed assetIn, address indexed assetOut, uint256 amountIn, uint256 amountOut);