ISwapRouter

Functions for swapping tokens via DragonswapV2

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

params

struct ISwapRouter.ExactInputSingleParams

The parameters necessary for the swap, encoded as ExactInputSingleParams in calldata

Return Values:โ€‹

NameTypeDescription

amountOut

struct ISwapRouter.ExactInputSingleParams

The 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

params

struct ISwapRouter.ExactInputParams

The parameters necessary for the multi-hop swap, encoded as ExactInputParams in calldata

Return Values:โ€‹

NameTypeDescription

amountOut

struct ISwapRouter.ExactInputParams

The 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

params

struct ISwapRouter.ExactOutputSingleParams

The parameters necessary for the swap, encoded as ExactOutputSingleParams in calldata

Return Values:โ€‹

NameTypeDescription

amountIn

struct ISwapRouter.ExactOutputSingleParams

The 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

params

struct ISwapRouter.ExactOutputParams

The parameters necessary for the multi-hop swap, encoded as ExactOutputParams in calldata

Return Values:โ€‹

NameTypeDescription

amountIn

struct ISwapRouter.ExactOutputParams

The amount of the input token

Last updated