Hello eth communities..
I am trying to interact with ethereum chain using programming and I'm using getAmountsOut to get swap path quote using sushiswap's contract. But the result in my vscode and sushiswap UI is veryyyy different even the path sushiswap UI(user interface) used is the same with mine(using only v2). See this senario
in my code the path WETH -> DPI gives me 8.988475884524729051 DPI
on sushiswap UI the path WETH- DPI gives me 9.26355
The path i used is only sushiswapv2
the path sushiswap UI used is sushiswapV2
Please help….. Even i deduct the gas from sushiswap UI resut, still the results are not even closer…. Also does getAmountsOut consider the gas cost?
Best Answer
I tested it, the prices are different across the two urls, app.sushi.com shows the same as getAmountOut with 2+% price impact.
www.sushi.com shows more as it is aggregating from multiple pools to give you the best price. If anything it is just an inaccuracy in what it is showing as the path on the newer UI.
edit:
On the simplest level you can call getAmountOut, or copy the way the function does it from the Uniswap library.
An example implementation might look like:
Have included the reserves in reverse of suggested as I think you got them back to front in the question.
The last result suggests 1.4273540241478273MKR for 1 ETH which is close to the current market rate.