@curvefi/api 2.65.16 → 2.65.18

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,5 +1,5 @@
1
1
  import memoize from "memoizee";
2
- import { IExtendedPoolDataFromApi, IDict, INetworkName, IPoolType, IGaugesDataFromApi, IDaoProposal, IDaoProposalListItem, IVolumeAndAPYs, ICurveLiteNetwork } from "./interfaces";
2
+ import { ICurveLiteNetwork, IDaoProposal, IDaoProposalListItem, IDict, IExtendedPoolDataFromApi, IGaugesDataFromApi, INetworkName, IPoolType, IVolumeAndAPYs } from "./interfaces";
3
3
  export declare const _getPoolsFromApi: ((network: INetworkName, poolType: IPoolType, isLiteChain?: any) => Promise<IExtendedPoolDataFromApi>) & memoize.Memoized<(network: INetworkName, poolType: IPoolType, isLiteChain?: any) => Promise<IExtendedPoolDataFromApi>>;
4
4
  export declare const _getAllPoolsFromApi: (network: INetworkName, isLiteChain?: boolean) => Promise<IExtendedPoolDataFromApi[]>;
5
5
  export declare const _getSubgraphData: ((network: INetworkName) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: INetworkName) => Promise<IVolumeAndAPYs>>;
@@ -244,22 +244,21 @@ export const _getCurveLiteNetworks = memoize(() => __awaiter(void 0, void 0, voi
244
244
  return [];
245
245
  }
246
246
  const { platforms, platformsMetadata } = response.data.data;
247
- const networks = Object.entries(platforms)
248
- .map(([platformId, _factories]) => {
249
- const metadata = platformsMetadata[platformId];
250
- if (!metadata)
251
- return null;
252
- return {
253
- id: platformId,
254
- name: metadata.name,
255
- rpcUrl: metadata.rpcUrl,
256
- chainId: metadata.chainId,
257
- explorerUrl: metadata.explorerBaseUrl,
258
- nativeCurrencySymbol: metadata.nativeCurrencySymbol,
247
+ return Object.keys(platforms)
248
+ .map((id) => {
249
+ var _a;
250
+ const { name, rpcUrl, nativeCurrencySymbol, explorerBaseUrl, isMainnet, chainId } = (_a = platformsMetadata[id]) !== null && _a !== void 0 ? _a : {};
251
+ return name && {
252
+ id,
253
+ name,
254
+ rpcUrl,
255
+ chainId,
256
+ explorerUrl: explorerBaseUrl,
257
+ nativeCurrencySymbol,
258
+ isTestnet: !isMainnet,
259
259
  };
260
260
  })
261
- .filter((network) => network !== null);
262
- return networks;
261
+ .filter(Boolean);
263
262
  }), {
264
263
  promise: true,
265
264
  maxAge: 5 * 60 * 1000, // 5 minutes
@@ -297,6 +297,7 @@ export interface ICurveLiteNetwork {
297
297
  rpcUrl: string;
298
298
  explorerUrl: string;
299
299
  nativeCurrencySymbol: string;
300
+ isTestnet: boolean;
300
301
  }
301
302
  export type TVoteType = "PARAMETER" | "OWNERSHIP";
302
303
  export type AbiParameter = {
@@ -1,11 +1,12 @@
1
1
  import type { IChainId, IDict, IPoolData, IRouteStep } from "./interfaces";
2
- import { curve } from "./curve.js";
2
+ 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;
@@ -1,4 +1,3 @@
1
- import { curve } from "./curve.js";
2
1
  export function routeGraphWorker() {
3
2
  const GRAPH_MAX_EDGES = 3;
4
3
  const SNX = {
@@ -12,7 +11,7 @@ export function routeGraphWorker() {
12
11
  ].map((a) => a.toLowerCase()),
13
12
  },
14
13
  };
15
- const createRouteGraph = ({ constants, chainId, allPools, amplificationCoefficientDict, poolTvlDict }) => {
14
+ const createRouteGraph = ({ constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict }) => {
16
15
  var _a, _b, _c;
17
16
  const routerGraph = {};
18
17
  // ETH <-> WETH (exclude Celo)
@@ -230,7 +229,7 @@ export function routeGraphWorker() {
230
229
  // Skip empty pools
231
230
  if (chainId === 1 && tvl < 1000)
232
231
  continue;
233
- if (chainId !== 1 && !curve.isLiteChain && tvl < 100)
232
+ if (chainId !== 1 && !isLiteChain && tvl < 100)
234
233
  continue;
235
234
  const excludedUnderlyingSwaps = (poolId === 'ib' && chainId === 1) ||
236
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.65.16",
3
+ "version": "2.65.18",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",