@curvefi/llamalend-api 1.0.23 → 1.0.24

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.
@@ -16,4 +16,5 @@ export declare const _getMarketsData: ((network: INetworkName) => Promise<IMarke
16
16
  export declare function _getQuoteOdos(this: Llamalend, fromToken: string, toToken: string, _amount: bigint, blacklist: string, pathVizImage: boolean, slippage?: number): Promise<IQuoteOdos>;
17
17
  export declare function _getExpectedOdos(this: Llamalend, fromToken: string, toToken: string, _amount: bigint, blacklist: string): Promise<string>;
18
18
  export declare function _assembleTxOdos(this: Llamalend, pathId: string): Promise<string>;
19
+ export declare const _getHiddenPools: (() => Promise<any>) & memoize.Memoized<() => Promise<any>>;
19
20
  export {};
@@ -188,3 +188,10 @@ export function _assembleTxOdos(pathId) {
188
188
  return _assembleTxOdosMemoized(this.constants.ALIASES.leverage_zap, pathId);
189
189
  });
190
190
  }
191
+ export const _getHiddenPools = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
192
+ const response = yield fetch(`https://api.curve.finance/api/getHiddenPools`);
193
+ return (yield response.json()).data;
194
+ }), {
195
+ promise: true,
196
+ maxAge: 5 * 60 * 1000, // 5m
197
+ });
@@ -64,6 +64,7 @@ declare class Llamalend implements ILlamalend {
64
64
  maxFeePerGas?: number;
65
65
  maxPriorityFeePerGas?: number;
66
66
  }): void;
67
+ _filterHiddenMarkets(markets: IDict<IOneWayMarket>): Promise<IDict<IOneWayMarket>>;
67
68
  getLendMarketList: () => string[];
68
69
  getMintMarketList: () => string[];
69
70
  getFactoryMarketData: () => Promise<Record<string, any>>;
package/lib/llamalend.js CHANGED
@@ -42,7 +42,7 @@ import { LLAMMAS } from "./constants/llammas";
42
42
  import { L2Networks } from "./constants/L2Networks.js";
43
43
  import { createCall, handleMultiCallResponse } from "./utils.js";
44
44
  import { cacheKey, cacheStats } from "./cache/index.js";
45
- import { _getMarketsData } from "./external-api.js";
45
+ import { _getMarketsData, _getHiddenPools } from "./external-api.js";
46
46
  import { extractDecimals } from "./constants/utils.js";
47
47
  export const NETWORK_CONSTANTS = {
48
48
  1: {
@@ -296,6 +296,7 @@ class Llamalend {
296
296
  collateral_token: COIN_DATA[collateral_tokens[index]],
297
297
  };
298
298
  });
299
+ this.constants.ONE_WAY_MARKETS = yield this._filterHiddenMarkets(this.constants.ONE_WAY_MARKETS);
299
300
  yield this.fetchStats(amms, controllers, vaults, borrowed_tokens, collateral_tokens);
300
301
  });
301
302
  this._fetchOneWayMarketsByAPI = () => __awaiter(this, void 0, void 0, function* () {
@@ -341,6 +342,7 @@ class Llamalend {
341
342
  collateral_token: COIN_DATA[collateral_tokens[index]],
342
343
  };
343
344
  });
345
+ this.constants.ONE_WAY_MARKETS = yield this._filterHiddenMarkets(this.constants.ONE_WAY_MARKETS);
344
346
  });
345
347
  this.address = '00000';
346
348
  this.crvUsdAddress = COINS_ETHEREUM.crvusd;
@@ -649,6 +651,12 @@ class Llamalend {
649
651
  setCustomFeeData(customFeeData) {
650
652
  this.feeData = Object.assign(Object.assign({}, this.feeData), customFeeData);
651
653
  }
654
+ _filterHiddenMarkets(markets) {
655
+ return __awaiter(this, void 0, void 0, function* () {
656
+ const hiddenMarkets = (yield _getHiddenPools())[this.constants.NETWORK_NAME] || [];
657
+ return Object.fromEntries(Object.entries(markets).filter(([id]) => !hiddenMarkets.includes(id)));
658
+ });
659
+ }
652
660
  formatUnits(value, unit) {
653
661
  return ethers.formatUnits(value, unit);
654
662
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -209,3 +209,15 @@ const _assembleTxOdosMemoized = memoize(
209
209
  export async function _assembleTxOdos(this: Llamalend, pathId: string): Promise<string> {
210
210
  return _assembleTxOdosMemoized(this.constants.ALIASES.leverage_zap, pathId);
211
211
  }
212
+
213
+ export const _getHiddenPools = memoize(
214
+ async () => {
215
+ const response = await fetch(`https://api.curve.finance/api/getHiddenPools`)
216
+
217
+ return (await response.json() as any).data
218
+ },
219
+ {
220
+ promise: true,
221
+ maxAge: 5 * 60 * 1000, // 5m
222
+ }
223
+ )
package/src/llamalend.ts CHANGED
@@ -79,7 +79,7 @@ import {LLAMMAS} from "./constants/llammas";
79
79
  import {L2Networks} from "./constants/L2Networks.js";
80
80
  import {createCall, handleMultiCallResponse} from "./utils.js";
81
81
  import {cacheKey, cacheStats} from "./cache/index.js";
82
- import {_getMarketsData} from "./external-api.js";
82
+ import {_getMarketsData, _getHiddenPools} from "./external-api.js";
83
83
  import {extractDecimals} from "./constants/utils.js";
84
84
 
85
85
  export const NETWORK_CONSTANTS: { [index: number]: any } = {
@@ -529,6 +529,11 @@ class Llamalend implements ILlamalend {
529
529
  this.feeData = { ...this.feeData, ...customFeeData };
530
530
  }
531
531
 
532
+ async _filterHiddenMarkets(markets: IDict<IOneWayMarket>): Promise<IDict<IOneWayMarket>> {
533
+ const hiddenMarkets = (await _getHiddenPools() as any)[this.constants.NETWORK_NAME] || [];
534
+ return Object.fromEntries(Object.entries(markets).filter(([id]) => !hiddenMarkets.includes(id))) as IDict<IOneWayMarket>;
535
+ }
536
+
532
537
  getLendMarketList = () => Object.keys(this.constants.ONE_WAY_MARKETS);
533
538
 
534
539
  getMintMarketList = () => Object.keys(this.constants.LLAMMAS);
@@ -720,6 +725,8 @@ class Llamalend implements ILlamalend {
720
725
  }
721
726
  })
722
727
 
728
+ this.constants.ONE_WAY_MARKETS = await this._filterHiddenMarkets(this.constants.ONE_WAY_MARKETS);
729
+
723
730
  await this.fetchStats(amms, controllers, vaults, borrowed_tokens, collateral_tokens);
724
731
  }
725
732
 
@@ -767,6 +774,8 @@ class Llamalend implements ILlamalend {
767
774
  collateral_token: COIN_DATA[collateral_tokens[index]],
768
775
  }
769
776
  })
777
+
778
+ this.constants.ONE_WAY_MARKETS = await this._filterHiddenMarkets(this.constants.ONE_WAY_MARKETS);
770
779
  }
771
780
 
772
781
  formatUnits(value: BigNumberish, unit?: string | Numeric): string {