|
|
@@ -13,7 +13,7 @@ contract PriceQueryTool {
|
|
|
try IUniswapV2Router(router).getAmountsOut(amountIn, path) returns (uint[] memory result) {
|
|
|
// Check the result length to avoid out-of-bounds access
|
|
|
if (result.length > 1) {
|
|
|
- outputAmount = result[1];
|
|
|
+ outputAmount = result[result.length - 1];
|
|
|
} else {
|
|
|
outputAmount = defaultOutputAmount;
|
|
|
}
|
|
|
@@ -35,7 +35,7 @@ contract PriceQueryTool {
|
|
|
try IUniswapV2Router(routers[routerIndex]).getAmountsOut(amountIn, path) returns (uint[] memory result) {
|
|
|
// Check the result length to avoid out-of-bounds access
|
|
|
if (result.length > 1) {
|
|
|
- outputAmounts[routerIndex] = result[1];
|
|
|
+ outputAmounts[routerIndex] = result[result.length - 1];
|
|
|
} else {
|
|
|
outputAmounts[routerIndex] = defaultOutputAmount;
|
|
|
}
|
|
|
@@ -59,7 +59,7 @@ contract PriceQueryTool {
|
|
|
try IUniswapV2Router(routers[routerIndex]).getAmountsOut(amountIn, paths[pathIndex]) returns (uint[] memory result) {
|
|
|
// Check the result length to avoid out-of-bounds access
|
|
|
if (result.length > 1) {
|
|
|
- pathsRoutersOutputAmounts[pathIndex][routerIndex] = result[1];
|
|
|
+ pathsRoutersOutputAmounts[pathIndex][routerIndex] = result[result.length - 1];
|
|
|
} else {
|
|
|
pathsRoutersOutputAmounts[pathIndex][routerIndex] = defaultOutputAmount;
|
|
|
}
|