@sovryn-zero/lib-base 0.2.0 → 0.2.2

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.
Files changed (41) hide show
  1. package/dist/index.d.ts +13 -13
  2. package/dist/index.js +25 -25
  3. package/dist/src/Decimal.d.ts +88 -88
  4. package/dist/src/Decimal.js +360 -360
  5. package/dist/src/Fees.d.ts +81 -81
  6. package/dist/src/Fees.js +122 -122
  7. package/dist/src/LiquityStore.d.ts +206 -208
  8. package/dist/src/LiquityStore.d.ts.map +1 -1
  9. package/dist/src/LiquityStore.js +207 -208
  10. package/dist/src/LiquityStore.js.map +1 -1
  11. package/dist/src/ObservableLiquity.d.ts +14 -14
  12. package/dist/src/ObservableLiquity.js +2 -2
  13. package/dist/src/PopulatableLiquity.d.ts +124 -124
  14. package/dist/src/PopulatableLiquity.js +2 -2
  15. package/dist/src/ReadableLiquity.d.ts +151 -155
  16. package/dist/src/ReadableLiquity.d.ts.map +1 -1
  17. package/dist/src/ReadableLiquity.js +2 -2
  18. package/dist/src/SendableLiquity.d.ts +155 -155
  19. package/dist/src/SendableLiquity.js +19 -19
  20. package/dist/src/StabilityDeposit.d.ts +58 -58
  21. package/dist/src/StabilityDeposit.js +79 -79
  22. package/dist/src/TransactableLiquity.d.ts +413 -413
  23. package/dist/src/TransactableLiquity.js +17 -17
  24. package/dist/src/Trove.d.ts +366 -366
  25. package/dist/src/Trove.js +422 -422
  26. package/dist/src/ZEROStake.d.ts +51 -51
  27. package/dist/src/ZEROStake.js +73 -73
  28. package/dist/src/_CachedReadableLiquity.d.ts +53 -54
  29. package/dist/src/_CachedReadableLiquity.d.ts.map +1 -1
  30. package/dist/src/_CachedReadableLiquity.js +88 -92
  31. package/dist/src/_CachedReadableLiquity.js.map +1 -1
  32. package/dist/src/constants.d.ts +60 -60
  33. package/dist/src/constants.d.ts.map +1 -1
  34. package/dist/src/constants.js +63 -63
  35. package/dist/src/constants.js.map +1 -1
  36. package/etc/lib-base.api.md +0 -4
  37. package/package.json +1 -1
  38. package/src/LiquityStore.ts +0 -9
  39. package/src/ReadableLiquity.ts +0 -5
  40. package/src/_CachedReadableLiquity.ts +0 -7
  41. package/src/constants.ts +1 -1
@@ -1,367 +1,367 @@
1
- import { Decimal, Decimalish } from "./Decimal";
2
- /** @internal */ export declare type _CollateralDeposit<T> = {
3
- depositCollateral: T;
4
- };
5
- /** @internal */ export declare type _CollateralWithdrawal<T> = {
6
- withdrawCollateral: T;
7
- };
8
- /** @internal */ export declare type _ZUSDBorrowing<T> = {
9
- borrowZUSD: T;
10
- };
11
- /** @internal */ export declare type _ZUSDRepayment<T> = {
12
- repayZUSD: T;
13
- };
14
- /** @internal */ export declare type _NoCollateralDeposit = Partial<_CollateralDeposit<undefined>>;
15
- /** @internal */ export declare type _NoCollateralWithdrawal = Partial<_CollateralWithdrawal<undefined>>;
16
- /** @internal */ export declare type _NoZUSDBorrowing = Partial<_ZUSDBorrowing<undefined>>;
17
- /** @internal */ export declare type _NoZUSDRepayment = Partial<_ZUSDRepayment<undefined>>;
18
- /** @internal */
19
- export declare type _CollateralChange<T> = (_CollateralDeposit<T> & _NoCollateralWithdrawal) | (_CollateralWithdrawal<T> & _NoCollateralDeposit);
20
- /** @internal */
21
- export declare type _NoCollateralChange = _NoCollateralDeposit & _NoCollateralWithdrawal;
22
- /** @internal */
23
- export declare type _DebtChange<T> = (_ZUSDBorrowing<T> & _NoZUSDRepayment) | (_ZUSDRepayment<T> & _NoZUSDBorrowing);
24
- /** @internal */
25
- export declare type _NoDebtChange = _NoZUSDBorrowing & _NoZUSDRepayment;
26
- /**
27
- * Parameters of an {@link TransactableLiquity.openTrove | openTrove()} transaction.
28
- *
29
- * @remarks
30
- * The type parameter `T` specifies the allowed value type(s) of the particular `TroveCreationParams`
31
- * object's properties.
32
- *
33
- * <h2>Properties</h2>
34
- *
35
- * <table>
36
- *
37
- * <tr>
38
- * <th> Property </th>
39
- * <th> Type </th>
40
- * <th> Description </th>
41
- * </tr>
42
- *
43
- * <tr>
44
- * <td> depositCollateral </td>
45
- * <td> T </td>
46
- * <td> The amount of collateral that's deposited. </td>
47
- * </tr>
48
- *
49
- * <tr>
50
- * <td> borrowZUSD </td>
51
- * <td> T </td>
52
- * <td> The amount of ZUSD that's borrowed. </td>
53
- * </tr>
54
- *
55
- * </table>
56
- *
57
- * @public
58
- */
59
- export declare type TroveCreationParams<T = unknown> = _CollateralDeposit<T> & _NoCollateralWithdrawal & _ZUSDBorrowing<T> & _NoZUSDRepayment;
60
- /**
61
- * Parameters of a {@link TransactableLiquity.closeTrove | closeTrove()} transaction.
62
- *
63
- * @remarks
64
- * The type parameter `T` specifies the allowed value type(s) of the particular `TroveClosureParams`
65
- * object's properties.
66
- *
67
- * <h2>Properties</h2>
68
- *
69
- * <table>
70
- *
71
- * <tr>
72
- * <th> Property </th>
73
- * <th> Type </th>
74
- * <th> Description </th>
75
- * </tr>
76
- *
77
- * <tr>
78
- * <td> withdrawCollateral </td>
79
- * <td> T </td>
80
- * <td> The amount of collateral that's withdrawn. </td>
81
- * </tr>
82
- *
83
- * <tr>
84
- * <td> repayZUSD? </td>
85
- * <td> T </td>
86
- * <td> <i>(Optional)</i> The amount of ZUSD that's repaid. </td>
87
- * </tr>
88
- *
89
- * </table>
90
- *
91
- * @public
92
- */
93
- export declare type TroveClosureParams<T> = _CollateralWithdrawal<T> & _NoCollateralDeposit & Partial<_ZUSDRepayment<T>> & _NoZUSDBorrowing;
94
- /**
95
- * Parameters of an {@link TransactableLiquity.adjustTrove | adjustTrove()} transaction.
96
- *
97
- * @remarks
98
- * The type parameter `T` specifies the allowed value type(s) of the particular
99
- * `TroveAdjustmentParams` object's properties.
100
- *
101
- * Even though all properties are optional, a valid `TroveAdjustmentParams` object must define at
102
- * least one.
103
- *
104
- * Defining both `depositCollateral` and `withdrawCollateral`, or both `borrowZUSD` and `repayZUSD`
105
- * at the same time is disallowed, and will result in a type-checking error.
106
- *
107
- * <h2>Properties</h2>
108
- *
109
- * <table>
110
- *
111
- * <tr>
112
- * <th> Property </th>
113
- * <th> Type </th>
114
- * <th> Description </th>
115
- * </tr>
116
- *
117
- * <tr>
118
- * <td> depositCollateral? </td>
119
- * <td> T </td>
120
- * <td> <i>(Optional)</i> The amount of collateral that's deposited. </td>
121
- * </tr>
122
- *
123
- * <tr>
124
- * <td> withdrawCollateral? </td>
125
- * <td> T </td>
126
- * <td> <i>(Optional)</i> The amount of collateral that's withdrawn. </td>
127
- * </tr>
128
- *
129
- * <tr>
130
- * <td> borrowZUSD? </td>
131
- * <td> T </td>
132
- * <td> <i>(Optional)</i> The amount of ZUSD that's borrowed. </td>
133
- * </tr>
134
- *
135
- * <tr>
136
- * <td> repayZUSD? </td>
137
- * <td> T </td>
138
- * <td> <i>(Optional)</i> The amount of ZUSD that's repaid. </td>
139
- * </tr>
140
- *
141
- * </table>
142
- *
143
- * @public
144
- */
145
- export declare type TroveAdjustmentParams<T = unknown> = (_CollateralChange<T> & _NoDebtChange) | (_DebtChange<T> & _NoCollateralChange) | (_CollateralChange<T> & _DebtChange<T>);
146
- /**
147
- * Describes why a Trove could not be created.
148
- *
149
- * @remarks
150
- * See {@link TroveChange}.
151
- *
152
- * <h2>Possible values</h2>
153
- *
154
- * <table>
155
- *
156
- * <tr>
157
- * <th> Value </th>
158
- * <th> Reason </th>
159
- * </tr>
160
- *
161
- * <tr>
162
- * <td> "missingLiquidationReserve" </td>
163
- * <td> A Trove's debt cannot be less than the liquidation reserve. </td>
164
- * </tr>
165
- *
166
- * </table>
167
- *
168
- * More errors may be added in the future.
169
- *
170
- * @public
171
- */
172
- export declare type TroveCreationError = "missingLiquidationReserve";
173
- /**
174
- * Represents the change between two Trove states.
175
- *
176
- * @remarks
177
- * Returned by {@link Trove.whatChanged}.
178
- *
179
- * Passed as a parameter to {@link Trove.apply}.
180
- *
181
- * @public
182
- */
183
- export declare type TroveChange<T> = {
184
- type: "invalidCreation";
185
- invalidTrove: Trove;
186
- error: TroveCreationError;
187
- } | {
188
- type: "creation";
189
- params: TroveCreationParams<T>;
190
- } | {
191
- type: "closure";
192
- params: TroveClosureParams<T>;
193
- } | {
194
- type: "adjustment";
195
- params: TroveAdjustmentParams<T>;
196
- setToZero?: "collateral" | "debt";
197
- };
198
- /** @internal */
199
- export declare const _normalizeTroveCreation: (params: Record<string, Decimalish | undefined>) => TroveCreationParams<Decimal>;
200
- /** @internal */
201
- export declare const _normalizeTroveAdjustment: (params: Record<string, Decimalish | undefined>) => TroveAdjustmentParams<Decimal>;
202
- /**
203
- * A combination of collateral and debt.
204
- *
205
- * @public
206
- */
207
- export declare class Trove {
208
- /** Amount of native currency (e.g. Ether) collateralized. */
209
- readonly collateral: Decimal;
210
- /** Amount of ZUSD owed. */
211
- readonly debt: Decimal;
212
- /** @internal */
213
- constructor(collateral?: Decimal, debt?: Decimal);
214
- get isEmpty(): boolean;
215
- /**
216
- * Amount of ZUSD that must be repaid to close this Trove.
217
- *
218
- * @remarks
219
- * This doesn't include the liquidation reserve, which is refunded in case of normal closure.
220
- */
221
- get netDebt(): Decimal;
222
- /** @internal */
223
- get _nominalCollateralRatio(): Decimal;
224
- /** Calculate the Trove's collateralization ratio at a given price. */
225
- collateralRatio(price: Decimalish): Decimal;
226
- /**
227
- * Whether the Trove is undercollateralized at a given price.
228
- *
229
- * @returns
230
- * `true` if the Trove's collateralization ratio is less than the
231
- * {@link MINIMUM_COLLATERAL_RATIO}.
232
- */
233
- collateralRatioIsBelowMinimum(price: Decimalish): boolean;
234
- /**
235
- * Whether the collateralization ratio is less than the {@link CRITICAL_COLLATERAL_RATIO} at a
236
- * given price.
237
- *
238
- * @example
239
- * Can be used to check whether the Zero protocol is in recovery mode by using it on the return
240
- * value of {@link ReadableLiquity.getTotal | getTotal()}. For example:
241
- *
242
- * ```typescript
243
- * const total = await zero.getTotal();
244
- * const price = await zero.getPrice();
245
- *
246
- * if (total.collateralRatioIsBelowCritical(price)) {
247
- * // Recovery mode is active
248
- * }
249
- * ```
250
- */
251
- collateralRatioIsBelowCritical(price: Decimalish): boolean;
252
- /** Whether the Trove is sufficiently collateralized to be opened during recovery mode. */
253
- isOpenableInRecoveryMode(price: Decimalish): boolean;
254
- /** @internal */
255
- toString(): string;
256
- equals(that: Trove): boolean;
257
- add(that: Trove): Trove;
258
- addCollateral(collateral: Decimalish): Trove;
259
- addDebt(debt: Decimalish): Trove;
260
- subtract(that: Trove): Trove;
261
- subtractCollateral(collateral: Decimalish): Trove;
262
- subtractDebt(debt: Decimalish): Trove;
263
- multiply(multiplier: Decimalish): Trove;
264
- setCollateral(collateral: Decimalish): Trove;
265
- setDebt(debt: Decimalish): Trove;
266
- private _debtChange;
267
- private _collateralChange;
268
- /**
269
- * Calculate the difference between this Trove and another.
270
- *
271
- * @param that - The other Trove.
272
- * @param borrowingRate - Borrowing rate to use when calculating a borrowed amount.
273
- *
274
- * @returns
275
- * An object representing the change, or `undefined` if the Troves are equal.
276
- */
277
- whatChanged(that: Trove, borrowingRate?: Decimalish): TroveChange<Decimal> | undefined;
278
- /**
279
- * Make a new Trove by applying a {@link TroveChange} to this Trove.
280
- *
281
- * @param change - The change to apply.
282
- * @param borrowingRate - Borrowing rate to use when adding a borrowed amount to the Trove's debt.
283
- */
284
- apply(change: TroveChange<Decimal> | undefined, borrowingRate?: Decimalish): Trove;
285
- /**
286
- * Calculate the result of an {@link TransactableLiquity.openTrove | openTrove()} transaction.
287
- *
288
- * @param params - Parameters of the transaction.
289
- * @param borrowingRate - Borrowing rate to use when calculating the Trove's debt.
290
- */
291
- static create(params: TroveCreationParams<Decimalish>, borrowingRate?: Decimalish): Trove;
292
- /**
293
- * Calculate the parameters of an {@link TransactableLiquity.openTrove | openTrove()} transaction
294
- * that will result in the given Trove.
295
- *
296
- * @param that - The Trove to recreate.
297
- * @param borrowingRate - Current borrowing rate.
298
- */
299
- static recreate(that: Trove, borrowingRate?: Decimalish): TroveCreationParams<Decimal>;
300
- /**
301
- * Calculate the result of an {@link TransactableLiquity.adjustTrove | adjustTrove()} transaction
302
- * on this Trove.
303
- *
304
- * @param params - Parameters of the transaction.
305
- * @param borrowingRate - Borrowing rate to use when adding to the Trove's debt.
306
- */
307
- adjust(params: TroveAdjustmentParams<Decimalish>, borrowingRate?: Decimalish): Trove;
308
- /**
309
- * Calculate the parameters of an {@link TransactableLiquity.adjustTrove | adjustTrove()}
310
- * transaction that will change this Trove into the given Trove.
311
- *
312
- * @param that - The desired result of the transaction.
313
- * @param borrowingRate - Current borrowing rate.
314
- */
315
- adjustTo(that: Trove, borrowingRate?: Decimalish): TroveAdjustmentParams<Decimal>;
316
- }
317
- /** @internal */
318
- export declare const _emptyTrove: Trove;
319
- /**
320
- * Represents whether a UserTrove is open or not, or why it was closed.
321
- *
322
- * @public
323
- */
324
- export declare type UserTroveStatus = "nonExistent" | "open" | "closedByOwner" | "closedByLiquidation" | "closedByRedemption";
325
- /**
326
- * A Trove that is associated with a single owner.
327
- *
328
- * @remarks
329
- * The SDK uses the base {@link Trove} class as a generic container of collateral and debt, for
330
- * example to represent the {@link ReadableLiquity.getTotal | total collateral and debt} locked up
331
- * in the protocol.
332
- *
333
- * The `UserTrove` class extends `Trove` with extra information that's only available for Troves
334
- * that are associated with a single owner (such as the owner's address, or the Trove's status).
335
- *
336
- * @public
337
- */
338
- export declare class UserTrove extends Trove {
339
- /** Address that owns this Trove. */
340
- readonly ownerAddress: string;
341
- /** Provides more information when the UserTrove is empty. */
342
- readonly status: UserTroveStatus;
343
- /** @internal */
344
- constructor(ownerAddress: string, status: UserTroveStatus, collateral?: Decimal, debt?: Decimal);
345
- equals(that: UserTrove): boolean;
346
- /** @internal */
347
- toString(): string;
348
- }
349
- /**
350
- * A Trove in its state after the last direct modification.
351
- *
352
- * @remarks
353
- * The Trove may have received collateral and debt shares from liquidations since then.
354
- * Use {@link TroveWithPendingRedistribution.applyRedistribution | applyRedistribution()} to
355
- * calculate the Trove's most up-to-date state.
356
- *
357
- * @public
358
- */
359
- export declare class TroveWithPendingRedistribution extends UserTrove {
360
- private readonly stake;
361
- private readonly snapshotOfTotalRedistributed;
362
- /** @internal */
363
- constructor(ownerAddress: string, status: UserTroveStatus, collateral?: Decimal, debt?: Decimal, stake?: Decimal, snapshotOfTotalRedistributed?: Trove);
364
- applyRedistribution(totalRedistributed: Trove): UserTrove;
365
- equals(that: TroveWithPendingRedistribution): boolean;
366
- }
1
+ import { Decimal, Decimalish } from "./Decimal";
2
+ /** @internal */ export declare type _CollateralDeposit<T> = {
3
+ depositCollateral: T;
4
+ };
5
+ /** @internal */ export declare type _CollateralWithdrawal<T> = {
6
+ withdrawCollateral: T;
7
+ };
8
+ /** @internal */ export declare type _ZUSDBorrowing<T> = {
9
+ borrowZUSD: T;
10
+ };
11
+ /** @internal */ export declare type _ZUSDRepayment<T> = {
12
+ repayZUSD: T;
13
+ };
14
+ /** @internal */ export declare type _NoCollateralDeposit = Partial<_CollateralDeposit<undefined>>;
15
+ /** @internal */ export declare type _NoCollateralWithdrawal = Partial<_CollateralWithdrawal<undefined>>;
16
+ /** @internal */ export declare type _NoZUSDBorrowing = Partial<_ZUSDBorrowing<undefined>>;
17
+ /** @internal */ export declare type _NoZUSDRepayment = Partial<_ZUSDRepayment<undefined>>;
18
+ /** @internal */
19
+ export declare type _CollateralChange<T> = (_CollateralDeposit<T> & _NoCollateralWithdrawal) | (_CollateralWithdrawal<T> & _NoCollateralDeposit);
20
+ /** @internal */
21
+ export declare type _NoCollateralChange = _NoCollateralDeposit & _NoCollateralWithdrawal;
22
+ /** @internal */
23
+ export declare type _DebtChange<T> = (_ZUSDBorrowing<T> & _NoZUSDRepayment) | (_ZUSDRepayment<T> & _NoZUSDBorrowing);
24
+ /** @internal */
25
+ export declare type _NoDebtChange = _NoZUSDBorrowing & _NoZUSDRepayment;
26
+ /**
27
+ * Parameters of an {@link TransactableLiquity.openTrove | openTrove()} transaction.
28
+ *
29
+ * @remarks
30
+ * The type parameter `T` specifies the allowed value type(s) of the particular `TroveCreationParams`
31
+ * object's properties.
32
+ *
33
+ * <h2>Properties</h2>
34
+ *
35
+ * <table>
36
+ *
37
+ * <tr>
38
+ * <th> Property </th>
39
+ * <th> Type </th>
40
+ * <th> Description </th>
41
+ * </tr>
42
+ *
43
+ * <tr>
44
+ * <td> depositCollateral </td>
45
+ * <td> T </td>
46
+ * <td> The amount of collateral that's deposited. </td>
47
+ * </tr>
48
+ *
49
+ * <tr>
50
+ * <td> borrowZUSD </td>
51
+ * <td> T </td>
52
+ * <td> The amount of ZUSD that's borrowed. </td>
53
+ * </tr>
54
+ *
55
+ * </table>
56
+ *
57
+ * @public
58
+ */
59
+ export declare type TroveCreationParams<T = unknown> = _CollateralDeposit<T> & _NoCollateralWithdrawal & _ZUSDBorrowing<T> & _NoZUSDRepayment;
60
+ /**
61
+ * Parameters of a {@link TransactableLiquity.closeTrove | closeTrove()} transaction.
62
+ *
63
+ * @remarks
64
+ * The type parameter `T` specifies the allowed value type(s) of the particular `TroveClosureParams`
65
+ * object's properties.
66
+ *
67
+ * <h2>Properties</h2>
68
+ *
69
+ * <table>
70
+ *
71
+ * <tr>
72
+ * <th> Property </th>
73
+ * <th> Type </th>
74
+ * <th> Description </th>
75
+ * </tr>
76
+ *
77
+ * <tr>
78
+ * <td> withdrawCollateral </td>
79
+ * <td> T </td>
80
+ * <td> The amount of collateral that's withdrawn. </td>
81
+ * </tr>
82
+ *
83
+ * <tr>
84
+ * <td> repayZUSD? </td>
85
+ * <td> T </td>
86
+ * <td> <i>(Optional)</i> The amount of ZUSD that's repaid. </td>
87
+ * </tr>
88
+ *
89
+ * </table>
90
+ *
91
+ * @public
92
+ */
93
+ export declare type TroveClosureParams<T> = _CollateralWithdrawal<T> & _NoCollateralDeposit & Partial<_ZUSDRepayment<T>> & _NoZUSDBorrowing;
94
+ /**
95
+ * Parameters of an {@link TransactableLiquity.adjustTrove | adjustTrove()} transaction.
96
+ *
97
+ * @remarks
98
+ * The type parameter `T` specifies the allowed value type(s) of the particular
99
+ * `TroveAdjustmentParams` object's properties.
100
+ *
101
+ * Even though all properties are optional, a valid `TroveAdjustmentParams` object must define at
102
+ * least one.
103
+ *
104
+ * Defining both `depositCollateral` and `withdrawCollateral`, or both `borrowZUSD` and `repayZUSD`
105
+ * at the same time is disallowed, and will result in a type-checking error.
106
+ *
107
+ * <h2>Properties</h2>
108
+ *
109
+ * <table>
110
+ *
111
+ * <tr>
112
+ * <th> Property </th>
113
+ * <th> Type </th>
114
+ * <th> Description </th>
115
+ * </tr>
116
+ *
117
+ * <tr>
118
+ * <td> depositCollateral? </td>
119
+ * <td> T </td>
120
+ * <td> <i>(Optional)</i> The amount of collateral that's deposited. </td>
121
+ * </tr>
122
+ *
123
+ * <tr>
124
+ * <td> withdrawCollateral? </td>
125
+ * <td> T </td>
126
+ * <td> <i>(Optional)</i> The amount of collateral that's withdrawn. </td>
127
+ * </tr>
128
+ *
129
+ * <tr>
130
+ * <td> borrowZUSD? </td>
131
+ * <td> T </td>
132
+ * <td> <i>(Optional)</i> The amount of ZUSD that's borrowed. </td>
133
+ * </tr>
134
+ *
135
+ * <tr>
136
+ * <td> repayZUSD? </td>
137
+ * <td> T </td>
138
+ * <td> <i>(Optional)</i> The amount of ZUSD that's repaid. </td>
139
+ * </tr>
140
+ *
141
+ * </table>
142
+ *
143
+ * @public
144
+ */
145
+ export declare type TroveAdjustmentParams<T = unknown> = (_CollateralChange<T> & _NoDebtChange) | (_DebtChange<T> & _NoCollateralChange) | (_CollateralChange<T> & _DebtChange<T>);
146
+ /**
147
+ * Describes why a Trove could not be created.
148
+ *
149
+ * @remarks
150
+ * See {@link TroveChange}.
151
+ *
152
+ * <h2>Possible values</h2>
153
+ *
154
+ * <table>
155
+ *
156
+ * <tr>
157
+ * <th> Value </th>
158
+ * <th> Reason </th>
159
+ * </tr>
160
+ *
161
+ * <tr>
162
+ * <td> "missingLiquidationReserve" </td>
163
+ * <td> A Trove's debt cannot be less than the liquidation reserve. </td>
164
+ * </tr>
165
+ *
166
+ * </table>
167
+ *
168
+ * More errors may be added in the future.
169
+ *
170
+ * @public
171
+ */
172
+ export declare type TroveCreationError = "missingLiquidationReserve";
173
+ /**
174
+ * Represents the change between two Trove states.
175
+ *
176
+ * @remarks
177
+ * Returned by {@link Trove.whatChanged}.
178
+ *
179
+ * Passed as a parameter to {@link Trove.apply}.
180
+ *
181
+ * @public
182
+ */
183
+ export declare type TroveChange<T> = {
184
+ type: "invalidCreation";
185
+ invalidTrove: Trove;
186
+ error: TroveCreationError;
187
+ } | {
188
+ type: "creation";
189
+ params: TroveCreationParams<T>;
190
+ } | {
191
+ type: "closure";
192
+ params: TroveClosureParams<T>;
193
+ } | {
194
+ type: "adjustment";
195
+ params: TroveAdjustmentParams<T>;
196
+ setToZero?: "collateral" | "debt";
197
+ };
198
+ /** @internal */
199
+ export declare const _normalizeTroveCreation: (params: Record<string, Decimalish | undefined>) => TroveCreationParams<Decimal>;
200
+ /** @internal */
201
+ export declare const _normalizeTroveAdjustment: (params: Record<string, Decimalish | undefined>) => TroveAdjustmentParams<Decimal>;
202
+ /**
203
+ * A combination of collateral and debt.
204
+ *
205
+ * @public
206
+ */
207
+ export declare class Trove {
208
+ /** Amount of native currency (e.g. Ether) collateralized. */
209
+ readonly collateral: Decimal;
210
+ /** Amount of ZUSD owed. */
211
+ readonly debt: Decimal;
212
+ /** @internal */
213
+ constructor(collateral?: Decimal, debt?: Decimal);
214
+ get isEmpty(): boolean;
215
+ /**
216
+ * Amount of ZUSD that must be repaid to close this Trove.
217
+ *
218
+ * @remarks
219
+ * This doesn't include the liquidation reserve, which is refunded in case of normal closure.
220
+ */
221
+ get netDebt(): Decimal;
222
+ /** @internal */
223
+ get _nominalCollateralRatio(): Decimal;
224
+ /** Calculate the Trove's collateralization ratio at a given price. */
225
+ collateralRatio(price: Decimalish): Decimal;
226
+ /**
227
+ * Whether the Trove is undercollateralized at a given price.
228
+ *
229
+ * @returns
230
+ * `true` if the Trove's collateralization ratio is less than the
231
+ * {@link MINIMUM_COLLATERAL_RATIO}.
232
+ */
233
+ collateralRatioIsBelowMinimum(price: Decimalish): boolean;
234
+ /**
235
+ * Whether the collateralization ratio is less than the {@link CRITICAL_COLLATERAL_RATIO} at a
236
+ * given price.
237
+ *
238
+ * @example
239
+ * Can be used to check whether the Zero protocol is in recovery mode by using it on the return
240
+ * value of {@link ReadableLiquity.getTotal | getTotal()}. For example:
241
+ *
242
+ * ```typescript
243
+ * const total = await zero.getTotal();
244
+ * const price = await zero.getPrice();
245
+ *
246
+ * if (total.collateralRatioIsBelowCritical(price)) {
247
+ * // Recovery mode is active
248
+ * }
249
+ * ```
250
+ */
251
+ collateralRatioIsBelowCritical(price: Decimalish): boolean;
252
+ /** Whether the Trove is sufficiently collateralized to be opened during recovery mode. */
253
+ isOpenableInRecoveryMode(price: Decimalish): boolean;
254
+ /** @internal */
255
+ toString(): string;
256
+ equals(that: Trove): boolean;
257
+ add(that: Trove): Trove;
258
+ addCollateral(collateral: Decimalish): Trove;
259
+ addDebt(debt: Decimalish): Trove;
260
+ subtract(that: Trove): Trove;
261
+ subtractCollateral(collateral: Decimalish): Trove;
262
+ subtractDebt(debt: Decimalish): Trove;
263
+ multiply(multiplier: Decimalish): Trove;
264
+ setCollateral(collateral: Decimalish): Trove;
265
+ setDebt(debt: Decimalish): Trove;
266
+ private _debtChange;
267
+ private _collateralChange;
268
+ /**
269
+ * Calculate the difference between this Trove and another.
270
+ *
271
+ * @param that - The other Trove.
272
+ * @param borrowingRate - Borrowing rate to use when calculating a borrowed amount.
273
+ *
274
+ * @returns
275
+ * An object representing the change, or `undefined` if the Troves are equal.
276
+ */
277
+ whatChanged(that: Trove, borrowingRate?: Decimalish): TroveChange<Decimal> | undefined;
278
+ /**
279
+ * Make a new Trove by applying a {@link TroveChange} to this Trove.
280
+ *
281
+ * @param change - The change to apply.
282
+ * @param borrowingRate - Borrowing rate to use when adding a borrowed amount to the Trove's debt.
283
+ */
284
+ apply(change: TroveChange<Decimal> | undefined, borrowingRate?: Decimalish): Trove;
285
+ /**
286
+ * Calculate the result of an {@link TransactableLiquity.openTrove | openTrove()} transaction.
287
+ *
288
+ * @param params - Parameters of the transaction.
289
+ * @param borrowingRate - Borrowing rate to use when calculating the Trove's debt.
290
+ */
291
+ static create(params: TroveCreationParams<Decimalish>, borrowingRate?: Decimalish): Trove;
292
+ /**
293
+ * Calculate the parameters of an {@link TransactableLiquity.openTrove | openTrove()} transaction
294
+ * that will result in the given Trove.
295
+ *
296
+ * @param that - The Trove to recreate.
297
+ * @param borrowingRate - Current borrowing rate.
298
+ */
299
+ static recreate(that: Trove, borrowingRate?: Decimalish): TroveCreationParams<Decimal>;
300
+ /**
301
+ * Calculate the result of an {@link TransactableLiquity.adjustTrove | adjustTrove()} transaction
302
+ * on this Trove.
303
+ *
304
+ * @param params - Parameters of the transaction.
305
+ * @param borrowingRate - Borrowing rate to use when adding to the Trove's debt.
306
+ */
307
+ adjust(params: TroveAdjustmentParams<Decimalish>, borrowingRate?: Decimalish): Trove;
308
+ /**
309
+ * Calculate the parameters of an {@link TransactableLiquity.adjustTrove | adjustTrove()}
310
+ * transaction that will change this Trove into the given Trove.
311
+ *
312
+ * @param that - The desired result of the transaction.
313
+ * @param borrowingRate - Current borrowing rate.
314
+ */
315
+ adjustTo(that: Trove, borrowingRate?: Decimalish): TroveAdjustmentParams<Decimal>;
316
+ }
317
+ /** @internal */
318
+ export declare const _emptyTrove: Trove;
319
+ /**
320
+ * Represents whether a UserTrove is open or not, or why it was closed.
321
+ *
322
+ * @public
323
+ */
324
+ export declare type UserTroveStatus = "nonExistent" | "open" | "closedByOwner" | "closedByLiquidation" | "closedByRedemption";
325
+ /**
326
+ * A Trove that is associated with a single owner.
327
+ *
328
+ * @remarks
329
+ * The SDK uses the base {@link Trove} class as a generic container of collateral and debt, for
330
+ * example to represent the {@link ReadableLiquity.getTotal | total collateral and debt} locked up
331
+ * in the protocol.
332
+ *
333
+ * The `UserTrove` class extends `Trove` with extra information that's only available for Troves
334
+ * that are associated with a single owner (such as the owner's address, or the Trove's status).
335
+ *
336
+ * @public
337
+ */
338
+ export declare class UserTrove extends Trove {
339
+ /** Address that owns this Trove. */
340
+ readonly ownerAddress: string;
341
+ /** Provides more information when the UserTrove is empty. */
342
+ readonly status: UserTroveStatus;
343
+ /** @internal */
344
+ constructor(ownerAddress: string, status: UserTroveStatus, collateral?: Decimal, debt?: Decimal);
345
+ equals(that: UserTrove): boolean;
346
+ /** @internal */
347
+ toString(): string;
348
+ }
349
+ /**
350
+ * A Trove in its state after the last direct modification.
351
+ *
352
+ * @remarks
353
+ * The Trove may have received collateral and debt shares from liquidations since then.
354
+ * Use {@link TroveWithPendingRedistribution.applyRedistribution | applyRedistribution()} to
355
+ * calculate the Trove's most up-to-date state.
356
+ *
357
+ * @public
358
+ */
359
+ export declare class TroveWithPendingRedistribution extends UserTrove {
360
+ private readonly stake;
361
+ private readonly snapshotOfTotalRedistributed;
362
+ /** @internal */
363
+ constructor(ownerAddress: string, status: UserTroveStatus, collateral?: Decimal, debt?: Decimal, stake?: Decimal, snapshotOfTotalRedistributed?: Trove);
364
+ applyRedistribution(totalRedistributed: Trove): UserTrove;
365
+ equals(that: TroveWithPendingRedistribution): boolean;
366
+ }
367
367
  //# sourceMappingURL=Trove.d.ts.map