@uniswap/router-sdk 1.11.1 → 1.12.0
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/constants.d.ts +4 -1
- package/dist/entities/mixedRoute/route.d.ts +1 -5
- package/dist/entities/mixedRoute/trade.d.ts +2 -5
- package/dist/router-sdk.cjs.development.js +53 -12
- 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 +50 -12
- package/dist/router-sdk.esm.js.map +1 -1
- package/dist/utils/TPool.d.ts +4 -0
- package/dist/utils/getOutputAmount.d.ts +1 -5
- package/dist/utils/index.d.ts +1 -5
- package/dist/utils/isValidTokenPath.d.ts +1 -5
- package/package.json +1 -1
package/dist/router-sdk.esm.js
CHANGED
|
@@ -16,8 +16,14 @@ var MSG_SENDER = '0x0000000000000000000000000000000000000001';
|
|
|
16
16
|
var ADDRESS_THIS = '0x0000000000000000000000000000000000000002';
|
|
17
17
|
var ZERO = /*#__PURE__*/JSBI.BigInt(0);
|
|
18
18
|
var ONE = /*#__PURE__*/JSBI.BigInt(1);
|
|
19
|
-
// = 1 << 23 or
|
|
20
|
-
var
|
|
19
|
+
// = 1 << 23 or 0b0100000000000000000000000
|
|
20
|
+
var MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER = 1 << 23;
|
|
21
|
+
// = 10 << 4 or 0b00100000
|
|
22
|
+
var MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER = 2 << 4;
|
|
23
|
+
// = 11 << 20 or 0b001100000000000000000000
|
|
24
|
+
var MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER = 3 << 20;
|
|
25
|
+
// = 100 << 20 or 0b010000000000000000000000
|
|
26
|
+
var MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER = 4 << 20;
|
|
21
27
|
var ZERO_PERCENT = /*#__PURE__*/new Percent(ZERO);
|
|
22
28
|
var ONE_HUNDRED_PERCENT = /*#__PURE__*/new Percent(100, 100);
|
|
23
29
|
|
|
@@ -1813,33 +1819,65 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1813
1819
|
* @returns the exactIn encoded path
|
|
1814
1820
|
*/
|
|
1815
1821
|
function encodeMixedRouteToPath(route) {
|
|
1816
|
-
var
|
|
1817
|
-
|
|
1822
|
+
var containsV4Pool = route.pools.some(function (pool) {
|
|
1823
|
+
return pool instanceof Pool;
|
|
1824
|
+
});
|
|
1825
|
+
var path;
|
|
1826
|
+
var types;
|
|
1827
|
+
if (containsV4Pool) {
|
|
1828
|
+
path = [route.adjustedInput.isNative ? ADDRESS_ZERO : route.adjustedInput.address];
|
|
1829
|
+
types = ['address'];
|
|
1830
|
+
var currencyIn = route.adjustedInput;
|
|
1831
|
+
for (var _iterator = _createForOfIteratorHelperLoose(route.pools), _step; !(_step = _iterator()).done;) {
|
|
1832
|
+
var pool = _step.value;
|
|
1833
|
+
var currencyOut = currencyIn.equals(pool.token0) ? pool.token1 : pool.token0;
|
|
1834
|
+
if (pool instanceof Pool) {
|
|
1835
|
+
var v4Fee = pool.fee + MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER;
|
|
1836
|
+
path.push(v4Fee, pool.tickSpacing, pool.hooks, currencyOut.isNative ? ADDRESS_ZERO : currencyOut.wrapped.address);
|
|
1837
|
+
types.push('uint24', 'uint24', 'address', 'address');
|
|
1838
|
+
} else if (pool instanceof Pool$1) {
|
|
1839
|
+
var v3Fee = pool.fee + MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER;
|
|
1840
|
+
path.push(v3Fee, currencyOut.wrapped.address);
|
|
1841
|
+
types.push('uint24', 'address');
|
|
1842
|
+
} else if (pool instanceof Pair) {
|
|
1843
|
+
var v2Fee = MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER;
|
|
1844
|
+
path.push(v2Fee, currencyOut.wrapped.address);
|
|
1845
|
+
types.push('uint8', 'address');
|
|
1846
|
+
} else {
|
|
1847
|
+
throw new Error("Unsupported pool type " + JSON.stringify(pool));
|
|
1848
|
+
}
|
|
1849
|
+
currencyIn = currencyOut;
|
|
1850
|
+
}
|
|
1851
|
+
} else {
|
|
1852
|
+
// TODO: ROUTE-276 - delete this else block
|
|
1853
|
+
// We introduced this else block as a safety measure to prevent non-v4 mixed routes from potentially regressing
|
|
1854
|
+
// We'd like to gain more confidence in the new implementation before removing this block
|
|
1855
|
+
var result = route.pools.reduce(function (_ref, pool, index) {
|
|
1818
1856
|
var inputToken = _ref.inputToken,
|
|
1819
1857
|
path = _ref.path,
|
|
1820
1858
|
types = _ref.types;
|
|
1821
|
-
if (pool instanceof Pool) throw 'Encoding mixed routes with V4 not supported';
|
|
1822
1859
|
var outputToken = pool.token0.equals(inputToken) ? pool.token1 : pool.token0;
|
|
1823
1860
|
if (index === 0) {
|
|
1824
1861
|
return {
|
|
1825
1862
|
inputToken: outputToken,
|
|
1826
1863
|
types: ['address', 'uint24', 'address'],
|
|
1827
|
-
path: [inputToken.wrapped.address, pool instanceof Pool$1 ? pool.fee :
|
|
1864
|
+
path: [inputToken.wrapped.address, pool instanceof Pool$1 ? pool.fee : MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER, outputToken.wrapped.address]
|
|
1828
1865
|
};
|
|
1829
1866
|
} else {
|
|
1830
1867
|
return {
|
|
1831
1868
|
inputToken: outputToken,
|
|
1832
1869
|
types: [].concat(types, ['uint24', 'address']),
|
|
1833
|
-
path: [].concat(path, [pool instanceof Pool$1 ? pool.fee :
|
|
1870
|
+
path: [].concat(path, [pool instanceof Pool$1 ? pool.fee : MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER, outputToken.wrapped.address])
|
|
1834
1871
|
};
|
|
1835
1872
|
}
|
|
1836
1873
|
}, {
|
|
1837
|
-
inputToken:
|
|
1874
|
+
inputToken: route.input,
|
|
1838
1875
|
path: [],
|
|
1839
1876
|
types: []
|
|
1840
|
-
})
|
|
1841
|
-
path =
|
|
1842
|
-
types =
|
|
1877
|
+
});
|
|
1878
|
+
path = result.path;
|
|
1879
|
+
types = result.types;
|
|
1880
|
+
}
|
|
1843
1881
|
return pack(types, path);
|
|
1844
1882
|
}
|
|
1845
1883
|
|
|
@@ -2322,5 +2360,5 @@ var SwapRouter = /*#__PURE__*/function () {
|
|
|
2322
2360
|
}();
|
|
2323
2361
|
SwapRouter.INTERFACE = /*#__PURE__*/new Interface(abi$3);
|
|
2324
2362
|
|
|
2325
|
-
export { ADDRESS_THIS, ADDRESS_ZERO, ApprovalTypes, ApproveAndCall, MSG_SENDER, MixedRoute, MixedRouteSDK, MixedRouteTrade, MulticallExtended, ONE, ONE_HUNDRED_PERCENT, PaymentsExtended, Protocol, RouteV2, RouteV3, RouteV4, SwapRouter, Trade,
|
|
2363
|
+
export { ADDRESS_THIS, ADDRESS_ZERO, ApprovalTypes, ApproveAndCall, MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER, MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER, MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER, MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER, MSG_SENDER, MixedRoute, MixedRouteSDK, MixedRouteTrade, MulticallExtended, ONE, ONE_HUNDRED_PERCENT, PaymentsExtended, Protocol, RouteV2, RouteV3, RouteV4, SwapRouter, Trade, ZERO, ZERO_PERCENT, encodeMixedRouteToPath, getOutputOfPools, isMint, partitionMixedRouteByProtocol, tradeComparator };
|
|
2326
2364
|
//# sourceMappingURL=router-sdk.esm.js.map
|