SwapTokensForExactTokens
Sushiswap Action Plugin - SwapTokensForExactTokens
Description
Swaps an exact amount of tokens for as much ETH as possible, along the route determined by the path.
Method
swapTokensForExactTokens(uint256, uint256, address[], address, uint256)
Input Parameters
to
FctAddress
Sushiswap Router address
Method Parameters
amountOut
FctValue
The amount of output tokens to receive.
amountInMax
FctValue
The maximum amount of input tokens that can be required before the transaction reverts.
path
FctAddressList
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
FctAddress
Recipient of the output tokens.
deadline
FctValue
Unix timestamp after which the transaction will revert.
Example
Example with initParams
const swapTokensForExactTokens = new Sushiswap.actions.SwapTokensForExactTokens({
chainId: 1,
initParams: {
to: "0x..." // Sushiswap Router
methodParams: {
amountOut: "...",
amountInMax: "...",
path: ["0x...", "0x..."],
to: "0x...",
deadline: "..."
}
}
})
Example without initParams
const swapTokensForExactTokens = new Sushiswap.actions.SwapTokensForExactTokens({
chainId: 1
})
await swapTokensForExactTokens.input.set({
to: "0x..." // Sushiswap Router
methodParams: {
amountOut: "...",
amountInMax: "...",
path: ["0x...", "0x..."],
to: "0x...",
deadline: "..."
}
})
Learn more
Learn more about Sushiswap SwapTokensForExactTokens function here
Last updated