@curvefi/llamalend-api 2.0.19 → 2.0.21

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.
@@ -29,6 +29,7 @@ export const ALIASES_OPTIMISM = lowerCaseValues({
29
29
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
30
30
  "gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
31
31
  "gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
32
+ "old_gauge_end_index": "4",
32
33
  "leverage_zap": "0xBFab8ebc836E1c4D81837798FC076D219C9a1855", // odos v3
33
34
  "leverage_zap_v2": "0xE94d1fBF399c27CCBf0185b2Dd11Bf0FA0f0D95C",
34
35
  "leverage_markets_start_id": "0",
@@ -41,6 +42,7 @@ export const ALIASES_FRAXTAL = lowerCaseValues({
41
42
  "gauge_controller": "0x0000000000000000000000000000000000000000", // <--- TODO CHANGE
42
43
  "gauge_factory_old": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
43
44
  "gauge_factory": "0x0b8d6b6cefc7aa1c2852442e518443b1b22e1c52",
45
+ "old_gauge_end_index": "3",
44
46
  "leverage_zap": "0x3294514B78Df4Bb90132567fcf8E5e99f390B687", // odos v3
45
47
  "leverage_zap_v2": "0x16C6521Dff6baB339122a0FE25a9116693265353",
46
48
  "leverage_markets_start_id": "0",
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { createCall, handleMultiCallResponse } from "../../utils.js";
11
11
  import { _getMarketsData } from "../../external-api.js";
12
12
  export const getFactoryMarketDataV1 = (llamalend) => __awaiter(void 0, void 0, void 0, function* () {
13
+ var _a;
13
14
  const factoryAlias = 'one_way_factory';
14
15
  if (!llamalend.constants.ALIASES[factoryAlias] || llamalend.constants.ALIASES[factoryAlias] === llamalend.constants.ZERO_ADDRESS) {
15
16
  throw new Error(`Factory v1 is not available for network ${llamalend.constants.NETWORK_NAME}`);
@@ -26,7 +27,15 @@ export const getFactoryMarketDataV1 = (llamalend) => __awaiter(void 0, void 0, v
26
27
  });
27
28
  }
28
29
  const res = (yield llamalend.multicallProvider.all(calls)).map((addr) => addr.toLowerCase());
29
- return handleMultiCallResponse(callsMap, res);
30
+ const factoryData = handleMultiCallResponse(callsMap, res);
31
+ const oldGaugeEndIndex = Number((_a = llamalend.constants.ALIASES.old_gauge_end_index) !== null && _a !== void 0 ? _a : -1);
32
+ if (oldGaugeEndIndex >= 0) {
33
+ const oldGaugeFactory = llamalend.contracts[llamalend.constants.ALIASES.gauge_factory_old];
34
+ const vaults = factoryData.vaults.slice(0, oldGaugeEndIndex + 1);
35
+ const gauges = (yield llamalend.multicallProvider.all(vaults.map((vault) => createCall(oldGaugeFactory, "get_gauge_from_lp_token", [vault])))).map((address) => address.toLowerCase());
36
+ gauges.forEach((gauge, i) => { factoryData.gauges[i] = gauge; });
37
+ }
38
+ return factoryData;
30
39
  });
31
40
  export const getFactoryMarketDataByAPI = (llamalend) => __awaiter(void 0, void 0, void 0, function* () {
32
41
  const apiData = (yield _getMarketsData(llamalend.constants.NETWORK_NAME)).lendingVaultData;
@@ -174,11 +174,12 @@ export class StatsBaseModule {
174
174
  }
175
175
  statsFutureRates(dReserves_1, dDebt_1) {
176
176
  return __awaiter(this, arguments, void 0, function* (dReserves, dDebt, useAPI = true) {
177
+ const isGetter = false;
177
178
  const _dReserves = parseUnits(dReserves, this.market.borrowed_token.decimals);
178
179
  const _dDebt = parseUnits(dDebt, this.market.borrowed_token.decimals);
179
180
  const _rate = yield this._getFutureRate(_dReserves, _dDebt);
180
- const debt = Number(yield this.statsTotalDebt()) + Number(dDebt);
181
- const cap = Number((yield this.statsCapAndAvailable(true, useAPI)).totalAssets) + Number(dReserves);
181
+ const debt = Number(yield this.statsTotalDebt(isGetter, useAPI)) + Number(dDebt);
182
+ const cap = Number((yield this.statsCapAndAvailable(isGetter, useAPI)).totalAssets) + Number(dReserves);
182
183
  return computeRatesFromRate(_rate, debt, cap);
183
184
  });
184
185
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -33,6 +33,7 @@ export const ALIASES_OPTIMISM = lowerCaseValues({
33
33
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
34
34
  "gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
35
35
  "gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
36
+ "old_gauge_end_index": "4",
36
37
  "leverage_zap": "0xBFab8ebc836E1c4D81837798FC076D219C9a1855", // odos v3
37
38
  "leverage_zap_v2": "0xE94d1fBF399c27CCBf0185b2Dd11Bf0FA0f0D95C",
38
39
  "leverage_markets_start_id": "0",
@@ -46,6 +47,7 @@ export const ALIASES_FRAXTAL = lowerCaseValues({
46
47
  "gauge_controller": "0x0000000000000000000000000000000000000000", // <--- TODO CHANGE
47
48
  "gauge_factory_old": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
48
49
  "gauge_factory": "0x0b8d6b6cefc7aa1c2852442e518443b1b22e1c52",
50
+ "old_gauge_end_index": "3",
49
51
  "leverage_zap": "0x3294514B78Df4Bb90132567fcf8E5e99f390B687", // odos v3
50
52
  "leverage_zap_v2": "0x16C6521Dff6baB339122a0FE25a9116693265353",
51
53
  "leverage_markets_start_id": "0",
@@ -25,7 +25,19 @@ export const getFactoryMarketDataV1 = async (llamalend: Llamalend) => {
25
25
  }
26
26
  const res = (await llamalend.multicallProvider.all(calls) as string[]).map((addr) => addr.toLowerCase());
27
27
 
28
- return handleMultiCallResponse(callsMap, res)
28
+ const factoryData = handleMultiCallResponse(callsMap, res);
29
+
30
+ const oldGaugeEndIndex = Number(llamalend.constants.ALIASES.old_gauge_end_index ?? -1);
31
+ if (oldGaugeEndIndex >= 0) {
32
+ const oldGaugeFactory = llamalend.contracts[llamalend.constants.ALIASES.gauge_factory_old];
33
+ const vaults = factoryData.vaults.slice(0, oldGaugeEndIndex + 1);
34
+ const gauges = (await llamalend.multicallProvider.all(
35
+ vaults.map((vault: string) => createCall(oldGaugeFactory, "get_gauge_from_lp_token", [vault]))
36
+ ) as string[]).map((address) => address.toLowerCase());
37
+ gauges.forEach((gauge, i) => { factoryData.gauges[i] = gauge; });
38
+ }
39
+
40
+ return factoryData;
29
41
  };
30
42
 
31
43
  export const getFactoryMarketDataByAPI = async (llamalend: Llamalend) => {
@@ -130,11 +130,12 @@ export class StatsBaseModule {
130
130
  }
131
131
 
132
132
  public async statsFutureRates(dReserves: TAmount, dDebt: TAmount, useAPI = true): Promise<{borrowApr: string, lendApr: string, borrowApy: string, lendApy: string}> {
133
+ const isGetter = false;
133
134
  const _dReserves = parseUnits(dReserves, this.market.borrowed_token.decimals);
134
135
  const _dDebt = parseUnits(dDebt, this.market.borrowed_token.decimals);
135
136
  const _rate = await this._getFutureRate(_dReserves, _dDebt);
136
- const debt = Number(await this.statsTotalDebt()) + Number(dDebt);
137
- const cap = Number((await this.statsCapAndAvailable(true, useAPI)).totalAssets) + Number(dReserves);
137
+ const debt = Number(await this.statsTotalDebt(isGetter, useAPI)) + Number(dDebt);
138
+ const cap = Number((await this.statsCapAndAvailable(isGetter, useAPI)).totalAssets) + Number(dReserves);
138
139
  return computeRatesFromRate(_rate, debt, cap);
139
140
  }
140
141