@ring-protocol/router-sdk 0.1.25 → 0.1.27
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/router-sdk.cjs.development.js +31 -18
- package/dist/router-sdk.cjs.development.js.map +1 -1
- package/dist/router-sdk.cjs.production.min.js +1 -1
- package/dist/router-sdk.cjs.production.min.js.map +1 -1
- package/dist/router-sdk.esm.js +32 -19
- package/dist/router-sdk.esm.js.map +1 -1
- package/package.json +4 -4
|
@@ -1076,31 +1076,44 @@ var MixedRouteTrade = /*#__PURE__*/function () {
|
|
|
1076
1076
|
Protocol["MIXED"] = "MIXED";
|
|
1077
1077
|
})(exports.Protocol || (exports.Protocol = {}));
|
|
1078
1078
|
|
|
1079
|
-
// Helper function to get the pathInput and pathOutput for a V2 / V3 route
|
|
1079
|
+
// Helper function to get the pathInput and pathOutput for a FEWV2 / V2 / V3 route
|
|
1080
1080
|
// currency could be native so we check against the wrapped version as they don't support native ETH in path
|
|
1081
1081
|
function getPathToken(currency, pool) {
|
|
1082
|
-
var
|
|
1083
|
-
if (
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1082
|
+
var isSupportFewV2 = currency.chainId !== sdkCore.ChainId.POLYGON;
|
|
1083
|
+
if (isSupportFewV2) {
|
|
1084
|
+
console.log('isSupportFewV2 16', isSupportFewV2, currency.chainId);
|
|
1085
|
+
var fewToken = fewV2Sdk.getFewTokenFromOriginalToken(currency.wrapped, currency.chainId);
|
|
1086
|
+
if (pool instanceof fewV2Sdk.Pair || pool instanceof v2Sdk.Pair) {
|
|
1087
|
+
if (pool.token0.wrapped.equals(fewToken)) {
|
|
1088
|
+
return pool.token0;
|
|
1089
|
+
} else if (pool.token1.wrapped.equals(fewToken)) {
|
|
1090
|
+
return pool.token1;
|
|
1091
|
+
} else if (pool.token0.wrapped.equals(currency.wrapped)) {
|
|
1092
|
+
return pool.token0;
|
|
1093
|
+
} else if (pool.token1.wrapped.equals(currency.wrapped)) {
|
|
1094
|
+
return pool.token1;
|
|
1095
|
+
} else {
|
|
1096
|
+
throw new Error("Expected fewToken " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
|
|
1097
|
+
}
|
|
1092
1098
|
} else {
|
|
1093
|
-
|
|
1099
|
+
console.log('isSupportFewV2 33', isSupportFewV2, currency.chainId);
|
|
1100
|
+
if (pool.token0.wrapped.equals(currency.wrapped)) {
|
|
1101
|
+
return pool.token0;
|
|
1102
|
+
} else if (pool.token1.wrapped.equals(currency.wrapped)) {
|
|
1103
|
+
return pool.token1;
|
|
1104
|
+
} else if (pool.token0.wrapped.equals(fewToken)) {
|
|
1105
|
+
return pool.token0;
|
|
1106
|
+
} else if (pool.token1.wrapped.equals(fewToken)) {
|
|
1107
|
+
return pool.token1;
|
|
1108
|
+
} else {
|
|
1109
|
+
throw new Error("Expected token " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
|
|
1110
|
+
}
|
|
1094
1111
|
}
|
|
1095
1112
|
} else {
|
|
1096
1113
|
if (pool.token0.wrapped.equals(currency.wrapped)) {
|
|
1097
1114
|
return pool.token0;
|
|
1098
1115
|
} else if (pool.token1.wrapped.equals(currency.wrapped)) {
|
|
1099
1116
|
return pool.token1;
|
|
1100
|
-
} else if (pool.token0.wrapped.equals(fewToken)) {
|
|
1101
|
-
return pool.token0;
|
|
1102
|
-
} else if (pool.token1.wrapped.equals(fewToken)) {
|
|
1103
|
-
return pool.token1;
|
|
1104
1117
|
} else {
|
|
1105
1118
|
throw new Error("Expected token " + currency.symbol + " to be either " + pool.token0.symbol + " or " + pool.token1.symbol);
|
|
1106
1119
|
}
|
|
@@ -1320,7 +1333,7 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1320
1333
|
if (amountOut === void 0) {
|
|
1321
1334
|
amountOut = this.outputAmount;
|
|
1322
1335
|
}
|
|
1323
|
-
!!slippageTolerance.lessThan(
|
|
1336
|
+
!!slippageTolerance.lessThan(ZERO) ? invariant(false, 'SLIPPAGE_TOLERANCE') : void 0;
|
|
1324
1337
|
if (this.tradeType === sdkCore.TradeType.EXACT_OUTPUT) {
|
|
1325
1338
|
return amountOut;
|
|
1326
1339
|
} else {
|
|
@@ -1337,7 +1350,7 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1337
1350
|
if (amountIn === void 0) {
|
|
1338
1351
|
amountIn = this.inputAmount;
|
|
1339
1352
|
}
|
|
1340
|
-
!!slippageTolerance.lessThan(
|
|
1353
|
+
!!slippageTolerance.lessThan(ZERO) ? invariant(false, 'SLIPPAGE_TOLERANCE') : void 0;
|
|
1341
1354
|
if (this.tradeType === sdkCore.TradeType.EXACT_INPUT) {
|
|
1342
1355
|
return amountIn;
|
|
1343
1356
|
} else {
|