swapTokensForExactTokens

This method swaps an amount of one ERC20 tokens (_token0) for an exact amount of another one (_token1).

Function

function swapTokensForExactTokens(
    address _to,
    address _token0,
    address _token1,
    uint _amount1Out,
    uint _amount0InMax,
    uint _deadline
  ) external returns (uint);

Parameters

ParameterDescription

_to

The address of the recipient.

_token0

An ERC20 token address.

_token1

An ERC20 token address.

_amount1Out

The amount of _token1 that one wants to receive.

_amount0InMax

The maximal amount of _token0 that the user is willing to trade for a given amount of _amount1Out

_deadline

The UTC timestamp that if reached, causes the swap transaction to fail automatically.

Return values

ValueDescription

uint _val

The amount of _token0.

Last updated