@curvefi/api 2.69.2 → 2.69.3

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/lib/curve.d.ts CHANGED
@@ -59,14 +59,14 @@ export declare class Curve implements ICurve {
59
59
  initContract: (address: string, abi: any, provider: BrowserProvider | JsonRpcProvider | Signer) => Contract;
60
60
  initMulticallContract: (address: string, abi: any) => MulticallContract;
61
61
  setContract(address: string | undefined, abi: any): void;
62
- _filterHiddenPools(pools: IDict<IPoolData>): Promise<IDict<IPoolData>>;
62
+ _filterHiddenPools(pools: IDict<IPoolData>, isFiltered?: boolean): Promise<IDict<IPoolData>>;
63
63
  _updateDecimalsAndGauges(pools: IDict<IPoolData>): void;
64
- fetchFactoryPools: (useApi?: boolean) => Promise<void>;
65
- fetchCrvusdFactoryPools: (useApi?: boolean) => Promise<void>;
66
- fetchCryptoFactoryPools: (useApi?: boolean) => Promise<void>;
67
- fetchStableNgFactoryPools: (useApi?: boolean) => Promise<void>;
68
- fetchTworyptoFactoryPools: (useApi?: boolean) => Promise<void>;
69
- fetchTricryptoFactoryPools: (useApi?: boolean) => Promise<void>;
64
+ fetchFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
65
+ fetchCrvusdFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
66
+ fetchCryptoFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
67
+ fetchStableNgFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
68
+ fetchTworyptoFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
69
+ fetchTricryptoFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
70
70
  fetchNewFactoryPools: () => Promise<string[]>;
71
71
  fetchNewCryptoFactoryPools: () => Promise<string[]>;
72
72
  fetchNewStableNgFactoryPools: () => Promise<string[]>;
package/lib/curve.js CHANGED
@@ -49,7 +49,7 @@ import circulatingSupplyABI from './constants/abis/circulating_supply.json' with
49
49
  import rootGaugeFactoryABI from "./constants/abis/gauge_factory/root_gauge_factory.json" with { type: "json" };
50
50
  import fastBridgeABI from './constants/abis/fastBridge.json' with { type: 'json' };
51
51
  import { extractDecimals, extractGauges, formatUnits, lowerCasePoolDataAddresses, parseUnits, } from "./constants/utils.js";
52
- import { _getHiddenPools } from "./external-api.js";
52
+ import { _getHiddenPools, _getPoolFilters } from "./external-api.js";
53
53
  import { L2Networks } from "./constants/L2Networks.js";
54
54
  import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto.js";
55
55
  import { applyFeeDataOverride, computeEip1559Fees, computeLegacyOrFallback, fetchFeeHistory, getNetworkConstants, } from "./utils.js";
@@ -85,7 +85,7 @@ export class Curve {
85
85
  constructor() {
86
86
  this.initContract = memoizedContract();
87
87
  this.initMulticallContract = memoizedMulticallContract();
88
- this.fetchFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
88
+ this.fetchFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
89
89
  if (!("factory" in this.constants.ALIASES))
90
90
  return;
91
91
  if (useApi) {
@@ -94,11 +94,11 @@ export class Curve {
94
94
  else {
95
95
  this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getFactoryPoolData.call(this));
96
96
  }
97
- this.constants.FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA);
97
+ this.constants.FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA, isFiltered);
98
98
  this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
99
99
  this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory"] = this.isNoRPC ? null : yield this.contracts[this.constants.ALIASES.factory].contract.gauge_implementation(this.constantOptions);
100
100
  });
101
- this.fetchCrvusdFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
101
+ this.fetchCrvusdFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
102
102
  if (!("crvusd_factory" in this.constants.ALIASES))
103
103
  return;
104
104
  if (useApi) {
@@ -110,10 +110,10 @@ export class Curve {
110
110
  }
111
111
  this.constants.CRVUSD_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.crvusd_factory));
112
112
  }
113
- this.constants.CRVUSD_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.CRVUSD_FACTORY_POOLS_DATA);
113
+ this.constants.CRVUSD_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.CRVUSD_FACTORY_POOLS_DATA, isFiltered);
114
114
  this._updateDecimalsAndGauges(this.constants.CRVUSD_FACTORY_POOLS_DATA);
115
115
  });
116
- this.fetchCryptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
116
+ this.fetchCryptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
117
117
  if (!("crypto_factory" in this.constants.ALIASES))
118
118
  return;
119
119
  if (useApi) {
@@ -125,11 +125,11 @@ export class Curve {
125
125
  }
126
126
  this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getCryptoFactoryPoolData.call(this));
127
127
  }
128
- this.constants.CRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA);
128
+ this.constants.CRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA, isFiltered);
129
129
  this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
130
130
  this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory-crypto"] = this.isNoRPC ? null : yield this.contracts[this.constants.ALIASES.crypto_factory].contract.gauge_implementation(this.constantOptions);
131
131
  });
132
- this.fetchStableNgFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
132
+ this.fetchStableNgFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
133
133
  if (!("stable_ng_factory" in this.constants.ALIASES))
134
134
  return;
135
135
  if (useApi) {
@@ -141,10 +141,10 @@ export class Curve {
141
141
  }
142
142
  this.constants.STABLE_NG_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.stable_ng_factory));
143
143
  }
144
- this.constants.STABLE_NG_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.STABLE_NG_FACTORY_POOLS_DATA);
144
+ this.constants.STABLE_NG_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.STABLE_NG_FACTORY_POOLS_DATA, isFiltered);
145
145
  this._updateDecimalsAndGauges(this.constants.STABLE_NG_FACTORY_POOLS_DATA);
146
146
  });
147
- this.fetchTworyptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
147
+ this.fetchTworyptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
148
148
  if (!("twocrypto_factory" in this.constants.ALIASES))
149
149
  return;
150
150
  if (useApi) {
@@ -156,7 +156,7 @@ export class Curve {
156
156
  }
157
157
  this.constants.TWOCRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getTwocryptoFactoryPoolData.call(this));
158
158
  }
159
- this.constants.TWOCRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.TWOCRYPTO_FACTORY_POOLS_DATA);
159
+ this.constants.TWOCRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.TWOCRYPTO_FACTORY_POOLS_DATA, isFiltered);
160
160
  this._updateDecimalsAndGauges(this.constants.TWOCRYPTO_FACTORY_POOLS_DATA);
161
161
  if (this.chainId === 1) {
162
162
  this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory-twocrypto"] = this.isNoRPC ? null :
@@ -167,7 +167,7 @@ export class Curve {
167
167
  yield this.contracts[this.constants.ALIASES.child_gauge_factory].contract.get_implementation(this.constantOptions);
168
168
  }
169
169
  });
170
- this.fetchTricryptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
170
+ this.fetchTricryptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
171
171
  if (!("tricrypto_factory" in this.constants.ALIASES))
172
172
  return;
173
173
  if (useApi) {
@@ -179,7 +179,7 @@ export class Curve {
179
179
  }
180
180
  this.constants.TRICRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getTricryptoFactoryPoolData.call(this));
181
181
  }
182
- this.constants.TRICRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
182
+ this.constants.TRICRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.TRICRYPTO_FACTORY_POOLS_DATA, isFiltered);
183
183
  this._updateDecimalsAndGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
184
184
  if (this.chainId === 1) {
185
185
  this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory-tricrypto"] = this.isNoRPC ? null :
@@ -662,10 +662,16 @@ export class Curve {
662
662
  };
663
663
  this.contracts[address] = new Proxy(coreContract, proxyHandler);
664
664
  }
665
- _filterHiddenPools(pools) {
666
- return __awaiter(this, void 0, void 0, function* () {
667
- const hiddenPools = (yield _getHiddenPools(this.isLiteChain))[this.constants.NETWORK_NAME] || [];
668
- return Object.fromEntries(Object.entries(pools).filter(([id]) => !hiddenPools.includes(id)));
665
+ _filterHiddenPools(pools_1) {
666
+ return __awaiter(this, arguments, void 0, function* (pools, isFiltered = false) {
667
+ const hiddenPoolsAll = yield _getHiddenPools(this.isLiteChain);
668
+ const hiddenPools = hiddenPoolsAll[this.constants.NETWORK_NAME];
669
+ let filteredAddresses;
670
+ if (isFiltered) {
671
+ const poolFilters = yield _getPoolFilters();
672
+ filteredAddresses = new Set(poolFilters[this.constants.NETWORK_NAME]);
673
+ }
674
+ return Object.fromEntries(Object.entries(pools).filter(([id, pool]) => !(hiddenPools === null || hiddenPools === void 0 ? void 0 : hiddenPools.includes(id)) && !(filteredAddresses === null || filteredAddresses === void 0 ? void 0 : filteredAddresses.has(pool.swap_address))));
669
675
  });
670
676
  }
671
677
  _updateDecimalsAndGauges(pools) {
@@ -9,6 +9,7 @@ export declare const _getFactoryAPYs: ((network: string) => Promise<IVolumeAndAP
9
9
  export declare const _getAllGauges: (() => Promise<IDict<IGaugesDataFromApi>>) & memoize.Memoized<() => Promise<IDict<IGaugesDataFromApi>>>;
10
10
  export declare const _getAllGaugesFormatted: (() => Promise<IDict<any>>) & memoize.Memoized<() => Promise<IDict<any>>>;
11
11
  export declare const _getHiddenPools: ((isLiteChain: boolean) => Promise<IDict<string[]>>) & memoize.Memoized<(isLiteChain: boolean) => Promise<IDict<string[]>>>;
12
+ export declare const _getPoolFilters: (() => Promise<IDict<string[]>>) & memoize.Memoized<() => Promise<IDict<string[]>>>;
12
13
  export declare const _generateBoostingProof: ((block: number, address: string) => Promise<{
13
14
  block_header_rlp: string;
14
15
  proof_rlp: string;
@@ -190,6 +190,19 @@ export const _getHiddenPools = memoize((isLiteChain) => fetchData(`https://${isL
190
190
  promise: true,
191
191
  maxAge: 5 * 60 * 1000, // 5m
192
192
  });
193
+ export const _getPoolFilters = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
194
+ try {
195
+ const { data } = yield fetchJson("https://prices.curve.finance/v1/chains/pool_filters");
196
+ return Object.fromEntries((data !== null && data !== void 0 ? data : []).map(({ chain, pools }) => [chain, pools.map((pool) => pool.address.toLowerCase())]));
197
+ }
198
+ catch (error) {
199
+ console.error('Error fetching pool filters:', error);
200
+ return {};
201
+ }
202
+ }), {
203
+ promise: true,
204
+ maxAge: 5 * 60 * 1000, // 5m
205
+ });
193
206
  export const _generateBoostingProof = memoize((block, address) => __awaiter(void 0, void 0, void 0, function* () {
194
207
  const url = `https://prices.curve.finance/v1/general/get_merkle_proof?block=${block}&account_address=${address}`;
195
208
  const { block_header_rlp, proof_rlp } = yield fetchJson(url);
package/lib/index.d.ts CHANGED
@@ -72,7 +72,7 @@ export declare const createCurve: () => {
72
72
  getIsLiteChain: () => boolean;
73
73
  isNoRPC: boolean;
74
74
  factory: {
75
- fetchPools: (useApi?: boolean) => Promise<void>;
75
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
76
76
  fetchNewPools: () => Promise<string[]>;
77
77
  getPoolList: () => string[];
78
78
  deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5, emaTime?: number | undefined, oracleAddress?: string | undefined, methodName?: string | undefined) => Promise<ethers.ContractTransactionResponse>;
@@ -98,11 +98,11 @@ export declare const createCurve: () => {
98
98
  };
99
99
  };
100
100
  crvUSDFactory: {
101
- fetchPools: (useApi?: boolean) => Promise<void>;
101
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
102
102
  getPoolList: () => string[];
103
103
  };
104
104
  stableNgFactory: {
105
- fetchPools: (useApi?: boolean) => Promise<void>;
105
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
106
106
  fetchNewPools: () => Promise<string[]>;
107
107
  getPoolList: () => string[];
108
108
  deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, offpegFeeMultiplier: string | number, assetTypes: (0 | 1 | 2 | 3)[], implementationIdx: 0, emaTime: number, oracleAddresses: string[], methodNames: string[]) => Promise<ethers.ContractTransactionResponse>;
@@ -122,7 +122,7 @@ export declare const createCurve: () => {
122
122
  };
123
123
  };
124
124
  cryptoFactory: {
125
- fetchPools: (useApi?: boolean) => Promise<void>;
125
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
126
126
  fetchNewPools: () => Promise<string[]>;
127
127
  getPoolList: () => string[];
128
128
  deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number) => Promise<ethers.ContractTransactionResponse>;
@@ -143,7 +143,7 @@ export declare const createCurve: () => {
143
143
  };
144
144
  };
145
145
  twocryptoFactory: {
146
- fetchPools: (useApi?: boolean) => Promise<void>;
146
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
147
147
  fetchNewPools: () => Promise<string[]>;
148
148
  getPoolList: () => string[];
149
149
  deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number, implementationIdx?: import("./constants/twoCryptoImplementations.js").TwoCryptoImplementation | undefined) => Promise<ethers.ContractTransactionResponse>;
@@ -165,7 +165,7 @@ export declare const createCurve: () => {
165
165
  };
166
166
  };
167
167
  tricryptoFactory: {
168
- fetchPools: (useApi?: boolean) => Promise<void>;
168
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
169
169
  fetchNewPools: () => Promise<string[]>;
170
170
  getPoolList: () => string[];
171
171
  deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, emaTime: number, initialPrices: (string | number)[]) => Promise<ethers.ContractTransactionResponse>;
@@ -404,7 +404,7 @@ declare const _default: {
404
404
  getIsLiteChain: () => boolean;
405
405
  isNoRPC: boolean;
406
406
  factory: {
407
- fetchPools: (useApi?: boolean) => Promise<void>;
407
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
408
408
  fetchNewPools: () => Promise<string[]>;
409
409
  getPoolList: () => string[];
410
410
  deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5, emaTime?: number | undefined, oracleAddress?: string | undefined, methodName?: string | undefined) => Promise<ethers.ContractTransactionResponse>;
@@ -430,11 +430,11 @@ declare const _default: {
430
430
  };
431
431
  };
432
432
  crvUSDFactory: {
433
- fetchPools: (useApi?: boolean) => Promise<void>;
433
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
434
434
  getPoolList: () => string[];
435
435
  };
436
436
  stableNgFactory: {
437
- fetchPools: (useApi?: boolean) => Promise<void>;
437
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
438
438
  fetchNewPools: () => Promise<string[]>;
439
439
  getPoolList: () => string[];
440
440
  deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, offpegFeeMultiplier: string | number, assetTypes: (0 | 1 | 2 | 3)[], implementationIdx: 0, emaTime: number, oracleAddresses: string[], methodNames: string[]) => Promise<ethers.ContractTransactionResponse>;
@@ -454,7 +454,7 @@ declare const _default: {
454
454
  };
455
455
  };
456
456
  cryptoFactory: {
457
- fetchPools: (useApi?: boolean) => Promise<void>;
457
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
458
458
  fetchNewPools: () => Promise<string[]>;
459
459
  getPoolList: () => string[];
460
460
  deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number) => Promise<ethers.ContractTransactionResponse>;
@@ -475,7 +475,7 @@ declare const _default: {
475
475
  };
476
476
  };
477
477
  twocryptoFactory: {
478
- fetchPools: (useApi?: boolean) => Promise<void>;
478
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
479
479
  fetchNewPools: () => Promise<string[]>;
480
480
  getPoolList: () => string[];
481
481
  deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number, implementationIdx?: import("./constants/twoCryptoImplementations.js").TwoCryptoImplementation | undefined) => Promise<ethers.ContractTransactionResponse>;
@@ -497,7 +497,7 @@ declare const _default: {
497
497
  };
498
498
  };
499
499
  tricryptoFactory: {
500
- fetchPools: (useApi?: boolean) => Promise<void>;
500
+ fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
501
501
  fetchNewPools: () => Promise<string[]>;
502
502
  getPoolList: () => string[];
503
503
  deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, emaTime: number, initialPrices: (string | number)[]) => Promise<ethers.ContractTransactionResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.69.2",
3
+ "version": "2.69.3",
4
4
  "description": "JavaScript library for curve.finance",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",