@curvefi/llamalend-api 2.0.13 → 2.0.15

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;
@@ -266,6 +266,7 @@ export class LeverageZapV1BaseModule {
266
266
  }
267
267
  const userEffectiveCollateralBN = maxBorrowableBN.gt(0) ? toBN(_userEffectiveCollateral, this.market.collateral_token.decimals) : BN(0);
268
268
  const maxLeverageCollateralBN = toBN(_maxLeverageCollateral, this.market.collateral_token.decimals);
269
+ maxBorrowableBN = maxBorrowableBN.gt(0) ? maxBorrowableBN : BN(0);
269
270
  return {
270
271
  maxDebt: formatNumber(maxBorrowableBN.toString(), this.market.borrowed_token.decimals),
271
272
  maxTotalCollateral: formatNumber(maxLeverageCollateralBN.plus(userEffectiveCollateralBN).toString(), this.market.collateral_token.decimals),
@@ -254,6 +254,7 @@ export class LeverageZapV2BaseModule {
254
254
  }
255
255
  const userEffectiveCollateralBN = maxBorrowableBN.gt(0) ? toBN(_userEffectiveCollateral, this.market.collateral_token.decimals) : BN(0);
256
256
  const maxLeverageCollateralBN = toBN(_maxLeverageCollateral, this.market.collateral_token.decimals);
257
+ maxBorrowableBN = maxBorrowableBN.gt(0) ? maxBorrowableBN : BN(0);
257
258
  return {
258
259
  maxDebt: formatNumber(maxBorrowableBN.toString(), this.market.borrowed_token.decimals),
259
260
  maxTotalCollateral: formatNumber(maxLeverageCollateralBN.plus(userEffectiveCollateralBN).toString(), this.market.collateral_token.decimals),
@@ -624,7 +625,7 @@ export class LeverageZapV2BaseModule {
624
625
  const health = yield this._leverageRepayHealth(stateCollateral, userCollateral, userBorrowed, quote, healthIsFull, address);
625
626
  const _stateCollateral = parseUnits(stateCollateral, this.market.collateral_token.decimals);
626
627
  const _userCollateral = parseUnits(userCollateral, this.market.collateral_token.decimals);
627
- const priceImpact = _stateCollateral + _userCollateral > BigInt(0) ? quote.priceImpact : 0;
628
+ const priceImpact = _stateCollateral + _userCollateral > BigInt(0) ? quote.priceImpact : null;
628
629
  return {
629
630
  priceImpact,
630
631
  bands: [Number(_n2), Number(_n1)],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
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,
@@ -116,6 +116,7 @@ export class LeverageZapV1BaseModule {
116
116
 
117
117
  const userEffectiveCollateralBN = maxBorrowableBN.gt(0) ? toBN(_userEffectiveCollateral, this.market.collateral_token.decimals) : BN(0);
118
118
  const maxLeverageCollateralBN = toBN(_maxLeverageCollateral, this.market.collateral_token.decimals);
119
+ maxBorrowableBN = maxBorrowableBN.gt(0) ? maxBorrowableBN : BN(0);
119
120
 
120
121
  return {
121
122
  maxDebt: formatNumber(maxBorrowableBN.toString(), this.market.borrowed_token.decimals),
@@ -134,6 +134,7 @@ export class LeverageZapV2BaseModule {
134
134
 
135
135
  const userEffectiveCollateralBN = maxBorrowableBN.gt(0) ? toBN(_userEffectiveCollateral, this.market.collateral_token.decimals) : BN(0);
136
136
  const maxLeverageCollateralBN = toBN(_maxLeverageCollateral, this.market.collateral_token.decimals);
137
+ maxBorrowableBN = maxBorrowableBN.gt(0) ? maxBorrowableBN : BN(0);
137
138
 
138
139
  return {
139
140
  maxDebt: formatNumber(maxBorrowableBN.toString(), this.market.borrowed_token.decimals),
@@ -880,7 +881,7 @@ export class LeverageZapV2BaseModule {
880
881
 
881
882
  const _stateCollateral = parseUnits(stateCollateral, this.market.collateral_token.decimals);
882
883
  const _userCollateral = parseUnits(userCollateral, this.market.collateral_token.decimals);
883
- const priceImpact = _stateCollateral + _userCollateral > BigInt(0) ? quote.priceImpact : 0;
884
+ const priceImpact = _stateCollateral + _userCollateral > BigInt(0) ? quote.priceImpact : null;
884
885
 
885
886
  return {
886
887
  priceImpact,