@curvefi/llamalend-api 1.1.12 → 1.1.13

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.
@@ -3,7 +3,7 @@ import type { Llamalend } from "../llamalend.js";
3
3
  import { IDict, TGas, TAmount, IReward, IQuoteOdos, IOneWayMarket, IPartialFrac } from "../interfaces.js";
4
4
  import { ILeverageZapV2 } from "./interfaces/leverageZapV2.js";
5
5
  export declare class LendMarketTemplate {
6
- private llamalend;
6
+ llamalend: Llamalend;
7
7
  id: string;
8
8
  name: string;
9
9
  addresses: {
@@ -535,5 +535,6 @@ export declare class LendMarketTemplate {
535
535
  currentPnL(userAddress?: string): Promise<Record<string, string>>;
536
536
  userBoost(address?: string): Promise<string>;
537
537
  forceUpdateUserState(newTx: string, userAddress?: string): Promise<void>;
538
- getLlamalend(): Llamalend;
538
+ /** Clears all memoization caches. */
539
+ clearCache(): void;
539
540
  }
@@ -2925,7 +2925,20 @@ export class LendMarketTemplate {
2925
2925
  yield _getUserCollateralForce(this.llamalend.constants.NETWORK_NAME, this.addresses.controller, address, newTx);
2926
2926
  });
2927
2927
  }
2928
- getLlamalend() {
2929
- return this.llamalend;
2928
+ /** Clears all memoization caches. */
2929
+ clearCache() {
2930
+ this.vaultRewardTokens.clear();
2931
+ this.statsParameters.clear();
2932
+ this.statsBandsInfo.clear();
2933
+ this.A.clear();
2934
+ this.basePrice.clear();
2935
+ this.oraclePrice.clear();
2936
+ this.oracleAddress.clear();
2937
+ this._userState.clear();
2938
+ this.createLoanMaxRecvAllRanges.clear();
2939
+ this.leverageCreateLoanMaxRecvAllRanges.clear();
2940
+ this._leverageCalcN1.clear();
2941
+ this._leverageCalcN1AllRanges.clear();
2942
+ this._leverageRepayBands.clear();
2930
2943
  }
2931
2944
  }
@@ -182,7 +182,7 @@ export class LeverageZapV2Module {
182
182
  maxAge: 5 * 60 * 1000, // 5m
183
183
  });
184
184
  this.market = market;
185
- this.llamalend = market.getLlamalend();
185
+ this.llamalend = market.llamalend;
186
186
  }
187
187
  _checkLeverageZap() {
188
188
  if (!this.hasLeverage()) {
@@ -3,7 +3,7 @@ import type { Llamalend } from "../llamalend.js";
3
3
  import { IDict, ILlamma, TGas, IRates } from "../interfaces.js";
4
4
  import { ILeverageV2 } from "./interfaces/leverage.js";
5
5
  export declare class MintMarketTemplate {
6
- private llamalend;
6
+ llamalend: Llamalend;
7
7
  id: string;
8
8
  address: string;
9
9
  controller: string;
@@ -177,6 +177,8 @@ export declare class MintMarketTemplate {
177
177
  stablecoin: string;
178
178
  debt: string;
179
179
  }>;
180
+ /** Clears all memoization caches. */
181
+ clearCache(): void;
180
182
  userLoss(userAddress?: string): Promise<{
181
183
  deposited_collateral: string;
182
184
  current_collateral_estimation: string;
@@ -342,5 +344,4 @@ export declare class MintMarketTemplate {
342
344
  private _checkLeverageForStats;
343
345
  currentLeverage(userAddress?: string): Promise<string>;
344
346
  currentPnL(userAddress?: string): Promise<Record<string, string>>;
345
- getLlamalend(): Llamalend;
346
347
  }
@@ -518,6 +518,25 @@ export class MintMarketTemplate {
518
518
  };
519
519
  });
520
520
  }
521
+ /** Clears all memoization caches. */
522
+ clearCache() {
523
+ this.statsParameters.clear();
524
+ this.statsMaxMinBands.clear();
525
+ this.statsActiveBand.clear();
526
+ this.statsTotalSupply.clear();
527
+ this.statsTotalDebt.clear();
528
+ this.statsTotalStablecoin.clear();
529
+ this.statsTotalCollateral.clear();
530
+ this.statsCapAndAvailable.clear();
531
+ this.oracleAddress.clear();
532
+ this.basePrice.clear();
533
+ this.createLoanMaxRecvAllRanges.clear();
534
+ this.leverageCreateLoanMaxRecvAllRanges.clear();
535
+ this._leverageCreateLoanMaxRecvAllRanges2.clear();
536
+ this._leverageCreateLoanCollateral.clear();
537
+ this.deleverageRepayStablecoins.clear();
538
+ this._deleverageRepayBands.clear();
539
+ }
521
540
  userLoss() {
522
541
  return __awaiter(this, arguments, void 0, function* (userAddress = "") {
523
542
  userAddress = _getAddress.call(this.llamalend, userAddress);
@@ -1861,7 +1880,4 @@ export class MintMarketTemplate {
1861
1880
  };
1862
1881
  });
1863
1882
  }
1864
- getLlamalend() {
1865
- return this.llamalend;
1866
- }
1867
1883
  }
@@ -209,7 +209,7 @@ export class LeverageV2Module {
209
209
  maxAge: 5 * 60 * 1000, // 5m
210
210
  });
211
211
  this.market = market;
212
- this.llamalend = market.getLlamalend();
212
+ this.llamalend = market.llamalend;
213
213
  }
214
214
  // ============ CREATE LOAN METHODS ============
215
215
  // ---------------- LEVERAGE CREATE LOAN ----------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -36,7 +36,7 @@ const WEEK = 7 * DAY;
36
36
 
37
37
 
38
38
  export class LendMarketTemplate {
39
- private llamalend: Llamalend;
39
+ llamalend: Llamalend;
40
40
  id: string;
41
41
  name: string
42
42
  addresses: {
@@ -3333,7 +3333,20 @@ export class LendMarketTemplate {
3333
3333
  );
3334
3334
  }
3335
3335
 
3336
- public getLlamalend(): Llamalend {
3337
- return this.llamalend;
3336
+ /** Clears all memoization caches. */
3337
+ public clearCache(): void {
3338
+ this.vaultRewardTokens.clear();
3339
+ this.statsParameters.clear();
3340
+ this.statsBandsInfo.clear();
3341
+ this.A.clear();
3342
+ this.basePrice.clear();
3343
+ this.oraclePrice.clear();
3344
+ this.oracleAddress.clear();
3345
+ this._userState.clear();
3346
+ this.createLoanMaxRecvAllRanges.clear();
3347
+ this.leverageCreateLoanMaxRecvAllRanges.clear();
3348
+ this._leverageCalcN1.clear();
3349
+ this._leverageCalcN1AllRanges.clear();
3350
+ this._leverageRepayBands.clear();
3338
3351
  }
3339
3352
  }
@@ -29,7 +29,7 @@ export class LeverageZapV2Module {
29
29
 
30
30
  constructor(market: LendMarketTemplate) {
31
31
  this.market = market;
32
- this.llamalend = market.getLlamalend();
32
+ this.llamalend = market.llamalend;
33
33
  }
34
34
 
35
35
  private _getMarketId = (): number => Number(this.market.id.split("-").slice(-1)[0]);
@@ -28,7 +28,7 @@ import { LeverageV2Module } from "./modules/index.js";
28
28
 
29
29
 
30
30
  export class MintMarketTemplate {
31
- private llamalend: Llamalend;
31
+ llamalend: Llamalend;
32
32
  id: string;
33
33
  address: string;
34
34
  controller: string;
@@ -546,6 +546,26 @@ export class MintMarketTemplate {
546
546
  };
547
547
  }
548
548
 
549
+ /** Clears all memoization caches. */
550
+ public clearCache(): void {
551
+ this.statsParameters.clear();
552
+ this.statsMaxMinBands.clear();
553
+ this.statsActiveBand.clear();
554
+ this.statsTotalSupply.clear();
555
+ this.statsTotalDebt.clear();
556
+ this.statsTotalStablecoin.clear();
557
+ this.statsTotalCollateral.clear();
558
+ this.statsCapAndAvailable.clear();
559
+ this.oracleAddress.clear();
560
+ this.basePrice.clear();
561
+ this.createLoanMaxRecvAllRanges.clear();
562
+ this.leverageCreateLoanMaxRecvAllRanges.clear();
563
+ this._leverageCreateLoanMaxRecvAllRanges2.clear();
564
+ this._leverageCreateLoanCollateral.clear();
565
+ this.deleverageRepayStablecoins.clear();
566
+ this._deleverageRepayBands.clear();
567
+ }
568
+
549
569
  public async userLoss(userAddress = ""): Promise<{ deposited_collateral: string, current_collateral_estimation: string, loss: string, loss_pct: string }> {
550
570
  userAddress = _getAddress.call(this.llamalend, userAddress);
551
571
  const [deposited_collateral, _current_collateral_estimation] = await Promise.all([
@@ -2007,8 +2027,4 @@ export class MintMarketTemplate {
2007
2027
  percentage: percentage.toString(),
2008
2028
  };
2009
2029
  }
2010
-
2011
- public getLlamalend(): Llamalend {
2012
- return this.llamalend;
2013
- }
2014
2030
  }
@@ -31,7 +31,7 @@ export class LeverageV2Module {
31
31
 
32
32
  constructor(market: MintMarketTemplate) {
33
33
  this.market = market;
34
- this.llamalend = market.getLlamalend();
34
+ this.llamalend = market.llamalend;
35
35
  }
36
36
 
37
37
  private _getMarketId = (): number => {