소스 검색

更新询价路由,用last价格

skyfffire 2 년 전
부모
커밋
ea3f78abc0
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      contracts/PriceQueryTool.sol

+ 3 - 3
contracts/PriceQueryTool.sol

@@ -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;
                     }