@ring-protocol/router-sdk 0.1.23 → 0.1.24

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.
@@ -1,4 +1,4 @@
1
- import { Percent, validateAndParseAddress, CurrencyAmount, Price, Fraction, TradeType, sortedInsert, ChainId, Ether, WETH9 } from '@ring-protocol/sdk-core';
1
+ import { Percent, validateAndParseAddress, CurrencyAmount, Price, Fraction, TradeType, sortedInsert, Ether, WETH9 } from '@ring-protocol/sdk-core';
2
2
  import JSBI from 'jsbi';
3
3
  import { Interface } from '@ethersproject/abi';
4
4
  import invariant from 'tiny-invariant';
@@ -1072,43 +1072,31 @@ var Protocol;
1072
1072
  Protocol["MIXED"] = "MIXED";
1073
1073
  })(Protocol || (Protocol = {}));
1074
1074
 
1075
+ // Helper function to get the pathInput and pathOutput for a V2 / V3 route
1075
1076
  // currency could be native so we check against the wrapped version as they don't support native ETH in path
1076
1077
  function getPathToken(currency, pool) {
1077
- var isSupportFewV2 = currency.chainId !== ChainId.POLYGON;
1078
- if (isSupportFewV2) {
1079
- console.log('isSupportFewV2 16', isSupportFewV2, currency.chainId);
1080
- var fewToken = getFewTokenFromOriginalToken(currency.wrapped, currency.chainId);
1081
- if (pool instanceof Pair$1 || pool instanceof Pair) {
1082
- if (pool.token0.wrapped.equals(fewToken)) {
1083
- return pool.token0;
1084
- } else if (pool.token1.wrapped.equals(fewToken)) {
1085
- return pool.token1;
1086
- } else if (pool.token0.wrapped.equals(currency.wrapped)) {
1087
- return pool.token0;
1088
- } else if (pool.token1.wrapped.equals(currency.wrapped)) {
1089
- return pool.token1;
1090
- } else {
1091
- throw new Error("Expected fewToken " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
1092
- }
1078
+ var fewToken = getFewTokenFromOriginalToken(currency.wrapped, currency.chainId);
1079
+ if (pool instanceof Pair$1 || pool instanceof Pair) {
1080
+ if (pool.token0.wrapped.equals(fewToken)) {
1081
+ return pool.token0;
1082
+ } else if (pool.token1.wrapped.equals(fewToken)) {
1083
+ return pool.token1;
1084
+ } else if (pool.token0.wrapped.equals(currency.wrapped)) {
1085
+ return pool.token0;
1086
+ } else if (pool.token1.wrapped.equals(currency.wrapped)) {
1087
+ return pool.token1;
1093
1088
  } else {
1094
- console.log('isSupportFewV2 33', isSupportFewV2, currency.chainId);
1095
- if (pool.token0.wrapped.equals(currency.wrapped)) {
1096
- return pool.token0;
1097
- } else if (pool.token1.wrapped.equals(currency.wrapped)) {
1098
- return pool.token1;
1099
- } else if (pool.token0.wrapped.equals(fewToken)) {
1100
- return pool.token0;
1101
- } else if (pool.token1.wrapped.equals(fewToken)) {
1102
- return pool.token1;
1103
- } else {
1104
- throw new Error("Expected token " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
1105
- }
1089
+ throw new Error("Expected fewToken " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
1106
1090
  }
1107
1091
  } else {
1108
1092
  if (pool.token0.wrapped.equals(currency.wrapped)) {
1109
1093
  return pool.token0;
1110
1094
  } else if (pool.token1.wrapped.equals(currency.wrapped)) {
1111
1095
  return pool.token1;
1096
+ } else if (pool.token0.wrapped.equals(fewToken)) {
1097
+ return pool.token0;
1098
+ } else if (pool.token1.wrapped.equals(fewToken)) {
1099
+ return pool.token1;
1112
1100
  } else {
1113
1101
  throw new Error("Expected token " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
1114
1102
  }
@@ -1328,7 +1316,7 @@ var Trade = /*#__PURE__*/function () {
1328
1316
  if (amountOut === void 0) {
1329
1317
  amountOut = this.outputAmount;
1330
1318
  }
1331
- !!slippageTolerance.lessThan(ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
1319
+ !!slippageTolerance.lessThan(0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
1332
1320
  if (this.tradeType === TradeType.EXACT_OUTPUT) {
1333
1321
  return amountOut;
1334
1322
  } else {
@@ -1345,7 +1333,7 @@ var Trade = /*#__PURE__*/function () {
1345
1333
  if (amountIn === void 0) {
1346
1334
  amountIn = this.inputAmount;
1347
1335
  }
1348
- !!slippageTolerance.lessThan(ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
1336
+ !!slippageTolerance.lessThan(0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
1349
1337
  if (this.tradeType === TradeType.EXACT_INPUT) {
1350
1338
  return amountIn;
1351
1339
  } else {