I am trying to swap some USDC(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)
token for USDT(0xdAC17F958D2ee523a2206206994597C13D831ec7)
token using UniswapV2Router02
at address 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F
(this is the Sushiswap's router on Ethereum mainnet)
Since I both USDC
and USDT
have 6 digits precision as amountIn
to the swapExactTokensForTokens
method I am passing number 3000 * 10 ** 6
(must be equal to $3000). As amountOutMin
I am passing 2850 * 10 ** 6
(must be equal to $2850, which is -5% from the amountIn
. In my opinion this is prety enough slippage tolerance)
Everything looks right? Yes but no: Everythime I ma trying to run this code:
UniswapV2Router(0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F) // Sushiswap router on ETH mainnet
.swapExactTokensForTokens(3000 * 10 ** 6, // 3000 USDC
2850 * 10 ** 6, // 2850 USDT
[
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC address on ETH mainnet
"0xdAC17F958D2ee523a2206206994597C13D831ec7" // USDT address on ETH mainnet
],
msg.sender,
<some deadline>);
I am getting the following error:
Revert message: UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT
Please help what I am missing?
EDIT: I am using truffle
and I have forked ETH mainnet
EDIT 2: The amount UniswapV2Router
is trying to return is 1327704386 ~ 1327 USDT
which is ~60%
slippage but in the liquidity pair there are assets for $2,036,392,078,752.44
It happened so thath the Sushiswap's USDC/USDT pool has only 5k
in liquidity and everything with my code is right.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.