@curvefi/llamalend-api 1.0.22-beta.1 → 1.0.22-beta.2

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.
@@ -4,7 +4,7 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
- - feat/init
7
+ - feat/hide-pools
8
8
 
9
9
  jobs:
10
10
  release:
@@ -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<IDict<string[]>>) & memoize.Memoized<() => Promise<IDict<string[]>>>;
19
20
  export {};
@@ -188,3 +188,9 @@ export function _assembleTxOdos(pathId) {
188
188
  return _assembleTxOdosMemoized(this.constants.ALIASES.leverage_zap, pathId);
189
189
  });
190
190
  }
191
+ export const _getHiddenPools = memoize(() => fetch(`https://api.curve.finance/api/getHiddenPools`)
192
+ .then((r) => (r.json()))
193
+ .then((json) => json.data), {
194
+ promise: true,
195
+ maxAge: 5 * 60 * 1000, // 5m
196
+ });
@@ -76,5 +76,6 @@ declare class Llamalend implements ILlamalend {
76
76
  formatUnits(value: BigNumberish, unit?: string | Numeric): string;
77
77
  parseUnits(value: string, unit?: string | Numeric): bigint;
78
78
  updateFeeData(): Promise<void>;
79
+ _filterHiddenPools(pools: IDict<ILlamma>): Promise<IDict<ILlamma>>;
79
80
  }
80
81
  export { Llamalend };
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 { _getHiddenPools, _getMarketsData } from "./external-api.js";
46
46
  import { extractDecimals } from "./constants/utils.js";
47
47
  export const NETWORK_CONSTANTS = {
48
48
  1: {
@@ -388,7 +388,7 @@ class Llamalend {
388
388
  this.options = {};
389
389
  this.constants = {
390
390
  ONE_WAY_MARKETS: {},
391
- LLAMMAS: Object.assign({}, LLAMMAS),
391
+ LLAMMAS: yield this._filterHiddenPools(LLAMMAS),
392
392
  COINS: {},
393
393
  DECIMALS: {},
394
394
  NETWORK_NAME: 'ethereum',
@@ -676,5 +676,11 @@ class Llamalend {
676
676
  }
677
677
  });
678
678
  }
679
+ _filterHiddenPools(pools) {
680
+ return __awaiter(this, void 0, void 0, function* () {
681
+ const hiddenPools = (yield _getHiddenPools())[this.constants.NETWORK_NAME] || [];
682
+ return Object.fromEntries(Object.entries(pools).filter(([id]) => !hiddenPools.includes(id)));
683
+ });
684
+ }
679
685
  }
680
686
  export { Llamalend };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "1.0.22-beta.1",
3
+ "version": "1.0.22-beta.2",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -209,3 +209,13 @@ 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
+ () => fetch(`https://api.curve.finance/api/getHiddenPools`)
215
+ .then((r) => (r.json()))
216
+ .then((json) => (json as {data: IDict<string[]>}).data),
217
+ {
218
+ promise: true,
219
+ maxAge: 5 * 60 * 1000, // 5m
220
+ }
221
+ )
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 {_getHiddenPools, _getMarketsData} from "./external-api.js";
83
83
  import {extractDecimals} from "./constants/utils.js";
84
84
 
85
85
  export const NETWORK_CONSTANTS: { [index: number]: any } = {
@@ -244,7 +244,7 @@ class Llamalend implements ILlamalend {
244
244
  this.options = {};
245
245
  this.constants = {
246
246
  ONE_WAY_MARKETS: {},
247
- LLAMMAS: {...LLAMMAS},
247
+ LLAMMAS: await this._filterHiddenPools(LLAMMAS),
248
248
  COINS: {},
249
249
  DECIMALS: {},
250
250
  NETWORK_NAME: 'ethereum',
@@ -797,6 +797,11 @@ class Llamalend implements ILlamalend {
797
797
  feeData.maxPriorityFeePerGas;
798
798
  }
799
799
  }
800
+
801
+ async _filterHiddenPools(pools: IDict<ILlamma>): Promise<IDict<ILlamma>> {
802
+ const hiddenPools = (await _getHiddenPools())[this.constants.NETWORK_NAME] || [];
803
+ return Object.fromEntries(Object.entries(pools).filter(([id]) => !hiddenPools.includes(id))) as IDict<ILlamma>;
804
+ }
800
805
  }
801
806
 
802
807
  export { Llamalend };