@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.
- package/dist/index.d.ts +13 -13
- package/dist/index.js +25 -25
- package/dist/src/Decimal.d.ts +88 -88
- package/dist/src/Decimal.js +360 -360
- package/dist/src/Fees.d.ts +81 -81
- package/dist/src/Fees.js +122 -122
- package/dist/src/LiquityStore.d.ts +206 -208
- package/dist/src/LiquityStore.d.ts.map +1 -1
- package/dist/src/LiquityStore.js +207 -208
- package/dist/src/LiquityStore.js.map +1 -1
- package/dist/src/ObservableLiquity.d.ts +14 -14
- package/dist/src/ObservableLiquity.js +2 -2
- package/dist/src/PopulatableLiquity.d.ts +124 -124
- package/dist/src/PopulatableLiquity.js +2 -2
- package/dist/src/ReadableLiquity.d.ts +151 -155
- package/dist/src/ReadableLiquity.d.ts.map +1 -1
- package/dist/src/ReadableLiquity.js +2 -2
- package/dist/src/SendableLiquity.d.ts +155 -155
- package/dist/src/SendableLiquity.js +19 -19
- package/dist/src/StabilityDeposit.d.ts +58 -58
- package/dist/src/StabilityDeposit.js +79 -79
- package/dist/src/TransactableLiquity.d.ts +413 -413
- package/dist/src/TransactableLiquity.js +17 -17
- package/dist/src/Trove.d.ts +366 -366
- package/dist/src/Trove.js +422 -422
- package/dist/src/ZEROStake.d.ts +51 -51
- package/dist/src/ZEROStake.js +73 -73
- package/dist/src/_CachedReadableLiquity.d.ts +53 -54
- package/dist/src/_CachedReadableLiquity.d.ts.map +1 -1
- package/dist/src/_CachedReadableLiquity.js +88 -92
- package/dist/src/_CachedReadableLiquity.js.map +1 -1
- package/dist/src/constants.d.ts +60 -60
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +63 -63
- package/dist/src/constants.js.map +1 -1
- package/etc/lib-base.api.md +0 -4
- package/package.json +1 -1
- package/src/LiquityStore.ts +0 -9
- package/src/ReadableLiquity.ts +0 -5
- package/src/_CachedReadableLiquity.ts +0 -7
- package/src/constants.ts +1 -1
@@ -1,414 +1,414 @@
|
|
1
|
-
import { Decimal, Decimalish } from "./Decimal";
|
2
|
-
import { Trove, TroveAdjustmentParams, TroveClosureParams, TroveCreationParams } from "./Trove";
|
3
|
-
import { StabilityDepositChange } from "./StabilityDeposit";
|
4
|
-
import { FailedReceipt } from "./SendableLiquity";
|
5
|
-
/**
|
6
|
-
* Thrown by {@link TransactableLiquity} functions in case of transaction failure.
|
7
|
-
*
|
8
|
-
* @public
|
9
|
-
*/
|
10
|
-
export declare class TransactionFailedError<T extends FailedReceipt = FailedReceipt> extends Error {
|
11
|
-
readonly failedReceipt: T;
|
12
|
-
/** @internal */
|
13
|
-
constructor(name: string, message: string, failedReceipt: T);
|
14
|
-
}
|
15
|
-
/**
|
16
|
-
* Details of an {@link TransactableLiquity.openTrove | openTrove()} transaction.
|
17
|
-
*
|
18
|
-
* @public
|
19
|
-
*/
|
20
|
-
export interface TroveCreationDetails {
|
21
|
-
/** How much was deposited and borrowed. */
|
22
|
-
params: TroveCreationParams<Decimal>;
|
23
|
-
/** The Trove that was created by the transaction. */
|
24
|
-
newTrove: Trove;
|
25
|
-
/** Amount of ZUSD added to the Trove's debt as borrowing fee. */
|
26
|
-
fee: Decimal;
|
27
|
-
}
|
28
|
-
/**
|
29
|
-
* Details of an {@link TransactableLiquity.adjustTrove | adjustTrove()} transaction.
|
30
|
-
*
|
31
|
-
* @public
|
32
|
-
*/
|
33
|
-
export interface TroveAdjustmentDetails {
|
34
|
-
/** Parameters of the adjustment. */
|
35
|
-
params: TroveAdjustmentParams<Decimal>;
|
36
|
-
/** New state of the adjusted Trove directly after the transaction. */
|
37
|
-
newTrove: Trove;
|
38
|
-
/** Amount of ZUSD added to the Trove's debt as borrowing fee. */
|
39
|
-
fee: Decimal;
|
40
|
-
}
|
41
|
-
/**
|
42
|
-
* Details of a {@link TransactableLiquity.closeTrove | closeTrove()} transaction.
|
43
|
-
*
|
44
|
-
* @public
|
45
|
-
*/
|
46
|
-
export interface TroveClosureDetails {
|
47
|
-
/** How much was withdrawn and repaid. */
|
48
|
-
params: TroveClosureParams<Decimal>;
|
49
|
-
}
|
50
|
-
/**
|
51
|
-
* Details of a {@link TransactableLiquity.liquidate | liquidate()} or
|
52
|
-
* {@link TransactableLiquity.liquidateUpTo | liquidateUpTo()} transaction.
|
53
|
-
*
|
54
|
-
* @public
|
55
|
-
*/
|
56
|
-
export interface LiquidationDetails {
|
57
|
-
/** Addresses whose Troves were liquidated by the transaction. */
|
58
|
-
liquidatedAddresses: string[];
|
59
|
-
/** Total collateral liquidated and debt cleared by the transaction. */
|
60
|
-
totalLiquidated: Trove;
|
61
|
-
/** Amount of ZUSD paid to the liquidator as gas compensation. */
|
62
|
-
zusdGasCompensation: Decimal;
|
63
|
-
/** Amount of native currency (e.g. Ether) paid to the liquidator as gas compensation. */
|
64
|
-
collateralGasCompensation: Decimal;
|
65
|
-
}
|
66
|
-
/**
|
67
|
-
* Details of a {@link TransactableLiquity.redeemZUSD | redeemZUSD()} transaction.
|
68
|
-
*
|
69
|
-
* @public
|
70
|
-
*/
|
71
|
-
export interface RedemptionDetails {
|
72
|
-
/** Amount of ZUSD the redeemer tried to redeem. */
|
73
|
-
attemptedZUSDAmount: Decimal;
|
74
|
-
/**
|
75
|
-
* Amount of ZUSD that was actually redeemed by the transaction.
|
76
|
-
*
|
77
|
-
* @remarks
|
78
|
-
* This can end up being lower than `attemptedZUSDAmount` due to interference from another
|
79
|
-
* transaction that modifies the list of Troves.
|
80
|
-
*
|
81
|
-
* @public
|
82
|
-
*/
|
83
|
-
actualZUSDAmount: Decimal;
|
84
|
-
/** Amount of collateral (e.g. Ether) taken from Troves by the transaction. */
|
85
|
-
collateralTaken: Decimal;
|
86
|
-
/** Amount of native currency (e.g. Ether) deducted as fee from collateral taken. */
|
87
|
-
fee: Decimal;
|
88
|
-
}
|
89
|
-
/**
|
90
|
-
* Details of a
|
91
|
-
* {@link TransactableLiquity.withdrawGainsFromStabilityPool | withdrawGainsFromStabilityPool()}
|
92
|
-
* transaction.
|
93
|
-
*
|
94
|
-
* @public
|
95
|
-
*/
|
96
|
-
export interface StabilityPoolGainsWithdrawalDetails {
|
97
|
-
/** Amount of ZUSD burned from the deposit by liquidations since the last modification. */
|
98
|
-
zusdLoss: Decimal;
|
99
|
-
/** Amount of ZUSD in the deposit directly after this transaction. */
|
100
|
-
newZUSDDeposit: Decimal;
|
101
|
-
/** Amount of native currency (e.g. Ether) paid out to the depositor in this transaction. */
|
102
|
-
collateralGain: Decimal;
|
103
|
-
/** Amount of ZERO rewarded to the depositor in this transaction. */
|
104
|
-
zeroReward: Decimal;
|
105
|
-
}
|
106
|
-
/**
|
107
|
-
* Details of a
|
108
|
-
* {@link TransactableLiquity.depositZUSDInStabilityPool | depositZUSDInStabilityPool()} or
|
109
|
-
* {@link TransactableLiquity.withdrawZUSDFromStabilityPool | withdrawZUSDFromStabilityPool()}
|
110
|
-
* transaction.
|
111
|
-
*
|
112
|
-
* @public
|
113
|
-
*/
|
114
|
-
export interface StabilityDepositChangeDetails extends StabilityPoolGainsWithdrawalDetails {
|
115
|
-
/** Change that was made to the deposit by this transaction. */
|
116
|
-
change: StabilityDepositChange<Decimal>;
|
117
|
-
}
|
118
|
-
/**
|
119
|
-
* Details of a
|
120
|
-
* {@link TransactableLiquity.transferCollateralGainToTrove | transferCollateralGainToTrove()}
|
121
|
-
* transaction.
|
122
|
-
*
|
123
|
-
* @public
|
124
|
-
*/
|
125
|
-
export interface CollateralGainTransferDetails extends StabilityPoolGainsWithdrawalDetails {
|
126
|
-
/** New state of the depositor's Trove directly after the transaction. */
|
127
|
-
newTrove: Trove;
|
128
|
-
}
|
129
|
-
/**
|
130
|
-
* Send Zero transactions and wait for them to succeed.
|
131
|
-
*
|
132
|
-
* @remarks
|
133
|
-
* The functions return the details of the transaction (if any), or throw an implementation-specific
|
134
|
-
* subclass of {@link TransactionFailedError} in case of transaction failure.
|
135
|
-
*
|
136
|
-
* Implemented by {@link @sovryn-zero/lib-ethers#EthersLiquity}.
|
137
|
-
*
|
138
|
-
* @public
|
139
|
-
*/
|
140
|
-
export interface TransactableLiquity {
|
141
|
-
/**
|
142
|
-
* Open a new Trove by depositing collateral and borrowing ZUSD.
|
143
|
-
*
|
144
|
-
* @param params - How much to deposit and borrow.
|
145
|
-
* @param maxBorrowingRate - Maximum acceptable
|
146
|
-
* {@link @sovryn-zero/lib-base#Fees.borrowingRate | borrowing rate}.
|
147
|
-
*
|
148
|
-
* @throws
|
149
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
150
|
-
*
|
151
|
-
* @remarks
|
152
|
-
* If `maxBorrowingRate` is omitted, the current borrowing rate plus 0.5% is used as maximum
|
153
|
-
* acceptable rate.
|
154
|
-
*/
|
155
|
-
openTrove(params: TroveCreationParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<TroveCreationDetails>;
|
156
|
-
/**
|
157
|
-
* Close existing Trove by repaying all debt and withdrawing all collateral.
|
158
|
-
*
|
159
|
-
* @throws
|
160
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
161
|
-
*/
|
162
|
-
closeTrove(): Promise<TroveClosureDetails>;
|
163
|
-
/**
|
164
|
-
* Adjust existing Trove by changing its collateral, debt, or both.
|
165
|
-
*
|
166
|
-
* @param params - Parameters of the adjustment.
|
167
|
-
* @param maxBorrowingRate - Maximum acceptable
|
168
|
-
* {@link @sovryn-zero/lib-base#Fees.borrowingRate | borrowing rate} if
|
169
|
-
* `params` includes `borrowZUSD`.
|
170
|
-
*
|
171
|
-
* @throws
|
172
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
173
|
-
*
|
174
|
-
* @remarks
|
175
|
-
* The transaction will fail if the Trove's debt would fall below
|
176
|
-
* {@link @sovryn-zero/lib-base#ZUSD_MINIMUM_DEBT}.
|
177
|
-
*
|
178
|
-
* If `maxBorrowingRate` is omitted, the current borrowing rate plus 0.5% is used as maximum
|
179
|
-
* acceptable rate.
|
180
|
-
*/
|
181
|
-
adjustTrove(params: TroveAdjustmentParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<TroveAdjustmentDetails>;
|
182
|
-
/**
|
183
|
-
* Adjust existing Trove by depositing more collateral.
|
184
|
-
*
|
185
|
-
* @param amount - The amount of collateral to add to the Trove's existing collateral.
|
186
|
-
*
|
187
|
-
* @throws
|
188
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
189
|
-
*
|
190
|
-
* @remarks
|
191
|
-
* Equivalent to:
|
192
|
-
*
|
193
|
-
* ```typescript
|
194
|
-
* adjustTrove({ depositCollateral: amount })
|
195
|
-
* ```
|
196
|
-
*/
|
197
|
-
depositCollateral(amount: Decimalish): Promise<TroveAdjustmentDetails>;
|
198
|
-
/**
|
199
|
-
* Adjust existing Trove by withdrawing some of its collateral.
|
200
|
-
*
|
201
|
-
* @param amount - The amount of collateral to withdraw from the Trove.
|
202
|
-
*
|
203
|
-
* @throws
|
204
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
205
|
-
*
|
206
|
-
* @remarks
|
207
|
-
* Equivalent to:
|
208
|
-
*
|
209
|
-
* ```typescript
|
210
|
-
* adjustTrove({ withdrawCollateral: amount })
|
211
|
-
* ```
|
212
|
-
*/
|
213
|
-
withdrawCollateral(amount: Decimalish): Promise<TroveAdjustmentDetails>;
|
214
|
-
/**
|
215
|
-
* Adjust existing Trove by borrowing more ZUSD.
|
216
|
-
*
|
217
|
-
* @param amount - The amount of ZUSD to borrow.
|
218
|
-
* @param maxBorrowingRate - Maximum acceptable
|
219
|
-
* {@link @sovryn-zero/lib-base#Fees.borrowingRate | borrowing rate}.
|
220
|
-
*
|
221
|
-
* @throws
|
222
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
223
|
-
*
|
224
|
-
* @remarks
|
225
|
-
* Equivalent to:
|
226
|
-
*
|
227
|
-
* ```typescript
|
228
|
-
* adjustTrove({ borrowZUSD: amount }, maxBorrowingRate)
|
229
|
-
* ```
|
230
|
-
*/
|
231
|
-
borrowZUSD(amount: Decimalish, maxBorrowingRate?: Decimalish): Promise<TroveAdjustmentDetails>;
|
232
|
-
/**
|
233
|
-
* Adjust existing Trove by repaying some of its debt.
|
234
|
-
*
|
235
|
-
* @param amount - The amount of ZUSD to repay.
|
236
|
-
*
|
237
|
-
* @throws
|
238
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
239
|
-
*
|
240
|
-
* @remarks
|
241
|
-
* Equivalent to:
|
242
|
-
*
|
243
|
-
* ```typescript
|
244
|
-
* adjustTrove({ repayZUSD: amount })
|
245
|
-
* ```
|
246
|
-
*/
|
247
|
-
repayZUSD(amount: Decimalish): Promise<TroveAdjustmentDetails>;
|
248
|
-
/** @internal */
|
249
|
-
setPrice(price: Decimalish): Promise<void>;
|
250
|
-
/**
|
251
|
-
* Liquidate one or more undercollateralized Troves.
|
252
|
-
*
|
253
|
-
* @param address - Address or array of addresses whose Troves to liquidate.
|
254
|
-
*
|
255
|
-
* @throws
|
256
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
257
|
-
*/
|
258
|
-
liquidate(address: string | string[]): Promise<LiquidationDetails>;
|
259
|
-
/**
|
260
|
-
* Liquidate the least collateralized Troves up to a maximum number.
|
261
|
-
*
|
262
|
-
* @param maximumNumberOfTrovesToLiquidate - Stop after liquidating this many Troves.
|
263
|
-
*
|
264
|
-
* @throws
|
265
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
266
|
-
*/
|
267
|
-
liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise<LiquidationDetails>;
|
268
|
-
/**
|
269
|
-
* Make a new Stability Deposit, or top up existing one.
|
270
|
-
*
|
271
|
-
* @param amount - Amount of ZUSD to add to new or existing deposit.
|
272
|
-
* @param frontendTag - Address that should receive a share of this deposit's ZERO rewards.
|
273
|
-
*
|
274
|
-
* @throws
|
275
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
276
|
-
*
|
277
|
-
* @remarks
|
278
|
-
* The `frontendTag` parameter is only effective when making a new deposit.
|
279
|
-
*
|
280
|
-
* As a side-effect, the transaction will also pay out an existing Stability Deposit's
|
281
|
-
* {@link @sovryn-zero/lib-base#StabilityDeposit.collateralGain | collateral gain} and
|
282
|
-
* {@link @sovryn-zero/lib-base#StabilityDeposit.zeroReward | ZERO reward}.
|
283
|
-
*/
|
284
|
-
depositZUSDInStabilityPool(amount: Decimalish, frontendTag?: string): Promise<StabilityDepositChangeDetails>;
|
285
|
-
/**
|
286
|
-
* Withdraw ZUSD from Stability Deposit.
|
287
|
-
*
|
288
|
-
* @param amount - Amount of ZUSD to withdraw.
|
289
|
-
*
|
290
|
-
* @throws
|
291
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
292
|
-
*
|
293
|
-
* @remarks
|
294
|
-
* As a side-effect, the transaction will also pay out the Stability Deposit's
|
295
|
-
* {@link @sovryn-zero/lib-base#StabilityDeposit.collateralGain | collateral gain} and
|
296
|
-
* {@link @sovryn-zero/lib-base#StabilityDeposit.zeroReward | ZERO reward}.
|
297
|
-
*/
|
298
|
-
withdrawZUSDFromStabilityPool(amount: Decimalish): Promise<StabilityDepositChangeDetails>;
|
299
|
-
/**
|
300
|
-
* Withdraw {@link @sovryn-zero/lib-base#StabilityDeposit.collateralGain | collateral gain} and
|
301
|
-
* {@link @sovryn-zero/lib-base#StabilityDeposit.zeroReward | ZERO reward} from Stability Deposit.
|
302
|
-
*
|
303
|
-
* @throws
|
304
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
305
|
-
*/
|
306
|
-
withdrawGainsFromStabilityPool(): Promise<StabilityPoolGainsWithdrawalDetails>;
|
307
|
-
/**
|
308
|
-
* Transfer {@link @sovryn-zero/lib-base#StabilityDeposit.collateralGain | collateral gain} from
|
309
|
-
* Stability Deposit to Trove.
|
310
|
-
*
|
311
|
-
* @throws
|
312
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
313
|
-
*
|
314
|
-
* @remarks
|
315
|
-
* The collateral gain is transfered to the Trove as additional collateral.
|
316
|
-
*
|
317
|
-
* As a side-effect, the transaction will also pay out the Stability Deposit's
|
318
|
-
* {@link @sovryn-zero/lib-base#StabilityDeposit.zeroReward | ZERO reward}.
|
319
|
-
*/
|
320
|
-
transferCollateralGainToTrove(): Promise<CollateralGainTransferDetails>;
|
321
|
-
/**
|
322
|
-
* Send ZUSD tokens to an address.
|
323
|
-
*
|
324
|
-
* @param toAddress - Address of receipient.
|
325
|
-
* @param amount - Amount of ZUSD to send.
|
326
|
-
*
|
327
|
-
* @throws
|
328
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
329
|
-
*/
|
330
|
-
sendZUSD(toAddress: string, amount: Decimalish): Promise<void>;
|
331
|
-
/**
|
332
|
-
* Send ZERO tokens to an address.
|
333
|
-
*
|
334
|
-
* @param toAddress - Address of receipient.
|
335
|
-
* @param amount - Amount of ZERO to send.
|
336
|
-
*
|
337
|
-
* @throws
|
338
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
339
|
-
*/
|
340
|
-
sendZERO(toAddress: string, amount: Decimalish): Promise<void>;
|
341
|
-
/**
|
342
|
-
* Redeem ZUSD to native currency (e.g. Ether) at face value.
|
343
|
-
*
|
344
|
-
* @param amount - Amount of ZUSD to be redeemed.
|
345
|
-
* @param maxRedemptionRate - Maximum acceptable
|
346
|
-
* {@link @sovryn-zero/lib-base#Fees.redemptionRate | redemption rate}.
|
347
|
-
*
|
348
|
-
* @throws
|
349
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
350
|
-
*
|
351
|
-
* @remarks
|
352
|
-
* If `maxRedemptionRate` is omitted, the current redemption rate (based on `amount`) plus 0.1%
|
353
|
-
* is used as maximum acceptable rate.
|
354
|
-
*/
|
355
|
-
redeemZUSD(amount: Decimalish, maxRedemptionRate?: Decimalish): Promise<RedemptionDetails>;
|
356
|
-
/**
|
357
|
-
* Claim leftover collateral after a liquidation or redemption.
|
358
|
-
*
|
359
|
-
* @remarks
|
360
|
-
* Use {@link @sovryn-zero/lib-base#ReadableLiquity.getCollateralSurplusBalance | getCollateralSurplusBalance()}
|
361
|
-
* to check the amount of collateral available for withdrawal.
|
362
|
-
*
|
363
|
-
* @throws
|
364
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
365
|
-
*/
|
366
|
-
claimCollateralSurplus(): Promise<void>;
|
367
|
-
/**
|
368
|
-
* Stake ZERO to start earning fee revenue or increase existing stake.
|
369
|
-
*
|
370
|
-
* @param amount - Amount of ZERO to add to new or existing stake.
|
371
|
-
*
|
372
|
-
* @throws
|
373
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
374
|
-
*
|
375
|
-
* @remarks
|
376
|
-
* As a side-effect, the transaction will also pay out an existing ZERO stake's
|
377
|
-
* {@link @sovryn-zero/lib-base#ZEROStake.collateralGain | collateral gain} and
|
378
|
-
* {@link @sovryn-zero/lib-base#ZEROStake.zusdGain | ZUSD gain}.
|
379
|
-
*/
|
380
|
-
stakeZERO(amount: Decimalish): Promise<void>;
|
381
|
-
/**
|
382
|
-
* Withdraw ZERO from staking.
|
383
|
-
*
|
384
|
-
* @param amount - Amount of ZERO to withdraw.
|
385
|
-
*
|
386
|
-
* @throws
|
387
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
388
|
-
*
|
389
|
-
* @remarks
|
390
|
-
* As a side-effect, the transaction will also pay out the ZERO stake's
|
391
|
-
* {@link @sovryn-zero/lib-base#ZEROStake.collateralGain | collateral gain} and
|
392
|
-
* {@link @sovryn-zero/lib-base#ZEROStake.zusdGain | ZUSD gain}.
|
393
|
-
*/
|
394
|
-
unstakeZERO(amount: Decimalish): Promise<void>;
|
395
|
-
/**
|
396
|
-
* Withdraw {@link @sovryn-zero/lib-base#ZEROStake.collateralGain | collateral gain} and
|
397
|
-
* {@link @sovryn-zero/lib-base#ZEROStake.zusdGain | ZUSD gain} from ZERO stake.
|
398
|
-
*
|
399
|
-
* @throws
|
400
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
401
|
-
*/
|
402
|
-
withdrawGainsFromStaking(): Promise<void>;
|
403
|
-
/**
|
404
|
-
* Register current wallet address as a Zero frontend.
|
405
|
-
*
|
406
|
-
* @param kickbackRate - The portion of ZERO rewards to pass onto users of the frontend
|
407
|
-
* (between 0 and 1).
|
408
|
-
*
|
409
|
-
* @throws
|
410
|
-
* Throws {@link TransactionFailedError} in case of transaction failure.
|
411
|
-
*/
|
412
|
-
registerFrontend(kickbackRate: Decimalish): Promise<void>;
|
413
|
-
}
|
1
|
+
import { Decimal, Decimalish } from "./Decimal";
|
2
|
+
import { Trove, TroveAdjustmentParams, TroveClosureParams, TroveCreationParams } from "./Trove";
|
3
|
+
import { StabilityDepositChange } from "./StabilityDeposit";
|
4
|
+
import { FailedReceipt } from "./SendableLiquity";
|
5
|
+
/**
|
6
|
+
* Thrown by {@link TransactableLiquity} functions in case of transaction failure.
|
7
|
+
*
|
8
|
+
* @public
|
9
|
+
*/
|
10
|
+
export declare class TransactionFailedError<T extends FailedReceipt = FailedReceipt> extends Error {
|
11
|
+
readonly failedReceipt: T;
|
12
|
+
/** @internal */
|
13
|
+
constructor(name: string, message: string, failedReceipt: T);
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* Details of an {@link TransactableLiquity.openTrove | openTrove()} transaction.
|
17
|
+
*
|
18
|
+
* @public
|
19
|
+
*/
|
20
|
+
export interface TroveCreationDetails {
|
21
|
+
/** How much was deposited and borrowed. */
|
22
|
+
params: TroveCreationParams<Decimal>;
|
23
|
+
/** The Trove that was created by the transaction. */
|
24
|
+
newTrove: Trove;
|
25
|
+
/** Amount of ZUSD added to the Trove's debt as borrowing fee. */
|
26
|
+
fee: Decimal;
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Details of an {@link TransactableLiquity.adjustTrove | adjustTrove()} transaction.
|
30
|
+
*
|
31
|
+
* @public
|
32
|
+
*/
|
33
|
+
export interface TroveAdjustmentDetails {
|
34
|
+
/** Parameters of the adjustment. */
|
35
|
+
params: TroveAdjustmentParams<Decimal>;
|
36
|
+
/** New state of the adjusted Trove directly after the transaction. */
|
37
|
+
newTrove: Trove;
|
38
|
+
/** Amount of ZUSD added to the Trove's debt as borrowing fee. */
|
39
|
+
fee: Decimal;
|
40
|
+
}
|
41
|
+
/**
|
42
|
+
* Details of a {@link TransactableLiquity.closeTrove | closeTrove()} transaction.
|
43
|
+
*
|
44
|
+
* @public
|
45
|
+
*/
|
46
|
+
export interface TroveClosureDetails {
|
47
|
+
/** How much was withdrawn and repaid. */
|
48
|
+
params: TroveClosureParams<Decimal>;
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* Details of a {@link TransactableLiquity.liquidate | liquidate()} or
|
52
|
+
* {@link TransactableLiquity.liquidateUpTo | liquidateUpTo()} transaction.
|
53
|
+
*
|
54
|
+
* @public
|
55
|
+
*/
|
56
|
+
export interface LiquidationDetails {
|
57
|
+
/** Addresses whose Troves were liquidated by the transaction. */
|
58
|
+
liquidatedAddresses: string[];
|
59
|
+
/** Total collateral liquidated and debt cleared by the transaction. */
|
60
|
+
totalLiquidated: Trove;
|
61
|
+
/** Amount of ZUSD paid to the liquidator as gas compensation. */
|
62
|
+
zusdGasCompensation: Decimal;
|
63
|
+
/** Amount of native currency (e.g. Ether) paid to the liquidator as gas compensation. */
|
64
|
+
collateralGasCompensation: Decimal;
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* Details of a {@link TransactableLiquity.redeemZUSD | redeemZUSD()} transaction.
|
68
|
+
*
|
69
|
+
* @public
|
70
|
+
*/
|
71
|
+
export interface RedemptionDetails {
|
72
|
+
/** Amount of ZUSD the redeemer tried to redeem. */
|
73
|
+
attemptedZUSDAmount: Decimal;
|
74
|
+
/**
|
75
|
+
* Amount of ZUSD that was actually redeemed by the transaction.
|
76
|
+
*
|
77
|
+
* @remarks
|
78
|
+
* This can end up being lower than `attemptedZUSDAmount` due to interference from another
|
79
|
+
* transaction that modifies the list of Troves.
|
80
|
+
*
|
81
|
+
* @public
|
82
|
+
*/
|
83
|
+
actualZUSDAmount: Decimal;
|
84
|
+
/** Amount of collateral (e.g. Ether) taken from Troves by the transaction. */
|
85
|
+
collateralTaken: Decimal;
|
86
|
+
/** Amount of native currency (e.g. Ether) deducted as fee from collateral taken. */
|
87
|
+
fee: Decimal;
|
88
|
+
}
|
89
|
+
/**
|
90
|
+
* Details of a
|
91
|
+
* {@link TransactableLiquity.withdrawGainsFromStabilityPool | withdrawGainsFromStabilityPool()}
|
92
|
+
* transaction.
|
93
|
+
*
|
94
|
+
* @public
|
95
|
+
*/
|
96
|
+
export interface StabilityPoolGainsWithdrawalDetails {
|
97
|
+
/** Amount of ZUSD burned from the deposit by liquidations since the last modification. */
|
98
|
+
zusdLoss: Decimal;
|
99
|
+
/** Amount of ZUSD in the deposit directly after this transaction. */
|
100
|
+
newZUSDDeposit: Decimal;
|
101
|
+
/** Amount of native currency (e.g. Ether) paid out to the depositor in this transaction. */
|
102
|
+
collateralGain: Decimal;
|
103
|
+
/** Amount of ZERO rewarded to the depositor in this transaction. */
|
104
|
+
zeroReward: Decimal;
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* Details of a
|
108
|
+
* {@link TransactableLiquity.depositZUSDInStabilityPool | depositZUSDInStabilityPool()} or
|
109
|
+
* {@link TransactableLiquity.withdrawZUSDFromStabilityPool | withdrawZUSDFromStabilityPool()}
|
110
|
+
* transaction.
|
111
|
+
*
|
112
|
+
* @public
|
113
|
+
*/
|
114
|
+
export interface StabilityDepositChangeDetails extends StabilityPoolGainsWithdrawalDetails {
|
115
|
+
/** Change that was made to the deposit by this transaction. */
|
116
|
+
change: StabilityDepositChange<Decimal>;
|
117
|
+
}
|
118
|
+
/**
|
119
|
+
* Details of a
|
120
|
+
* {@link TransactableLiquity.transferCollateralGainToTrove | transferCollateralGainToTrove()}
|
121
|
+
* transaction.
|
122
|
+
*
|
123
|
+
* @public
|
124
|
+
*/
|
125
|
+
export interface CollateralGainTransferDetails extends StabilityPoolGainsWithdrawalDetails {
|
126
|
+
/** New state of the depositor's Trove directly after the transaction. */
|
127
|
+
newTrove: Trove;
|
128
|
+
}
|
129
|
+
/**
|
130
|
+
* Send Zero transactions and wait for them to succeed.
|
131
|
+
*
|
132
|
+
* @remarks
|
133
|
+
* The functions return the details of the transaction (if any), or throw an implementation-specific
|
134
|
+
* subclass of {@link TransactionFailedError} in case of transaction failure.
|
135
|
+
*
|
136
|
+
* Implemented by {@link @sovryn-zero/lib-ethers#EthersLiquity}.
|
137
|
+
*
|
138
|
+
* @public
|
139
|
+
*/
|
140
|
+
export interface TransactableLiquity {
|
141
|
+
/**
|
142
|
+
* Open a new Trove by depositing collateral and borrowing ZUSD.
|
143
|
+
*
|
144
|
+
* @param params - How much to deposit and borrow.
|
145
|
+
* @param maxBorrowingRate - Maximum acceptable
|
146
|
+
* {@link @sovryn-zero/lib-base#Fees.borrowingRate | borrowing rate}.
|
147
|
+
*
|
148
|
+
* @throws
|
149
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
150
|
+
*
|
151
|
+
* @remarks
|
152
|
+
* If `maxBorrowingRate` is omitted, the current borrowing rate plus 0.5% is used as maximum
|
153
|
+
* acceptable rate.
|
154
|
+
*/
|
155
|
+
openTrove(params: TroveCreationParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<TroveCreationDetails>;
|
156
|
+
/**
|
157
|
+
* Close existing Trove by repaying all debt and withdrawing all collateral.
|
158
|
+
*
|
159
|
+
* @throws
|
160
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
161
|
+
*/
|
162
|
+
closeTrove(): Promise<TroveClosureDetails>;
|
163
|
+
/**
|
164
|
+
* Adjust existing Trove by changing its collateral, debt, or both.
|
165
|
+
*
|
166
|
+
* @param params - Parameters of the adjustment.
|
167
|
+
* @param maxBorrowingRate - Maximum acceptable
|
168
|
+
* {@link @sovryn-zero/lib-base#Fees.borrowingRate | borrowing rate} if
|
169
|
+
* `params` includes `borrowZUSD`.
|
170
|
+
*
|
171
|
+
* @throws
|
172
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
173
|
+
*
|
174
|
+
* @remarks
|
175
|
+
* The transaction will fail if the Trove's debt would fall below
|
176
|
+
* {@link @sovryn-zero/lib-base#ZUSD_MINIMUM_DEBT}.
|
177
|
+
*
|
178
|
+
* If `maxBorrowingRate` is omitted, the current borrowing rate plus 0.5% is used as maximum
|
179
|
+
* acceptable rate.
|
180
|
+
*/
|
181
|
+
adjustTrove(params: TroveAdjustmentParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<TroveAdjustmentDetails>;
|
182
|
+
/**
|
183
|
+
* Adjust existing Trove by depositing more collateral.
|
184
|
+
*
|
185
|
+
* @param amount - The amount of collateral to add to the Trove's existing collateral.
|
186
|
+
*
|
187
|
+
* @throws
|
188
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
189
|
+
*
|
190
|
+
* @remarks
|
191
|
+
* Equivalent to:
|
192
|
+
*
|
193
|
+
* ```typescript
|
194
|
+
* adjustTrove({ depositCollateral: amount })
|
195
|
+
* ```
|
196
|
+
*/
|
197
|
+
depositCollateral(amount: Decimalish): Promise<TroveAdjustmentDetails>;
|
198
|
+
/**
|
199
|
+
* Adjust existing Trove by withdrawing some of its collateral.
|
200
|
+
*
|
201
|
+
* @param amount - The amount of collateral to withdraw from the Trove.
|
202
|
+
*
|
203
|
+
* @throws
|
204
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
205
|
+
*
|
206
|
+
* @remarks
|
207
|
+
* Equivalent to:
|
208
|
+
*
|
209
|
+
* ```typescript
|
210
|
+
* adjustTrove({ withdrawCollateral: amount })
|
211
|
+
* ```
|
212
|
+
*/
|
213
|
+
withdrawCollateral(amount: Decimalish): Promise<TroveAdjustmentDetails>;
|
214
|
+
/**
|
215
|
+
* Adjust existing Trove by borrowing more ZUSD.
|
216
|
+
*
|
217
|
+
* @param amount - The amount of ZUSD to borrow.
|
218
|
+
* @param maxBorrowingRate - Maximum acceptable
|
219
|
+
* {@link @sovryn-zero/lib-base#Fees.borrowingRate | borrowing rate}.
|
220
|
+
*
|
221
|
+
* @throws
|
222
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
223
|
+
*
|
224
|
+
* @remarks
|
225
|
+
* Equivalent to:
|
226
|
+
*
|
227
|
+
* ```typescript
|
228
|
+
* adjustTrove({ borrowZUSD: amount }, maxBorrowingRate)
|
229
|
+
* ```
|
230
|
+
*/
|
231
|
+
borrowZUSD(amount: Decimalish, maxBorrowingRate?: Decimalish): Promise<TroveAdjustmentDetails>;
|
232
|
+
/**
|
233
|
+
* Adjust existing Trove by repaying some of its debt.
|
234
|
+
*
|
235
|
+
* @param amount - The amount of ZUSD to repay.
|
236
|
+
*
|
237
|
+
* @throws
|
238
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
239
|
+
*
|
240
|
+
* @remarks
|
241
|
+
* Equivalent to:
|
242
|
+
*
|
243
|
+
* ```typescript
|
244
|
+
* adjustTrove({ repayZUSD: amount })
|
245
|
+
* ```
|
246
|
+
*/
|
247
|
+
repayZUSD(amount: Decimalish): Promise<TroveAdjustmentDetails>;
|
248
|
+
/** @internal */
|
249
|
+
setPrice(price: Decimalish): Promise<void>;
|
250
|
+
/**
|
251
|
+
* Liquidate one or more undercollateralized Troves.
|
252
|
+
*
|
253
|
+
* @param address - Address or array of addresses whose Troves to liquidate.
|
254
|
+
*
|
255
|
+
* @throws
|
256
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
257
|
+
*/
|
258
|
+
liquidate(address: string | string[]): Promise<LiquidationDetails>;
|
259
|
+
/**
|
260
|
+
* Liquidate the least collateralized Troves up to a maximum number.
|
261
|
+
*
|
262
|
+
* @param maximumNumberOfTrovesToLiquidate - Stop after liquidating this many Troves.
|
263
|
+
*
|
264
|
+
* @throws
|
265
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
266
|
+
*/
|
267
|
+
liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise<LiquidationDetails>;
|
268
|
+
/**
|
269
|
+
* Make a new Stability Deposit, or top up existing one.
|
270
|
+
*
|
271
|
+
* @param amount - Amount of ZUSD to add to new or existing deposit.
|
272
|
+
* @param frontendTag - Address that should receive a share of this deposit's ZERO rewards.
|
273
|
+
*
|
274
|
+
* @throws
|
275
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
276
|
+
*
|
277
|
+
* @remarks
|
278
|
+
* The `frontendTag` parameter is only effective when making a new deposit.
|
279
|
+
*
|
280
|
+
* As a side-effect, the transaction will also pay out an existing Stability Deposit's
|
281
|
+
* {@link @sovryn-zero/lib-base#StabilityDeposit.collateralGain | collateral gain} and
|
282
|
+
* {@link @sovryn-zero/lib-base#StabilityDeposit.zeroReward | ZERO reward}.
|
283
|
+
*/
|
284
|
+
depositZUSDInStabilityPool(amount: Decimalish, frontendTag?: string): Promise<StabilityDepositChangeDetails>;
|
285
|
+
/**
|
286
|
+
* Withdraw ZUSD from Stability Deposit.
|
287
|
+
*
|
288
|
+
* @param amount - Amount of ZUSD to withdraw.
|
289
|
+
*
|
290
|
+
* @throws
|
291
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
292
|
+
*
|
293
|
+
* @remarks
|
294
|
+
* As a side-effect, the transaction will also pay out the Stability Deposit's
|
295
|
+
* {@link @sovryn-zero/lib-base#StabilityDeposit.collateralGain | collateral gain} and
|
296
|
+
* {@link @sovryn-zero/lib-base#StabilityDeposit.zeroReward | ZERO reward}.
|
297
|
+
*/
|
298
|
+
withdrawZUSDFromStabilityPool(amount: Decimalish): Promise<StabilityDepositChangeDetails>;
|
299
|
+
/**
|
300
|
+
* Withdraw {@link @sovryn-zero/lib-base#StabilityDeposit.collateralGain | collateral gain} and
|
301
|
+
* {@link @sovryn-zero/lib-base#StabilityDeposit.zeroReward | ZERO reward} from Stability Deposit.
|
302
|
+
*
|
303
|
+
* @throws
|
304
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
305
|
+
*/
|
306
|
+
withdrawGainsFromStabilityPool(): Promise<StabilityPoolGainsWithdrawalDetails>;
|
307
|
+
/**
|
308
|
+
* Transfer {@link @sovryn-zero/lib-base#StabilityDeposit.collateralGain | collateral gain} from
|
309
|
+
* Stability Deposit to Trove.
|
310
|
+
*
|
311
|
+
* @throws
|
312
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
313
|
+
*
|
314
|
+
* @remarks
|
315
|
+
* The collateral gain is transfered to the Trove as additional collateral.
|
316
|
+
*
|
317
|
+
* As a side-effect, the transaction will also pay out the Stability Deposit's
|
318
|
+
* {@link @sovryn-zero/lib-base#StabilityDeposit.zeroReward | ZERO reward}.
|
319
|
+
*/
|
320
|
+
transferCollateralGainToTrove(): Promise<CollateralGainTransferDetails>;
|
321
|
+
/**
|
322
|
+
* Send ZUSD tokens to an address.
|
323
|
+
*
|
324
|
+
* @param toAddress - Address of receipient.
|
325
|
+
* @param amount - Amount of ZUSD to send.
|
326
|
+
*
|
327
|
+
* @throws
|
328
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
329
|
+
*/
|
330
|
+
sendZUSD(toAddress: string, amount: Decimalish): Promise<void>;
|
331
|
+
/**
|
332
|
+
* Send ZERO tokens to an address.
|
333
|
+
*
|
334
|
+
* @param toAddress - Address of receipient.
|
335
|
+
* @param amount - Amount of ZERO to send.
|
336
|
+
*
|
337
|
+
* @throws
|
338
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
339
|
+
*/
|
340
|
+
sendZERO(toAddress: string, amount: Decimalish): Promise<void>;
|
341
|
+
/**
|
342
|
+
* Redeem ZUSD to native currency (e.g. Ether) at face value.
|
343
|
+
*
|
344
|
+
* @param amount - Amount of ZUSD to be redeemed.
|
345
|
+
* @param maxRedemptionRate - Maximum acceptable
|
346
|
+
* {@link @sovryn-zero/lib-base#Fees.redemptionRate | redemption rate}.
|
347
|
+
*
|
348
|
+
* @throws
|
349
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
350
|
+
*
|
351
|
+
* @remarks
|
352
|
+
* If `maxRedemptionRate` is omitted, the current redemption rate (based on `amount`) plus 0.1%
|
353
|
+
* is used as maximum acceptable rate.
|
354
|
+
*/
|
355
|
+
redeemZUSD(amount: Decimalish, maxRedemptionRate?: Decimalish): Promise<RedemptionDetails>;
|
356
|
+
/**
|
357
|
+
* Claim leftover collateral after a liquidation or redemption.
|
358
|
+
*
|
359
|
+
* @remarks
|
360
|
+
* Use {@link @sovryn-zero/lib-base#ReadableLiquity.getCollateralSurplusBalance | getCollateralSurplusBalance()}
|
361
|
+
* to check the amount of collateral available for withdrawal.
|
362
|
+
*
|
363
|
+
* @throws
|
364
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
365
|
+
*/
|
366
|
+
claimCollateralSurplus(): Promise<void>;
|
367
|
+
/**
|
368
|
+
* Stake ZERO to start earning fee revenue or increase existing stake.
|
369
|
+
*
|
370
|
+
* @param amount - Amount of ZERO to add to new or existing stake.
|
371
|
+
*
|
372
|
+
* @throws
|
373
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
374
|
+
*
|
375
|
+
* @remarks
|
376
|
+
* As a side-effect, the transaction will also pay out an existing ZERO stake's
|
377
|
+
* {@link @sovryn-zero/lib-base#ZEROStake.collateralGain | collateral gain} and
|
378
|
+
* {@link @sovryn-zero/lib-base#ZEROStake.zusdGain | ZUSD gain}.
|
379
|
+
*/
|
380
|
+
stakeZERO(amount: Decimalish): Promise<void>;
|
381
|
+
/**
|
382
|
+
* Withdraw ZERO from staking.
|
383
|
+
*
|
384
|
+
* @param amount - Amount of ZERO to withdraw.
|
385
|
+
*
|
386
|
+
* @throws
|
387
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
388
|
+
*
|
389
|
+
* @remarks
|
390
|
+
* As a side-effect, the transaction will also pay out the ZERO stake's
|
391
|
+
* {@link @sovryn-zero/lib-base#ZEROStake.collateralGain | collateral gain} and
|
392
|
+
* {@link @sovryn-zero/lib-base#ZEROStake.zusdGain | ZUSD gain}.
|
393
|
+
*/
|
394
|
+
unstakeZERO(amount: Decimalish): Promise<void>;
|
395
|
+
/**
|
396
|
+
* Withdraw {@link @sovryn-zero/lib-base#ZEROStake.collateralGain | collateral gain} and
|
397
|
+
* {@link @sovryn-zero/lib-base#ZEROStake.zusdGain | ZUSD gain} from ZERO stake.
|
398
|
+
*
|
399
|
+
* @throws
|
400
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
401
|
+
*/
|
402
|
+
withdrawGainsFromStaking(): Promise<void>;
|
403
|
+
/**
|
404
|
+
* Register current wallet address as a Zero frontend.
|
405
|
+
*
|
406
|
+
* @param kickbackRate - The portion of ZERO rewards to pass onto users of the frontend
|
407
|
+
* (between 0 and 1).
|
408
|
+
*
|
409
|
+
* @throws
|
410
|
+
* Throws {@link TransactionFailedError} in case of transaction failure.
|
411
|
+
*/
|
412
|
+
registerFrontend(kickbackRate: Decimalish): Promise<void>;
|
413
|
+
}
|
414
414
|
//# sourceMappingURL=TransactableLiquity.d.ts.map
|