@curvefi/api 2.65.15 → 2.65.17
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.
|
@@ -3,9 +3,10 @@ import type { curve } from "./curve";
|
|
|
3
3
|
export type IRouteGraphInput = {
|
|
4
4
|
constants: typeof curve['constants'];
|
|
5
5
|
chainId: IChainId;
|
|
6
|
+
isLiteChain: boolean;
|
|
6
7
|
allPools: [string, IPoolData][];
|
|
7
8
|
amplificationCoefficientDict: IDict<number>;
|
|
8
9
|
poolTvlDict: IDict<number>;
|
|
9
10
|
};
|
|
10
|
-
export declare function routeGraphWorker(): (({ constants, chainId, allPools, amplificationCoefficientDict, poolTvlDict }: IRouteGraphInput) => IDict<IDict<IRouteStep[]>>) | undefined;
|
|
11
|
+
export declare function routeGraphWorker(): (({ constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict }: IRouteGraphInput) => IDict<IDict<IRouteStep[]>>) | undefined;
|
|
11
12
|
export declare const routeGraphWorkerCode: string;
|
|
@@ -11,7 +11,7 @@ export function routeGraphWorker() {
|
|
|
11
11
|
].map((a) => a.toLowerCase()),
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
|
-
const createRouteGraph = ({ constants, chainId, allPools, amplificationCoefficientDict, poolTvlDict }) => {
|
|
14
|
+
const createRouteGraph = ({ constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict }) => {
|
|
15
15
|
var _a, _b, _c;
|
|
16
16
|
const routerGraph = {};
|
|
17
17
|
// ETH <-> WETH (exclude Celo)
|
|
@@ -229,7 +229,7 @@ export function routeGraphWorker() {
|
|
|
229
229
|
// Skip empty pools
|
|
230
230
|
if (chainId === 1 && tvl < 1000)
|
|
231
231
|
continue;
|
|
232
|
-
if (chainId !== 1 && tvl < 100)
|
|
232
|
+
if (chainId !== 1 && !isLiteChain && tvl < 100)
|
|
233
233
|
continue;
|
|
234
234
|
const excludedUnderlyingSwaps = (poolId === 'ib' && chainId === 1) ||
|
|
235
235
|
(poolId === 'geist' && chainId === 250) ||
|
package/lib/router.js
CHANGED
|
@@ -35,19 +35,19 @@ function mapDict(dict, mapper) {
|
|
|
35
35
|
Object.entries(dict).forEach(([key, value]) => result[key] = mapper(key, value));
|
|
36
36
|
return result;
|
|
37
37
|
}
|
|
38
|
-
const _buildRouteGraph = memoize((chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const _buildRouteGraph = memoize((chainId, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
39
|
const constants = curve.constants;
|
|
40
40
|
const allPools = Object.entries(curve.getPoolsData()).filter(([id]) => !["crveth", "y", "busd", "pax"].includes(id));
|
|
41
41
|
const amplificationCoefficientDict = yield _getAmplificationCoefficientsFromApi();
|
|
42
42
|
const poolTvlDict = yield entriesToDictAsync(allPools, _getTVL);
|
|
43
|
-
const input = { constants, chainId, allPools, amplificationCoefficientDict, poolTvlDict };
|
|
43
|
+
const input = { constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict };
|
|
44
44
|
return runWorker(routeGraphWorkerCode, routeGraphWorker, Object.assign({ type: 'createRouteGraph' }, input));
|
|
45
45
|
}), {
|
|
46
46
|
promise: true,
|
|
47
47
|
maxAge: 5 * 60 * 1000, // 5m
|
|
48
48
|
});
|
|
49
49
|
const _findRoutes = (inputCoinAddress, outputCoinAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
const routerGraph = yield _buildRouteGraph(curve.chainId); // It's important to pass chainId to not use cache from another network
|
|
50
|
+
const routerGraph = yield _buildRouteGraph(curve.chainId, curve.isLiteChain); // It's important to pass chainId to not use cache from another network
|
|
51
51
|
// extract only the fields we need for the worker
|
|
52
52
|
const poolData = mapDict(curve.getPoolsData(), (_, { is_lending, wrapped_coin_addresses, underlying_coin_addresses, token_address }) => ({ is_lending, wrapped_coin_addresses, underlying_coin_addresses, token_address }));
|
|
53
53
|
const input = { inputCoinAddress, outputCoinAddress, routerGraph, poolData };
|