@curvefi/llamalend-api 1.0.22 → 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.
@@ -1,5 +1,5 @@
1
- import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' assert { type: 'json' };
2
- import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' assert { type: 'json' };
1
+ import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' with { type: 'json' };
2
+ import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' with { type: 'json' };
3
3
  import { lowerCaseLlammasAddresses } from "./utils";
4
4
  export const LLAMMAS = lowerCaseLlammasAddresses({
5
5
  sfrxeth: {
@@ -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
+ });
@@ -11,7 +11,7 @@ import memoize from "memoizee";
11
11
  import BigNumber from "bignumber.js";
12
12
  import { _getAddress, parseUnits, BN, toBN, fromBN, getBalances, _ensureAllowance, ensureAllowance, hasAllowance, ensureAllowanceEstimateGas, _cutZeros, formatUnits, formatNumber, MAX_ALLOWANCE, MAX_ACTIVE_BAND, _mulBy1_3, _getUsdRate, DIGas, smartNumber, } from "../utils.js";
13
13
  import { _getExpectedOdos, _getQuoteOdos, _assembleTxOdos, _getUserCollateral, _getMarketsData } from "../external-api.js";
14
- import ERC20Abi from '../constants/abis/ERC20.json' assert { type: 'json' };
14
+ import ERC20Abi from '../constants/abis/ERC20.json' with { type: 'json' };
15
15
  import { cacheKey, cacheStats } from "../cache/index.js";
16
16
  const DAY = 86400;
17
17
  const WEEK = 7 * DAY;
@@ -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
@@ -10,39 +10,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { ethers, Contract, AbstractProvider } from "ethers";
11
11
  import { Provider as MulticallProvider, Contract as MulticallContract } from '@curvefi/ethcall';
12
12
  // OneWayMarket ABIs
13
- import OneWayLendingFactoryABI from "./constants/abis/OneWayLendingFactoryABI.json" assert { type: 'json' };
14
- import ERC20ABI from './constants/abis/ERC20.json' assert { type: 'json' };
15
- import ERC4626ABI from './constants/abis/ERC4626.json' assert { type: 'json' };
16
- import LlammaABI from './constants/abis/Llamma.json' assert { type: 'json' };
17
- import ControllerABI from './constants/abis/Controller.json' assert { type: 'json' };
18
- import MonetaryPolicyABI from './constants/abis/MonetaryPolicy.json' assert { type: 'json' };
19
- import VaultABI from './constants/abis/Vault.json' assert { type: 'json' };
20
- import GaugeABI from './constants/abis/GaugeV5.json' assert { type: 'json' };
21
- import SidechainGaugeABI from './constants/abis/SidechainGauge.json' assert { type: 'json' };
22
- import GaugeControllerABI from './constants/abis/GaugeController.json' assert { type: 'json' };
23
- import GaugeFactoryMainnetABI from './constants/abis/GaugeFactoryMainnet.json' assert { type: 'json' };
24
- import GaugeFactorySidechainABI from './constants/abis/GaugeFactorySidechain.json' assert { type: 'json' };
25
- import MinterABI from './constants/abis/Minter.json' assert { type: 'json' };
26
- import LeverageZapABI from './constants/abis/LeverageZap.json' assert { type: 'json' };
27
- import gasOracleABI from './constants/abis/gas_oracle_optimism.json' assert { type: 'json' };
28
- import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' assert { type: 'json' };
13
+ import OneWayLendingFactoryABI from "./constants/abis/OneWayLendingFactoryABI.json" with { type: 'json' };
14
+ import ERC20ABI from './constants/abis/ERC20.json' with { type: 'json' };
15
+ import ERC4626ABI from './constants/abis/ERC4626.json' with { type: 'json' };
16
+ import LlammaABI from './constants/abis/Llamma.json' with { type: 'json' };
17
+ import ControllerABI from './constants/abis/Controller.json' with { type: 'json' };
18
+ import MonetaryPolicyABI from './constants/abis/MonetaryPolicy.json' with { type: 'json' };
19
+ import VaultABI from './constants/abis/Vault.json' with { type: 'json' };
20
+ import GaugeABI from './constants/abis/GaugeV5.json' with { type: 'json' };
21
+ import SidechainGaugeABI from './constants/abis/SidechainGauge.json' with { type: 'json' };
22
+ import GaugeControllerABI from './constants/abis/GaugeController.json' with { type: 'json' };
23
+ import GaugeFactoryMainnetABI from './constants/abis/GaugeFactoryMainnet.json' with { type: 'json' };
24
+ import GaugeFactorySidechainABI from './constants/abis/GaugeFactorySidechain.json' with { type: 'json' };
25
+ import MinterABI from './constants/abis/Minter.json' with { type: 'json' };
26
+ import LeverageZapABI from './constants/abis/LeverageZap.json' with { type: 'json' };
27
+ import gasOracleABI from './constants/abis/gas_oracle_optimism.json' with { type: 'json' };
28
+ import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' with { type: 'json' };
29
29
  // crvUSD ABIs
30
- import llammaABI from "./constants/abis/crvUSD/llamma.json" assert { type: 'json' };
31
- import controllerABI from "./constants/abis/crvUSD/controller.json" assert { type: 'json' };
30
+ import llammaABI from "./constants/abis/crvUSD/llamma.json" with { type: 'json' };
31
+ import controllerABI from "./constants/abis/crvUSD/controller.json" with { type: 'json' };
32
32
  import controllerV2ABI from "./constants/abis/crvUSD/controller_v2.json";
33
- import PegKeeper from "./constants/abis/crvUSD/PegKeeper.json" assert { type: 'json' };
34
- import FactoryABI from "./constants/abis/crvUSD/Factory.json" assert { type: 'json' };
35
- import MonetaryPolicy2ABI from "./constants/abis/crvUSD/MonetaryPolicy2.json" assert { type: 'json' };
36
- import HealthCalculatorZapABI from "./constants/abis/crvUSD/HealthCalculatorZap.json" assert { type: 'json' };
37
- import LeverageZapCrvUSDABI from "./constants/abis/crvUSD/LeverageZap.json" assert { type: 'json' };
38
- import DeleverageZapABI from "./constants/abis/crvUSD/DeleverageZap.json" assert { type: 'json' };
33
+ import PegKeeper from "./constants/abis/crvUSD/PegKeeper.json" with { type: 'json' };
34
+ import FactoryABI from "./constants/abis/crvUSD/Factory.json" with { type: 'json' };
35
+ import MonetaryPolicy2ABI from "./constants/abis/crvUSD/MonetaryPolicy2.json" with { type: 'json' };
36
+ import HealthCalculatorZapABI from "./constants/abis/crvUSD/HealthCalculatorZap.json" with { type: 'json' };
37
+ import LeverageZapCrvUSDABI from "./constants/abis/crvUSD/LeverageZap.json" with { type: 'json' };
38
+ import DeleverageZapABI from "./constants/abis/crvUSD/DeleverageZap.json" with { type: 'json' };
39
39
  import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_POLYGON, ALIASES_FANTOM, ALIASES_AVALANCHE, ALIASES_ARBITRUM, ALIASES_XDAI, ALIASES_MOONBEAM, ALIASES_AURORA, ALIASES_KAVA, ALIASES_CELO, ALIASES_ZKSYNC, ALIASES_BASE, ALIASES_BSC, ALIASES_FRAXTAL, ALIASES_SONIC, } from "./constants/aliases.js";
40
40
  import { COINS_ETHEREUM, COINS_OPTIMISM, COINS_POLYGON, COINS_FANTOM, COINS_AVALANCHE, COINS_ARBITRUM, COINS_XDAI, COINS_MOONBEAM, COINS_AURORA, COINS_KAVA, COINS_CELO, COINS_ZKSYNC, COINS_BASE, COINS_BSC, COINS_FRAXTAL, COINS_SONIC, } from "./constants/coins.js";
41
41
  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.22",
3
+ "version": "1.0.24",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -1,6 +1,6 @@
1
1
  import { IDict, ILlamma } from "../interfaces";
2
- import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' assert { type: 'json'};
3
- import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' assert { type: 'json'};
2
+ import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' with {type: 'json'};
3
+ import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' with {type: 'json'};
4
4
  import { lowerCaseLlammasAddresses } from "./utils";
5
5
 
6
6
 
@@ -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
+ )
@@ -24,7 +24,7 @@ import {
24
24
  } from "../utils.js";
25
25
  import {IDict, TGas, TAmount, IReward, IQuoteOdos, IOneWayMarket} from "../interfaces.js";
26
26
  import { _getExpectedOdos, _getQuoteOdos, _assembleTxOdos, _getUserCollateral, _getMarketsData } from "../external-api.js";
27
- import ERC20Abi from '../constants/abis/ERC20.json' assert { type: 'json' };
27
+ import ERC20Abi from '../constants/abis/ERC20.json' with {type: 'json'};
28
28
  import {cacheKey, cacheStats} from "../cache/index.js";
29
29
 
30
30
 
package/src/llamalend.ts CHANGED
@@ -12,32 +12,32 @@ import {
12
12
  IMarketDataAPI,
13
13
  } from "./interfaces.js";
14
14
  // OneWayMarket ABIs
15
- import OneWayLendingFactoryABI from "./constants/abis/OneWayLendingFactoryABI.json" assert { type: 'json' };
16
- import ERC20ABI from './constants/abis/ERC20.json' assert {type: 'json'};
17
- import ERC4626ABI from './constants/abis/ERC4626.json' assert {type: 'json'};
18
- import LlammaABI from './constants/abis/Llamma.json' assert {type: 'json'};
19
- import ControllerABI from './constants/abis/Controller.json' assert {type: 'json'};
20
- import MonetaryPolicyABI from './constants/abis/MonetaryPolicy.json' assert {type: 'json'};
21
- import VaultABI from './constants/abis/Vault.json' assert {type: 'json'};
22
- import GaugeABI from './constants/abis/GaugeV5.json' assert {type: 'json'};
23
- import SidechainGaugeABI from './constants/abis/SidechainGauge.json' assert {type: 'json'};
24
- import GaugeControllerABI from './constants/abis/GaugeController.json' assert {type: 'json'};
25
- import GaugeFactoryMainnetABI from './constants/abis/GaugeFactoryMainnet.json' assert {type: 'json'};
26
- import GaugeFactorySidechainABI from './constants/abis/GaugeFactorySidechain.json' assert {type: 'json'};
27
- import MinterABI from './constants/abis/Minter.json' assert {type: 'json'};
28
- import LeverageZapABI from './constants/abis/LeverageZap.json' assert {type: 'json'};
29
- import gasOracleABI from './constants/abis/gas_oracle_optimism.json' assert {type: 'json'};
30
- import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' assert {type: 'json'};
15
+ import OneWayLendingFactoryABI from "./constants/abis/OneWayLendingFactoryABI.json" with {type: 'json'};
16
+ import ERC20ABI from './constants/abis/ERC20.json' with {type: 'json'};
17
+ import ERC4626ABI from './constants/abis/ERC4626.json' with {type: 'json'};
18
+ import LlammaABI from './constants/abis/Llamma.json' with {type: 'json'};
19
+ import ControllerABI from './constants/abis/Controller.json' with {type: 'json'};
20
+ import MonetaryPolicyABI from './constants/abis/MonetaryPolicy.json' with {type: 'json'};
21
+ import VaultABI from './constants/abis/Vault.json' with {type: 'json'};
22
+ import GaugeABI from './constants/abis/GaugeV5.json' with {type: 'json'};
23
+ import SidechainGaugeABI from './constants/abis/SidechainGauge.json' with {type: 'json'};
24
+ import GaugeControllerABI from './constants/abis/GaugeController.json' with {type: 'json'};
25
+ import GaugeFactoryMainnetABI from './constants/abis/GaugeFactoryMainnet.json' with {type: 'json'};
26
+ import GaugeFactorySidechainABI from './constants/abis/GaugeFactorySidechain.json' with {type: 'json'};
27
+ import MinterABI from './constants/abis/Minter.json' with {type: 'json'};
28
+ import LeverageZapABI from './constants/abis/LeverageZap.json' with {type: 'json'};
29
+ import gasOracleABI from './constants/abis/gas_oracle_optimism.json' with {type: 'json'};
30
+ import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' with {type: 'json'};
31
31
  // crvUSD ABIs
32
- import llammaABI from "./constants/abis/crvUSD/llamma.json" assert { type: 'json'};
33
- import controllerABI from "./constants/abis/crvUSD/controller.json" assert { type: 'json'};
32
+ import llammaABI from "./constants/abis/crvUSD/llamma.json" with {type: 'json'};
33
+ import controllerABI from "./constants/abis/crvUSD/controller.json" with {type: 'json'};
34
34
  import controllerV2ABI from "./constants/abis/crvUSD/controller_v2.json";
35
- import PegKeeper from "./constants/abis/crvUSD/PegKeeper.json" assert { type: 'json'};
36
- import FactoryABI from "./constants/abis/crvUSD/Factory.json" assert { type: 'json'};
37
- import MonetaryPolicy2ABI from "./constants/abis/crvUSD/MonetaryPolicy2.json" assert { type: 'json'};
38
- import HealthCalculatorZapABI from "./constants/abis/crvUSD/HealthCalculatorZap.json" assert { type: 'json'};
39
- import LeverageZapCrvUSDABI from "./constants/abis/crvUSD/LeverageZap.json" assert { type: 'json'};
40
- import DeleverageZapABI from "./constants/abis/crvUSD/DeleverageZap.json" assert { type: 'json'};
35
+ import PegKeeper from "./constants/abis/crvUSD/PegKeeper.json" with {type: 'json'};
36
+ import FactoryABI from "./constants/abis/crvUSD/Factory.json" with {type: 'json'};
37
+ import MonetaryPolicy2ABI from "./constants/abis/crvUSD/MonetaryPolicy2.json" with {type: 'json'};
38
+ import HealthCalculatorZapABI from "./constants/abis/crvUSD/HealthCalculatorZap.json" with {type: 'json'};
39
+ import LeverageZapCrvUSDABI from "./constants/abis/crvUSD/LeverageZap.json" with {type: 'json'};
40
+ import DeleverageZapABI from "./constants/abis/crvUSD/DeleverageZap.json" with {type: 'json'};
41
41
 
42
42
  import {
43
43
  ALIASES_ETHEREUM,
@@ -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 {