@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.
- 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 +208 -208
- package/dist/src/LiquityStore.js +208 -208
- 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 +155 -155
- 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 +54 -54
- package/dist/src/_CachedReadableLiquity.js +92 -92
- 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/package.json +2 -2
- package/src/constants.ts +3 -3
package/dist/src/ZEROStake.d.ts
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
import { Decimal, Decimalish } from "./Decimal";
|
2
|
-
/**
|
3
|
-
* Represents the change between two states of an ZERO Stake.
|
4
|
-
*
|
5
|
-
* @public
|
6
|
-
*/
|
7
|
-
export declare type ZEROStakeChange<T> = {
|
8
|
-
stakeZERO: T;
|
9
|
-
unstakeZERO?: undefined;
|
10
|
-
} | {
|
11
|
-
stakeZERO?: undefined;
|
12
|
-
unstakeZERO: T;
|
13
|
-
unstakeAllZERO: boolean;
|
14
|
-
};
|
15
|
-
/**
|
16
|
-
* Represents a user's ZERO stake and accrued gains.
|
17
|
-
*
|
18
|
-
* @remarks
|
19
|
-
* Returned by the {@link ReadableLiquity.getZEROStake | getZEROStake()} function.
|
20
|
-
|
21
|
-
* @public
|
22
|
-
*/
|
23
|
-
export declare class ZEROStake {
|
24
|
-
/** The amount of ZERO that's staked. */
|
25
|
-
readonly stakedZERO: Decimal;
|
26
|
-
/** Collateral gain available to withdraw. */
|
27
|
-
readonly collateralGain: Decimal;
|
28
|
-
/** ZUSD gain available to withdraw. */
|
29
|
-
readonly zusdGain: Decimal;
|
30
|
-
/** @internal */
|
31
|
-
constructor(stakedZERO?: Decimal, collateralGain?: Decimal, zusdGain?: Decimal);
|
32
|
-
get isEmpty(): boolean;
|
33
|
-
/** @internal */
|
34
|
-
toString(): string;
|
35
|
-
/**
|
36
|
-
* Compare to another instance of `ZEROStake`.
|
37
|
-
*/
|
38
|
-
equals(that: ZEROStake): boolean;
|
39
|
-
/**
|
40
|
-
* Calculate the difference between this `ZEROStake` and `thatStakedZERO`.
|
41
|
-
*
|
42
|
-
* @returns An object representing the change, or `undefined` if the staked amounts are equal.
|
43
|
-
*/
|
44
|
-
whatChanged(thatStakedZERO: Decimalish): ZEROStakeChange<Decimal> | undefined;
|
45
|
-
/**
|
46
|
-
* Apply a {@link ZEROStakeChange} to this `ZEROStake`.
|
47
|
-
*
|
48
|
-
* @returns The new staked ZERO amount.
|
49
|
-
*/
|
50
|
-
apply(change: ZEROStakeChange<Decimalish> | undefined): Decimal;
|
51
|
-
}
|
1
|
+
import { Decimal, Decimalish } from "./Decimal";
|
2
|
+
/**
|
3
|
+
* Represents the change between two states of an ZERO Stake.
|
4
|
+
*
|
5
|
+
* @public
|
6
|
+
*/
|
7
|
+
export declare type ZEROStakeChange<T> = {
|
8
|
+
stakeZERO: T;
|
9
|
+
unstakeZERO?: undefined;
|
10
|
+
} | {
|
11
|
+
stakeZERO?: undefined;
|
12
|
+
unstakeZERO: T;
|
13
|
+
unstakeAllZERO: boolean;
|
14
|
+
};
|
15
|
+
/**
|
16
|
+
* Represents a user's ZERO stake and accrued gains.
|
17
|
+
*
|
18
|
+
* @remarks
|
19
|
+
* Returned by the {@link ReadableLiquity.getZEROStake | getZEROStake()} function.
|
20
|
+
|
21
|
+
* @public
|
22
|
+
*/
|
23
|
+
export declare class ZEROStake {
|
24
|
+
/** The amount of ZERO that's staked. */
|
25
|
+
readonly stakedZERO: Decimal;
|
26
|
+
/** Collateral gain available to withdraw. */
|
27
|
+
readonly collateralGain: Decimal;
|
28
|
+
/** ZUSD gain available to withdraw. */
|
29
|
+
readonly zusdGain: Decimal;
|
30
|
+
/** @internal */
|
31
|
+
constructor(stakedZERO?: Decimal, collateralGain?: Decimal, zusdGain?: Decimal);
|
32
|
+
get isEmpty(): boolean;
|
33
|
+
/** @internal */
|
34
|
+
toString(): string;
|
35
|
+
/**
|
36
|
+
* Compare to another instance of `ZEROStake`.
|
37
|
+
*/
|
38
|
+
equals(that: ZEROStake): boolean;
|
39
|
+
/**
|
40
|
+
* Calculate the difference between this `ZEROStake` and `thatStakedZERO`.
|
41
|
+
*
|
42
|
+
* @returns An object representing the change, or `undefined` if the staked amounts are equal.
|
43
|
+
*/
|
44
|
+
whatChanged(thatStakedZERO: Decimalish): ZEROStakeChange<Decimal> | undefined;
|
45
|
+
/**
|
46
|
+
* Apply a {@link ZEROStakeChange} to this `ZEROStake`.
|
47
|
+
*
|
48
|
+
* @returns The new staked ZERO amount.
|
49
|
+
*/
|
50
|
+
apply(change: ZEROStakeChange<Decimalish> | undefined): Decimal;
|
51
|
+
}
|
52
52
|
//# sourceMappingURL=ZEROStake.d.ts.map
|
package/dist/src/ZEROStake.js
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ZEROStake = void 0;
|
4
|
-
const Decimal_1 = require("./Decimal");
|
5
|
-
/**
|
6
|
-
* Represents a user's ZERO stake and accrued gains.
|
7
|
-
*
|
8
|
-
* @remarks
|
9
|
-
* Returned by the {@link ReadableLiquity.getZEROStake | getZEROStake()} function.
|
10
|
-
|
11
|
-
* @public
|
12
|
-
*/
|
13
|
-
class ZEROStake {
|
14
|
-
/** @internal */
|
15
|
-
constructor(stakedZERO = Decimal_1.Decimal.ZERO, collateralGain = Decimal_1.Decimal.ZERO, zusdGain = Decimal_1.Decimal.ZERO) {
|
16
|
-
this.stakedZERO = stakedZERO;
|
17
|
-
this.collateralGain = collateralGain;
|
18
|
-
this.zusdGain = zusdGain;
|
19
|
-
}
|
20
|
-
get isEmpty() {
|
21
|
-
return this.stakedZERO.isZero && this.collateralGain.isZero && this.zusdGain.isZero;
|
22
|
-
}
|
23
|
-
/** @internal */
|
24
|
-
toString() {
|
25
|
-
return (`{ stakedZERO: ${this.stakedZERO}` +
|
26
|
-
`, collateralGain: ${this.collateralGain}` +
|
27
|
-
`, zusdGain: ${this.zusdGain} }`);
|
28
|
-
}
|
29
|
-
/**
|
30
|
-
* Compare to another instance of `ZEROStake`.
|
31
|
-
*/
|
32
|
-
equals(that) {
|
33
|
-
return (this.stakedZERO.eq(that.stakedZERO) &&
|
34
|
-
this.collateralGain.eq(that.collateralGain) &&
|
35
|
-
this.zusdGain.eq(that.zusdGain));
|
36
|
-
}
|
37
|
-
/**
|
38
|
-
* Calculate the difference between this `ZEROStake` and `thatStakedZERO`.
|
39
|
-
*
|
40
|
-
* @returns An object representing the change, or `undefined` if the staked amounts are equal.
|
41
|
-
*/
|
42
|
-
whatChanged(thatStakedZERO) {
|
43
|
-
thatStakedZERO = Decimal_1.Decimal.from(thatStakedZERO);
|
44
|
-
if (thatStakedZERO.lt(this.stakedZERO)) {
|
45
|
-
return {
|
46
|
-
unstakeZERO: this.stakedZERO.sub(thatStakedZERO),
|
47
|
-
unstakeAllZERO: thatStakedZERO.isZero
|
48
|
-
};
|
49
|
-
}
|
50
|
-
if (thatStakedZERO.gt(this.stakedZERO)) {
|
51
|
-
return { stakeZERO: thatStakedZERO.sub(this.stakedZERO) };
|
52
|
-
}
|
53
|
-
}
|
54
|
-
/**
|
55
|
-
* Apply a {@link ZEROStakeChange} to this `ZEROStake`.
|
56
|
-
*
|
57
|
-
* @returns The new staked ZERO amount.
|
58
|
-
*/
|
59
|
-
apply(change) {
|
60
|
-
if (!change) {
|
61
|
-
return this.stakedZERO;
|
62
|
-
}
|
63
|
-
if (change.unstakeZERO !== undefined) {
|
64
|
-
return change.unstakeAllZERO || this.stakedZERO.lte(change.unstakeZERO)
|
65
|
-
? Decimal_1.Decimal.ZERO
|
66
|
-
: this.stakedZERO.sub(change.unstakeZERO);
|
67
|
-
}
|
68
|
-
else {
|
69
|
-
return this.stakedZERO.add(change.stakeZERO);
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
exports.ZEROStake = ZEROStake;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ZEROStake = void 0;
|
4
|
+
const Decimal_1 = require("./Decimal");
|
5
|
+
/**
|
6
|
+
* Represents a user's ZERO stake and accrued gains.
|
7
|
+
*
|
8
|
+
* @remarks
|
9
|
+
* Returned by the {@link ReadableLiquity.getZEROStake | getZEROStake()} function.
|
10
|
+
|
11
|
+
* @public
|
12
|
+
*/
|
13
|
+
class ZEROStake {
|
14
|
+
/** @internal */
|
15
|
+
constructor(stakedZERO = Decimal_1.Decimal.ZERO, collateralGain = Decimal_1.Decimal.ZERO, zusdGain = Decimal_1.Decimal.ZERO) {
|
16
|
+
this.stakedZERO = stakedZERO;
|
17
|
+
this.collateralGain = collateralGain;
|
18
|
+
this.zusdGain = zusdGain;
|
19
|
+
}
|
20
|
+
get isEmpty() {
|
21
|
+
return this.stakedZERO.isZero && this.collateralGain.isZero && this.zusdGain.isZero;
|
22
|
+
}
|
23
|
+
/** @internal */
|
24
|
+
toString() {
|
25
|
+
return (`{ stakedZERO: ${this.stakedZERO}` +
|
26
|
+
`, collateralGain: ${this.collateralGain}` +
|
27
|
+
`, zusdGain: ${this.zusdGain} }`);
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Compare to another instance of `ZEROStake`.
|
31
|
+
*/
|
32
|
+
equals(that) {
|
33
|
+
return (this.stakedZERO.eq(that.stakedZERO) &&
|
34
|
+
this.collateralGain.eq(that.collateralGain) &&
|
35
|
+
this.zusdGain.eq(that.zusdGain));
|
36
|
+
}
|
37
|
+
/**
|
38
|
+
* Calculate the difference between this `ZEROStake` and `thatStakedZERO`.
|
39
|
+
*
|
40
|
+
* @returns An object representing the change, or `undefined` if the staked amounts are equal.
|
41
|
+
*/
|
42
|
+
whatChanged(thatStakedZERO) {
|
43
|
+
thatStakedZERO = Decimal_1.Decimal.from(thatStakedZERO);
|
44
|
+
if (thatStakedZERO.lt(this.stakedZERO)) {
|
45
|
+
return {
|
46
|
+
unstakeZERO: this.stakedZERO.sub(thatStakedZERO),
|
47
|
+
unstakeAllZERO: thatStakedZERO.isZero
|
48
|
+
};
|
49
|
+
}
|
50
|
+
if (thatStakedZERO.gt(this.stakedZERO)) {
|
51
|
+
return { stakeZERO: thatStakedZERO.sub(this.stakedZERO) };
|
52
|
+
}
|
53
|
+
}
|
54
|
+
/**
|
55
|
+
* Apply a {@link ZEROStakeChange} to this `ZEROStake`.
|
56
|
+
*
|
57
|
+
* @returns The new staked ZERO amount.
|
58
|
+
*/
|
59
|
+
apply(change) {
|
60
|
+
if (!change) {
|
61
|
+
return this.stakedZERO;
|
62
|
+
}
|
63
|
+
if (change.unstakeZERO !== undefined) {
|
64
|
+
return change.unstakeAllZERO || this.stakedZERO.lte(change.unstakeZERO)
|
65
|
+
? Decimal_1.Decimal.ZERO
|
66
|
+
: this.stakedZERO.sub(change.unstakeZERO);
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
return this.stakedZERO.add(change.stakeZERO);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
exports.ZEROStake = ZEROStake;
|
74
74
|
//# sourceMappingURL=ZEROStake.js.map
|
@@ -1,55 +1,55 @@
|
|
1
|
-
import { Decimal } from "./Decimal";
|
2
|
-
import { Fees } from "./Fees";
|
3
|
-
import { ZEROStake } from "./ZEROStake";
|
4
|
-
import { StabilityDeposit } from "./StabilityDeposit";
|
5
|
-
import { Trove, TroveWithPendingRedistribution, UserTrove } from "./Trove";
|
6
|
-
import { FrontendStatus, ReadableLiquity, TroveListingParams } from "./ReadableLiquity";
|
7
|
-
/** @internal */
|
8
|
-
export declare type _ReadableLiquityWithExtraParamsBase<T extends unknown[]> = {
|
9
|
-
[P in keyof ReadableLiquity]: ReadableLiquity[P] extends (...params: infer A) => infer R ? (...params: [...originalParams: A, ...extraParams: T]) => R : never;
|
10
|
-
};
|
11
|
-
/** @internal */
|
12
|
-
export declare type _LiquityReadCacheBase<T extends unknown[]> = {
|
13
|
-
[P in keyof ReadableLiquity]: ReadableLiquity[P] extends (...args: infer A) => Promise<infer R> ? (...params: [...originalParams: A, ...extraParams: T]) => R | undefined : never;
|
14
|
-
};
|
15
|
-
/** @internal */
|
16
|
-
export interface _ReadableLiquityWithExtraParams<T extends unknown[]> extends _ReadableLiquityWithExtraParamsBase<T> {
|
17
|
-
getTroves(params: TroveListingParams & {
|
18
|
-
beforeRedistribution: true;
|
19
|
-
}, ...extraParams: T): Promise<TroveWithPendingRedistribution[]>;
|
20
|
-
getTroves(params: TroveListingParams, ...extraParams: T): Promise<UserTrove[]>;
|
21
|
-
}
|
22
|
-
/** @internal */
|
23
|
-
export interface _LiquityReadCache<T extends unknown[]> extends _LiquityReadCacheBase<T> {
|
24
|
-
getTroves(params: TroveListingParams & {
|
25
|
-
beforeRedistribution: true;
|
26
|
-
}, ...extraParams: T): TroveWithPendingRedistribution[] | undefined;
|
27
|
-
getTroves(params: TroveListingParams, ...extraParams: T): UserTrove[] | undefined;
|
28
|
-
}
|
29
|
-
/** @internal */
|
30
|
-
export declare class _CachedReadableLiquity<T extends unknown[]> implements _ReadableLiquityWithExtraParams<T> {
|
31
|
-
private _readable;
|
32
|
-
private _cache;
|
33
|
-
constructor(readable: _ReadableLiquityWithExtraParams<T>, cache: _LiquityReadCache<T>);
|
34
|
-
getTotalRedistributed(...extraParams: T): Promise<Trove>;
|
35
|
-
getTroveBeforeRedistribution(address?: string, ...extraParams: T): Promise<TroveWithPendingRedistribution>;
|
36
|
-
getTrove(address?: string, ...extraParams: T): Promise<UserTrove>;
|
37
|
-
getNumberOfTroves(...extraParams: T): Promise<number>;
|
38
|
-
getPrice(...extraParams: T): Promise<Decimal>;
|
39
|
-
getTotal(...extraParams: T): Promise<Trove>;
|
40
|
-
getStabilityDeposit(address?: string, ...extraParams: T): Promise<StabilityDeposit>;
|
41
|
-
getRemainingStabilityPoolZEROReward(...extraParams: T): Promise<Decimal>;
|
42
|
-
getZUSDInStabilityPool(...extraParams: T): Promise<Decimal>;
|
43
|
-
getZUSDBalance(address?: string, ...extraParams: T): Promise<Decimal>;
|
44
|
-
getZEROBalance(address?: string, ...extraParams: T): Promise<Decimal>;
|
45
|
-
getCollateralSurplusBalance(address?: string, ...extraParams: T): Promise<Decimal>;
|
46
|
-
getTroves(params: TroveListingParams & {
|
47
|
-
beforeRedistribution: true;
|
48
|
-
}, ...extraParams: T): Promise<TroveWithPendingRedistribution[]>;
|
49
|
-
getTroves(params: TroveListingParams, ...extraParams: T): Promise<UserTrove[]>;
|
50
|
-
getFees(...extraParams: T): Promise<Fees>;
|
51
|
-
getZEROStake(address?: string, ...extraParams: T): Promise<ZEROStake>;
|
52
|
-
getTotalStakedZERO(...extraParams: T): Promise<Decimal>;
|
53
|
-
getFrontendStatus(address?: string, ...extraParams: T): Promise<FrontendStatus>;
|
54
|
-
}
|
1
|
+
import { Decimal } from "./Decimal";
|
2
|
+
import { Fees } from "./Fees";
|
3
|
+
import { ZEROStake } from "./ZEROStake";
|
4
|
+
import { StabilityDeposit } from "./StabilityDeposit";
|
5
|
+
import { Trove, TroveWithPendingRedistribution, UserTrove } from "./Trove";
|
6
|
+
import { FrontendStatus, ReadableLiquity, TroveListingParams } from "./ReadableLiquity";
|
7
|
+
/** @internal */
|
8
|
+
export declare type _ReadableLiquityWithExtraParamsBase<T extends unknown[]> = {
|
9
|
+
[P in keyof ReadableLiquity]: ReadableLiquity[P] extends (...params: infer A) => infer R ? (...params: [...originalParams: A, ...extraParams: T]) => R : never;
|
10
|
+
};
|
11
|
+
/** @internal */
|
12
|
+
export declare type _LiquityReadCacheBase<T extends unknown[]> = {
|
13
|
+
[P in keyof ReadableLiquity]: ReadableLiquity[P] extends (...args: infer A) => Promise<infer R> ? (...params: [...originalParams: A, ...extraParams: T]) => R | undefined : never;
|
14
|
+
};
|
15
|
+
/** @internal */
|
16
|
+
export interface _ReadableLiquityWithExtraParams<T extends unknown[]> extends _ReadableLiquityWithExtraParamsBase<T> {
|
17
|
+
getTroves(params: TroveListingParams & {
|
18
|
+
beforeRedistribution: true;
|
19
|
+
}, ...extraParams: T): Promise<TroveWithPendingRedistribution[]>;
|
20
|
+
getTroves(params: TroveListingParams, ...extraParams: T): Promise<UserTrove[]>;
|
21
|
+
}
|
22
|
+
/** @internal */
|
23
|
+
export interface _LiquityReadCache<T extends unknown[]> extends _LiquityReadCacheBase<T> {
|
24
|
+
getTroves(params: TroveListingParams & {
|
25
|
+
beforeRedistribution: true;
|
26
|
+
}, ...extraParams: T): TroveWithPendingRedistribution[] | undefined;
|
27
|
+
getTroves(params: TroveListingParams, ...extraParams: T): UserTrove[] | undefined;
|
28
|
+
}
|
29
|
+
/** @internal */
|
30
|
+
export declare class _CachedReadableLiquity<T extends unknown[]> implements _ReadableLiquityWithExtraParams<T> {
|
31
|
+
private _readable;
|
32
|
+
private _cache;
|
33
|
+
constructor(readable: _ReadableLiquityWithExtraParams<T>, cache: _LiquityReadCache<T>);
|
34
|
+
getTotalRedistributed(...extraParams: T): Promise<Trove>;
|
35
|
+
getTroveBeforeRedistribution(address?: string, ...extraParams: T): Promise<TroveWithPendingRedistribution>;
|
36
|
+
getTrove(address?: string, ...extraParams: T): Promise<UserTrove>;
|
37
|
+
getNumberOfTroves(...extraParams: T): Promise<number>;
|
38
|
+
getPrice(...extraParams: T): Promise<Decimal>;
|
39
|
+
getTotal(...extraParams: T): Promise<Trove>;
|
40
|
+
getStabilityDeposit(address?: string, ...extraParams: T): Promise<StabilityDeposit>;
|
41
|
+
getRemainingStabilityPoolZEROReward(...extraParams: T): Promise<Decimal>;
|
42
|
+
getZUSDInStabilityPool(...extraParams: T): Promise<Decimal>;
|
43
|
+
getZUSDBalance(address?: string, ...extraParams: T): Promise<Decimal>;
|
44
|
+
getZEROBalance(address?: string, ...extraParams: T): Promise<Decimal>;
|
45
|
+
getCollateralSurplusBalance(address?: string, ...extraParams: T): Promise<Decimal>;
|
46
|
+
getTroves(params: TroveListingParams & {
|
47
|
+
beforeRedistribution: true;
|
48
|
+
}, ...extraParams: T): Promise<TroveWithPendingRedistribution[]>;
|
49
|
+
getTroves(params: TroveListingParams, ...extraParams: T): Promise<UserTrove[]>;
|
50
|
+
getFees(...extraParams: T): Promise<Fees>;
|
51
|
+
getZEROStake(address?: string, ...extraParams: T): Promise<ZEROStake>;
|
52
|
+
getTotalStakedZERO(...extraParams: T): Promise<Decimal>;
|
53
|
+
getFrontendStatus(address?: string, ...extraParams: T): Promise<FrontendStatus>;
|
54
|
+
}
|
55
55
|
//# sourceMappingURL=_CachedReadableLiquity.d.ts.map
|
@@ -1,93 +1,93 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports._CachedReadableLiquity = void 0;
|
4
|
-
/** @internal */
|
5
|
-
class _CachedReadableLiquity {
|
6
|
-
constructor(readable, cache) {
|
7
|
-
this._readable = readable;
|
8
|
-
this._cache = cache;
|
9
|
-
}
|
10
|
-
async getTotalRedistributed(...extraParams) {
|
11
|
-
var _a;
|
12
|
-
return ((_a = this._cache.getTotalRedistributed(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTotalRedistributed(...extraParams));
|
13
|
-
}
|
14
|
-
async getTroveBeforeRedistribution(address, ...extraParams) {
|
15
|
-
var _a;
|
16
|
-
return ((_a = this._cache.getTroveBeforeRedistribution(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTroveBeforeRedistribution(address, ...extraParams));
|
17
|
-
}
|
18
|
-
async getTrove(address, ...extraParams) {
|
19
|
-
const [troveBeforeRedistribution, totalRedistributed] = await Promise.all([
|
20
|
-
this.getTroveBeforeRedistribution(address, ...extraParams),
|
21
|
-
this.getTotalRedistributed(...extraParams)
|
22
|
-
]);
|
23
|
-
return troveBeforeRedistribution.applyRedistribution(totalRedistributed);
|
24
|
-
}
|
25
|
-
async getNumberOfTroves(...extraParams) {
|
26
|
-
var _a;
|
27
|
-
return ((_a = this._cache.getNumberOfTroves(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getNumberOfTroves(...extraParams));
|
28
|
-
}
|
29
|
-
async getPrice(...extraParams) {
|
30
|
-
var _a;
|
31
|
-
return (_a = this._cache.getPrice(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getPrice(...extraParams);
|
32
|
-
}
|
33
|
-
async getTotal(...extraParams) {
|
34
|
-
var _a;
|
35
|
-
return (_a = this._cache.getTotal(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTotal(...extraParams);
|
36
|
-
}
|
37
|
-
async getStabilityDeposit(address, ...extraParams) {
|
38
|
-
var _a;
|
39
|
-
return ((_a = this._cache.getStabilityDeposit(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getStabilityDeposit(address, ...extraParams));
|
40
|
-
}
|
41
|
-
async getRemainingStabilityPoolZEROReward(...extraParams) {
|
42
|
-
var _a;
|
43
|
-
return ((_a = this._cache.getRemainingStabilityPoolZEROReward(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getRemainingStabilityPoolZEROReward(...extraParams));
|
44
|
-
}
|
45
|
-
async getZUSDInStabilityPool(...extraParams) {
|
46
|
-
var _a;
|
47
|
-
return ((_a = this._cache.getZUSDInStabilityPool(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getZUSDInStabilityPool(...extraParams));
|
48
|
-
}
|
49
|
-
async getZUSDBalance(address, ...extraParams) {
|
50
|
-
var _a;
|
51
|
-
return ((_a = this._cache.getZUSDBalance(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getZUSDBalance(address, ...extraParams));
|
52
|
-
}
|
53
|
-
async getZEROBalance(address, ...extraParams) {
|
54
|
-
var _a;
|
55
|
-
return ((_a = this._cache.getZEROBalance(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getZEROBalance(address, ...extraParams));
|
56
|
-
}
|
57
|
-
async getCollateralSurplusBalance(address, ...extraParams) {
|
58
|
-
var _a;
|
59
|
-
return ((_a = this._cache.getCollateralSurplusBalance(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getCollateralSurplusBalance(address, ...extraParams));
|
60
|
-
}
|
61
|
-
async getTroves(params, ...extraParams) {
|
62
|
-
var _a;
|
63
|
-
const { beforeRedistribution, ...restOfParams } = params;
|
64
|
-
const [totalRedistributed, troves] = await Promise.all([
|
65
|
-
beforeRedistribution ? undefined : this.getTotalRedistributed(...extraParams),
|
66
|
-
(_a = this._cache.getTroves({ beforeRedistribution: true, ...restOfParams }, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTroves({ beforeRedistribution: true, ...restOfParams }, ...extraParams)
|
67
|
-
]);
|
68
|
-
if (totalRedistributed) {
|
69
|
-
return troves.map(trove => trove.applyRedistribution(totalRedistributed));
|
70
|
-
}
|
71
|
-
else {
|
72
|
-
return troves;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
async getFees(...extraParams) {
|
76
|
-
var _a;
|
77
|
-
return (_a = this._cache.getFees(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getFees(...extraParams);
|
78
|
-
}
|
79
|
-
async getZEROStake(address, ...extraParams) {
|
80
|
-
var _a;
|
81
|
-
return ((_a = this._cache.getZEROStake(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getZEROStake(address, ...extraParams));
|
82
|
-
}
|
83
|
-
async getTotalStakedZERO(...extraParams) {
|
84
|
-
var _a;
|
85
|
-
return ((_a = this._cache.getTotalStakedZERO(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTotalStakedZERO(...extraParams));
|
86
|
-
}
|
87
|
-
async getFrontendStatus(address, ...extraParams) {
|
88
|
-
var _a;
|
89
|
-
return ((_a = this._cache.getFrontendStatus(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getFrontendStatus(address, ...extraParams));
|
90
|
-
}
|
91
|
-
}
|
92
|
-
exports._CachedReadableLiquity = _CachedReadableLiquity;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports._CachedReadableLiquity = void 0;
|
4
|
+
/** @internal */
|
5
|
+
class _CachedReadableLiquity {
|
6
|
+
constructor(readable, cache) {
|
7
|
+
this._readable = readable;
|
8
|
+
this._cache = cache;
|
9
|
+
}
|
10
|
+
async getTotalRedistributed(...extraParams) {
|
11
|
+
var _a;
|
12
|
+
return ((_a = this._cache.getTotalRedistributed(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTotalRedistributed(...extraParams));
|
13
|
+
}
|
14
|
+
async getTroveBeforeRedistribution(address, ...extraParams) {
|
15
|
+
var _a;
|
16
|
+
return ((_a = this._cache.getTroveBeforeRedistribution(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTroveBeforeRedistribution(address, ...extraParams));
|
17
|
+
}
|
18
|
+
async getTrove(address, ...extraParams) {
|
19
|
+
const [troveBeforeRedistribution, totalRedistributed] = await Promise.all([
|
20
|
+
this.getTroveBeforeRedistribution(address, ...extraParams),
|
21
|
+
this.getTotalRedistributed(...extraParams)
|
22
|
+
]);
|
23
|
+
return troveBeforeRedistribution.applyRedistribution(totalRedistributed);
|
24
|
+
}
|
25
|
+
async getNumberOfTroves(...extraParams) {
|
26
|
+
var _a;
|
27
|
+
return ((_a = this._cache.getNumberOfTroves(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getNumberOfTroves(...extraParams));
|
28
|
+
}
|
29
|
+
async getPrice(...extraParams) {
|
30
|
+
var _a;
|
31
|
+
return (_a = this._cache.getPrice(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getPrice(...extraParams);
|
32
|
+
}
|
33
|
+
async getTotal(...extraParams) {
|
34
|
+
var _a;
|
35
|
+
return (_a = this._cache.getTotal(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTotal(...extraParams);
|
36
|
+
}
|
37
|
+
async getStabilityDeposit(address, ...extraParams) {
|
38
|
+
var _a;
|
39
|
+
return ((_a = this._cache.getStabilityDeposit(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getStabilityDeposit(address, ...extraParams));
|
40
|
+
}
|
41
|
+
async getRemainingStabilityPoolZEROReward(...extraParams) {
|
42
|
+
var _a;
|
43
|
+
return ((_a = this._cache.getRemainingStabilityPoolZEROReward(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getRemainingStabilityPoolZEROReward(...extraParams));
|
44
|
+
}
|
45
|
+
async getZUSDInStabilityPool(...extraParams) {
|
46
|
+
var _a;
|
47
|
+
return ((_a = this._cache.getZUSDInStabilityPool(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getZUSDInStabilityPool(...extraParams));
|
48
|
+
}
|
49
|
+
async getZUSDBalance(address, ...extraParams) {
|
50
|
+
var _a;
|
51
|
+
return ((_a = this._cache.getZUSDBalance(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getZUSDBalance(address, ...extraParams));
|
52
|
+
}
|
53
|
+
async getZEROBalance(address, ...extraParams) {
|
54
|
+
var _a;
|
55
|
+
return ((_a = this._cache.getZEROBalance(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getZEROBalance(address, ...extraParams));
|
56
|
+
}
|
57
|
+
async getCollateralSurplusBalance(address, ...extraParams) {
|
58
|
+
var _a;
|
59
|
+
return ((_a = this._cache.getCollateralSurplusBalance(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getCollateralSurplusBalance(address, ...extraParams));
|
60
|
+
}
|
61
|
+
async getTroves(params, ...extraParams) {
|
62
|
+
var _a;
|
63
|
+
const { beforeRedistribution, ...restOfParams } = params;
|
64
|
+
const [totalRedistributed, troves] = await Promise.all([
|
65
|
+
beforeRedistribution ? undefined : this.getTotalRedistributed(...extraParams),
|
66
|
+
(_a = this._cache.getTroves({ beforeRedistribution: true, ...restOfParams }, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTroves({ beforeRedistribution: true, ...restOfParams }, ...extraParams)
|
67
|
+
]);
|
68
|
+
if (totalRedistributed) {
|
69
|
+
return troves.map(trove => trove.applyRedistribution(totalRedistributed));
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
return troves;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
async getFees(...extraParams) {
|
76
|
+
var _a;
|
77
|
+
return (_a = this._cache.getFees(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getFees(...extraParams);
|
78
|
+
}
|
79
|
+
async getZEROStake(address, ...extraParams) {
|
80
|
+
var _a;
|
81
|
+
return ((_a = this._cache.getZEROStake(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getZEROStake(address, ...extraParams));
|
82
|
+
}
|
83
|
+
async getTotalStakedZERO(...extraParams) {
|
84
|
+
var _a;
|
85
|
+
return ((_a = this._cache.getTotalStakedZERO(...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getTotalStakedZERO(...extraParams));
|
86
|
+
}
|
87
|
+
async getFrontendStatus(address, ...extraParams) {
|
88
|
+
var _a;
|
89
|
+
return ((_a = this._cache.getFrontendStatus(address, ...extraParams)) !== null && _a !== void 0 ? _a : this._readable.getFrontendStatus(address, ...extraParams));
|
90
|
+
}
|
91
|
+
}
|
92
|
+
exports._CachedReadableLiquity = _CachedReadableLiquity;
|
93
93
|
//# sourceMappingURL=_CachedReadableLiquity.js.map
|