@ring-protocol/router-sdk 0.1.25 → 0.1.26

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, Ether, WETH9 } from '@ring-protocol/sdk-core';
1
+ import { Percent, validateAndParseAddress, CurrencyAmount, Price, Fraction, TradeType, sortedInsert, ChainId, 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,31 +1072,43 @@ 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
1076
1075
  // currency could be native so we check against the wrapped version as they don't support native ETH in path
1077
1076
  function getPathToken(currency, pool) {
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;
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
+ }
1088
1093
  } else {
1089
- throw new Error("Expected fewToken " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
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
+ }
1090
1106
  }
1091
1107
  } else {
1092
1108
  if (pool.token0.wrapped.equals(currency.wrapped)) {
1093
1109
  return pool.token0;
1094
1110
  } else if (pool.token1.wrapped.equals(currency.wrapped)) {
1095
1111
  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;
1100
1112
  } else {
1101
1113
  throw new Error("Expected token " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
1102
1114
  }
@@ -1316,7 +1328,7 @@ var Trade = /*#__PURE__*/function () {
1316
1328
  if (amountOut === void 0) {
1317
1329
  amountOut = this.outputAmount;
1318
1330
  }
1319
- !!slippageTolerance.lessThan(0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
1331
+ !!slippageTolerance.lessThan(ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
1320
1332
  if (this.tradeType === TradeType.EXACT_OUTPUT) {
1321
1333
  return amountOut;
1322
1334
  } else {
@@ -1333,7 +1345,7 @@ var Trade = /*#__PURE__*/function () {
1333
1345
  if (amountIn === void 0) {
1334
1346
  amountIn = this.inputAmount;
1335
1347
  }
1336
- !!slippageTolerance.lessThan(0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
1348
+ !!slippageTolerance.lessThan(ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SLIPPAGE_TOLERANCE') : invariant(false) : void 0;
1337
1349
  if (this.tradeType === TradeType.EXACT_INPUT) {
1338
1350
  return amountIn;
1339
1351
  } else {