@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,125 @@
1
+ import { Decimal, Decimalish } from "./Decimal";
2
+ import { TroveAdjustmentParams, TroveCreationParams } from "./Trove";
3
+ import { LiquityReceipt, SendableLiquity, SentLiquityTransaction } from "./SendableLiquity";
4
+ import { CollateralGainTransferDetails, LiquidationDetails, RedemptionDetails, StabilityDepositChangeDetails, StabilityPoolGainsWithdrawalDetails, TroveAdjustmentDetails, TroveClosureDetails, TroveCreationDetails } from "./TransactableLiquity";
5
+ /**
6
+ * A transaction that has been prepared for sending.
7
+ *
8
+ * @remarks
9
+ * Implemented by {@link @sovryn-zero/lib-ethers#PopulatedEthersLiquityTransaction}.
10
+ *
11
+ * @public
12
+ */
13
+ export interface PopulatedLiquityTransaction<P = unknown, T extends SentLiquityTransaction = SentLiquityTransaction> {
14
+ /** Implementation-specific populated transaction object. */
15
+ readonly rawPopulatedTransaction: P;
16
+ /**
17
+ * Send the transaction.
18
+ *
19
+ * @returns An object that implements {@link @sovryn-zero/lib-base#SentLiquityTransaction}.
20
+ */
21
+ send(): Promise<T>;
22
+ }
23
+ /**
24
+ * A redemption transaction that has been prepared for sending.
25
+ *
26
+ * @remarks
27
+ * The Zero protocol fulfills redemptions by repaying the debt of Troves in ascending order of
28
+ * their collateralization ratio, and taking a portion of their collateral in exchange. Due to the
29
+ * {@link @sovryn-zero/lib-base#ZUSD_MINIMUM_DEBT | minimum debt} requirement that Troves must fulfill,
30
+ * some ZUSD amounts are not possible to redeem exactly.
31
+ *
32
+ * When {@link @sovryn-zero/lib-base#PopulatableLiquity.redeemZUSD | redeemZUSD()} is called with an
33
+ * amount that can't be fully redeemed, the amount will be truncated (see the `redeemableZUSDAmount`
34
+ * property). When this happens, the redeemer can either redeem the truncated amount by sending the
35
+ * transaction unchanged, or prepare a new transaction by
36
+ * {@link @sovryn-zero/lib-base#PopulatedRedemption.increaseAmountByMinimumNetDebt | increasing the amount}
37
+ * to the next lowest possible value, which is the sum of the truncated amount and
38
+ * {@link @sovryn-zero/lib-base#ZUSD_MINIMUM_NET_DEBT}.
39
+ *
40
+ * @public
41
+ */
42
+ export interface PopulatedRedemption<P = unknown, S = unknown, R = unknown> extends PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, RedemptionDetails>>> {
43
+ /** Amount of ZUSD the redeemer is trying to redeem. */
44
+ readonly attemptedZUSDAmount: Decimal;
45
+ /** Maximum amount of ZUSD that is currently redeemable from `attemptedZUSDAmount`. */
46
+ readonly redeemableZUSDAmount: Decimal;
47
+ /** Whether `redeemableZUSDAmount` is less than `attemptedZUSDAmount`. */
48
+ readonly isTruncated: boolean;
49
+ /**
50
+ * Prepare a new transaction by increasing the attempted amount to the next lowest redeemable
51
+ * value.
52
+ *
53
+ * @param maxRedemptionRate - Maximum acceptable
54
+ * {@link @sovryn-zero/lib-base#Fees.redemptionRate | redemption rate} to
55
+ * use in the new transaction.
56
+ *
57
+ * @remarks
58
+ * If `maxRedemptionRate` is omitted, the original transaction's `maxRedemptionRate` is reused
59
+ * unless that was also omitted, in which case the current redemption rate (based on the increased
60
+ * amount) plus 0.1% is used as maximum acceptable rate.
61
+ */
62
+ increaseAmountByMinimumNetDebt(maxRedemptionRate?: Decimalish): Promise<PopulatedRedemption<P, S, R>>;
63
+ }
64
+ /** @internal */
65
+ export declare type _PopulatableFrom<T, P> = {
66
+ [M in keyof T]: T[M] extends (...args: infer A) => Promise<infer U> ? U extends SentLiquityTransaction ? (...args: A) => Promise<PopulatedLiquityTransaction<P, U>> : never : never;
67
+ };
68
+ /**
69
+ * Prepare Zero transactions for sending.
70
+ *
71
+ * @remarks
72
+ * The functions return an object implementing {@link PopulatedLiquityTransaction}, which can be
73
+ * used to send the transaction and get a {@link SentLiquityTransaction}.
74
+ *
75
+ * Implemented by {@link @sovryn-zero/lib-ethers#PopulatableEthersLiquity}.
76
+ *
77
+ * @public
78
+ */
79
+ export interface PopulatableLiquity<R = unknown, S = unknown, P = unknown> extends _PopulatableFrom<SendableLiquity<R, S>, P> {
80
+ /** {@inheritDoc TransactableLiquity.openTrove} */
81
+ openTrove(params: TroveCreationParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveCreationDetails>>>>;
82
+ /** {@inheritDoc TransactableLiquity.closeTrove} */
83
+ closeTrove(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveClosureDetails>>>>;
84
+ /** {@inheritDoc TransactableLiquity.adjustTrove} */
85
+ adjustTrove(params: TroveAdjustmentParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
86
+ /** {@inheritDoc TransactableLiquity.depositCollateral} */
87
+ depositCollateral(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
88
+ /** {@inheritDoc TransactableLiquity.withdrawCollateral} */
89
+ withdrawCollateral(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
90
+ /** {@inheritDoc TransactableLiquity.borrowZUSD} */
91
+ borrowZUSD(amount: Decimalish, maxBorrowingRate?: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
92
+ /** {@inheritDoc TransactableLiquity.repayZUSD} */
93
+ repayZUSD(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>>;
94
+ /** @internal */
95
+ setPrice(price: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
96
+ /** {@inheritDoc TransactableLiquity.liquidate} */
97
+ liquidate(address: string | string[]): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, LiquidationDetails>>>>;
98
+ /** {@inheritDoc TransactableLiquity.liquidateUpTo} */
99
+ liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, LiquidationDetails>>>>;
100
+ /** {@inheritDoc TransactableLiquity.depositZUSDInStabilityPool} */
101
+ depositZUSDInStabilityPool(amount: Decimalish, frontendTag?: string): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, StabilityDepositChangeDetails>>>>;
102
+ /** {@inheritDoc TransactableLiquity.withdrawZUSDFromStabilityPool} */
103
+ withdrawZUSDFromStabilityPool(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, StabilityDepositChangeDetails>>>>;
104
+ /** {@inheritDoc TransactableLiquity.withdrawGainsFromStabilityPool} */
105
+ withdrawGainsFromStabilityPool(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, StabilityPoolGainsWithdrawalDetails>>>>;
106
+ /** {@inheritDoc TransactableLiquity.transferCollateralGainToTrove} */
107
+ transferCollateralGainToTrove(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, CollateralGainTransferDetails>>>>;
108
+ /** {@inheritDoc TransactableLiquity.sendZUSD} */
109
+ sendZUSD(toAddress: string, amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
110
+ /** {@inheritDoc TransactableLiquity.sendZERO} */
111
+ sendZERO(toAddress: string, amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
112
+ /** {@inheritDoc TransactableLiquity.redeemZUSD} */
113
+ redeemZUSD(amount: Decimalish, maxRedemptionRate?: Decimalish): Promise<PopulatedRedemption<P, S, R>>;
114
+ /** {@inheritDoc TransactableLiquity.claimCollateralSurplus} */
115
+ claimCollateralSurplus(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
116
+ /** {@inheritDoc TransactableLiquity.stakeZERO} */
117
+ stakeZERO(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
118
+ /** {@inheritDoc TransactableLiquity.unstakeZERO} */
119
+ unstakeZERO(amount: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
120
+ /** {@inheritDoc TransactableLiquity.withdrawGainsFromStaking} */
121
+ withdrawGainsFromStaking(): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
122
+ /** {@inheritDoc TransactableLiquity.registerFrontend} */
123
+ registerFrontend(kickbackRate: Decimalish): Promise<PopulatedLiquityTransaction<P, SentLiquityTransaction<S, LiquityReceipt<R, void>>>>;
124
+ }
125
+ //# sourceMappingURL=PopulatableLiquity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PopulatableLiquity.d.ts","sourceRoot":"","sources":["../../src/PopulatableLiquity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE5F,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,EAC7B,mCAAmC,EACnC,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;GAOG;AACH,M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AE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/F,oDAAoD;IACpD,WAAW,CACT,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,2BAA2B,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/F,iEAAiE;IACjE,wBAAwB,IAAI,OAAO,CACjC,2BAA2B,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CACnF,CAAC;IAEF,yDAAyD;IACzD,gBAAgB,CACd,YAAY,EAAE,UAAU,GACvB,OAAO,CAAC,2BAA2B,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;CAChG"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=PopulatableLiquity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PopulatableLiquity.js","sourceRoot":"","sources":["../../src/PopulatableLiquity.ts"],"names":[],"mappings":""}
@@ -0,0 +1,156 @@
1
+ import { Decimal } from "./Decimal";
2
+ import { Trove, TroveWithPendingRedistribution, UserTrove } from "./Trove";
3
+ import { StabilityDeposit } from "./StabilityDeposit";
4
+ import { Fees } from "./Fees";
5
+ import { ZEROStake } from "./ZEROStake";
6
+ /**
7
+ * Represents whether an address has been registered as a Zero frontend.
8
+ *
9
+ * @remarks
10
+ * Returned by the {@link ReadableLiquity.getFrontendStatus | getFrontendStatus()} function.
11
+ *
12
+ * When `status` is `"registered"`, `kickbackRate` gives the frontend's kickback rate as a
13
+ * {@link Decimal} between 0 and 1.
14
+ *
15
+ * @public
16
+ */
17
+ export declare type FrontendStatus = {
18
+ status: "unregistered";
19
+ } | {
20
+ status: "registered";
21
+ kickbackRate: Decimal;
22
+ };
23
+ /**
24
+ * Parameters of the {@link ReadableLiquity.(getTroves:2) | getTroves()} function.
25
+ *
26
+ * @public
27
+ */
28
+ export interface TroveListingParams {
29
+ /** Number of Troves to retrieve. */
30
+ readonly first: number;
31
+ /** How the Troves should be sorted. */
32
+ readonly sortedBy: "ascendingCollateralRatio" | "descendingCollateralRatio";
33
+ /** Index of the first Trove to retrieve from the sorted list. */
34
+ readonly startingAt?: number;
35
+ /**
36
+ * When set to `true`, the retrieved Troves won't include the liquidation shares received since
37
+ * the last time they were directly modified.
38
+ *
39
+ * @remarks
40
+ * Changes the type of returned Troves to {@link TroveWithPendingRedistribution}.
41
+ */
42
+ readonly beforeRedistribution?: boolean;
43
+ }
44
+ /**
45
+ * Read the state of the Zero protocol.
46
+ *
47
+ * @remarks
48
+ * Implemented by {@link @sovryn-zero/lib-ethers#EthersLiquity}.
49
+ *
50
+ * @public
51
+ */
52
+ export interface ReadableLiquity {
53
+ /**
54
+ * Get the total collateral and debt per stake that has been liquidated through redistribution.
55
+ *
56
+ * @remarks
57
+ * Needed when dealing with instances of {@link @sovryn-zero/lib-base#TroveWithPendingRedistribution}.
58
+ */
59
+ getTotalRedistributed(): Promise<Trove>;
60
+ /**
61
+ * Get a Trove in its state after the last direct modification.
62
+ *
63
+ * @param address - Address that owns the Trove.
64
+ *
65
+ * @remarks
66
+ * The current state of a Trove can be fetched using
67
+ * {@link @sovryn-zero/lib-base#ReadableLiquity.getTrove | getTrove()}.
68
+ */
69
+ getTroveBeforeRedistribution(address?: string): Promise<TroveWithPendingRedistribution>;
70
+ /**
71
+ * Get the current state of a Trove.
72
+ *
73
+ * @param address - Address that owns the Trove.
74
+ */
75
+ getTrove(address?: string): Promise<UserTrove>;
76
+ /**
77
+ * Get number of Troves that are currently open.
78
+ */
79
+ getNumberOfTroves(): Promise<number>;
80
+ /**
81
+ * Get the current price of the native currency (e.g. Ether) in USD.
82
+ */
83
+ getPrice(): Promise<Decimal>;
84
+ /**
85
+ * Get the total amount of collateral and debt in the Zero system.
86
+ */
87
+ getTotal(): Promise<Trove>;
88
+ /**
89
+ * Get the current state of a Stability Deposit.
90
+ *
91
+ * @param address - Address that owns the Stability Deposit.
92
+ */
93
+ getStabilityDeposit(address?: string): Promise<StabilityDeposit>;
94
+ /**
95
+ * Get the remaining ZERO that will be collectively rewarded to stability depositors.
96
+ */
97
+ getRemainingStabilityPoolZEROReward(): Promise<Decimal>;
98
+ /**
99
+ * Get the total amount of ZUSD currently deposited in the Stability Pool.
100
+ */
101
+ getZUSDInStabilityPool(): Promise<Decimal>;
102
+ /**
103
+ * Get the amount of ZUSD held by an address.
104
+ *
105
+ * @param address - Address whose balance should be retrieved.
106
+ */
107
+ getZUSDBalance(address?: string): Promise<Decimal>;
108
+ /**
109
+ * Get the amount of ZERO held by an address.
110
+ *
111
+ * @param address - Address whose balance should be retrieved.
112
+ */
113
+ getZEROBalance(address?: string): Promise<Decimal>;
114
+ /**
115
+ * Get the amount of leftover collateral available for withdrawal by an address.
116
+ *
117
+ * @remarks
118
+ * When a Trove gets liquidated or redeemed, any collateral it has above 110% (in case of
119
+ * liquidation) or 100% collateralization (in case of redemption) gets sent to a pool, where it
120
+ * can be withdrawn from using
121
+ * {@link @sovryn-zero/lib-base#TransactableLiquity.claimCollateralSurplus | claimCollateralSurplus()}.
122
+ */
123
+ getCollateralSurplusBalance(address?: string): Promise<Decimal>;
124
+ /** @internal */
125
+ getTroves(params: TroveListingParams & {
126
+ beforeRedistribution: true;
127
+ }): Promise<TroveWithPendingRedistribution[]>;
128
+ /**
129
+ * Get a slice from the list of Troves.
130
+ *
131
+ * @param params - Controls how the list is sorted, and where the slice begins and ends.
132
+ * @returns Pairs of owner addresses and their Troves.
133
+ */
134
+ getTroves(params: TroveListingParams): Promise<UserTrove[]>;
135
+ /**
136
+ * Get a calculator for current fees.
137
+ */
138
+ getFees(): Promise<Fees>;
139
+ /**
140
+ * Get the current state of an ZERO Stake.
141
+ *
142
+ * @param address - Address that owns the ZERO Stake.
143
+ */
144
+ getZEROStake(address?: string): Promise<ZEROStake>;
145
+ /**
146
+ * Get the total amount of ZERO currently staked.
147
+ */
148
+ getTotalStakedZERO(): Promise<Decimal>;
149
+ /**
150
+ * Check whether an address is registered as a Zero frontend, and what its kickback rate is.
151
+ *
152
+ * @param address - Address to check.
153
+ */
154
+ getFrontendStatus(address?: string): Promise<FrontendStatus>;
155
+ }
156
+ //# sourceMappingURL=ReadableLiquity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadableLiquity.d.ts","sourceRoot":"","sources":["../../src/ReadableLiquity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,8BAA8B,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;GAUG;AACH,oBAAY,cAAc,GACtB;IAAE,MAAM,EAAE,cAAc,CAAA;CAAE,GAC1B;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,uCAAuC;IACvC,QAAQ,CAAC,QAAQ,EAAE,0BAA0B,GAAG,2BAA2B,CAAC;IAE5E,iEAAiE;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;;OAMG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,qBAAqB,IAAI,OA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B;;;;OAIG;IACH,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAEnD;;OAEG;IACH,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEvC;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC9D"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ReadableLiquity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadableLiquity.js","sourceRoot":"","sources":["../../src/ReadableLiquity.ts"],"names":[],"mappings":""}
@@ -0,0 +1,156 @@
1
+ import { Decimalish } from "./Decimal";
2
+ import { TroveAdjustmentParams, TroveCreationParams } from "./Trove";
3
+ import { CollateralGainTransferDetails, LiquidationDetails, RedemptionDetails, StabilityDepositChangeDetails, StabilityPoolGainsWithdrawalDetails, TransactableLiquity, TroveAdjustmentDetails, TroveClosureDetails, TroveCreationDetails } from "./TransactableLiquity";
4
+ /**
5
+ * A transaction that has already been sent.
6
+ *
7
+ * @remarks
8
+ * Implemented by {@link @sovryn-zero/lib-ethers#SentEthersLiquityTransaction}.
9
+ *
10
+ * @public
11
+ */
12
+ export interface SentLiquityTransaction<S = unknown, T extends LiquityReceipt = LiquityReceipt> {
13
+ /** Implementation-specific sent transaction object. */
14
+ readonly rawSentTransaction: S;
15
+ /**
16
+ * Check whether the transaction has been mined, and whether it was successful.
17
+ *
18
+ * @remarks
19
+ * Unlike {@link @sovryn-zero/lib-base#SentLiquityTransaction.waitForReceipt | waitForReceipt()},
20
+ * this function doesn't wait for the transaction to be mined.
21
+ */
22
+ getReceipt(): Promise<T>;
23
+ /**
24
+ * Wait for the transaction to be mined, and check whether it was successful.
25
+ *
26
+ * @returns Either a {@link @sovryn-zero/lib-base#FailedReceipt} or a
27
+ * {@link @sovryn-zero/lib-base#SuccessfulReceipt}.
28
+ */
29
+ waitForReceipt(): Promise<Extract<T, MinedReceipt>>;
30
+ }
31
+ /**
32
+ * Indicates that the transaction hasn't been mined yet.
33
+ *
34
+ * @remarks
35
+ * Returned by {@link SentLiquityTransaction.getReceipt}.
36
+ *
37
+ * @public
38
+ */
39
+ export declare type PendingReceipt = {
40
+ status: "pending";
41
+ };
42
+ /** @internal */
43
+ export declare const _pendingReceipt: PendingReceipt;
44
+ /**
45
+ * Indicates that the transaction has been mined, but it failed.
46
+ *
47
+ * @remarks
48
+ * The `rawReceipt` property is an implementation-specific transaction receipt object.
49
+ *
50
+ * Returned by {@link SentLiquityTransaction.getReceipt} and
51
+ * {@link SentLiquityTransaction.waitForReceipt}.
52
+ *
53
+ * @public
54
+ */
55
+ export declare type FailedReceipt<R = unknown> = {
56
+ status: "failed";
57
+ rawReceipt: R;
58
+ };
59
+ /** @internal */
60
+ export declare const _failedReceipt: <R>(rawReceipt: R) => FailedReceipt<R>;
61
+ /**
62
+ * Indicates that the transaction has succeeded.
63
+ *
64
+ * @remarks
65
+ * The `rawReceipt` property is an implementation-specific transaction receipt object.
66
+ *
67
+ * The `details` property may contain more information about the transaction.
68
+ * See the return types of {@link TransactableLiquity} functions for the exact contents of `details`
69
+ * for each type of Zero transaction.
70
+ *
71
+ * Returned by {@link SentLiquityTransaction.getReceipt} and
72
+ * {@link SentLiquityTransaction.waitForReceipt}.
73
+ *
74
+ * @public
75
+ */
76
+ export declare type SuccessfulReceipt<R = unknown, D = unknown> = {
77
+ status: "succeeded";
78
+ rawReceipt: R;
79
+ details: D;
80
+ };
81
+ /** @internal */
82
+ export declare const _successfulReceipt: <R, D>(rawReceipt: R, details: D, toString?: (() => string) | undefined) => SuccessfulReceipt<R, D>;
83
+ /**
84
+ * Either a {@link FailedReceipt} or a {@link SuccessfulReceipt}.
85
+ *
86
+ * @public
87
+ */
88
+ export declare type MinedReceipt<R = unknown, D = unknown> = FailedReceipt<R> | SuccessfulReceipt<R, D>;
89
+ /**
90
+ * One of either a {@link PendingReceipt}, a {@link FailedReceipt} or a {@link SuccessfulReceipt}.
91
+ *
92
+ * @public
93
+ */
94
+ export declare type LiquityReceipt<R = unknown, D = unknown> = PendingReceipt | MinedReceipt<R, D>;
95
+ /** @internal */
96
+ export declare type _SendableFrom<T, R, S> = {
97
+ [M in keyof T]: T[M] extends (...args: infer A) => Promise<infer D> ? (...args: A) => Promise<SentLiquityTransaction<S, LiquityReceipt<R, D>>> : never;
98
+ };
99
+ /**
100
+ * Send Zero transactions.
101
+ *
102
+ * @remarks
103
+ * The functions return an object implementing {@link SentLiquityTransaction}, which can be used
104
+ * to monitor the transaction and get its details when it succeeds.
105
+ *
106
+ * Implemented by {@link @sovryn-zero/lib-ethers#SendableEthersLiquity}.
107
+ *
108
+ * @public
109
+ */
110
+ export interface SendableLiquity<R = unknown, S = unknown> extends _SendableFrom<TransactableLiquity, R, S> {
111
+ /** {@inheritDoc TransactableLiquity.openTrove} */
112
+ openTrove(params: TroveCreationParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveCreationDetails>>>;
113
+ /** {@inheritDoc TransactableLiquity.closeTrove} */
114
+ closeTrove(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveClosureDetails>>>;
115
+ /** {@inheritDoc TransactableLiquity.adjustTrove} */
116
+ adjustTrove(params: TroveAdjustmentParams<Decimalish>, maxBorrowingRate?: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
117
+ /** {@inheritDoc TransactableLiquity.depositCollateral} */
118
+ depositCollateral(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
119
+ /** {@inheritDoc TransactableLiquity.withdrawCollateral} */
120
+ withdrawCollateral(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
121
+ /** {@inheritDoc TransactableLiquity.borrowZUSD} */
122
+ borrowZUSD(amount: Decimalish, maxBorrowingRate?: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
123
+ /** {@inheritDoc TransactableLiquity.repayZUSD} */
124
+ repayZUSD(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, TroveAdjustmentDetails>>>;
125
+ /** @internal */
126
+ setPrice(price: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
127
+ /** {@inheritDoc TransactableLiquity.liquidate} */
128
+ liquidate(address: string | string[]): Promise<SentLiquityTransaction<S, LiquityReceipt<R, LiquidationDetails>>>;
129
+ /** {@inheritDoc TransactableLiquity.liquidateUpTo} */
130
+ liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise<SentLiquityTransaction<S, LiquityReceipt<R, LiquidationDetails>>>;
131
+ /** {@inheritDoc TransactableLiquity.depositZUSDInStabilityPool} */
132
+ depositZUSDInStabilityPool(amount: Decimalish, frontendTag?: string): Promise<SentLiquityTransaction<S, LiquityReceipt<R, StabilityDepositChangeDetails>>>;
133
+ /** {@inheritDoc TransactableLiquity.withdrawZUSDFromStabilityPool} */
134
+ withdrawZUSDFromStabilityPool(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, StabilityDepositChangeDetails>>>;
135
+ /** {@inheritDoc TransactableLiquity.withdrawGainsFromStabilityPool} */
136
+ withdrawGainsFromStabilityPool(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, StabilityPoolGainsWithdrawalDetails>>>;
137
+ /** {@inheritDoc TransactableLiquity.transferCollateralGainToTrove} */
138
+ transferCollateralGainToTrove(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, CollateralGainTransferDetails>>>;
139
+ /** {@inheritDoc TransactableLiquity.sendZUSD} */
140
+ sendZUSD(toAddress: string, amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
141
+ /** {@inheritDoc TransactableLiquity.sendZERO} */
142
+ sendZERO(toAddress: string, amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
143
+ /** {@inheritDoc TransactableLiquity.redeemZUSD} */
144
+ redeemZUSD(amount: Decimalish, maxRedemptionRate?: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, RedemptionDetails>>>;
145
+ /** {@inheritDoc TransactableLiquity.claimCollateralSurplus} */
146
+ claimCollateralSurplus(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
147
+ /** {@inheritDoc TransactableLiquity.stakeZERO} */
148
+ stakeZERO(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
149
+ /** {@inheritDoc TransactableLiquity.unstakeZERO} */
150
+ unstakeZERO(amount: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
151
+ /** {@inheritDoc TransactableLiquity.withdrawGainsFromStaking} */
152
+ withdrawGainsFromStaking(): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
153
+ /** {@inheritDoc TransactableLiquity.registerFrontend} */
154
+ registerFrontend(kickbackRate: Decimalish): Promise<SentLiquityTransaction<S, LiquityReceipt<R, void>>>;
155
+ }
156
+ //# sourceMappingURL=SendableLiquity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SendableLiquity.d.ts","sourceRoot":"","sources":["../../src/SendableLiquity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAErE,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,EAC7B,mCAAmC,EACnC,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,OAAO,EAAE,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CAAC;IAE7F,iEAAiE;IACjE,wBAAwB,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAExF,yDAAyD;IACzD,gBAAgB,CACd,YAAY,EAAE,UAAU,GACvB,OAAO,CAAC,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;CAChE"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._successfulReceipt = exports._failedReceipt = exports._pendingReceipt = void 0;
4
+ /** @internal */
5
+ exports._pendingReceipt = { status: "pending" };
6
+ /** @internal */
7
+ const _failedReceipt = (rawReceipt) => ({
8
+ status: "failed",
9
+ rawReceipt
10
+ });
11
+ exports._failedReceipt = _failedReceipt;
12
+ /** @internal */
13
+ const _successfulReceipt = (rawReceipt, details, toString) => ({
14
+ status: "succeeded",
15
+ rawReceipt,
16
+ details,
17
+ ...(toString ? { toString } : {})
18
+ });
19
+ exports._successfulReceipt = _successfulReceipt;
20
+ //# sourceMappingURL=SendableLiquity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SendableLiquity.js","sourceRoot":"","sources":["../../src/SendableLiquity.ts"],"names":[],"mappings":";;;AAuDA,gBAAgB;AACH,QAAA,eAAe,GAAmB,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAerE,gBAAgB;AACT,MAAM,cAAc,GAAG,CAAI,UAAa,EAAoB,EAAE,CAAC,CAAC;IACrE,MAAM,EAAE,QAAQ;IAChB,UAAU;CACX,CAAC,CAAC;AAHU,QAAA,cAAc,kBAGxB;AAuBH,gBAAgB;AACT,MAAM,kBAAkB,GAAG,CAChC,UAAa,EACb,OAAU,EACV,QAAuB,EACE,EAAE,CAAC,CAAC;IAC7B,MAAM,EAAE,WAAW;IACnB,UAAU;IACV,OAAO;IACP,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAClC,CAAC,CAAC;AATU,QAAA,kBAAkB,sBAS5B"}
@@ -0,0 +1,59 @@
1
+ import { Decimal, Decimalish } from "./Decimal";
2
+ /**
3
+ * Represents the change between two Stability Deposit states.
4
+ *
5
+ * @public
6
+ */
7
+ export declare type StabilityDepositChange<T> = {
8
+ depositZUSD: T;
9
+ withdrawZUSD?: undefined;
10
+ } | {
11
+ depositZUSD?: undefined;
12
+ withdrawZUSD: T;
13
+ withdrawAllZUSD: boolean;
14
+ };
15
+ /**
16
+ * A Stability Deposit and its accrued gains.
17
+ *
18
+ * @public
19
+ */
20
+ export declare class StabilityDeposit {
21
+ /** Amount of ZUSD in the Stability Deposit at the time of the last direct modification. */
22
+ readonly initialZUSD: Decimal;
23
+ /** Amount of ZUSD left in the Stability Deposit. */
24
+ readonly currentZUSD: Decimal;
25
+ /** Amount of native currency (e.g. Ether) received in exchange for the used-up ZUSD. */
26
+ readonly collateralGain: Decimal;
27
+ /** Amount of ZERO rewarded since the last modification of the Stability Deposit. */
28
+ readonly zeroReward: Decimal;
29
+ /**
30
+ * Address of frontend through which this Stability Deposit was made.
31
+ *
32
+ * @remarks
33
+ * If the Stability Deposit was made through a frontend that doesn't tag deposits, this will be
34
+ * the zero-address.
35
+ */
36
+ readonly frontendTag: string;
37
+ /** @internal */
38
+ constructor(initialZUSD: Decimal, currentZUSD: Decimal, collateralGain: Decimal, zeroReward: Decimal, frontendTag: string);
39
+ get isEmpty(): boolean;
40
+ /** @internal */
41
+ toString(): string;
42
+ /**
43
+ * Compare to another instance of `StabilityDeposit`.
44
+ */
45
+ equals(that: StabilityDeposit): boolean;
46
+ /**
47
+ * Calculate the difference between the `currentZUSD` in this Stability Deposit and `thatZUSD`.
48
+ *
49
+ * @returns An object representing the change, or `undefined` if the deposited amounts are equal.
50
+ */
51
+ whatChanged(thatZUSD: Decimalish): StabilityDepositChange<Decimal> | undefined;
52
+ /**
53
+ * Apply a {@link StabilityDepositChange} to this Stability Deposit.
54
+ *
55
+ * @returns The new deposited ZUSD amount.
56
+ */
57
+ apply(change: StabilityDepositChange<Decimalish> | undefined): Decimal;
58
+ }
59
+ //# sourceMappingURL=StabilityDeposit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StabilityDeposit.d.ts","sourceRoot":"","sources":["../../src/StabilityDeposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;GAIG;AACH,oBAAY,sBAAsB,CAAC,CAAC,IAChC;IAAE,WAAW,EAAE,CAAC,CAAC;IAAC,YAAY,CAAC,EAAE,SAAS,CAAA;CAAE,GAC5C;IAAE,WAAW,CAAC,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,CAAC,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3E;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,2FAA2F;IAC3F,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAE9B,oDAAoD;IACpD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAE9B,wFAAwF;IACxF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IAEjC,oFAAoF;IACpF,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,gBAAgB;gBAEd,WAAW,EAAE,OAAO,EACpB,WAAW,EAAE,OAAO,EACpB,cAAc,EAAE,OAAO,EACvB,UAAU,EAAE,OAAO,EACnB,WAAW,EAAE,MAAM;IAarB,IAAI,OAAO,IAAI,OAAO,CAOrB;IAED,gBAAgB;IAChB,QAAQ,IAAI,MAAM;IAUlB;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO;IAUvC;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,sBAAsB,CAAC,OAAO,CAAC,GAAG,SAAS;IAY9E;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,sBAAsB,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,OAAO;CAavE"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StabilityDeposit = void 0;
4
+ const Decimal_1 = require("./Decimal");
5
+ /**
6
+ * A Stability Deposit and its accrued gains.
7
+ *
8
+ * @public
9
+ */
10
+ class StabilityDeposit {
11
+ /** @internal */
12
+ constructor(initialZUSD, currentZUSD, collateralGain, zeroReward, frontendTag) {
13
+ this.initialZUSD = initialZUSD;
14
+ this.currentZUSD = currentZUSD;
15
+ this.collateralGain = collateralGain;
16
+ this.zeroReward = zeroReward;
17
+ this.frontendTag = frontendTag;
18
+ if (this.currentZUSD.gt(this.initialZUSD)) {
19
+ throw new Error("currentZUSD can't be greater than initialZUSD");
20
+ }
21
+ }
22
+ get isEmpty() {
23
+ return (this.initialZUSD.isZero &&
24
+ this.currentZUSD.isZero &&
25
+ this.collateralGain.isZero &&
26
+ this.zeroReward.isZero);
27
+ }
28
+ /** @internal */
29
+ toString() {
30
+ return (`{ initialZUSD: ${this.initialZUSD}` +
31
+ `, currentZUSD: ${this.currentZUSD}` +
32
+ `, collateralGain: ${this.collateralGain}` +
33
+ `, zeroReward: ${this.zeroReward}` +
34
+ `, frontendTag: "${this.frontendTag}" }`);
35
+ }
36
+ /**
37
+ * Compare to another instance of `StabilityDeposit`.
38
+ */
39
+ equals(that) {
40
+ return (this.initialZUSD.eq(that.initialZUSD) &&
41
+ this.currentZUSD.eq(that.currentZUSD) &&
42
+ this.collateralGain.eq(that.collateralGain) &&
43
+ this.zeroReward.eq(that.zeroReward) &&
44
+ this.frontendTag === that.frontendTag);
45
+ }
46
+ /**
47
+ * Calculate the difference between the `currentZUSD` in this Stability Deposit and `thatZUSD`.
48
+ *
49
+ * @returns An object representing the change, or `undefined` if the deposited amounts are equal.
50
+ */
51
+ whatChanged(thatZUSD) {
52
+ thatZUSD = Decimal_1.Decimal.from(thatZUSD);
53
+ if (thatZUSD.lt(this.currentZUSD)) {
54
+ return { withdrawZUSD: this.currentZUSD.sub(thatZUSD), withdrawAllZUSD: thatZUSD.isZero };
55
+ }
56
+ if (thatZUSD.gt(this.currentZUSD)) {
57
+ return { depositZUSD: thatZUSD.sub(this.currentZUSD) };
58
+ }
59
+ }
60
+ /**
61
+ * Apply a {@link StabilityDepositChange} to this Stability Deposit.
62
+ *
63
+ * @returns The new deposited ZUSD amount.
64
+ */
65
+ apply(change) {
66
+ if (!change) {
67
+ return this.currentZUSD;
68
+ }
69
+ if (change.withdrawZUSD !== undefined) {
70
+ return change.withdrawAllZUSD || this.currentZUSD.lte(change.withdrawZUSD)
71
+ ? Decimal_1.Decimal.ZERO
72
+ : this.currentZUSD.sub(change.withdrawZUSD);
73
+ }
74
+ else {
75
+ return this.currentZUSD.add(change.depositZUSD);
76
+ }
77
+ }
78
+ }
79
+ exports.StabilityDeposit = StabilityDeposit;
80
+ //# sourceMappingURL=StabilityDeposit.js.map