@curvefi/llamalend-api 2.0.12 → 2.0.14

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.
@@ -222,10 +222,10 @@ export interface IResponseApi {
222
222
  }
223
223
  export interface IQuote {
224
224
  outAmount: string;
225
- priceImpact: number;
225
+ priceImpact: number | null;
226
226
  }
227
227
  export interface ILeverageMetrics {
228
- priceImpact: number;
228
+ priceImpact: number | null;
229
229
  bands: [number, number];
230
230
  prices: string[];
231
231
  health: string;
@@ -66,6 +66,7 @@ export class LendMarketTemplate {
66
66
  userBoost: userPosition.userBoost.bind(userPosition),
67
67
  forceUpdateUserState: userPosition.forceUpdateUserState.bind(userPosition),
68
68
  getCurrentLeverageParams: userPosition.getCurrentLeverageParams.bind(userPosition),
69
+ clearCache: userPosition.clearCache.bind(userPosition),
69
70
  };
70
71
  this.stats = {
71
72
  parameters: stats.statsParameters.bind(stats),
@@ -38,4 +38,5 @@ export interface IUserPosition {
38
38
  stateCollateral: string;
39
39
  totalDepositFromUser: string;
40
40
  }>;
41
+ clearCache: () => void;
41
42
  }
@@ -624,7 +624,7 @@ export class LeverageZapV2BaseModule {
624
624
  const health = yield this._leverageRepayHealth(stateCollateral, userCollateral, userBorrowed, quote, healthIsFull, address);
625
625
  const _stateCollateral = parseUnits(stateCollateral, this.market.collateral_token.decimals);
626
626
  const _userCollateral = parseUnits(userCollateral, this.market.collateral_token.decimals);
627
- const priceImpact = _stateCollateral + _userCollateral > BigInt(0) ? quote.priceImpact : 0;
627
+ const priceImpact = _stateCollateral + _userCollateral > BigInt(0) ? quote.priceImpact : null;
628
628
  return {
629
629
  priceImpact,
630
630
  bands: [Number(_n2), Number(_n1)],
@@ -44,5 +44,7 @@ export declare class UserPositionModule implements IUserPosition {
44
44
  stateCollateral: string;
45
45
  totalDepositFromUser: string;
46
46
  }>;
47
+ /** Clears the user position cache for the current user. */
48
+ clearCache: () => void;
47
49
  forceUpdateUserState(newTx: string, userAddress?: string): Promise<void>;
48
50
  }
@@ -21,6 +21,8 @@ export class UserPositionModule {
21
21
  promise: true,
22
22
  maxAge: 10 * 1000, // 10s
23
23
  });
24
+ /** Clears the user position cache for the current user. */
25
+ this.clearCache = () => this._userState.clear();
24
26
  this.market = market;
25
27
  this.llamalend = market.getLlamalend();
26
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
package/src/interfaces.ts CHANGED
@@ -235,11 +235,11 @@ export interface IResponseApi {
235
235
 
236
236
  export interface IQuote {
237
237
  outAmount: string,
238
- priceImpact: number
238
+ priceImpact: number | null
239
239
  }
240
240
 
241
241
  export interface ILeverageMetrics {
242
- priceImpact: number,
242
+ priceImpact: number | null,
243
243
  bands: [number, number],
244
244
  prices: string[],
245
245
  health: string,
@@ -163,6 +163,7 @@ export class LendMarketTemplate<V extends 'v1' | 'v2' = 'v1' | 'v2'> {
163
163
  userBoost: userPosition.userBoost.bind(userPosition),
164
164
  forceUpdateUserState: userPosition.forceUpdateUserState.bind(userPosition),
165
165
  getCurrentLeverageParams: userPosition.getCurrentLeverageParams.bind(userPosition),
166
+ clearCache: userPosition.clearCache.bind(userPosition),
166
167
  }
167
168
 
168
169
  this.stats = {
@@ -21,4 +21,5 @@ export interface IUserPosition {
21
21
  userBoost: (address?: string) => Promise<string>,
22
22
  forceUpdateUserState: (newTx: string, userAddress?: string) => Promise<void>,
23
23
  getCurrentLeverageParams: (userAddress: string) => Promise<{ stateCollateral: string, totalDepositFromUser: string }>,
24
+ clearCache: () => void,
24
25
  }
@@ -880,7 +880,7 @@ export class LeverageZapV2BaseModule {
880
880
 
881
881
  const _stateCollateral = parseUnits(stateCollateral, this.market.collateral_token.decimals);
882
882
  const _userCollateral = parseUnits(userCollateral, this.market.collateral_token.decimals);
883
- const priceImpact = _stateCollateral + _userCollateral > BigInt(0) ? quote.priceImpact : 0;
883
+ const priceImpact = _stateCollateral + _userCollateral > BigInt(0) ? quote.priceImpact : null;
884
884
 
885
885
  return {
886
886
  priceImpact,
@@ -231,6 +231,9 @@ export class UserPositionModule implements IUserPosition {
231
231
  };
232
232
  }
233
233
 
234
+ /** Clears the user position cache for the current user. */
235
+ public clearCache = (): void => this._userState.clear();
236
+
234
237
  public async forceUpdateUserState(newTx: string, userAddress?: string): Promise<void> {
235
238
  const address = userAddress || this.llamalend.signerAddress;
236
239
  if (!address) throw Error("Need to connect wallet or pass address into args");