@curvefi/llamalend-api 2.0.10 → 2.0.11

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.
@@ -469,6 +469,36 @@ market.loan.estimateGas.repay({ debt, address?, shrink? }) // params: { debt: T
469
469
  | forceUpdateUserState() | ✅ | ✅ | ✅ | ✅ | ✅ |
470
470
  | getCurrentLeverageParams() | ✅ | ✅ | ✅ | ✅ | ✅ |
471
471
 
472
+ ### `isSoftLiquidation` field in `userState` / `userStateBigInt`
473
+
474
+ The `userState` and `userStateBigInt` methods now include an `isSoftLiquidation` field in their return value.
475
+
476
+ **Updated return types:**
477
+
478
+ ```ts
479
+ // userState
480
+ market.userPosition.userState(address?: string): Promise<{
481
+ collateral: string,
482
+ borrowed: string,
483
+ debt: string,
484
+ N: string,
485
+ isSoftLiquidation: boolean,
486
+ }>
487
+
488
+ // userStateBigInt
489
+ market.userPosition.userStateBigInt(address?: string): Promise<{
490
+ _collateral: bigint,
491
+ _borrowed: bigint,
492
+ _debt: bigint,
493
+ _N: bigint,
494
+ isSoftLiquidation: boolean,
495
+ }>
496
+ ```
497
+
498
+ **Logic:** `isSoftLiquidation` is `true` when the user has an active loan (`debt > 0`) and the AMM has partially converted collateral into the borrowed token (`borrowed > 0`).
499
+
500
+ **Note:** Also applies to mint markets (`MintMarketTemplate`). In mint markets the field is returned by `userState` and is `true` when `stablecoin > 0` (the stablecoin amount reflects converted collateral in the AMM).
501
+
472
502
  ---
473
503
 
474
504
  ## Leverage Module (`market.leverage`)
@@ -6,6 +6,7 @@ export interface IUserPosition {
6
6
  _borrowed: bigint;
7
7
  _debt: bigint;
8
8
  _N: bigint;
9
+ isSoftLiquidation: boolean;
9
10
  }>;
10
11
  userBandsBigInt: (address: string) => Promise<bigint[]>;
11
12
  userState: (address?: string) => Promise<{
@@ -13,6 +14,7 @@ export interface IUserPosition {
13
14
  borrowed: string;
14
15
  debt: string;
15
16
  N: string;
17
+ isSoftLiquidation: boolean;
16
18
  }>;
17
19
  userHealth: (full?: boolean, address?: string) => Promise<string>;
18
20
  userBands: (address?: string) => Promise<number[]>;
@@ -12,12 +12,14 @@ export declare class UserPositionModule implements IUserPosition {
12
12
  borrowed: string;
13
13
  debt: string;
14
14
  N: string;
15
+ isSoftLiquidation: boolean;
15
16
  }>;
16
17
  userStateBigInt(address?: string): Promise<{
17
18
  _collateral: bigint;
18
19
  _borrowed: bigint;
19
20
  _debt: bigint;
20
21
  _N: bigint;
22
+ isSoftLiquidation: boolean;
21
23
  }>;
22
24
  userHealth(full?: boolean, address?: string): Promise<string>;
23
25
  private _userBands;
@@ -38,12 +38,14 @@ export class UserPositionModule {
38
38
  borrowed: formatUnits(_borrowed, this.market.borrowed_token.decimals),
39
39
  debt: formatUnits(_debt, this.market.borrowed_token.decimals),
40
40
  N: formatUnits(_N, 0),
41
+ isSoftLiquidation: !!_debt && !!_borrowed,
41
42
  };
42
43
  });
43
44
  }
44
45
  userStateBigInt() {
45
46
  return __awaiter(this, arguments, void 0, function* (address = "") {
46
- return yield this._userState(address);
47
+ const state = yield this._userState(address);
48
+ return Object.assign(Object.assign({}, state), { isSoftLiquidation: !!state._debt && !!state._borrowed });
47
49
  });
48
50
  }
49
51
  userHealth() {
@@ -176,6 +176,7 @@ export declare class MintMarketTemplate {
176
176
  collateral: string;
177
177
  stablecoin: string;
178
178
  debt: string;
179
+ isSoftLiquidation: boolean;
179
180
  }>;
180
181
  userLoss(userAddress?: string): Promise<{
181
182
  deposited_collateral: string;
@@ -515,6 +515,7 @@ export class MintMarketTemplate {
515
515
  collateral: formatUnits(_collateral, this.collateralDecimals),
516
516
  stablecoin: formatUnits(_stablecoin),
517
517
  debt: formatUnits(_debt),
518
+ isSoftLiquidation: !!_debt && !!_stablecoin,
518
519
  };
519
520
  });
520
521
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -2,9 +2,9 @@ import {IDict} from "../../../interfaces";
2
2
 
3
3
  export interface IUserPosition {
4
4
  userLoanExists: (address?: string) => Promise<boolean>,
5
- userStateBigInt: (address?: string) => Promise<{ _collateral: bigint, _borrowed: bigint, _debt: bigint, _N: bigint }>,
5
+ userStateBigInt: (address?: string) => Promise<{ _collateral: bigint, _borrowed: bigint, _debt: bigint, _N: bigint, isSoftLiquidation: boolean }>,
6
6
  userBandsBigInt:(address: string) => Promise<bigint[]>,
7
- userState: (address?: string) => Promise<{ collateral: string, borrowed: string, debt: string, N: string }>,
7
+ userState: (address?: string) => Promise<{ collateral: string, borrowed: string, debt: string, N: string, isSoftLiquidation: boolean }>,
8
8
  userHealth: (full?: boolean, address?: string) => Promise<string>,
9
9
  userBands: (address?: string) => Promise<number[]>,
10
10
  userRange: (address?: string) => Promise<number>,
@@ -36,7 +36,7 @@ export class UserPositionModule implements IUserPosition {
36
36
  maxAge: 10 * 1000, // 10s
37
37
  });
38
38
 
39
- public async userState(address = ""): Promise<{ collateral: string, borrowed: string, debt: string, N: string }> {
39
+ public async userState(address = ""): Promise<{ collateral: string, borrowed: string, debt: string, N: string, isSoftLiquidation: boolean }> {
40
40
  const { _collateral, _borrowed, _debt, _N } = await this._userState(address);
41
41
 
42
42
  return {
@@ -44,11 +44,13 @@ export class UserPositionModule implements IUserPosition {
44
44
  borrowed: formatUnits(_borrowed, this.market.borrowed_token.decimals),
45
45
  debt: formatUnits(_debt, this.market.borrowed_token.decimals),
46
46
  N: formatUnits(_N, 0),
47
+ isSoftLiquidation: !!_debt && !!_borrowed,
47
48
  };
48
49
  }
49
50
 
50
- public async userStateBigInt(address = ""): Promise<{ _collateral: bigint, _borrowed: bigint, _debt: bigint, _N: bigint }> {
51
- return await this._userState(address);
51
+ public async userStateBigInt(address = ""): Promise<{ _collateral: bigint, _borrowed: bigint, _debt: bigint, _N: bigint, isSoftLiquidation: boolean }> {
52
+ const state = await this._userState(address);
53
+ return { ...state, isSoftLiquidation: !!state._debt && !!state._borrowed };
52
54
  }
53
55
 
54
56
  public async userHealth(full = true, address = ""): Promise<string> {
@@ -536,13 +536,14 @@ export class MintMarketTemplate {
536
536
  return { _collateral, _stablecoin, _debt }
537
537
  }
538
538
 
539
- public async userState(address = ""): Promise<{ collateral: string, stablecoin: string, debt: string }> {
539
+ public async userState(address = ""): Promise<{ collateral: string, stablecoin: string, debt: string, isSoftLiquidation: boolean }> {
540
540
  const { _collateral, _stablecoin, _debt } = await this._userState(address);
541
541
 
542
542
  return {
543
543
  collateral: formatUnits(_collateral, this.collateralDecimals),
544
544
  stablecoin: formatUnits(_stablecoin),
545
545
  debt: formatUnits(_debt),
546
+ isSoftLiquidation: !!_debt && !!_stablecoin,
546
547
  };
547
548
  }
548
549