swapTokensForExactTokens

function swapTokensForExactTokens(
    uint _amountOut,
    uint _amountInMax,
    address[] calldata _path,
    address _to,
    uint _deadline
) external virtual ensure(_deadline) returns (uint[] memory amounts)

토큰->ν† ν°μœΌλ‘œ swap (TO->FROM)

Parameters

Return Values

Example

// 토큰 κ±°λž˜μ— λŒ€ν•œ ν—ˆμš©
await mockToken0Contract.approve(routerContract.address, MaxUint256)
await mockToken1Contract.approve(routerContract.address, MaxUint256)

// swap
await swapRouterContract.swapTokensForExactTokens(
    5000,
    MaxUint256,
    [mockToken0Contract.address, mockToken1Contract.address],
    accounts[0].address,
    MaxUint256,
    overrides
)

2022.12.22

Last updated