CenturionDEX
Launch App

ISwapRouter

Last modified:

Functions for swapping tokens via CenturionDEX v3

Parameter Structs

Note that fee is in hundredths of basis points (e.g. the fee for a pool at the 0.3% tier is 3000; the fee for a pool at the 0.01% tier is 100).

ExactInputSingleParams

    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

ExactInputParams

   struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

ExactOutputSingleParams

    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

ExactOutputParams

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

Functions

exactInputSingle

  function exactInputSingle(
    struct ISwapRouter.ExactInputSingleParams params
  ) external returns (uint256 amountOut)

Swaps amountIn of one token for as much as possible of another token

Parameters:

NameTypeDescription
paramsstruct ISwapRouter.ExactInputSingleParamsThe parameters necessary for the swap, encoded as ExactInputSingleParams in calldata

Return Values:

NameTypeDescription
amountOutstruct ISwapRouter.ExactInputSingleParamsThe amount of the received token

exactInput

  function exactInput(
    struct ISwapRouter.ExactInputParams params
  ) external returns (uint256 amountOut)

Swaps amountIn of one token for as much as possible of another along the specified path

Parameters:

NameTypeDescription
paramsstruct ISwapRouter.ExactInputParamsThe parameters necessary for the multi-hop swap, encoded as ExactInputParams in calldata

Return Values:

NameTypeDescription
amountOutstruct ISwapRouter.ExactInputParamsThe amount of the received token

exactOutputSingle

  function exactOutputSingle(
    struct ISwapRouter.ExactOutputSingleParams params
  ) external returns (uint256 amountIn)

Swaps as little as possible of one token for amountOut of another token

Parameters:

NameTypeDescription
paramsstruct ISwapRouter.ExactOutputSingleParamsThe parameters necessary for the swap, encoded as ExactOutputSingleParams in calldata

Return Values:

NameTypeDescription
amountInstruct ISwapRouter.ExactOutputSingleParamsThe amount of the input token

exactOutput

  function exactOutput(
    struct ISwapRouter.ExactOutputParams params
  ) external returns (uint256 amountIn)

Swaps as little as possible of one token for amountOut of another along the specified path (reversed)

Parameters:

NameTypeDescription
paramsstruct ISwapRouter.ExactOutputParamsThe parameters necessary for the multi-hop swap, encoded as ExactOutputParams in calldata

Return Values:

NameTypeDescription
amountInstruct ISwapRouter.ExactOutputParamsThe amount of the input token