@sovryn-zero/lib-base 0.1.0 → 0.2.1

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.
@@ -1,125 +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
- }
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
125
  //# sourceMappingURL=PopulatableLiquity.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=PopulatableLiquity.js.map
@@ -1,156 +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
- }
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
156
  //# sourceMappingURL=ReadableLiquity.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=ReadableLiquity.js.map