@uniswap/router-sdk 1.11.2 → 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/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/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export declare const MSG_SENDER = "0x0000000000000000000000000000000000000001";
|
|
|
5
5
|
export declare const ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
|
|
6
6
|
export declare const ZERO: JSBI;
|
|
7
7
|
export declare const ONE: JSBI;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER: number;
|
|
9
|
+
export declare const MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER: number;
|
|
10
|
+
export declare const MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER: number;
|
|
11
|
+
export declare const MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER: number;
|
|
9
12
|
export declare const ZERO_PERCENT: Percent;
|
|
10
13
|
export declare const ONE_HUNDRED_PERCENT: Percent;
|
|
@@ -22,8 +22,14 @@ var MSG_SENDER = '0x0000000000000000000000000000000000000001';
|
|
|
22
22
|
var ADDRESS_THIS = '0x0000000000000000000000000000000000000002';
|
|
23
23
|
var ZERO = /*#__PURE__*/JSBI.BigInt(0);
|
|
24
24
|
var ONE = /*#__PURE__*/JSBI.BigInt(1);
|
|
25
|
-
// = 1 << 23 or
|
|
26
|
-
var
|
|
25
|
+
// = 1 << 23 or 0b0100000000000000000000000
|
|
26
|
+
var MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER = 1 << 23;
|
|
27
|
+
// = 10 << 4 or 0b00100000
|
|
28
|
+
var MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER = 2 << 4;
|
|
29
|
+
// = 11 << 20 or 0b001100000000000000000000
|
|
30
|
+
var MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER = 3 << 20;
|
|
31
|
+
// = 100 << 20 or 0b010000000000000000000000
|
|
32
|
+
var MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER = 4 << 20;
|
|
27
33
|
var ZERO_PERCENT = /*#__PURE__*/new sdkCore.Percent(ZERO);
|
|
28
34
|
var ONE_HUNDRED_PERCENT = /*#__PURE__*/new sdkCore.Percent(100, 100);
|
|
29
35
|
|
|
@@ -1817,33 +1823,65 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1817
1823
|
* @returns the exactIn encoded path
|
|
1818
1824
|
*/
|
|
1819
1825
|
function encodeMixedRouteToPath(route) {
|
|
1820
|
-
var
|
|
1821
|
-
|
|
1826
|
+
var containsV4Pool = route.pools.some(function (pool) {
|
|
1827
|
+
return pool instanceof v4Sdk.Pool;
|
|
1828
|
+
});
|
|
1829
|
+
var path;
|
|
1830
|
+
var types;
|
|
1831
|
+
if (containsV4Pool) {
|
|
1832
|
+
path = [route.adjustedInput.isNative ? ADDRESS_ZERO : route.adjustedInput.address];
|
|
1833
|
+
types = ['address'];
|
|
1834
|
+
var currencyIn = route.adjustedInput;
|
|
1835
|
+
for (var _iterator = _createForOfIteratorHelperLoose(route.pools), _step; !(_step = _iterator()).done;) {
|
|
1836
|
+
var pool = _step.value;
|
|
1837
|
+
var currencyOut = currencyIn.equals(pool.token0) ? pool.token1 : pool.token0;
|
|
1838
|
+
if (pool instanceof v4Sdk.Pool) {
|
|
1839
|
+
var v4Fee = pool.fee + MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER;
|
|
1840
|
+
path.push(v4Fee, pool.tickSpacing, pool.hooks, currencyOut.isNative ? ADDRESS_ZERO : currencyOut.wrapped.address);
|
|
1841
|
+
types.push('uint24', 'uint24', 'address', 'address');
|
|
1842
|
+
} else if (pool instanceof v3Sdk.Pool) {
|
|
1843
|
+
var v3Fee = pool.fee + MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER;
|
|
1844
|
+
path.push(v3Fee, currencyOut.wrapped.address);
|
|
1845
|
+
types.push('uint24', 'address');
|
|
1846
|
+
} else if (pool instanceof v2Sdk.Pair) {
|
|
1847
|
+
var v2Fee = MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER;
|
|
1848
|
+
path.push(v2Fee, currencyOut.wrapped.address);
|
|
1849
|
+
types.push('uint8', 'address');
|
|
1850
|
+
} else {
|
|
1851
|
+
throw new Error("Unsupported pool type " + JSON.stringify(pool));
|
|
1852
|
+
}
|
|
1853
|
+
currencyIn = currencyOut;
|
|
1854
|
+
}
|
|
1855
|
+
} else {
|
|
1856
|
+
// TODO: ROUTE-276 - delete this else block
|
|
1857
|
+
// We introduced this else block as a safety measure to prevent non-v4 mixed routes from potentially regressing
|
|
1858
|
+
// We'd like to gain more confidence in the new implementation before removing this block
|
|
1859
|
+
var result = route.pools.reduce(function (_ref, pool, index) {
|
|
1822
1860
|
var inputToken = _ref.inputToken,
|
|
1823
1861
|
path = _ref.path,
|
|
1824
1862
|
types = _ref.types;
|
|
1825
|
-
if (pool instanceof v4Sdk.Pool) throw 'Encoding mixed routes with V4 not supported';
|
|
1826
1863
|
var outputToken = pool.token0.equals(inputToken) ? pool.token1 : pool.token0;
|
|
1827
1864
|
if (index === 0) {
|
|
1828
1865
|
return {
|
|
1829
1866
|
inputToken: outputToken,
|
|
1830
1867
|
types: ['address', 'uint24', 'address'],
|
|
1831
|
-
path: [inputToken.wrapped.address, pool instanceof v3Sdk.Pool ? pool.fee :
|
|
1868
|
+
path: [inputToken.wrapped.address, pool instanceof v3Sdk.Pool ? pool.fee : MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER, outputToken.wrapped.address]
|
|
1832
1869
|
};
|
|
1833
1870
|
} else {
|
|
1834
1871
|
return {
|
|
1835
1872
|
inputToken: outputToken,
|
|
1836
1873
|
types: [].concat(types, ['uint24', 'address']),
|
|
1837
|
-
path: [].concat(path, [pool instanceof v3Sdk.Pool ? pool.fee :
|
|
1874
|
+
path: [].concat(path, [pool instanceof v3Sdk.Pool ? pool.fee : MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER, outputToken.wrapped.address])
|
|
1838
1875
|
};
|
|
1839
1876
|
}
|
|
1840
1877
|
}, {
|
|
1841
|
-
inputToken:
|
|
1878
|
+
inputToken: route.input,
|
|
1842
1879
|
path: [],
|
|
1843
1880
|
types: []
|
|
1844
|
-
})
|
|
1845
|
-
path =
|
|
1846
|
-
types =
|
|
1881
|
+
});
|
|
1882
|
+
path = result.path;
|
|
1883
|
+
types = result.types;
|
|
1884
|
+
}
|
|
1847
1885
|
return solidity.pack(types, path);
|
|
1848
1886
|
}
|
|
1849
1887
|
|
|
@@ -2329,6 +2367,10 @@ SwapRouter.INTERFACE = /*#__PURE__*/new abi.Interface(ISwapRouter02_json.abi);
|
|
|
2329
2367
|
exports.ADDRESS_THIS = ADDRESS_THIS;
|
|
2330
2368
|
exports.ADDRESS_ZERO = ADDRESS_ZERO;
|
|
2331
2369
|
exports.ApproveAndCall = ApproveAndCall;
|
|
2370
|
+
exports.MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER = MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER;
|
|
2371
|
+
exports.MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER = MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER;
|
|
2372
|
+
exports.MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER = MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER;
|
|
2373
|
+
exports.MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER = MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER;
|
|
2332
2374
|
exports.MSG_SENDER = MSG_SENDER;
|
|
2333
2375
|
exports.MixedRoute = MixedRoute;
|
|
2334
2376
|
exports.MixedRouteSDK = MixedRouteSDK;
|
|
@@ -2342,7 +2384,6 @@ exports.RouteV3 = RouteV3;
|
|
|
2342
2384
|
exports.RouteV4 = RouteV4;
|
|
2343
2385
|
exports.SwapRouter = SwapRouter;
|
|
2344
2386
|
exports.Trade = Trade;
|
|
2345
|
-
exports.V2_FEE_PATH_PLACEHOLDER = V2_FEE_PATH_PLACEHOLDER;
|
|
2346
2387
|
exports.ZERO = ZERO;
|
|
2347
2388
|
exports.ZERO_PERCENT = ZERO_PERCENT;
|
|
2348
2389
|
exports.encodeMixedRouteToPath = encodeMixedRouteToPath;
|