@sovryn-zero/lib-base 0.1.0

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 (84) hide show
  1. package/.eslintrc.json +17 -0
  2. package/.mocharc.yml +1 -0
  3. package/LICENSE +905 -0
  4. package/README.md +23 -0
  5. package/api-extractor.json +4 -0
  6. package/dist/index.d.ts +14 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +26 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/src/Decimal.d.ts +89 -0
  11. package/dist/src/Decimal.d.ts.map +1 -0
  12. package/dist/src/Decimal.js +361 -0
  13. package/dist/src/Decimal.js.map +1 -0
  14. package/dist/src/Fees.d.ts +82 -0
  15. package/dist/src/Fees.d.ts.map +1 -0
  16. package/dist/src/Fees.js +123 -0
  17. package/dist/src/Fees.js.map +1 -0
  18. package/dist/src/LiquityStore.d.ts +209 -0
  19. package/dist/src/LiquityStore.d.ts.map +1 -0
  20. package/dist/src/LiquityStore.js +209 -0
  21. package/dist/src/LiquityStore.js.map +1 -0
  22. package/dist/src/ObservableLiquity.d.ts +15 -0
  23. package/dist/src/ObservableLiquity.d.ts.map +1 -0
  24. package/dist/src/ObservableLiquity.js +3 -0
  25. package/dist/src/ObservableLiquity.js.map +1 -0
  26. package/dist/src/PopulatableLiquity.d.ts +125 -0
  27. package/dist/src/PopulatableLiquity.d.ts.map +1 -0
  28. package/dist/src/PopulatableLiquity.js +3 -0
  29. package/dist/src/PopulatableLiquity.js.map +1 -0
  30. package/dist/src/ReadableLiquity.d.ts +156 -0
  31. package/dist/src/ReadableLiquity.d.ts.map +1 -0
  32. package/dist/src/ReadableLiquity.js +3 -0
  33. package/dist/src/ReadableLiquity.js.map +1 -0
  34. package/dist/src/SendableLiquity.d.ts +156 -0
  35. package/dist/src/SendableLiquity.d.ts.map +1 -0
  36. package/dist/src/SendableLiquity.js +20 -0
  37. package/dist/src/SendableLiquity.js.map +1 -0
  38. package/dist/src/StabilityDeposit.d.ts +59 -0
  39. package/dist/src/StabilityDeposit.d.ts.map +1 -0
  40. package/dist/src/StabilityDeposit.js +80 -0
  41. package/dist/src/StabilityDeposit.js.map +1 -0
  42. package/dist/src/TransactableLiquity.d.ts +414 -0
  43. package/dist/src/TransactableLiquity.d.ts.map +1 -0
  44. package/dist/src/TransactableLiquity.js +18 -0
  45. package/dist/src/TransactableLiquity.js.map +1 -0
  46. package/dist/src/Trove.d.ts +367 -0
  47. package/dist/src/Trove.d.ts.map +1 -0
  48. package/dist/src/Trove.js +423 -0
  49. package/dist/src/Trove.js.map +1 -0
  50. package/dist/src/ZEROStake.d.ts +52 -0
  51. package/dist/src/ZEROStake.d.ts.map +1 -0
  52. package/dist/src/ZEROStake.js +74 -0
  53. package/dist/src/ZEROStake.js.map +1 -0
  54. package/dist/src/_CachedReadableLiquity.d.ts +55 -0
  55. package/dist/src/_CachedReadableLiquity.d.ts.map +1 -0
  56. package/dist/src/_CachedReadableLiquity.js +93 -0
  57. package/dist/src/_CachedReadableLiquity.js.map +1 -0
  58. package/dist/src/constants.d.ts +61 -0
  59. package/dist/src/constants.d.ts.map +1 -0
  60. package/dist/src/constants.js +64 -0
  61. package/dist/src/constants.js.map +1 -0
  62. package/dist/tsdoc-metadata.json +11 -0
  63. package/etc/lib-base.api.md +788 -0
  64. package/index.ts +13 -0
  65. package/package.json +52 -0
  66. package/src/Decimal.ts +456 -0
  67. package/src/Fees.ts +160 -0
  68. package/src/LiquityStore.ts +563 -0
  69. package/src/ObservableLiquity.ts +32 -0
  70. package/src/PopulatableLiquity.ts +280 -0
  71. package/src/ReadableLiquity.ts +175 -0
  72. package/src/SendableLiquity.ts +251 -0
  73. package/src/StabilityDeposit.ts +126 -0
  74. package/src/TransactableLiquity.ts +471 -0
  75. package/src/Trove.ts +824 -0
  76. package/src/ZEROStake.ts +99 -0
  77. package/src/_CachedReadableLiquity.ts +186 -0
  78. package/src/constants.ts +68 -0
  79. package/test/Decimal.test.ts +212 -0
  80. package/test/StabilityDeposit.test.ts +30 -0
  81. package/test/Trove.test.ts +143 -0
  82. package/test/ZEROStake.test.ts +24 -0
  83. package/tsconfig.dist.json +8 -0
  84. package/tsconfig.json +5 -0
@@ -0,0 +1,788 @@
1
+ ## API Report File for "@sovryn-zero/lib-base"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ // @internal (undocumented)
8
+ export class _CachedReadableLiquity<T extends unknown[]> implements _ReadableLiquityWithExtraParams<T> {
9
+ constructor(readable: _ReadableLiquityWithExtraParams<T>, cache: _LiquityReadCache<T>);
10
+ // (undocumented)
11
+ getCollateralSurplusBalance(address?: string, ...extraParams: T): Promise<Decimal>;
12
+ // (undocumented)
13
+ getFees(...extraParams: T): Promise<Fees>;
14
+ // (undocumented)
15
+ getFrontendStatus(address?: string, ...extraParams: T): Promise<FrontendStatus>;
16
+ // (undocumented)
17
+ getNumberOfTroves(...extraParams: T): Promise<number>;
18
+ // (undocumented)
19
+ getPrice(...extraParams: T): Promise<Decimal>;
20
+ // (undocumented)
21
+ getRemainingStabilityPoolZEROReward(...extraParams: T): Promise<Decimal>;
22
+ // (undocumented)
23
+ getStabilityDeposit(address?: string, ...extraParams: T): Promise<StabilityDeposit>;
24
+ // (undocumented)
25
+ getTotal(...extraParams: T): Promise<Trove>;
26
+ // (undocumented)
27
+ getTotalRedistributed(...extraParams: T): Promise<Trove>;
28
+ // (undocumented)
29
+ getTotalStakedZERO(...extraParams: T): Promise<Decimal>;
30
+ // (undocumented)
31
+ getTrove(address?: string, ...extraParams: T): Promise<UserTrove>;
32
+ // (undocumented)
33
+ getTroveBeforeRedistribution(address?: string, ...extraParams: T): Promise<TroveWithPendingRedistribution>;
34
+ // (undocumented)
35
+ getTroves(params: TroveListingParams & {
36
+ beforeRedistribution: true;
37
+ }, ...extraParams: T): Promise<TroveWithPendingRedistribution[]>;
38
+ // (undocumented)
39
+ getTroves(params: TroveListingParams, ...extraParams: T): Promise<UserTrove[]>;
40
+ // (undocumented)
41
+ getZEROBalance(address?: string, ...extraParams: T): Promise<Decimal>;
42
+ // (undocumented)
43
+ getZEROStake(address?: string, ...extraParams: T): Promise<ZEROStake>;
44
+ // (undocumented)
45
+ getZUSDBalance(address?: string, ...extraParams: T): Promise<Decimal>;
46
+ // (undocumented)
47
+ getZUSDInStabilityPool(...extraParams: T): Promise<Decimal>;
48
+ }
49
+
50
+ // @internal (undocumented)
51
+ export type _CollateralChange<T> = (_CollateralDeposit<T> & _NoCollateralWithdrawal) | (_CollateralWithdrawal<T> & _NoCollateralDeposit);
52
+
53
+ // @internal (undocumented)
54
+ export type _CollateralDeposit<T> = {
55
+ depositCollateral: T;
56
+ };
57
+
58
+ // @public
59
+ export interface CollateralGainTransferDetails extends StabilityPoolGainsWithdrawalDetails {
60
+ newTrove: Trove;
61
+ }
62
+
63
+ // @internal (undocumented)
64
+ export type _CollateralWithdrawal<T> = {
65
+ withdrawCollateral: T;
66
+ };
67
+
68
+ // @public
69
+ export const CRITICAL_COLLATERAL_RATIO: Decimal;
70
+
71
+ // @internal (undocumented)
72
+ export type _DebtChange<T> = (_ZUSDBorrowing<T> & _NoZUSDRepayment) | (_ZUSDRepayment<T> & _NoZUSDBorrowing);
73
+
74
+ // @public
75
+ export class Decimal {
76
+ // @internal (undocumented)
77
+ get absoluteValue(): this;
78
+ // (undocumented)
79
+ add(addend: Decimalish): Decimal;
80
+ // @internal (undocumented)
81
+ get bigNumber(): string;
82
+ // (undocumented)
83
+ div(divider: Decimalish): Decimal;
84
+ // @internal (undocumented)
85
+ _divCeil(divider: Decimalish): Decimal;
86
+ // (undocumented)
87
+ eq(that: Decimalish): boolean;
88
+ // (undocumented)
89
+ get finite(): this | undefined;
90
+ // (undocumented)
91
+ static from(decimalish: Decimalish): Decimal;
92
+ // (undocumented)
93
+ static fromBigNumberString(bigNumberString: string): Decimal;
94
+ // (undocumented)
95
+ gt(that: Decimalish): boolean;
96
+ // (undocumented)
97
+ gte(that: Decimalish): boolean;
98
+ // (undocumented)
99
+ static readonly HALF: Decimal;
100
+ // @internal (undocumented)
101
+ get hex(): string;
102
+ // (undocumented)
103
+ get infinite(): this | undefined;
104
+ // (undocumented)
105
+ static readonly INFINITY: Decimal;
106
+ // (undocumented)
107
+ get isZero(): boolean;
108
+ // (undocumented)
109
+ lt(that: Decimalish): boolean;
110
+ // (undocumented)
111
+ lte(that: Decimalish): boolean;
112
+ // (undocumented)
113
+ static max(a: Decimalish, b: Decimalish): Decimal;
114
+ // (undocumented)
115
+ static min(a: Decimalish, b: Decimalish): Decimal;
116
+ // (undocumented)
117
+ mul(multiplier: Decimalish): Decimal;
118
+ // (undocumented)
119
+ mulDiv(multiplier: Decimalish, divider: Decimalish): Decimal;
120
+ // (undocumented)
121
+ get nonZero(): this | undefined;
122
+ // (undocumented)
123
+ static readonly ONE: Decimal;
124
+ // (undocumented)
125
+ pow(exponent: number): Decimal;
126
+ // (undocumented)
127
+ prettify(precision?: number): string;
128
+ // (undocumented)
129
+ shorten(): string;
130
+ // (undocumented)
131
+ sub(subtrahend: Decimalish): Decimal;
132
+ // (undocumented)
133
+ toString(precision?: number): string;
134
+ // (undocumented)
135
+ static readonly ZERO: Decimal;
136
+ // (undocumented)
137
+ get zero(): this | undefined;
138
+ }
139
+
140
+ // @public
141
+ export type Decimalish = Decimal | number | string;
142
+
143
+ // @alpha (undocumented)
144
+ export class Difference {
145
+ // (undocumented)
146
+ get absoluteValue(): Decimal | undefined;
147
+ // (undocumented)
148
+ static between(d1: Decimalish | undefined, d2: Decimalish | undefined): Difference;
149
+ // (undocumented)
150
+ get finite(): this | undefined;
151
+ // (undocumented)
152
+ get infinite(): this | undefined;
153
+ // (undocumented)
154
+ mul(multiplier: Decimalish): Difference;
155
+ // (undocumented)
156
+ get negative(): this | undefined;
157
+ // (undocumented)
158
+ get nonZero(): this | undefined;
159
+ // (undocumented)
160
+ get positive(): this | undefined;
161
+ // (undocumented)
162
+ prettify(precision?: number): string;
163
+ // (undocumented)
164
+ toString(precision?: number): string;
165
+ }
166
+
167
+ // @internal (undocumented)
168
+ export const _emptyTrove: Trove;
169
+
170
+ // @public
171
+ export type FailedReceipt<R = unknown> = {
172
+ status: "failed";
173
+ rawReceipt: R;
174
+ };
175
+
176
+ // @internal (undocumented)
177
+ export const _failedReceipt: <R>(rawReceipt: R) => FailedReceipt<R>;
178
+
179
+ // @public
180
+ export class Fees {
181
+ // @internal
182
+ constructor(baseRateWithoutDecay: Decimalish, minuteDecayFactor: Decimalish, beta: Decimalish, lastFeeOperation: Date, timeOfLatestBlock: Date, recoveryMode: boolean);
183
+ // @internal (undocumented)
184
+ baseRate(when?: Date): Decimal;
185
+ borrowingRate(when?: Date): Decimal;
186
+ equals(that: Fees): boolean;
187
+ redemptionRate(redeemedFractionOfSupply?: Decimalish, when?: Date): Decimal;
188
+ // @internal (undocumented)
189
+ _setRecoveryMode(recoveryMode: boolean): Fees;
190
+ // @internal (undocumented)
191
+ toString(): string;
192
+ }
193
+
194
+ // @public
195
+ export type FrontendStatus = {
196
+ status: "unregistered";
197
+ } | {
198
+ status: "registered";
199
+ kickbackRate: Decimal;
200
+ };
201
+
202
+ // @public
203
+ export interface LiquidationDetails {
204
+ collateralGasCompensation: Decimal;
205
+ liquidatedAddresses: string[];
206
+ totalLiquidated: Trove;
207
+ zusdGasCompensation: Decimal;
208
+ }
209
+
210
+ // @internal (undocumented)
211
+ export interface _LiquityReadCache<T extends unknown[]> extends _LiquityReadCacheBase<T> {
212
+ // (undocumented)
213
+ getTroves(params: TroveListingParams & {
214
+ beforeRedistribution: true;
215
+ }, ...extraParams: T): TroveWithPendingRedistribution[] | undefined;
216
+ // (undocumented)
217
+ getTroves(params: TroveListingParams, ...extraParams: T): UserTrove[] | undefined;
218
+ }
219
+
220
+ // @internal (undocumented)
221
+ export type _LiquityReadCacheBase<T extends unknown[]> = {
222
+ [P in keyof ReadableLiquity]: ReadableLiquity[P] extends (...args: infer A) => Promise<infer R> ? (...params: [...originalParams: A, ...extraParams: T]) => R | undefined : never;
223
+ };
224
+
225
+ // @public
226
+ export type LiquityReceipt<R = unknown, D = unknown> = PendingReceipt | MinedReceipt<R, D>;
227
+
228
+ // @public
229
+ export abstract class LiquityStore<T = unknown> {
230
+ // @internal (undocumented)
231
+ protected abstract _doStart(): () => void;
232
+ // @internal (undocumented)
233
+ protected _load(baseState: LiquityStoreBaseState, extraState?: T): void;
234
+ // @internal (undocumented)
235
+ protected _loaded: boolean;
236
+ logging: boolean;
237
+ onLoaded?: () => void;
238
+ // @internal (undocumented)
239
+ protected abstract _reduceExtra(extraState: T, extraStateUpdate: Partial<T>): T;
240
+ start(): () => void;
241
+ get state(): LiquityStoreState<T>;
242
+ subscribe(listener: (params: LiquityStoreListenerParams<T>) => void): () => void;
243
+ // @internal (undocumented)
244
+ protected _update(baseStateUpdate?: Partial<LiquityStoreBaseState>, extraStateUpdate?: Partial<T>): void;
245
+ }
246
+
247
+ // @public
248
+ export interface LiquityStoreBaseState {
249
+ accountBalance: Decimal;
250
+ collateralSurplusBalance: Decimal;
251
+ // @internal (undocumented)
252
+ _feesInNormalMode: Fees;
253
+ frontend: FrontendStatus;
254
+ nueBalance: Decimal;
255
+ numberOfTroves: number;
256
+ ownFrontend: FrontendStatus;
257
+ price: Decimal;
258
+ remainingStabilityPoolZEROReward: Decimal;
259
+ // @internal (undocumented)
260
+ _riskiestTroveBeforeRedistribution: TroveWithPendingRedistribution;
261
+ stabilityDeposit: StabilityDeposit;
262
+ total: Trove;
263
+ totalRedistributed: Trove;
264
+ totalStakedZERO: Decimal;
265
+ troveBeforeRedistribution: TroveWithPendingRedistribution;
266
+ zeroBalance: Decimal;
267
+ zeroStake: ZEROStake;
268
+ zusdBalance: Decimal;
269
+ zusdInStabilityPool: Decimal;
270
+ }
271
+
272
+ // @public
273
+ export interface LiquityStoreDerivedState {
274
+ borrowingRate: Decimal;
275
+ fees: Fees;
276
+ haveUndercollateralizedTroves: boolean;
277
+ redemptionRate: Decimal;
278
+ trove: UserTrove;
279
+ }
280
+
281
+ // @public
282
+ export interface LiquityStoreListenerParams<T = unknown> {
283
+ newState: LiquityStoreState<T>;
284
+ oldState: LiquityStoreState<T>;
285
+ stateChange: Partial<LiquityStoreState<T>>;
286
+ }
287
+
288
+ // @public
289
+ export type LiquityStoreState<T = unknown> = LiquityStoreBaseState & LiquityStoreDerivedState & T;
290
+
291
+ // @public
292
+ export const MAXIMUM_BORROWING_RATE: Decimal;
293
+
294
+ // @public
295
+ export type MinedReceipt<R = unknown, D = unknown> = FailedReceipt<R> | SuccessfulReceipt<R, D>;
296
+
297
+ // @public
298
+ export const MINIMUM_BORROWING_RATE: Decimal;
299
+
300
+ // @public
301
+ export const MINIMUM_COLLATERAL_RATIO: Decimal;
302
+
303
+ // @public
304
+ export const MINIMUM_REDEMPTION_RATE: Decimal;
305
+
306
+ // @internal (undocumented)
307
+ export type _NoCollateralChange = _NoCollateralDeposit & _NoCollateralWithdrawal;
308
+
309
+ // @internal (undocumented)
310
+ export type _NoCollateralDeposit = Partial<_CollateralDeposit<undefined>>;
311
+
312
+ // @internal (undocumented)
313
+ export type _NoCollateralWithdrawal = Partial<_CollateralWithdrawal<undefined>>;
314
+
315
+ // @internal (undocumented)
316
+ export type _NoDebtChange = _NoZUSDBorrowing & _NoZUSDRepayment;
317
+
318
+ // @internal (undocumented)
319
+ export const _normalizeTroveAdjustment: (params: Record<string, Decimalish | undefined>) => TroveAdjustmentParams<Decimal>;
320
+
321
+ // @internal (undocumented)
322
+ export const _normalizeTroveCreation: (params: Record<string, Decimalish | undefined>) => TroveCreationParams<Decimal>;
323
+
324
+ // @internal (undocumented)
325
+ export type _NoZUSDBorrowing = Partial<_ZUSDBorrowing<undefined>>;
326
+
327
+ // @internal (undocumented)
328
+ export type _NoZUSDRepayment = Partial<_ZUSDRepayment<undefined>>;
329
+
330
+ // @alpha (undocumented)
331
+ export interface ObservableLiquity {
332
+ // (undocumented)
333
+ watchNumberOfTroves(onNumberOfTrovesChanged: (numberOfTroves: number) => void): () => void;
334
+ // (undocumented)
335
+ watchPrice(onPriceChanged: (price: Decimal) => void): () => void;
336
+ // (undocumented)
337
+ watchStabilityDeposit(onStabilityDepositChanged: (stabilityDeposit: StabilityDeposit) => void, address?: string): () => void;
338
+ // (undocumented)
339
+ watchTotal(onTotalChanged: (total: Trove) => void): () => void;
340
+ // (undocumented)
341
+ watchTotalRedistributed(onTotalRedistributedChanged: (totalRedistributed: Trove) => void): () => void;
342
+ // (undocumented)
343
+ watchTroveWithoutRewards(onTroveChanged: (trove: TroveWithPendingRedistribution) => void, address?: string): () => void;
344
+ // (undocumented)
345
+ watchZUSDBalance(onZUSDBalanceChanged: (balance: Decimal) => void, address?: string): () => void;
346
+ // (undocumented)
347
+ watchZUSDInStabilityPool(onZUSDInStabilityPoolChanged: (zusdInStabilityPool: Decimal) => void): () => void;
348
+ }
349
+
350
+ // @public
351
+ export type PendingReceipt = {
352
+ status: "pending";
353
+ };
354
+
355
+ // @internal (undocumented)
356
+ export const _pendingReceipt: PendingReceipt;
357
+
358
+ // @alpha (undocumented)
359
+ export class Percent<T extends {
360
+ infinite?: T | undefined;
361
+ absoluteValue?: A | undefined;
362
+ mul?(hundred: 100): T;
363
+ toString(precision?: number): string;
364
+ }, A extends {
365
+ gte(n: string): boolean;
366
+ }> {
367
+ constructor(ratio: T);
368
+ // (undocumented)
369
+ nonZeroish(precision: number): this | undefined;
370
+ // (undocumented)
371
+ prettify(): string;
372
+ // (undocumented)
373
+ toString(precision: number): string;
374
+ }
375
+
376
+ // @internal (undocumented)
377
+ export type _PopulatableFrom<T, P> = {
378
+ [M in keyof T]: T[M] extends (...args: infer A) => Promise<infer U> ? U extends SentLiquityTransaction ? (...args: A) => Promise<PopulatedLiquityTransaction<P, U>> : never : never;
379
+ };
380
+
381
+ // Warning: (ae-incompatible-release-tags) The symbol "PopulatableLiquity" is marked as @public, but its signature references "_PopulatableFrom" which is marked as @internal
382
+ //
383
+ // @public
384
+ export interface PopulatableLiquity<R = unknown, S = unknown, P = unknown> extends _PopulatableFrom<SendableLiquity<R, S>, P> {
385
+ adjustTrove(params: TroveAdjustmentParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
386
+ borrowZUSD(amount: Decimalish, maxBorrowingRate?: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
387
+ claimCollateralSurplus(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
388
+ closeTrove(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveClosureDetails>>>>;
389
+ depositCollateral(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
390
+ depositZUSDInStabilityPool(amount: Decimalish, frontendTag?: string): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, StabilityDepositChangeDetails>>>>;
391
+ liquidate(address: string | string[]): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, LiquidationDetails>>>>;
392
+ liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, LiquidationDetails>>>>;
393
+ openTrove(params: TroveCreationParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveCreationDetails>>>>;
394
+ redeemZUSD(amount: Decimalish, maxRedemptionRate?: Decimalish): Promise<PopulatedRedemption<P, S, R>>;
395
+ registerFrontend(kickbackRate: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
396
+ repayZUSD(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
397
+ sendZERO(toAddress: string, amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
398
+ sendZUSD(toAddress: string, amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
399
+ // @internal (undocumented)
400
+ setPrice(price: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
401
+ stakeZERO(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
402
+ transferCollateralGainToTrove(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, CollateralGainTransferDetails>>>>;
403
+ unstakeZERO(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
404
+ withdrawCollateral(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
405
+ withdrawGainsFromStabilityPool(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, StabilityPoolGainsWithdrawalDetails>>>>;
406
+ withdrawGainsFromStaking(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
407
+ withdrawZUSDFromStabilityPool(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, StabilityDepositChangeDetails>>>>;
408
+ }
409
+
410
+ // @public
411
+ export interface PopulatedLiquityTransaction<P = unknown, T extends SentLiquityTransaction = SentLiquityTransaction> {
412
+ readonly rawPopulatedTransaction: P;
413
+ send(): Promise<T>;
414
+ }
415
+
416
+ // @public
417
+ export interface PopulatedRedemption<P = unknown, S = unknown, R = unknown> extends PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, RedemptionDetails>>> {
418
+ readonly attemptedZUSDAmount: Decimal;
419
+ increaseAmountByMinimumNetDebt(maxRedemptionRate?: Decimalish): Promise<PopulatedRedemption<P, S, R>>;
420
+ readonly isTruncated: boolean;
421
+ readonly redeemableZUSDAmount: Decimal;
422
+ }
423
+
424
+ // @public
425
+ export interface ReadableLiquity {
426
+ getCollateralSurplusBalance(address?: string): Promise<Decimal>;
427
+ getFees(): Promise<Fees>;
428
+ getFrontendStatus(address?: string): Promise<FrontendStatus>;
429
+ getNumberOfTroves(): Promise<number>;
430
+ getPrice(): Promise<Decimal>;
431
+ getRemainingStabilityPoolZEROReward(): Promise<Decimal>;
432
+ getStabilityDeposit(address?: string): Promise<StabilityDeposit>;
433
+ getTotal(): Promise<Trove>;
434
+ getTotalRedistributed(): Promise<Trove>;
435
+ getTotalStakedZERO(): Promise<Decimal>;
436
+ getTrove(address?: string): Promise<UserTrove>;
437
+ getTroveBeforeRedistribution(address?: string): Promise<TroveWithPendingRedistribution>;
438
+ // @internal (undocumented)
439
+ getTroves(params: TroveListingParams & {
440
+ beforeRedistribution: true;
441
+ }): Promise<TroveWithPendingRedistribution[]>;
442
+ getTroves(params: TroveListingParams): Promise<UserTrove[]>;
443
+ getZEROBalance(address?: string): Promise<Decimal>;
444
+ getZEROStake(address?: string): Promise<ZEROStake>;
445
+ getZUSDBalance(address?: string): Promise<Decimal>;
446
+ getZUSDInStabilityPool(): Promise<Decimal>;
447
+ }
448
+
449
+ // @internal (undocumented)
450
+ export interface _ReadableLiquityWithExtraParams<T extends unknown[]> extends _ReadableLiquityWithExtraParamsBase<T> {
451
+ // (undocumented)
452
+ getTroves(params: TroveListingParams & {
453
+ beforeRedistribution: true;
454
+ }, ...extraParams: T): Promise<TroveWithPendingRedistribution[]>;
455
+ // (undocumented)
456
+ getTroves(params: TroveListingParams, ...extraParams: T): Promise<UserTrove[]>;
457
+ }
458
+
459
+ // @internal (undocumented)
460
+ export type _ReadableLiquityWithExtraParamsBase<T extends unknown[]> = {
461
+ [P in keyof ReadableLiquity]: ReadableLiquity[P] extends (...params: infer A) => infer R ? (...params: [...originalParams: A, ...extraParams: T]) => R : never;
462
+ };
463
+
464
+ // @public
465
+ export interface RedemptionDetails {
466
+ actualZUSDAmount: Decimal;
467
+ attemptedZUSDAmount: Decimal;
468
+ collateralTaken: Decimal;
469
+ fee: Decimal;
470
+ }
471
+
472
+ // @internal (undocumented)
473
+ export type _SendableFrom<T, R, S> = {
474
+ [M in keyof T]: T[M] extends (...args: infer A) => Promise<infer D> ? (...args: A) => Promise<SentLiquityTransaction<S, LiquityReceipt<R, D>>> : never;
475
+ };
476
+
477
+ // Warning: (ae-incompatible-release-tags) The symbol "SendableLiquity" is marked as @public, but its signature references "_SendableFrom" which is marked as @internal
478
+ //
479
+ // @public
480
+ export interface SendableLiquity<R = unknown, S = unknown> extends _SendableFrom<TransactableLiquity, R, S> {
481
+ adjustTrove(params: TroveAdjustmentParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
482
+ borrowZUSD(amount: Decimalish, maxBorrowingRate?: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
483
+ claimCollateralSurplus(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
484
+ closeTrove(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveClosureDetails>>>;
485
+ depositCollateral(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
486
+ depositZUSDInStabilityPool(amount: Decimalish, frontendTag?: string): Promise<SentLiquityTransaction<S, LiquityReceipt<R, StabilityDepositChangeDetails>>>;
487
+ liquidate(address: string | string[]): Promise<SentLiquityTransaction<S, LiquityReceipt<R, LiquidationDetails>>>;
488
+ liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise<SentLiquityTransaction<S, LiquityReceipt<R, LiquidationDetails>>>;
489
+ openTrove(params: TroveCreationParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveCreationDetails>>>;
490
+ redeemZUSD(amount: Decimalish, maxRedemptionRate?: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, RedemptionDetails>>>;
491
+ registerFrontend(kickbackRate: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
492
+ repayZUSD(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
493
+ sendZERO(toAddress: string, amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
494
+ sendZUSD(toAddress: string, amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
495
+ // @internal (undocumented)
496
+ setPrice(price: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
497
+ stakeZERO(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
498
+ transferCollateralGainToTrove(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, CollateralGainTransferDetails>>>;
499
+ unstakeZERO(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
500
+ withdrawCollateral(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
501
+ withdrawGainsFromStabilityPool(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, StabilityPoolGainsWithdrawalDetails>>>;
502
+ withdrawGainsFromStaking(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
503
+ withdrawZUSDFromStabilityPool(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, StabilityDepositChangeDetails>>>;
504
+ }
505
+
506
+ // @public
507
+ export interface SentLiquityTransaction<S = unknown, T extends LiquityReceipt = LiquityReceipt> {
508
+ getReceipt(): Promise<T>;
509
+ readonly rawSentTransaction: S;
510
+ waitForReceipt(): Promise<Extract<T, MinedReceipt>>;
511
+ }
512
+
513
+ // @public
514
+ export class StabilityDeposit {
515
+ // @internal
516
+ constructor(initialZUSD: Decimal, currentZUSD: Decimal, collateralGain: Decimal, zeroReward: Decimal, frontendTag: string);
517
+ apply(change: StabilityDepositChange<Decimalish> | undefined): Decimal;
518
+ readonly collateralGain: Decimal;
519
+ readonly currentZUSD: Decimal;
520
+ equals(that: StabilityDeposit): boolean;
521
+ readonly frontendTag: string;
522
+ readonly initialZUSD: Decimal;
523
+ // (undocumented)
524
+ get isEmpty(): boolean;
525
+ // @internal (undocumented)
526
+ toString(): string;
527
+ whatChanged(thatZUSD: Decimalish): StabilityDepositChange<Decimal> | undefined;
528
+ readonly zeroReward: Decimal;
529
+ }
530
+
531
+ // @public
532
+ export type StabilityDepositChange<T> = {
533
+ depositZUSD: T;
534
+ withdrawZUSD?: undefined;
535
+ } | {
536
+ depositZUSD?: undefined;
537
+ withdrawZUSD: T;
538
+ withdrawAllZUSD: boolean;
539
+ };
540
+
541
+ // @public
542
+ export interface StabilityDepositChangeDetails extends StabilityPoolGainsWithdrawalDetails {
543
+ change: StabilityDepositChange<Decimal>;
544
+ }
545
+
546
+ // @public
547
+ export interface StabilityPoolGainsWithdrawalDetails {
548
+ collateralGain: Decimal;
549
+ newZUSDDeposit: Decimal;
550
+ zeroReward: Decimal;
551
+ zusdLoss: Decimal;
552
+ }
553
+
554
+ // @public
555
+ export type SuccessfulReceipt<R = unknown, D = unknown> = {
556
+ status: "succeeded";
557
+ rawReceipt: R;
558
+ details: D;
559
+ };
560
+
561
+ // @internal (undocumented)
562
+ export const _successfulReceipt: <R, D>(rawReceipt: R, details: D, toString?: (() => string) | undefined) => SuccessfulReceipt<R, D>;
563
+
564
+ // @public
565
+ export interface TransactableLiquity {
566
+ adjustTrove(params: TroveAdjustmentParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<TroveAdjustmentDetails>;
567
+ borrowZUSD(amount: Decimalish, maxBorrowingRate?: Decimalish): Promise<TroveAdjustmentDetails>;
568
+ claimCollateralSurplus(): Promise<void>;
569
+ closeTrove(): Promise<TroveClosureDetails>;
570
+ depositCollateral(amount: Decimalish): Promise<TroveAdjustmentDetails>;
571
+ depositZUSDInStabilityPool(amount: Decimalish, frontendTag?: string): Promise<StabilityDepositChangeDetails>;
572
+ liquidate(address: string | string[]): Promise<LiquidationDetails>;
573
+ liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise<LiquidationDetails>;
574
+ openTrove(params: TroveCreationParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<TroveCreationDetails>;
575
+ redeemZUSD(amount: Decimalish, maxRedemptionRate?: Decimalish): Promise<RedemptionDetails>;
576
+ registerFrontend(kickbackRate: Decimalish): Promise<void>;
577
+ repayZUSD(amount: Decimalish): Promise<TroveAdjustmentDetails>;
578
+ sendZERO(toAddress: string, amount: Decimalish): Promise<void>;
579
+ sendZUSD(toAddress: string, amount: Decimalish): Promise<void>;
580
+ // @internal (undocumented)
581
+ setPrice(price: Decimalish): Promise<void>;
582
+ stakeZERO(amount: Decimalish): Promise<void>;
583
+ transferCollateralGainToTrove(): Promise<CollateralGainTransferDetails>;
584
+ unstakeZERO(amount: Decimalish): Promise<void>;
585
+ withdrawCollateral(amount: Decimalish): Promise<TroveAdjustmentDetails>;
586
+ withdrawGainsFromStabilityPool(): Promise<StabilityPoolGainsWithdrawalDetails>;
587
+ withdrawGainsFromStaking(): Promise<void>;
588
+ withdrawZUSDFromStabilityPool(amount: Decimalish): Promise<StabilityDepositChangeDetails>;
589
+ }
590
+
591
+ // @public
592
+ export class TransactionFailedError<T extends FailedReceipt = FailedReceipt> extends Error {
593
+ // @internal
594
+ constructor(name: string, message: string, failedReceipt: T);
595
+ // (undocumented)
596
+ readonly failedReceipt: T;
597
+ }
598
+
599
+ // @public
600
+ export class Trove {
601
+ // @internal
602
+ constructor(collateral?: Decimal, debt?: Decimal);
603
+ // (undocumented)
604
+ add(that: Trove): Trove;
605
+ // (undocumented)
606
+ addCollateral(collateral: Decimalish): Trove;
607
+ // (undocumented)
608
+ addDebt(debt: Decimalish): Trove;
609
+ adjust(params: TroveAdjustmentParams<Decimalish>, borrowingRate?: Decimalish): Trove;
610
+ adjustTo(that: Trove, borrowingRate?: Decimalish): TroveAdjustmentParams<Decimal>;
611
+ apply(change: TroveChange<Decimal> | undefined, borrowingRate?: Decimalish): Trove;
612
+ readonly collateral: Decimal;
613
+ collateralRatio(price: Decimalish): Decimal;
614
+ collateralRatioIsBelowCritical(price: Decimalish): boolean;
615
+ collateralRatioIsBelowMinimum(price: Decimalish): boolean;
616
+ static create(params: TroveCreationParams<Decimalish>, borrowingRate?: Decimalish): Trove;
617
+ readonly debt: Decimal;
618
+ // (undocumented)
619
+ equals(that: Trove): boolean;
620
+ // (undocumented)
621
+ get isEmpty(): boolean;
622
+ isOpenableInRecoveryMode(price: Decimalish): boolean;
623
+ // (undocumented)
624
+ multiply(multiplier: Decimalish): Trove;
625
+ get netDebt(): Decimal;
626
+ // @internal (undocumented)
627
+ get _nominalCollateralRatio(): Decimal;
628
+ static recreate(that: Trove, borrowingRate?: Decimalish): TroveCreationParams<Decimal>;
629
+ // (undocumented)
630
+ setCollateral(collateral: Decimalish): Trove;
631
+ // (undocumented)
632
+ setDebt(debt: Decimalish): Trove;
633
+ // (undocumented)
634
+ subtract(that: Trove): Trove;
635
+ // (undocumented)
636
+ subtractCollateral(collateral: Decimalish): Trove;
637
+ // (undocumented)
638
+ subtractDebt(debt: Decimalish): Trove;
639
+ // @internal (undocumented)
640
+ toString(): string;
641
+ whatChanged(that: Trove, borrowingRate?: Decimalish): TroveChange<Decimal> | undefined;
642
+ }
643
+
644
+ // @public
645
+ export interface TroveAdjustmentDetails {
646
+ fee: Decimal;
647
+ newTrove: Trove;
648
+ params: TroveAdjustmentParams<Decimal>;
649
+ }
650
+
651
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveAdjustmentParams" is marked as @public, but its signature references "_CollateralChange" which is marked as @internal
652
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveAdjustmentParams" is marked as @public, but its signature references "_NoDebtChange" which is marked as @internal
653
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveAdjustmentParams" is marked as @public, but its signature references "_DebtChange" which is marked as @internal
654
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveAdjustmentParams" is marked as @public, but its signature references "_NoCollateralChange" which is marked as @internal
655
+ //
656
+ // @public
657
+ export type TroveAdjustmentParams<T = unknown> = (_CollateralChange<T> & _NoDebtChange) | (_DebtChange<T> & _NoCollateralChange) | (_CollateralChange<T> & _DebtChange<T>);
658
+
659
+ // @public
660
+ export type TroveChange<T> = {
661
+ type: "invalidCreation";
662
+ invalidTrove: Trove;
663
+ error: TroveCreationError;
664
+ } | {
665
+ type: "creation";
666
+ params: TroveCreationParams<T>;
667
+ } | {
668
+ type: "closure";
669
+ params: TroveClosureParams<T>;
670
+ } | {
671
+ type: "adjustment";
672
+ params: TroveAdjustmentParams<T>;
673
+ setToZero?: "collateral" | "debt";
674
+ };
675
+
676
+ // @public
677
+ export interface TroveClosureDetails {
678
+ params: TroveClosureParams<Decimal>;
679
+ }
680
+
681
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveClosureParams" is marked as @public, but its signature references "_CollateralWithdrawal" which is marked as @internal
682
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveClosureParams" is marked as @public, but its signature references "_NoCollateralDeposit" which is marked as @internal
683
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveClosureParams" is marked as @public, but its signature references "_ZUSDRepayment" which is marked as @internal
684
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveClosureParams" is marked as @public, but its signature references "_NoZUSDBorrowing" which is marked as @internal
685
+ //
686
+ // @public
687
+ export type TroveClosureParams<T> = _CollateralWithdrawal<T> & _NoCollateralDeposit & Partial<_ZUSDRepayment<T>> & _NoZUSDBorrowing;
688
+
689
+ // @public
690
+ export interface TroveCreationDetails {
691
+ fee: Decimal;
692
+ newTrove: Trove;
693
+ params: TroveCreationParams<Decimal>;
694
+ }
695
+
696
+ // @public
697
+ export type TroveCreationError = "missingLiquidationReserve";
698
+
699
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveCreationParams" is marked as @public, but its signature references "_CollateralDeposit" which is marked as @internal
700
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveCreationParams" is marked as @public, but its signature references "_NoCollateralWithdrawal" which is marked as @internal
701
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveCreationParams" is marked as @public, but its signature references "_ZUSDBorrowing" which is marked as @internal
702
+ // Warning: (ae-incompatible-release-tags) The symbol "TroveCreationParams" is marked as @public, but its signature references "_NoZUSDRepayment" which is marked as @internal
703
+ //
704
+ // @public
705
+ export type TroveCreationParams<T = unknown> = _CollateralDeposit<T> & _NoCollateralWithdrawal & _ZUSDBorrowing<T> & _NoZUSDRepayment;
706
+
707
+ // @public
708
+ export interface TroveListingParams {
709
+ readonly beforeRedistribution?: boolean;
710
+ readonly first: number;
711
+ readonly sortedBy: "ascendingCollateralRatio" | "descendingCollateralRatio";
712
+ readonly startingAt?: number;
713
+ }
714
+
715
+ // @public
716
+ export class TroveWithPendingRedistribution extends UserTrove {
717
+ // @internal
718
+ constructor(ownerAddress: string, status: UserTroveStatus, collateral?: Decimal, debt?: Decimal, stake?: Decimal, snapshotOfTotalRedistributed?: Trove);
719
+ // (undocumented)
720
+ applyRedistribution(totalRedistributed: Trove): UserTrove;
721
+ // (undocumented)
722
+ equals(that: TroveWithPendingRedistribution): boolean;
723
+ }
724
+
725
+ // @public
726
+ export class UserTrove extends Trove {
727
+ // @internal
728
+ constructor(ownerAddress: string, status: UserTroveStatus, collateral?: Decimal, debt?: Decimal);
729
+ // (undocumented)
730
+ equals(that: UserTrove): boolean;
731
+ readonly ownerAddress: string;
732
+ readonly status: UserTroveStatus;
733
+ // @internal (undocumented)
734
+ toString(): string;
735
+ }
736
+
737
+ // @public
738
+ export type UserTroveStatus = "nonExistent" | "open" | "closedByOwner" | "closedByLiquidation" | "closedByRedemption";
739
+
740
+ // @public
741
+ export class ZEROStake {
742
+ // @internal
743
+ constructor(stakedZERO?: Decimal, collateralGain?: Decimal, zusdGain?: Decimal);
744
+ apply(change: ZEROStakeChange<Decimalish> | undefined): Decimal;
745
+ readonly collateralGain: Decimal;
746
+ equals(that: ZEROStake): boolean;
747
+ // (undocumented)
748
+ get isEmpty(): boolean;
749
+ readonly stakedZERO: Decimal;
750
+ // @internal (undocumented)
751
+ toString(): string;
752
+ whatChanged(thatStakedZERO: Decimalish): ZEROStakeChange<Decimal> | undefined;
753
+ readonly zusdGain: Decimal;
754
+ }
755
+
756
+ // @public
757
+ export type ZEROStakeChange<T> = {
758
+ stakeZERO: T;
759
+ unstakeZERO?: undefined;
760
+ } | {
761
+ stakeZERO?: undefined;
762
+ unstakeZERO: T;
763
+ unstakeAllZERO: boolean;
764
+ };
765
+
766
+ // @public
767
+ export const ZUSD_LIQUIDATION_RESERVE: Decimal;
768
+
769
+ // @public
770
+ export const ZUSD_MINIMUM_DEBT: Decimal;
771
+
772
+ // @public
773
+ export const ZUSD_MINIMUM_NET_DEBT: Decimal;
774
+
775
+ // @internal (undocumented)
776
+ export type _ZUSDBorrowing<T> = {
777
+ borrowZUSD: T;
778
+ };
779
+
780
+ // @internal (undocumented)
781
+ export type _ZUSDRepayment<T> = {
782
+ repayZUSD: T;
783
+ };
784
+
785
+
786
+ // (No @packageDocumentation comment for this package)
787
+
788
+ ```