@t2000/sdk 0.46.13 → 0.46.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -754,7 +754,7 @@ async function findSwapRoute(params) {
754
754
  amountIn: routerData.amountIn.toString(),
755
755
  amountOut: routerData.amountOut.toString(),
756
756
  byAmountIn: params.byAmountIn,
757
- priceImpact: routerData.deviationRatio,
757
+ priceImpact: normalizePriceImpact(routerData.deviationRatio),
758
758
  insufficientLiquidity: true
759
759
  };
760
760
  }
@@ -767,10 +767,14 @@ async function findSwapRoute(params) {
767
767
  amountIn: routerData.amountIn.toString(),
768
768
  amountOut: routerData.amountOut.toString(),
769
769
  byAmountIn: params.byAmountIn,
770
- priceImpact: routerData.deviationRatio,
770
+ priceImpact: normalizePriceImpact(routerData.deviationRatio),
771
771
  insufficientLiquidity: false
772
772
  };
773
773
  }
774
+ function normalizePriceImpact(value) {
775
+ const n = typeof value === "number" ? value : Number(value);
776
+ return Number.isFinite(n) ? n : 0;
777
+ }
774
778
  async function buildSwapTx(params) {
775
779
  const client = getClient(params.walletAddress);
776
780
  const clampedSlippage = Math.max(1e-3, Math.min(params.slippage, 0.05));