diff --git a/api-documenter.json b/api-documenter.json new file mode 100644 index 000000000..aae3c5626 --- /dev/null +++ b/api-documenter.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-documenter.schema.json", + "newlineKind": "lf", + "outputTarget": "markdown" +} diff --git a/docs/sdk/decimal.decimal._constructor_.md b/docs/sdk/decimal.decimal._constructor_.md new file mode 100644 index 000000000..d7e9d42ce --- /dev/null +++ b/docs/sdk/decimal.decimal._constructor_.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [(constructor)](./decimal.decimal._constructor_.md) + +## Decimal.(constructor) + +Constructs a new instance of the `Decimal` class + +Signature: + +```typescript +constructor(bigNumber: BigNumber); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| bigNumber | BigNumber | | + diff --git a/docs/sdk/decimal.decimal.absolutevalue.md b/docs/sdk/decimal.decimal.absolutevalue.md new file mode 100644 index 000000000..736dd8d11 --- /dev/null +++ b/docs/sdk/decimal.decimal.absolutevalue.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [absoluteValue](./decimal.decimal.absolutevalue.md) + +## Decimal.absoluteValue property + +Signature: + +```typescript +get absoluteValue(): this; +``` diff --git a/docs/sdk/decimal.decimal.add.md b/docs/sdk/decimal.decimal.add.md new file mode 100644 index 000000000..0cd9331b8 --- /dev/null +++ b/docs/sdk/decimal.decimal.add.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [add](./decimal.decimal.add.md) + +## Decimal.add() method + +Signature: + +```typescript +add(addend: Decimalish): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| addend | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/decimal.decimal.bignumber.md b/docs/sdk/decimal.decimal.bignumber.md new file mode 100644 index 000000000..70e6431cd --- /dev/null +++ b/docs/sdk/decimal.decimal.bignumber.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [bigNumber](./decimal.decimal.bignumber.md) + +## Decimal.bigNumber property + +Signature: + +```typescript +readonly bigNumber: BigNumber; +``` diff --git a/docs/sdk/decimal.decimal.bignumberfrom.md b/docs/sdk/decimal.decimal.bignumberfrom.md new file mode 100644 index 000000000..d83061c90 --- /dev/null +++ b/docs/sdk/decimal.decimal.bignumberfrom.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [bigNumberFrom](./decimal.decimal.bignumberfrom.md) + +## Decimal.bigNumberFrom() method + +Signature: + +```typescript +static bigNumberFrom(decimalish: Decimalish): BigNumber; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| decimalish | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +BigNumber + diff --git a/docs/sdk/decimal.decimal.digits.md b/docs/sdk/decimal.decimal.digits.md new file mode 100644 index 000000000..b6a12f428 --- /dev/null +++ b/docs/sdk/decimal.decimal.digits.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [DIGITS](./decimal.decimal.digits.md) + +## Decimal.DIGITS property + +Signature: + +```typescript +static readonly DIGITS: BigNumber; +``` diff --git a/docs/sdk/decimal.decimal.div.md b/docs/sdk/decimal.decimal.div.md new file mode 100644 index 000000000..934a7d901 --- /dev/null +++ b/docs/sdk/decimal.decimal.div.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [div](./decimal.decimal.div.md) + +## Decimal.div() method + +Signature: + +```typescript +div(divider: Decimalish): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| divider | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/decimal.decimal.eq.md b/docs/sdk/decimal.decimal.eq.md new file mode 100644 index 000000000..5168ea3a5 --- /dev/null +++ b/docs/sdk/decimal.decimal.eq.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [eq](./decimal.decimal.eq.md) + +## Decimal.eq() method + +Signature: + +```typescript +eq(that: Decimalish): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/decimal.decimal.finite.md b/docs/sdk/decimal.decimal.finite.md new file mode 100644 index 000000000..feede3c31 --- /dev/null +++ b/docs/sdk/decimal.decimal.finite.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [finite](./decimal.decimal.finite.md) + +## Decimal.finite property + +Signature: + +```typescript +get finite(): this | undefined; +``` diff --git a/docs/sdk/decimal.decimal.from.md b/docs/sdk/decimal.decimal.from.md new file mode 100644 index 000000000..777510988 --- /dev/null +++ b/docs/sdk/decimal.decimal.from.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [from](./decimal.decimal.from.md) + +## Decimal.from() method + +Signature: + +```typescript +static from(decimalish: Decimalish): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| decimalish | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/decimal.decimal.gt.md b/docs/sdk/decimal.decimal.gt.md new file mode 100644 index 000000000..e4c016ebc --- /dev/null +++ b/docs/sdk/decimal.decimal.gt.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [gt](./decimal.decimal.gt.md) + +## Decimal.gt() method + +Signature: + +```typescript +gt(that: Decimalish): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/decimal.decimal.gte.md b/docs/sdk/decimal.decimal.gte.md new file mode 100644 index 000000000..e362acdb2 --- /dev/null +++ b/docs/sdk/decimal.decimal.gte.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [gte](./decimal.decimal.gte.md) + +## Decimal.gte() method + +Signature: + +```typescript +gte(that: Decimalish): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/decimal.decimal.half.md b/docs/sdk/decimal.decimal.half.md new file mode 100644 index 000000000..d7c9f7166 --- /dev/null +++ b/docs/sdk/decimal.decimal.half.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [HALF](./decimal.decimal.half.md) + +## Decimal.HALF property + +Signature: + +```typescript +static readonly HALF: Decimal; +``` diff --git a/docs/sdk/decimal.decimal.infinite.md b/docs/sdk/decimal.decimal.infinite.md new file mode 100644 index 000000000..8ce00ade8 --- /dev/null +++ b/docs/sdk/decimal.decimal.infinite.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [infinite](./decimal.decimal.infinite.md) + +## Decimal.infinite property + +Signature: + +```typescript +get infinite(): this | undefined; +``` diff --git a/docs/sdk/decimal.decimal.infinity.md b/docs/sdk/decimal.decimal.infinity.md new file mode 100644 index 000000000..ab66ececc --- /dev/null +++ b/docs/sdk/decimal.decimal.infinity.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [INFINITY](./decimal.decimal.infinity.md) + +## Decimal.INFINITY property + +Signature: + +```typescript +static readonly INFINITY: Decimal; +``` diff --git a/docs/sdk/decimal.decimal.iszero.md b/docs/sdk/decimal.decimal.iszero.md new file mode 100644 index 000000000..f0dd5fcc5 --- /dev/null +++ b/docs/sdk/decimal.decimal.iszero.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [isZero](./decimal.decimal.iszero.md) + +## Decimal.isZero property + +Signature: + +```typescript +get isZero(): boolean; +``` diff --git a/docs/sdk/decimal.decimal.lt.md b/docs/sdk/decimal.decimal.lt.md new file mode 100644 index 000000000..78b09b264 --- /dev/null +++ b/docs/sdk/decimal.decimal.lt.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [lt](./decimal.decimal.lt.md) + +## Decimal.lt() method + +Signature: + +```typescript +lt(that: Decimalish): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/decimal.decimal.lte.md b/docs/sdk/decimal.decimal.lte.md new file mode 100644 index 000000000..f27258e7c --- /dev/null +++ b/docs/sdk/decimal.decimal.lte.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [lte](./decimal.decimal.lte.md) + +## Decimal.lte() method + +Signature: + +```typescript +lte(that: Decimalish): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/decimal.decimal.md b/docs/sdk/decimal.decimal.md new file mode 100644 index 000000000..46ecd7fef --- /dev/null +++ b/docs/sdk/decimal.decimal.md @@ -0,0 +1,60 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) + +## Decimal class + + +Signature: + +```typescript +export declare class Decimal +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(bigNumber)](./decimal.decimal._constructor_.md) | | Constructs a new instance of the Decimal class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [absoluteValue](./decimal.decimal.absolutevalue.md) | | this | | +| [bigNumber](./decimal.decimal.bignumber.md) | | BigNumber | | +| [DIGITS](./decimal.decimal.digits.md) | static | BigNumber | | +| [finite](./decimal.decimal.finite.md) | | this \| undefined | | +| [HALF](./decimal.decimal.half.md) | static | [Decimal](./decimal.decimal.md) | | +| [infinite](./decimal.decimal.infinite.md) | | this \| undefined | | +| [INFINITY](./decimal.decimal.infinity.md) | static | [Decimal](./decimal.decimal.md) | | +| [isZero](./decimal.decimal.iszero.md) | | boolean | | +| [nonZero](./decimal.decimal.nonzero.md) | | this \| undefined | | +| [ONE](./decimal.decimal.one.md) | static | [Decimal](./decimal.decimal.md) | | +| [PRECISION](./decimal.decimal.precision.md) | static | (not declared) | | +| [zero](./decimal.decimal.zero.md) | | this \| undefined | | +| [ZERO](./decimal.decimal.zero.md) | static | [Decimal](./decimal.decimal.md) | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(addend)](./decimal.decimal.add.md) | | | +| [bigNumberFrom(decimalish)](./decimal.decimal.bignumberfrom.md) | static | | +| [div(divider)](./decimal.decimal.div.md) | | | +| [eq(that)](./decimal.decimal.eq.md) | | | +| [from(decimalish)](./decimal.decimal.from.md) | static | | +| [gt(that)](./decimal.decimal.gt.md) | | | +| [gte(that)](./decimal.decimal.gte.md) | | | +| [lt(that)](./decimal.decimal.lt.md) | | | +| [lte(that)](./decimal.decimal.lte.md) | | | +| [mul(multiplier)](./decimal.decimal.mul.md) | | | +| [mulDiv(multiplier, divider)](./decimal.decimal.muldiv.md) | | | +| [pow(exponent)](./decimal.decimal.pow.md) | | | +| [prettify(precision)](./decimal.decimal.prettify.md) | | | +| [prettify(bigNumberish)](./decimal.decimal.prettify.md) | static | | +| [shorten()](./decimal.decimal.shorten.md) | | | +| [shorten(bigNumber)](./decimal.decimal.shorten.md) | static | | +| [sub(subtrahend)](./decimal.decimal.sub.md) | | | +| [toString(precision)](./decimal.decimal.tostring.md) | | | + diff --git a/docs/sdk/decimal.decimal.mul.md b/docs/sdk/decimal.decimal.mul.md new file mode 100644 index 000000000..b8b514b62 --- /dev/null +++ b/docs/sdk/decimal.decimal.mul.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [mul](./decimal.decimal.mul.md) + +## Decimal.mul() method + +Signature: + +```typescript +mul(multiplier: Decimalish): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| multiplier | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/decimal.decimal.muldiv.md b/docs/sdk/decimal.decimal.muldiv.md new file mode 100644 index 000000000..fa67ad85b --- /dev/null +++ b/docs/sdk/decimal.decimal.muldiv.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [mulDiv](./decimal.decimal.muldiv.md) + +## Decimal.mulDiv() method + +Signature: + +```typescript +mulDiv(multiplier: Decimalish, divider: Decimalish): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| multiplier | [Decimalish](./decimal.decimalish.md) | | +| divider | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/decimal.decimal.nonzero.md b/docs/sdk/decimal.decimal.nonzero.md new file mode 100644 index 000000000..21fe612b8 --- /dev/null +++ b/docs/sdk/decimal.decimal.nonzero.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [nonZero](./decimal.decimal.nonzero.md) + +## Decimal.nonZero property + +Signature: + +```typescript +get nonZero(): this | undefined; +``` diff --git a/docs/sdk/decimal.decimal.one.md b/docs/sdk/decimal.decimal.one.md new file mode 100644 index 000000000..b2c0e8a95 --- /dev/null +++ b/docs/sdk/decimal.decimal.one.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [ONE](./decimal.decimal.one.md) + +## Decimal.ONE property + +Signature: + +```typescript +static readonly ONE: Decimal; +``` diff --git a/docs/sdk/decimal.decimal.pow.md b/docs/sdk/decimal.decimal.pow.md new file mode 100644 index 000000000..12111a407 --- /dev/null +++ b/docs/sdk/decimal.decimal.pow.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [pow](./decimal.decimal.pow.md) + +## Decimal.pow() method + +Signature: + +```typescript +pow(exponent: number): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| exponent | number | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/decimal.decimal.precision.md b/docs/sdk/decimal.decimal.precision.md new file mode 100644 index 000000000..9085a2652 --- /dev/null +++ b/docs/sdk/decimal.decimal.precision.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [PRECISION](./decimal.decimal.precision.md) + +## Decimal.PRECISION property + +Signature: + +```typescript +static readonly PRECISION = 18; +``` diff --git a/docs/sdk/decimal.decimal.prettify.md b/docs/sdk/decimal.decimal.prettify.md new file mode 100644 index 000000000..9fdb9367a --- /dev/null +++ b/docs/sdk/decimal.decimal.prettify.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [prettify](./decimal.decimal.prettify.md) + +## Decimal.prettify() method + +Signature: + +```typescript +static prettify(bigNumberish: BigNumberish): string; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| bigNumberish | BigNumberish | | + +Returns: + +string + diff --git a/docs/sdk/decimal.decimal.shorten.md b/docs/sdk/decimal.decimal.shorten.md new file mode 100644 index 000000000..010015430 --- /dev/null +++ b/docs/sdk/decimal.decimal.shorten.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [shorten](./decimal.decimal.shorten.md) + +## Decimal.shorten() method + +Signature: + +```typescript +static shorten(bigNumber: BigNumber): string; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| bigNumber | BigNumber | | + +Returns: + +string + diff --git a/docs/sdk/decimal.decimal.sub.md b/docs/sdk/decimal.decimal.sub.md new file mode 100644 index 000000000..ce7b9fb1e --- /dev/null +++ b/docs/sdk/decimal.decimal.sub.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [sub](./decimal.decimal.sub.md) + +## Decimal.sub() method + +Signature: + +```typescript +sub(subtrahend: Decimalish): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subtrahend | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/decimal.decimal.tostring.md b/docs/sdk/decimal.decimal.tostring.md new file mode 100644 index 000000000..d94c6b177 --- /dev/null +++ b/docs/sdk/decimal.decimal.tostring.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [toString](./decimal.decimal.tostring.md) + +## Decimal.toString() method + +Signature: + +```typescript +toString(precision?: number): string; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| precision | number | | + +Returns: + +string + diff --git a/docs/sdk/decimal.decimal.zero.md b/docs/sdk/decimal.decimal.zero.md new file mode 100644 index 000000000..4b5d91ba5 --- /dev/null +++ b/docs/sdk/decimal.decimal.zero.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimal](./decimal.decimal.md) > [ZERO](./decimal.decimal.zero.md) + +## Decimal.ZERO property + +Signature: + +```typescript +static readonly ZERO: Decimal; +``` diff --git a/docs/sdk/decimal.decimalish.md b/docs/sdk/decimal.decimalish.md new file mode 100644 index 000000000..2007cd0f4 --- /dev/null +++ b/docs/sdk/decimal.decimalish.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) > [Decimalish](./decimal.decimalish.md) + +## Decimalish type + + +Signature: + +```typescript +export declare type Decimalish = Decimal | number | string; +``` +References: [Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/decimal.md b/docs/sdk/decimal.md new file mode 100644 index 000000000..0ab38b5a6 --- /dev/null +++ b/docs/sdk/decimal.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/decimal](./decimal.md) + +## decimal package + +## Classes + +| Class | Description | +| --- | --- | +| [Decimal](./decimal.decimal.md) | | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [Decimalish](./decimal.decimalish.md) | | + diff --git a/docs/sdk/index.md b/docs/sdk/index.md new file mode 100644 index 000000000..cf12e5cd0 --- /dev/null +++ b/docs/sdk/index.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) + +## API Reference + +## Packages + +| Package | Description | +| --- | --- | +| [@liquity/decimal](./decimal.md) | | +| [@liquity/lib-base](./lib-base.md) | | +| [@liquity/lib-ethers](./lib-ethers.md) | | + diff --git a/docs/sdk/lib-base.collateralgaintransferdetails.md b/docs/sdk/lib-base.collateralgaintransferdetails.md new file mode 100644 index 000000000..19388ab0e --- /dev/null +++ b/docs/sdk/lib-base.collateralgaintransferdetails.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [CollateralGainTransferDetails](./lib-base.collateralgaintransferdetails.md) + +## CollateralGainTransferDetails interface + +Signature: + +```typescript +export interface CollateralGainTransferDetails extends StabilityPoolGainsWithdrawalDetails +``` +Extends: [StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [newTrove](./lib-base.collateralgaintransferdetails.newtrove.md) | [Trove](./lib-base.trove.md) | | + diff --git a/docs/sdk/lib-base.collateralgaintransferdetails.newtrove.md b/docs/sdk/lib-base.collateralgaintransferdetails.newtrove.md new file mode 100644 index 000000000..6322c9834 --- /dev/null +++ b/docs/sdk/lib-base.collateralgaintransferdetails.newtrove.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [CollateralGainTransferDetails](./lib-base.collateralgaintransferdetails.md) > [newTrove](./lib-base.collateralgaintransferdetails.newtrove.md) + +## CollateralGainTransferDetails.newTrove property + +Signature: + +```typescript +newTrove: Trove; +``` diff --git a/docs/sdk/lib-base.critical_collateral_ratio.md b/docs/sdk/lib-base.critical_collateral_ratio.md new file mode 100644 index 000000000..a5a85d1e4 --- /dev/null +++ b/docs/sdk/lib-base.critical_collateral_ratio.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [CRITICAL\_COLLATERAL\_RATIO](./lib-base.critical_collateral_ratio.md) + +## CRITICAL\_COLLATERAL\_RATIO variable + +Total collateral ratio below which recovery mode is triggered. + +Signature: + +```typescript +CRITICAL_COLLATERAL_RATIO: Decimal +``` diff --git a/docs/sdk/lib-base.failedreceipt.md b/docs/sdk/lib-base.failedreceipt.md new file mode 100644 index 000000000..ab413028c --- /dev/null +++ b/docs/sdk/lib-base.failedreceipt.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [FailedReceipt](./lib-base.failedreceipt.md) + +## FailedReceipt type + +Signature: + +```typescript +export declare type FailedReceipt = { + status: "failed"; + rawReceipt: R; +}; +``` diff --git a/docs/sdk/lib-base.fees.borrowingfeefactor.md b/docs/sdk/lib-base.fees.borrowingfeefactor.md new file mode 100644 index 000000000..6a21c3f90 --- /dev/null +++ b/docs/sdk/lib-base.fees.borrowingfeefactor.md @@ -0,0 +1,33 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Fees](./lib-base.fees.md) > [borrowingFeeFactor](./lib-base.fees.borrowingfeefactor.md) + +## Fees.borrowingFeeFactor() method + +Calculate the current borrowing fee factor. + +Signature: + +```typescript +borrowingFeeFactor(): Decimal; +``` +Returns: + +[Decimal](./decimal.decimal.md) + +## Remarks + +To calculate the borrowing fee in LUSD, multiply the borrowed LUSD amount with the borrowing fee factor. + +## Example + + +```typescript +const fees = await liquity.getFees(); + +const borrowedLUSDAmount = 100; +const borrowingFeeFactor = fees.borrowingFeeFactor(); +const borrowingFeeLUSD = borrowingFeeFactor.mul(borrowedLUSDAmount); + +``` + diff --git a/docs/sdk/lib-base.fees.equals.md b/docs/sdk/lib-base.fees.equals.md new file mode 100644 index 000000000..1c550a04e --- /dev/null +++ b/docs/sdk/lib-base.fees.equals.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Fees](./lib-base.fees.md) > [equals](./lib-base.fees.equals.md) + +## Fees.equals() method + +Compare to another instance of `Fees`. + +Signature: + +```typescript +equals(that: Fees): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Fees](./lib-base.fees.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/lib-base.fees.md b/docs/sdk/lib-base.fees.md new file mode 100644 index 000000000..22a3f2fa5 --- /dev/null +++ b/docs/sdk/lib-base.fees.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Fees](./lib-base.fees.md) + +## Fees class + +Calculator for fees. + +Signature: + +```typescript +export declare class Fees +``` + +## Remarks + +Returned by the [getFees()](./lib-base.readableliquity.getfees.md) function. + +The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `Fees` class. + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [borrowingFeeFactor()](./lib-base.fees.borrowingfeefactor.md) | | Calculate the current borrowing fee factor. | +| [equals(that)](./lib-base.fees.equals.md) | | Compare to another instance of Fees. | +| [redemptionFeeFactor(redeemedFractionOfSupply)](./lib-base.fees.redemptionfeefactor.md) | | Calculate the current redemption fee factor. | + diff --git a/docs/sdk/lib-base.fees.redemptionfeefactor.md b/docs/sdk/lib-base.fees.redemptionfeefactor.md new file mode 100644 index 000000000..e92fb02a6 --- /dev/null +++ b/docs/sdk/lib-base.fees.redemptionfeefactor.md @@ -0,0 +1,44 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Fees](./lib-base.fees.md) > [redemptionFeeFactor](./lib-base.fees.redemptionfeefactor.md) + +## Fees.redemptionFeeFactor() method + +Calculate the current redemption fee factor. + +Signature: + +```typescript +redemptionFeeFactor(redeemedFractionOfSupply?: Decimalish): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| redeemedFractionOfSupply | [Decimalish](./decimal.decimalish.md) | the amount of LUSD being redeemed divided by the total supply | + +Returns: + +[Decimal](./decimal.decimal.md) + +## Remarks + +Unlike the borrowing fee factor, the redemption fee factor depends on the amount being redeemed. To be more precise, it depends on the fraction of the redeemed amount compared to the total LUSD supply, which must be passed as a parameter. + +To calculate the redemption fee in LUSD, multiply the redeemed LUSD amount with the redemption fee factor. + +## Example + + +```typescript +const fees = await liquity.getFees(); +const total = await liquity.getTotal(); + +const redeemedLUSDAmount = Decimal.from(100); +const redeemedFractionOfSupply = redeemedLUSDAmount.div(total.debt); +const redemptionFeeFactor = fees.redemptionFeeFactor(redeemedFractionOfSupply); +const redemptionFeeLUSD = redemptionFeeFactor.mul(redeemedLUSDAmount); + +``` + diff --git a/docs/sdk/lib-base.frontendstatus.md b/docs/sdk/lib-base.frontendstatus.md new file mode 100644 index 000000000..ff9e0539c --- /dev/null +++ b/docs/sdk/lib-base.frontendstatus.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [FrontendStatus](./lib-base.frontendstatus.md) + +## FrontendStatus type + +Represents whether an address has been registered as a Liquity frontend. + +Signature: + +```typescript +export declare type FrontendStatus = { + status: "unregistered"; +} | { + status: "registered"; + kickbackRate: Decimal; +}; +``` +References: [Decimal](./decimal.decimal.md) + +## Remarks + +Returned by the [getFrontendStatus()](./lib-base.readableliquity.getfrontendstatus.md) function. + +When `status` is `"registered"`, `kickbackRate` gives the frontend's kickback rate as a [Decimal](./decimal.decimal.md) between 0 and 1. + diff --git a/docs/sdk/lib-base.liquidationdetails.collateralgascompensation.md b/docs/sdk/lib-base.liquidationdetails.collateralgascompensation.md new file mode 100644 index 000000000..30e807635 --- /dev/null +++ b/docs/sdk/lib-base.liquidationdetails.collateralgascompensation.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquidationDetails](./lib-base.liquidationdetails.md) > [collateralGasCompensation](./lib-base.liquidationdetails.collateralgascompensation.md) + +## LiquidationDetails.collateralGasCompensation property + +Signature: + +```typescript +collateralGasCompensation: Decimal; +``` diff --git a/docs/sdk/lib-base.liquidationdetails.liquidatedaddresses.md b/docs/sdk/lib-base.liquidationdetails.liquidatedaddresses.md new file mode 100644 index 000000000..53e5dc00b --- /dev/null +++ b/docs/sdk/lib-base.liquidationdetails.liquidatedaddresses.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquidationDetails](./lib-base.liquidationdetails.md) > [liquidatedAddresses](./lib-base.liquidationdetails.liquidatedaddresses.md) + +## LiquidationDetails.liquidatedAddresses property + +Signature: + +```typescript +liquidatedAddresses: string[]; +``` diff --git a/docs/sdk/lib-base.liquidationdetails.lusdgascompensation.md b/docs/sdk/lib-base.liquidationdetails.lusdgascompensation.md new file mode 100644 index 000000000..d2c1efc81 --- /dev/null +++ b/docs/sdk/lib-base.liquidationdetails.lusdgascompensation.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquidationDetails](./lib-base.liquidationdetails.md) > [lusdGasCompensation](./lib-base.liquidationdetails.lusdgascompensation.md) + +## LiquidationDetails.lusdGasCompensation property + +Signature: + +```typescript +lusdGasCompensation: Decimal; +``` diff --git a/docs/sdk/lib-base.liquidationdetails.md b/docs/sdk/lib-base.liquidationdetails.md new file mode 100644 index 000000000..24e081fae --- /dev/null +++ b/docs/sdk/lib-base.liquidationdetails.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquidationDetails](./lib-base.liquidationdetails.md) + +## LiquidationDetails interface + +Signature: + +```typescript +export interface LiquidationDetails +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [collateralGasCompensation](./lib-base.liquidationdetails.collateralgascompensation.md) | [Decimal](./decimal.decimal.md) | | +| [liquidatedAddresses](./lib-base.liquidationdetails.liquidatedaddresses.md) | string\[\] | | +| [lusdGasCompensation](./lib-base.liquidationdetails.lusdgascompensation.md) | [Decimal](./decimal.decimal.md) | | +| [totalLiquidated](./lib-base.liquidationdetails.totalliquidated.md) | [Trove](./lib-base.trove.md) | | + diff --git a/docs/sdk/lib-base.liquidationdetails.totalliquidated.md b/docs/sdk/lib-base.liquidationdetails.totalliquidated.md new file mode 100644 index 000000000..4a87a450f --- /dev/null +++ b/docs/sdk/lib-base.liquidationdetails.totalliquidated.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquidationDetails](./lib-base.liquidationdetails.md) > [totalLiquidated](./lib-base.liquidationdetails.totalliquidated.md) + +## LiquidationDetails.totalLiquidated property + +Signature: + +```typescript +totalLiquidated: Trove; +``` diff --git a/docs/sdk/lib-base.liquityreceipt.md b/docs/sdk/lib-base.liquityreceipt.md new file mode 100644 index 000000000..4432bb672 --- /dev/null +++ b/docs/sdk/lib-base.liquityreceipt.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityReceipt](./lib-base.liquityreceipt.md) + +## LiquityReceipt type + +Signature: + +```typescript +export declare type LiquityReceipt = PendingReceipt | MinedReceipt; +``` +References: [PendingReceipt](./lib-base.pendingreceipt.md), [MinedReceipt](./lib-base.minedreceipt.md) + diff --git a/docs/sdk/lib-base.liquitystore.logging.md b/docs/sdk/lib-base.liquitystore.logging.md new file mode 100644 index 000000000..5e7ba84df --- /dev/null +++ b/docs/sdk/lib-base.liquitystore.logging.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStore](./lib-base.liquitystore.md) > [logging](./lib-base.liquitystore.logging.md) + +## LiquityStore.logging property + +Turn console logging on/off. + +Signature: + +```typescript +logging: boolean; +``` diff --git a/docs/sdk/lib-base.liquitystore.md b/docs/sdk/lib-base.liquitystore.md new file mode 100644 index 000000000..bec1752cc --- /dev/null +++ b/docs/sdk/lib-base.liquitystore.md @@ -0,0 +1,35 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStore](./lib-base.liquitystore.md) + +## LiquityStore class + +Abstract base class of Liquity data store implementations. + +Signature: + +```typescript +export declare abstract class LiquityStore +``` + +## Remarks + +The type parameter `T` may be used to type extra state added to [LiquityStoreState](./lib-base.liquitystorestate.md) by the subclass. + +Currently, the only implementation is [BlockPolledLiquityStore](./lib-ethers.blockpolledliquitystore.md). + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [logging](./lib-base.liquitystore.logging.md) | | boolean | Turn console logging on/off. | +| [onLoaded?](./lib-base.liquitystore.onloaded.md) | | () => void | (Optional) Called after the state is fetched for the first time. | +| [state](./lib-base.liquitystore.state.md) | | [LiquityStoreState](./lib-base.liquitystorestate.md)<T> | The current store state. | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [start()](./lib-base.liquitystore.start.md) | | Start monitoring the blockchain for Liquity state changes. | +| [subscribe(listener)](./lib-base.liquitystore.subscribe.md) | | Register a state change listener. | + diff --git a/docs/sdk/lib-base.liquitystore.onloaded.md b/docs/sdk/lib-base.liquitystore.onloaded.md new file mode 100644 index 000000000..e659e722f --- /dev/null +++ b/docs/sdk/lib-base.liquitystore.onloaded.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStore](./lib-base.liquitystore.md) > [onLoaded](./lib-base.liquitystore.onloaded.md) + +## LiquityStore.onLoaded property + +Called after the state is fetched for the first time. + +Signature: + +```typescript +onLoaded?: () => void; +``` + +## Remarks + +See [start()](./lib-base.liquitystore.start.md). + diff --git a/docs/sdk/lib-base.liquitystore.start.md b/docs/sdk/lib-base.liquitystore.start.md new file mode 100644 index 000000000..9598fabed --- /dev/null +++ b/docs/sdk/lib-base.liquitystore.start.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStore](./lib-base.liquitystore.md) > [start](./lib-base.liquitystore.start.md) + +## LiquityStore.start() method + +Start monitoring the blockchain for Liquity state changes. + +Signature: + +```typescript +start(): () => void; +``` +Returns: + +() => void + +Function to stop the monitoring. + +## Remarks + +The [onLoaded](./lib-base.liquitystore.onloaded.md) callback will be called after the state is fetched for the first time. + +Use the [subscribe()](./lib-base.liquitystore.subscribe.md) function to register listeners. + diff --git a/docs/sdk/lib-base.liquitystore.state.md b/docs/sdk/lib-base.liquitystore.state.md new file mode 100644 index 000000000..35ba58f51 --- /dev/null +++ b/docs/sdk/lib-base.liquitystore.state.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStore](./lib-base.liquitystore.md) > [state](./lib-base.liquitystore.state.md) + +## LiquityStore.state property + +The current store state. + +Signature: + +```typescript +get state(): LiquityStoreState; +``` + +## Remarks + +Should not be accessed before the store is loaded. Assign a function to [onLoaded](./lib-base.liquitystore.onloaded.md) to get a callback when this happens. + +See [LiquityStoreState](./lib-base.liquitystorestate.md) for the list of properties returned. + diff --git a/docs/sdk/lib-base.liquitystore.subscribe.md b/docs/sdk/lib-base.liquitystore.subscribe.md new file mode 100644 index 000000000..e8e7bcebc --- /dev/null +++ b/docs/sdk/lib-base.liquitystore.subscribe.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStore](./lib-base.liquitystore.md) > [subscribe](./lib-base.liquitystore.subscribe.md) + +## LiquityStore.subscribe() method + +Register a state change listener. + +Signature: + +```typescript +subscribe(listener: (params: LiquityStoreListenerParams) => void): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| listener | (params: [LiquityStoreListenerParams](./lib-base.liquitystorelistenerparams.md)<T>) => void | Function that will be called whenever state changes. | + +Returns: + +() => void + +Function to unregister this listener. + diff --git a/docs/sdk/lib-base.liquitystorebasestate.accountbalance.md b/docs/sdk/lib-base.liquitystorebasestate.accountbalance.md new file mode 100644 index 000000000..dd518f022 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.accountbalance.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [accountBalance](./lib-base.liquitystorebasestate.accountbalance.md) + +## LiquityStoreBaseState.accountBalance property + +User's native currency balance (e.g. Ether). + +Signature: + +```typescript +accountBalance: Decimal; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.collateralsurplusbalance.md b/docs/sdk/lib-base.liquitystorebasestate.collateralsurplusbalance.md new file mode 100644 index 000000000..c5df60feb --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.collateralsurplusbalance.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [collateralSurplusBalance](./lib-base.liquitystorebasestate.collateralsurplusbalance.md) + +## LiquityStoreBaseState.collateralSurplusBalance property + +Amount of leftover collateral available for withdrawal to the user. + +Signature: + +```typescript +collateralSurplusBalance: Decimal; +``` + +## Remarks + +When the user's Trove gets liquidated or redeemed, any collateral they have above 110% (in case of liquidation) or 100% collateralization (in case of redemption) gets sent to a pool, where it can be withdrawn from using [claimCollateralSurplus()](./lib-base.transactableliquity.claimcollateralsurplus.md). + diff --git a/docs/sdk/lib-base.liquitystorebasestate.deposit.md b/docs/sdk/lib-base.liquitystorebasestate.deposit.md new file mode 100644 index 000000000..fee002a7f --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.deposit.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [deposit](./lib-base.liquitystorebasestate.deposit.md) + +## LiquityStoreBaseState.deposit property + +User's stability deposit. + +Signature: + +```typescript +deposit: StabilityDeposit; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.fees.md b/docs/sdk/lib-base.liquitystorebasestate.fees.md new file mode 100644 index 000000000..3369d4678 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.fees.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [fees](./lib-base.liquitystorebasestate.fees.md) + +## LiquityStoreBaseState.fees property + +Calculator for current fees. + +Signature: + +```typescript +fees: Fees; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.frontend.md b/docs/sdk/lib-base.liquitystorebasestate.frontend.md new file mode 100644 index 000000000..d82984ecd --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.frontend.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [frontend](./lib-base.liquitystorebasestate.frontend.md) + +## LiquityStoreBaseState.frontend property + +Status of currently used frontend. + +Signature: + +```typescript +frontend: FrontendStatus; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.lqtybalance.md b/docs/sdk/lib-base.liquitystorebasestate.lqtybalance.md new file mode 100644 index 000000000..aff22825d --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.lqtybalance.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [lqtyBalance](./lib-base.liquitystorebasestate.lqtybalance.md) + +## LiquityStoreBaseState.lqtyBalance property + +User's LQTY token balance. + +Signature: + +```typescript +lqtyBalance: Decimal; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.lqtystake.md b/docs/sdk/lib-base.liquitystorebasestate.lqtystake.md new file mode 100644 index 000000000..f93476d4f --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.lqtystake.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [lqtyStake](./lib-base.liquitystorebasestate.lqtystake.md) + +## LiquityStoreBaseState.lqtyStake property + +User's LQTY stake. + +Signature: + +```typescript +lqtyStake: LQTYStake; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.lusdbalance.md b/docs/sdk/lib-base.liquitystorebasestate.lusdbalance.md new file mode 100644 index 000000000..da831e0a5 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.lusdbalance.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [lusdBalance](./lib-base.liquitystorebasestate.lusdbalance.md) + +## LiquityStoreBaseState.lusdBalance property + +User's LUSD token balance. + +Signature: + +```typescript +lusdBalance: Decimal; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.lusdinstabilitypool.md b/docs/sdk/lib-base.liquitystorebasestate.lusdinstabilitypool.md new file mode 100644 index 000000000..6a05b0f38 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.lusdinstabilitypool.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [lusdInStabilityPool](./lib-base.liquitystorebasestate.lusdinstabilitypool.md) + +## LiquityStoreBaseState.lusdInStabilityPool property + +Total amount of LUSD currently deposited in the Stability Pool. + +Signature: + +```typescript +lusdInStabilityPool: Decimal; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.md b/docs/sdk/lib-base.liquitystorebasestate.md new file mode 100644 index 000000000..59bd61d24 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.md @@ -0,0 +1,35 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) + +## LiquityStoreBaseState interface + +State variables read from the blockchain. + +Signature: + +```typescript +export interface LiquityStoreBaseState +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [accountBalance](./lib-base.liquitystorebasestate.accountbalance.md) | [Decimal](./decimal.decimal.md) | User's native currency balance (e.g. Ether). | +| [collateralSurplusBalance](./lib-base.liquitystorebasestate.collateralsurplusbalance.md) | [Decimal](./decimal.decimal.md) | Amount of leftover collateral available for withdrawal to the user. | +| [deposit](./lib-base.liquitystorebasestate.deposit.md) | [StabilityDeposit](./lib-base.stabilitydeposit.md) | User's stability deposit. | +| [fees](./lib-base.liquitystorebasestate.fees.md) | [Fees](./lib-base.fees.md) | Calculator for current fees. | +| [frontend](./lib-base.liquitystorebasestate.frontend.md) | [FrontendStatus](./lib-base.frontendstatus.md) | Status of currently used frontend. | +| [lqtyBalance](./lib-base.liquitystorebasestate.lqtybalance.md) | [Decimal](./decimal.decimal.md) | User's LQTY token balance. | +| [lqtyStake](./lib-base.liquitystorebasestate.lqtystake.md) | [LQTYStake](./lib-base.lqtystake.md) | User's LQTY stake. | +| [lusdBalance](./lib-base.liquitystorebasestate.lusdbalance.md) | [Decimal](./decimal.decimal.md) | User's LUSD token balance. | +| [lusdInStabilityPool](./lib-base.liquitystorebasestate.lusdinstabilitypool.md) | [Decimal](./decimal.decimal.md) | Total amount of LUSD currently deposited in the Stability Pool. | +| [numberOfTroves](./lib-base.liquitystorebasestate.numberoftroves.md) | number | Number of Troves that are currently open. | +| [ownFrontend](./lib-base.liquitystorebasestate.ownfrontend.md) | [FrontendStatus](./lib-base.frontendstatus.md) | Status of user's own frontend. | +| [price](./lib-base.liquitystorebasestate.price.md) | [Decimal](./decimal.decimal.md) | Current price of the native currency (e.g. Ether) in USD. | +| [total](./lib-base.liquitystorebasestate.total.md) | [Trove](./lib-base.trove.md) | Total collateral and debt in the Liquity system. | +| [totalRedistributed](./lib-base.liquitystorebasestate.totalredistributed.md) | [Trove](./lib-base.trove.md) | Total collateral and debt per stake that has been liquidated through redistribution. | +| [totalStakedLQTY](./lib-base.liquitystorebasestate.totalstakedlqty.md) | [Decimal](./decimal.decimal.md) | Total amount of LQTY currently staked. | +| [troveWithoutRewards](./lib-base.liquitystorebasestate.trovewithoutrewards.md) | [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) | User's Trove in its state after the last direct modification. | + diff --git a/docs/sdk/lib-base.liquitystorebasestate.numberoftroves.md b/docs/sdk/lib-base.liquitystorebasestate.numberoftroves.md new file mode 100644 index 000000000..85ff24b77 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.numberoftroves.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [numberOfTroves](./lib-base.liquitystorebasestate.numberoftroves.md) + +## LiquityStoreBaseState.numberOfTroves property + +Number of Troves that are currently open. + +Signature: + +```typescript +numberOfTroves: number; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.ownfrontend.md b/docs/sdk/lib-base.liquitystorebasestate.ownfrontend.md new file mode 100644 index 000000000..28fec13f6 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.ownfrontend.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [ownFrontend](./lib-base.liquitystorebasestate.ownfrontend.md) + +## LiquityStoreBaseState.ownFrontend property + +Status of user's own frontend. + +Signature: + +```typescript +ownFrontend: FrontendStatus; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.price.md b/docs/sdk/lib-base.liquitystorebasestate.price.md new file mode 100644 index 000000000..a04bdbafc --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.price.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [price](./lib-base.liquitystorebasestate.price.md) + +## LiquityStoreBaseState.price property + +Current price of the native currency (e.g. Ether) in USD. + +Signature: + +```typescript +price: Decimal; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.total.md b/docs/sdk/lib-base.liquitystorebasestate.total.md new file mode 100644 index 000000000..93871667b --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.total.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [total](./lib-base.liquitystorebasestate.total.md) + +## LiquityStoreBaseState.total property + +Total collateral and debt in the Liquity system. + +Signature: + +```typescript +total: Trove; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.totalredistributed.md b/docs/sdk/lib-base.liquitystorebasestate.totalredistributed.md new file mode 100644 index 000000000..a1ef83cbf --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.totalredistributed.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [totalRedistributed](./lib-base.liquitystorebasestate.totalredistributed.md) + +## LiquityStoreBaseState.totalRedistributed property + +Total collateral and debt per stake that has been liquidated through redistribution. + +Signature: + +```typescript +totalRedistributed: Trove; +``` + +## Remarks + +Needed when dealing with instances of [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md). + diff --git a/docs/sdk/lib-base.liquitystorebasestate.totalstakedlqty.md b/docs/sdk/lib-base.liquitystorebasestate.totalstakedlqty.md new file mode 100644 index 000000000..89d044f47 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.totalstakedlqty.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [totalStakedLQTY](./lib-base.liquitystorebasestate.totalstakedlqty.md) + +## LiquityStoreBaseState.totalStakedLQTY property + +Total amount of LQTY currently staked. + +Signature: + +```typescript +totalStakedLQTY: Decimal; +``` diff --git a/docs/sdk/lib-base.liquitystorebasestate.trovewithoutrewards.md b/docs/sdk/lib-base.liquitystorebasestate.trovewithoutrewards.md new file mode 100644 index 000000000..22e4f4dea --- /dev/null +++ b/docs/sdk/lib-base.liquitystorebasestate.trovewithoutrewards.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) > [troveWithoutRewards](./lib-base.liquitystorebasestate.trovewithoutrewards.md) + +## LiquityStoreBaseState.troveWithoutRewards property + +User's Trove in its state after the last direct modification. + +Signature: + +```typescript +troveWithoutRewards: TroveWithPendingRewards; +``` + +## Remarks + +The current state of the user's Trove can be found as [trove](./lib-base.liquitystorederivedstate.trove.md). + diff --git a/docs/sdk/lib-base.liquitystorederivedstate.borrowingfeefactor.md b/docs/sdk/lib-base.liquitystorederivedstate.borrowingfeefactor.md new file mode 100644 index 000000000..e0489c60a --- /dev/null +++ b/docs/sdk/lib-base.liquitystorederivedstate.borrowingfeefactor.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreDerivedState](./lib-base.liquitystorederivedstate.md) > [borrowingFeeFactor](./lib-base.liquitystorederivedstate.borrowingfeefactor.md) + +## LiquityStoreDerivedState.borrowingFeeFactor property + +Current borrowing fee factor. + +Signature: + +```typescript +borrowingFeeFactor: Decimal; +``` diff --git a/docs/sdk/lib-base.liquitystorederivedstate.md b/docs/sdk/lib-base.liquitystorederivedstate.md new file mode 100644 index 000000000..a08a8c567 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorederivedstate.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreDerivedState](./lib-base.liquitystorederivedstate.md) + +## LiquityStoreDerivedState interface + +State variables derived from [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md). + +Signature: + +```typescript +export interface LiquityStoreDerivedState +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [borrowingFeeFactor](./lib-base.liquitystorederivedstate.borrowingfeefactor.md) | [Decimal](./decimal.decimal.md) | Current borrowing fee factor. | +| [redemptionFeeFactor](./lib-base.liquitystorederivedstate.redemptionfeefactor.md) | [Decimal](./decimal.decimal.md) | Current redemption fee factor. | +| [trove](./lib-base.liquitystorederivedstate.trove.md) | [Trove](./lib-base.trove.md) | Current state of user's Trove | + diff --git a/docs/sdk/lib-base.liquitystorederivedstate.redemptionfeefactor.md b/docs/sdk/lib-base.liquitystorederivedstate.redemptionfeefactor.md new file mode 100644 index 000000000..6ab4845f0 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorederivedstate.redemptionfeefactor.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreDerivedState](./lib-base.liquitystorederivedstate.md) > [redemptionFeeFactor](./lib-base.liquitystorederivedstate.redemptionfeefactor.md) + +## LiquityStoreDerivedState.redemptionFeeFactor property + +Current redemption fee factor. + +Signature: + +```typescript +redemptionFeeFactor: Decimal; +``` + +## Remarks + +Note that the actual redemption fee will depend on the amount of LUSD being redeemed. + +Use [Fees.redemptionFeeFactor()](./lib-base.fees.redemptionfeefactor.md) to calculate a precise redemption fee factor. + diff --git a/docs/sdk/lib-base.liquitystorederivedstate.trove.md b/docs/sdk/lib-base.liquitystorederivedstate.trove.md new file mode 100644 index 000000000..2fafd5c96 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorederivedstate.trove.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreDerivedState](./lib-base.liquitystorederivedstate.md) > [trove](./lib-base.liquitystorederivedstate.trove.md) + +## LiquityStoreDerivedState.trove property + +Current state of user's Trove + +Signature: + +```typescript +trove: Trove; +``` diff --git a/docs/sdk/lib-base.liquitystorelistenerparams.md b/docs/sdk/lib-base.liquitystorelistenerparams.md new file mode 100644 index 000000000..a7c7e8807 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorelistenerparams.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreListenerParams](./lib-base.liquitystorelistenerparams.md) + +## LiquityStoreListenerParams interface + +Parameters passed to [LiquityStore](./lib-base.liquitystore.md) listeners. + +Signature: + +```typescript +export interface LiquityStoreListenerParams +``` + +## Remarks + +Use the [subscribe()](./lib-base.liquitystore.subscribe.md) function to register a listener. + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [newState](./lib-base.liquitystorelistenerparams.newstate.md) | [LiquityStoreState](./lib-base.liquitystorestate.md)<T> | The entire previous state. | +| [oldState](./lib-base.liquitystorelistenerparams.oldstate.md) | [LiquityStoreState](./lib-base.liquitystorestate.md)<T> | The entire new state. | +| [stateChange](./lib-base.liquitystorelistenerparams.statechange.md) | Partial<[LiquityStoreState](./lib-base.liquitystorestate.md)<T>> | Only the state variables that have changed. | + diff --git a/docs/sdk/lib-base.liquitystorelistenerparams.newstate.md b/docs/sdk/lib-base.liquitystorelistenerparams.newstate.md new file mode 100644 index 000000000..d15e7a19d --- /dev/null +++ b/docs/sdk/lib-base.liquitystorelistenerparams.newstate.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreListenerParams](./lib-base.liquitystorelistenerparams.md) > [newState](./lib-base.liquitystorelistenerparams.newstate.md) + +## LiquityStoreListenerParams.newState property + +The entire previous state. + +Signature: + +```typescript +newState: LiquityStoreState; +``` diff --git a/docs/sdk/lib-base.liquitystorelistenerparams.oldstate.md b/docs/sdk/lib-base.liquitystorelistenerparams.oldstate.md new file mode 100644 index 000000000..caf4c4b4c --- /dev/null +++ b/docs/sdk/lib-base.liquitystorelistenerparams.oldstate.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreListenerParams](./lib-base.liquitystorelistenerparams.md) > [oldState](./lib-base.liquitystorelistenerparams.oldstate.md) + +## LiquityStoreListenerParams.oldState property + +The entire new state. + +Signature: + +```typescript +oldState: LiquityStoreState; +``` diff --git a/docs/sdk/lib-base.liquitystorelistenerparams.statechange.md b/docs/sdk/lib-base.liquitystorelistenerparams.statechange.md new file mode 100644 index 000000000..3408cc43c --- /dev/null +++ b/docs/sdk/lib-base.liquitystorelistenerparams.statechange.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreListenerParams](./lib-base.liquitystorelistenerparams.md) > [stateChange](./lib-base.liquitystorelistenerparams.statechange.md) + +## LiquityStoreListenerParams.stateChange property + +Only the state variables that have changed. + +Signature: + +```typescript +stateChange: Partial>; +``` diff --git a/docs/sdk/lib-base.liquitystorestate.md b/docs/sdk/lib-base.liquitystorestate.md new file mode 100644 index 000000000..2057ae022 --- /dev/null +++ b/docs/sdk/lib-base.liquitystorestate.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LiquityStoreState](./lib-base.liquitystorestate.md) + +## LiquityStoreState type + +Type of [LiquityStore](./lib-base.liquitystore.md)'s [state](./lib-base.liquitystore.state.md). + +Signature: + +```typescript +export declare type LiquityStoreState = LiquityStoreBaseState & LiquityStoreDerivedState & T; +``` +References: [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md), [LiquityStoreDerivedState](./lib-base.liquitystorederivedstate.md) + +## Remarks + +It combines all properties of [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) and [LiquityStoreDerivedState](./lib-base.liquitystorederivedstate.md) with optional extra state added by the particular `LiquityStore` implementation. + +The type parameter `T` may be used to type the extra state. + diff --git a/docs/sdk/lib-base.lqtystake.apply.md b/docs/sdk/lib-base.lqtystake.apply.md new file mode 100644 index 000000000..46a798b92 --- /dev/null +++ b/docs/sdk/lib-base.lqtystake.apply.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStake](./lib-base.lqtystake.md) > [apply](./lib-base.lqtystake.apply.md) + +## LQTYStake.apply() method + +Apply a stake change to this `LQTYStake`. + +Signature: + +```typescript +apply(change: LQTYStakeChange | undefined): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| change | [LQTYStakeChange](./lib-base.lqtystakechange.md)<[Decimalish](./decimal.decimalish.md)> \| undefined | | + +Returns: + +[Decimal](./decimal.decimal.md) + +The new staked LQTY amount. + diff --git a/docs/sdk/lib-base.lqtystake.collateralgain.md b/docs/sdk/lib-base.lqtystake.collateralgain.md new file mode 100644 index 000000000..2fdfcc82e --- /dev/null +++ b/docs/sdk/lib-base.lqtystake.collateralgain.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStake](./lib-base.lqtystake.md) > [collateralGain](./lib-base.lqtystake.collateralgain.md) + +## LQTYStake.collateralGain property + +Collateral gain available to withdraw. + +Signature: + +```typescript +readonly collateralGain: Decimal; +``` diff --git a/docs/sdk/lib-base.lqtystake.equals.md b/docs/sdk/lib-base.lqtystake.equals.md new file mode 100644 index 000000000..1c83912df --- /dev/null +++ b/docs/sdk/lib-base.lqtystake.equals.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStake](./lib-base.lqtystake.md) > [equals](./lib-base.lqtystake.equals.md) + +## LQTYStake.equals() method + +Compare to another instance of `LQTYStake`. + +Signature: + +```typescript +equals(that: LQTYStake): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [LQTYStake](./lib-base.lqtystake.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/lib-base.lqtystake.isempty.md b/docs/sdk/lib-base.lqtystake.isempty.md new file mode 100644 index 000000000..174b0a10c --- /dev/null +++ b/docs/sdk/lib-base.lqtystake.isempty.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStake](./lib-base.lqtystake.md) > [isEmpty](./lib-base.lqtystake.isempty.md) + +## LQTYStake.isEmpty property + +Signature: + +```typescript +get isEmpty(): boolean; +``` diff --git a/docs/sdk/lib-base.lqtystake.lusdgain.md b/docs/sdk/lib-base.lqtystake.lusdgain.md new file mode 100644 index 000000000..512c3c29b --- /dev/null +++ b/docs/sdk/lib-base.lqtystake.lusdgain.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStake](./lib-base.lqtystake.md) > [lusdGain](./lib-base.lqtystake.lusdgain.md) + +## LQTYStake.lusdGain property + +LUSD gain available to withdraw. + +Signature: + +```typescript +readonly lusdGain: Decimal; +``` diff --git a/docs/sdk/lib-base.lqtystake.md b/docs/sdk/lib-base.lqtystake.md new file mode 100644 index 000000000..5de594075 --- /dev/null +++ b/docs/sdk/lib-base.lqtystake.md @@ -0,0 +1,37 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStake](./lib-base.lqtystake.md) + +## LQTYStake class + +Represents a user's LQTY stake and accrued gains. + +Signature: + +```typescript +export declare class LQTYStake +``` + +## Remarks + +Returned by the [getLQTYStake()](./lib-base.readableliquity.getlqtystake.md) function. + +The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `LQTYStake` class. + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [collateralGain](./lib-base.lqtystake.collateralgain.md) | | [Decimal](./decimal.decimal.md) | Collateral gain available to withdraw. | +| [isEmpty](./lib-base.lqtystake.isempty.md) | | boolean | | +| [lusdGain](./lib-base.lqtystake.lusdgain.md) | | [Decimal](./decimal.decimal.md) | LUSD gain available to withdraw. | +| [stakedLQTY](./lib-base.lqtystake.stakedlqty.md) | | [Decimal](./decimal.decimal.md) | The amount of LQTY that's staked. | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [apply(change)](./lib-base.lqtystake.apply.md) | | Apply a stake change to this LQTYStake. | +| [equals(that)](./lib-base.lqtystake.equals.md) | | Compare to another instance of LQTYStake. | +| [whatChanged(thatStakedLQTY)](./lib-base.lqtystake.whatchanged.md) | | Calculate the difference between this LQTYStake and thatStakedLQTY. | + diff --git a/docs/sdk/lib-base.lqtystake.stakedlqty.md b/docs/sdk/lib-base.lqtystake.stakedlqty.md new file mode 100644 index 000000000..11e8c01f6 --- /dev/null +++ b/docs/sdk/lib-base.lqtystake.stakedlqty.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStake](./lib-base.lqtystake.md) > [stakedLQTY](./lib-base.lqtystake.stakedlqty.md) + +## LQTYStake.stakedLQTY property + +The amount of LQTY that's staked. + +Signature: + +```typescript +readonly stakedLQTY: Decimal; +``` diff --git a/docs/sdk/lib-base.lqtystake.whatchanged.md b/docs/sdk/lib-base.lqtystake.whatchanged.md new file mode 100644 index 000000000..a22e5a562 --- /dev/null +++ b/docs/sdk/lib-base.lqtystake.whatchanged.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStake](./lib-base.lqtystake.md) > [whatChanged](./lib-base.lqtystake.whatchanged.md) + +## LQTYStake.whatChanged() method + +Calculate the difference between this `LQTYStake` and `thatStakedLQTY`. + +Signature: + +```typescript +whatChanged(thatStakedLQTY: Decimalish): LQTYStakeChange | undefined; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| thatStakedLQTY | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[LQTYStakeChange](./lib-base.lqtystakechange.md)<[Decimal](./decimal.decimal.md)> \| undefined + diff --git a/docs/sdk/lib-base.lqtystakechange.md b/docs/sdk/lib-base.lqtystakechange.md new file mode 100644 index 000000000..39c6ee9ca --- /dev/null +++ b/docs/sdk/lib-base.lqtystakechange.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LQTYStakeChange](./lib-base.lqtystakechange.md) + +## LQTYStakeChange type + + +Signature: + +```typescript +export declare type LQTYStakeChange = { + stakeLQTY: T; + unstakeLQTY?: undefined; +} | { + stakeLQTY?: undefined; + unstakeLQTY: T; + unstakeAllLQTY: boolean; +}; +``` diff --git a/docs/sdk/lib-base.lusd_liquidation_reserve.md b/docs/sdk/lib-base.lusd_liquidation_reserve.md new file mode 100644 index 000000000..a06cd2d1e --- /dev/null +++ b/docs/sdk/lib-base.lusd_liquidation_reserve.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [LUSD\_LIQUIDATION\_RESERVE](./lib-base.lusd_liquidation_reserve.md) + +## LUSD\_LIQUIDATION\_RESERVE variable + +Amount of LUSD that's reserved for compensating the liquidator of a Trove. + +Signature: + +```typescript +LUSD_LIQUIDATION_RESERVE: Decimal +``` diff --git a/docs/sdk/lib-base.md b/docs/sdk/lib-base.md new file mode 100644 index 000000000..a4b44f41b --- /dev/null +++ b/docs/sdk/lib-base.md @@ -0,0 +1,64 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) + +## lib-base package + +## Classes + +| Class | Description | +| --- | --- | +| [Fees](./lib-base.fees.md) | Calculator for fees. | +| [LiquityStore](./lib-base.liquitystore.md) | Abstract base class of Liquity data store implementations. | +| [LQTYStake](./lib-base.lqtystake.md) | Represents a user's LQTY stake and accrued gains. | +| [StabilityDeposit](./lib-base.stabilitydeposit.md) | | +| [Trove](./lib-base.trove.md) | | +| [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) | | + +## Interfaces + +| Interface | Description | +| --- | --- | +| [CollateralGainTransferDetails](./lib-base.collateralgaintransferdetails.md) | | +| [LiquidationDetails](./lib-base.liquidationdetails.md) | | +| [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md) | State variables read from the blockchain. | +| [LiquityStoreDerivedState](./lib-base.liquitystorederivedstate.md) | State variables derived from [LiquityStoreBaseState](./lib-base.liquitystorebasestate.md). | +| [LiquityStoreListenerParams](./lib-base.liquitystorelistenerparams.md) | Parameters passed to [LiquityStore](./lib-base.liquitystore.md) listeners. | +| [PopulatedLiquityTransaction](./lib-base.populatedliquitytransaction.md) | | +| [ReadableLiquity](./lib-base.readableliquity.md) | | +| [RedemptionDetails](./lib-base.redemptiondetails.md) | | +| [SentLiquityTransaction](./lib-base.sentliquitytransaction.md) | | +| [StabilityDepositChangeDetails](./lib-base.stabilitydepositchangedetails.md) | | +| [StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md) | | +| [TransactableLiquity](./lib-base.transactableliquity.md) | | +| [TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md) | | +| [TroveClosureDetails](./lib-base.troveclosuredetails.md) | | +| [TroveCreationDetails](./lib-base.trovecreationdetails.md) | | + +## Variables + +| Variable | Description | +| --- | --- | +| [CRITICAL\_COLLATERAL\_RATIO](./lib-base.critical_collateral_ratio.md) | Total collateral ratio below which recovery mode is triggered. | +| [LUSD\_LIQUIDATION\_RESERVE](./lib-base.lusd_liquidation_reserve.md) | Amount of LUSD that's reserved for compensating the liquidator of a Trove. | +| [MINIMUM\_COLLATERAL\_RATIO](./lib-base.minimum_collateral_ratio.md) | Collateral ratio below which a Trove can be liquidated in normal mode. | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [FailedReceipt](./lib-base.failedreceipt.md) | | +| [FrontendStatus](./lib-base.frontendstatus.md) | Represents whether an address has been registered as a Liquity frontend. | +| [LiquityReceipt](./lib-base.liquityreceipt.md) | | +| [LiquityStoreState](./lib-base.liquitystorestate.md) | Type of [LiquityStore](./lib-base.liquitystore.md)'s [state](./lib-base.liquitystore.state.md). | +| [LQTYStakeChange](./lib-base.lqtystakechange.md) | | +| [MinedReceipt](./lib-base.minedreceipt.md) | | +| [PendingReceipt](./lib-base.pendingreceipt.md) | | +| [StabilityDepositChange](./lib-base.stabilitydepositchange.md) | | +| [SuccessfulReceipt](./lib-base.successfulreceipt.md) | | +| [TroveAdjustmentParams](./lib-base.troveadjustmentparams.md) | Parameters of Trove adjustment. | +| [TroveChange](./lib-base.trovechange.md) | Represents the change from one Trove to another. | +| [TroveClosureParams](./lib-base.troveclosureparams.md) | Parameters of Trove closure. | +| [TroveCreationError](./lib-base.trovecreationerror.md) | Describes why a Trove could not be created. | +| [TroveCreationParams](./lib-base.trovecreationparams.md) | Parameters of Trove creation. | + diff --git a/docs/sdk/lib-base.minedreceipt.md b/docs/sdk/lib-base.minedreceipt.md new file mode 100644 index 000000000..2ff0b29ca --- /dev/null +++ b/docs/sdk/lib-base.minedreceipt.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [MinedReceipt](./lib-base.minedreceipt.md) + +## MinedReceipt type + +Signature: + +```typescript +export declare type MinedReceipt = FailedReceipt | SuccessfulReceipt; +``` +References: [FailedReceipt](./lib-base.failedreceipt.md), [SuccessfulReceipt](./lib-base.successfulreceipt.md) + diff --git a/docs/sdk/lib-base.minimum_collateral_ratio.md b/docs/sdk/lib-base.minimum_collateral_ratio.md new file mode 100644 index 000000000..f885ac00c --- /dev/null +++ b/docs/sdk/lib-base.minimum_collateral_ratio.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [MINIMUM\_COLLATERAL\_RATIO](./lib-base.minimum_collateral_ratio.md) + +## MINIMUM\_COLLATERAL\_RATIO variable + +Collateral ratio below which a Trove can be liquidated in normal mode. + +Signature: + +```typescript +MINIMUM_COLLATERAL_RATIO: Decimal +``` diff --git a/docs/sdk/lib-base.pendingreceipt.md b/docs/sdk/lib-base.pendingreceipt.md new file mode 100644 index 000000000..c2afbff51 --- /dev/null +++ b/docs/sdk/lib-base.pendingreceipt.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [PendingReceipt](./lib-base.pendingreceipt.md) + +## PendingReceipt type + +Signature: + +```typescript +export declare type PendingReceipt = { + status: "pending"; +}; +``` diff --git a/docs/sdk/lib-base.populatedliquitytransaction.md b/docs/sdk/lib-base.populatedliquitytransaction.md new file mode 100644 index 000000000..045c54d87 --- /dev/null +++ b/docs/sdk/lib-base.populatedliquitytransaction.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [PopulatedLiquityTransaction](./lib-base.populatedliquitytransaction.md) + +## PopulatedLiquityTransaction interface + +Signature: + +```typescript +export interface PopulatedLiquityTransaction

+``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [rawPopulatedTransaction](./lib-base.populatedliquitytransaction.rawpopulatedtransaction.md) | P | | + +## Methods + +| Method | Description | +| --- | --- | +| [send()](./lib-base.populatedliquitytransaction.send.md) | | + diff --git a/docs/sdk/lib-base.populatedliquitytransaction.rawpopulatedtransaction.md b/docs/sdk/lib-base.populatedliquitytransaction.rawpopulatedtransaction.md new file mode 100644 index 000000000..1efc8ee1a --- /dev/null +++ b/docs/sdk/lib-base.populatedliquitytransaction.rawpopulatedtransaction.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [PopulatedLiquityTransaction](./lib-base.populatedliquitytransaction.md) > [rawPopulatedTransaction](./lib-base.populatedliquitytransaction.rawpopulatedtransaction.md) + +## PopulatedLiquityTransaction.rawPopulatedTransaction property + +Signature: + +```typescript +rawPopulatedTransaction: P; +``` diff --git a/docs/sdk/lib-base.populatedliquitytransaction.send.md b/docs/sdk/lib-base.populatedliquitytransaction.send.md new file mode 100644 index 000000000..1080670ec --- /dev/null +++ b/docs/sdk/lib-base.populatedliquitytransaction.send.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [PopulatedLiquityTransaction](./lib-base.populatedliquitytransaction.md) > [send](./lib-base.populatedliquitytransaction.send.md) + +## PopulatedLiquityTransaction.send() method + +Signature: + +```typescript +send(): Promise; +``` +Returns: + +Promise<T> + diff --git a/docs/sdk/lib-base.readableliquity.getcollateralsurplusbalance.md b/docs/sdk/lib-base.readableliquity.getcollateralsurplusbalance.md new file mode 100644 index 000000000..3399c8d9e --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getcollateralsurplusbalance.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getCollateralSurplusBalance](./lib-base.readableliquity.getcollateralsurplusbalance.md) + +## ReadableLiquity.getCollateralSurplusBalance() method + +Signature: + +```typescript +getCollateralSurplusBalance(address?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-base.readableliquity.getfees.md b/docs/sdk/lib-base.readableliquity.getfees.md new file mode 100644 index 000000000..49bb615b9 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getfees.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getFees](./lib-base.readableliquity.getfees.md) + +## ReadableLiquity.getFees() method + +Signature: + +```typescript +getFees(): Promise; +``` +Returns: + +Promise<[Fees](./lib-base.fees.md)> + diff --git a/docs/sdk/lib-base.readableliquity.getfirsttroves.md b/docs/sdk/lib-base.readableliquity.getfirsttroves.md new file mode 100644 index 000000000..2186a2ad6 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getfirsttroves.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getFirstTroves](./lib-base.readableliquity.getfirsttroves.md) + +## ReadableLiquity.getFirstTroves() method + +Signature: + +```typescript +getFirstTroves(startIdx: number, numberOfTroves: number): Promise<[string, TroveWithPendingRewards][]>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| startIdx | number | | +| numberOfTroves | number | | + +Returns: + +Promise<\[string, [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md)\]\[\]> + diff --git a/docs/sdk/lib-base.readableliquity.getfrontendstatus.md b/docs/sdk/lib-base.readableliquity.getfrontendstatus.md new file mode 100644 index 000000000..95b596968 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getfrontendstatus.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getFrontendStatus](./lib-base.readableliquity.getfrontendstatus.md) + +## ReadableLiquity.getFrontendStatus() method + +Signature: + +```typescript +getFrontendStatus(address?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[FrontendStatus](./lib-base.frontendstatus.md)> + diff --git a/docs/sdk/lib-base.readableliquity.getlasttroves.md b/docs/sdk/lib-base.readableliquity.getlasttroves.md new file mode 100644 index 000000000..fe7a93af4 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getlasttroves.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getLastTroves](./lib-base.readableliquity.getlasttroves.md) + +## ReadableLiquity.getLastTroves() method + +Signature: + +```typescript +getLastTroves(startIdx: number, numberOfTroves: number): Promise<[string, TroveWithPendingRewards][]>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| startIdx | number | | +| numberOfTroves | number | | + +Returns: + +Promise<\[string, [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md)\]\[\]> + diff --git a/docs/sdk/lib-base.readableliquity.getlqtybalance.md b/docs/sdk/lib-base.readableliquity.getlqtybalance.md new file mode 100644 index 000000000..a535e1411 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getlqtybalance.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getLQTYBalance](./lib-base.readableliquity.getlqtybalance.md) + +## ReadableLiquity.getLQTYBalance() method + +Signature: + +```typescript +getLQTYBalance(address?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-base.readableliquity.getlqtystake.md b/docs/sdk/lib-base.readableliquity.getlqtystake.md new file mode 100644 index 000000000..ce73c3e71 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getlqtystake.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getLQTYStake](./lib-base.readableliquity.getlqtystake.md) + +## ReadableLiquity.getLQTYStake() method + +Signature: + +```typescript +getLQTYStake(address?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[LQTYStake](./lib-base.lqtystake.md)> + diff --git a/docs/sdk/lib-base.readableliquity.getlusdbalance.md b/docs/sdk/lib-base.readableliquity.getlusdbalance.md new file mode 100644 index 000000000..9fc0b4006 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getlusdbalance.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getLUSDBalance](./lib-base.readableliquity.getlusdbalance.md) + +## ReadableLiquity.getLUSDBalance() method + +Signature: + +```typescript +getLUSDBalance(address?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-base.readableliquity.getlusdinstabilitypool.md b/docs/sdk/lib-base.readableliquity.getlusdinstabilitypool.md new file mode 100644 index 000000000..0cf264754 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getlusdinstabilitypool.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getLUSDInStabilityPool](./lib-base.readableliquity.getlusdinstabilitypool.md) + +## ReadableLiquity.getLUSDInStabilityPool() method + +Signature: + +```typescript +getLUSDInStabilityPool(): Promise; +``` +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-base.readableliquity.getnumberoftroves.md b/docs/sdk/lib-base.readableliquity.getnumberoftroves.md new file mode 100644 index 000000000..09cfc5fc0 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getnumberoftroves.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getNumberOfTroves](./lib-base.readableliquity.getnumberoftroves.md) + +## ReadableLiquity.getNumberOfTroves() method + +Signature: + +```typescript +getNumberOfTroves(): Promise; +``` +Returns: + +Promise<number> + diff --git a/docs/sdk/lib-base.readableliquity.getprice.md b/docs/sdk/lib-base.readableliquity.getprice.md new file mode 100644 index 000000000..549d05c37 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getprice.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getPrice](./lib-base.readableliquity.getprice.md) + +## ReadableLiquity.getPrice() method + +Signature: + +```typescript +getPrice(): Promise; +``` +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-base.readableliquity.getstabilitydeposit.md b/docs/sdk/lib-base.readableliquity.getstabilitydeposit.md new file mode 100644 index 000000000..2313e02a1 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.getstabilitydeposit.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getStabilityDeposit](./lib-base.readableliquity.getstabilitydeposit.md) + +## ReadableLiquity.getStabilityDeposit() method + +Signature: + +```typescript +getStabilityDeposit(address?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[StabilityDeposit](./lib-base.stabilitydeposit.md)> + diff --git a/docs/sdk/lib-base.readableliquity.gettotal.md b/docs/sdk/lib-base.readableliquity.gettotal.md new file mode 100644 index 000000000..3628b8eab --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.gettotal.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getTotal](./lib-base.readableliquity.gettotal.md) + +## ReadableLiquity.getTotal() method + +Signature: + +```typescript +getTotal(): Promise; +``` +Returns: + +Promise<[Trove](./lib-base.trove.md)> + diff --git a/docs/sdk/lib-base.readableliquity.gettotalredistributed.md b/docs/sdk/lib-base.readableliquity.gettotalredistributed.md new file mode 100644 index 000000000..219f78936 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.gettotalredistributed.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getTotalRedistributed](./lib-base.readableliquity.gettotalredistributed.md) + +## ReadableLiquity.getTotalRedistributed() method + +Get the total collateral and debt per stake that has been liquidated through redistribution. + +Signature: + +```typescript +getTotalRedistributed(): Promise; +``` +Returns: + +Promise<[Trove](./lib-base.trove.md)> + +## Remarks + +Needed when dealing with instances of [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md). + +## Example + +See [getLastTroves()](./lib-base.readableliquity.getlasttroves.md) for an example of how it's used. + diff --git a/docs/sdk/lib-base.readableliquity.gettotalstakedlqty.md b/docs/sdk/lib-base.readableliquity.gettotalstakedlqty.md new file mode 100644 index 000000000..b5d7d2b67 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.gettotalstakedlqty.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getTotalStakedLQTY](./lib-base.readableliquity.gettotalstakedlqty.md) + +## ReadableLiquity.getTotalStakedLQTY() method + +Signature: + +```typescript +getTotalStakedLQTY(): Promise; +``` +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-base.readableliquity.gettrove.md b/docs/sdk/lib-base.readableliquity.gettrove.md new file mode 100644 index 000000000..38c2ba3c0 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.gettrove.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getTrove](./lib-base.readableliquity.gettrove.md) + +## ReadableLiquity.getTrove() method + +Signature: + +```typescript +getTrove(address?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[Trove](./lib-base.trove.md)> + diff --git a/docs/sdk/lib-base.readableliquity.gettrovewithoutrewards.md b/docs/sdk/lib-base.readableliquity.gettrovewithoutrewards.md new file mode 100644 index 000000000..15be77b14 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.gettrovewithoutrewards.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) > [getTroveWithoutRewards](./lib-base.readableliquity.gettrovewithoutrewards.md) + +## ReadableLiquity.getTroveWithoutRewards() method + +Signature: + +```typescript +getTroveWithoutRewards(address?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md)> + diff --git a/docs/sdk/lib-base.readableliquity.md b/docs/sdk/lib-base.readableliquity.md new file mode 100644 index 000000000..7c504b9c5 --- /dev/null +++ b/docs/sdk/lib-base.readableliquity.md @@ -0,0 +1,35 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [ReadableLiquity](./lib-base.readableliquity.md) + +## ReadableLiquity interface + + +Signature: + +```typescript +export interface ReadableLiquity +``` + +## Methods + +| Method | Description | +| --- | --- | +| [getCollateralSurplusBalance(address)](./lib-base.readableliquity.getcollateralsurplusbalance.md) | | +| [getFees()](./lib-base.readableliquity.getfees.md) | | +| [getFirstTroves(startIdx, numberOfTroves)](./lib-base.readableliquity.getfirsttroves.md) | | +| [getFrontendStatus(address)](./lib-base.readableliquity.getfrontendstatus.md) | | +| [getLastTroves(startIdx, numberOfTroves)](./lib-base.readableliquity.getlasttroves.md) | | +| [getLQTYBalance(address)](./lib-base.readableliquity.getlqtybalance.md) | | +| [getLQTYStake(address)](./lib-base.readableliquity.getlqtystake.md) | | +| [getLUSDBalance(address)](./lib-base.readableliquity.getlusdbalance.md) | | +| [getLUSDInStabilityPool()](./lib-base.readableliquity.getlusdinstabilitypool.md) | | +| [getNumberOfTroves()](./lib-base.readableliquity.getnumberoftroves.md) | | +| [getPrice()](./lib-base.readableliquity.getprice.md) | | +| [getStabilityDeposit(address)](./lib-base.readableliquity.getstabilitydeposit.md) | | +| [getTotal()](./lib-base.readableliquity.gettotal.md) | | +| [getTotalRedistributed()](./lib-base.readableliquity.gettotalredistributed.md) | Get the total collateral and debt per stake that has been liquidated through redistribution. | +| [getTotalStakedLQTY()](./lib-base.readableliquity.gettotalstakedlqty.md) | | +| [getTrove(address)](./lib-base.readableliquity.gettrove.md) | | +| [getTroveWithoutRewards(address)](./lib-base.readableliquity.gettrovewithoutrewards.md) | | + diff --git a/docs/sdk/lib-base.redemptiondetails.actuallusdamount.md b/docs/sdk/lib-base.redemptiondetails.actuallusdamount.md new file mode 100644 index 000000000..351754b74 --- /dev/null +++ b/docs/sdk/lib-base.redemptiondetails.actuallusdamount.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [RedemptionDetails](./lib-base.redemptiondetails.md) > [actualLUSDAmount](./lib-base.redemptiondetails.actuallusdamount.md) + +## RedemptionDetails.actualLUSDAmount property + +Signature: + +```typescript +actualLUSDAmount: Decimal; +``` diff --git a/docs/sdk/lib-base.redemptiondetails.attemptedlusdamount.md b/docs/sdk/lib-base.redemptiondetails.attemptedlusdamount.md new file mode 100644 index 000000000..dfcfe21e9 --- /dev/null +++ b/docs/sdk/lib-base.redemptiondetails.attemptedlusdamount.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [RedemptionDetails](./lib-base.redemptiondetails.md) > [attemptedLUSDAmount](./lib-base.redemptiondetails.attemptedlusdamount.md) + +## RedemptionDetails.attemptedLUSDAmount property + +Signature: + +```typescript +attemptedLUSDAmount: Decimal; +``` diff --git a/docs/sdk/lib-base.redemptiondetails.collateralreceived.md b/docs/sdk/lib-base.redemptiondetails.collateralreceived.md new file mode 100644 index 000000000..9db65aa9b --- /dev/null +++ b/docs/sdk/lib-base.redemptiondetails.collateralreceived.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [RedemptionDetails](./lib-base.redemptiondetails.md) > [collateralReceived](./lib-base.redemptiondetails.collateralreceived.md) + +## RedemptionDetails.collateralReceived property + +Signature: + +```typescript +collateralReceived: Decimal; +``` diff --git a/docs/sdk/lib-base.redemptiondetails.fee.md b/docs/sdk/lib-base.redemptiondetails.fee.md new file mode 100644 index 000000000..8c235e8c5 --- /dev/null +++ b/docs/sdk/lib-base.redemptiondetails.fee.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [RedemptionDetails](./lib-base.redemptiondetails.md) > [fee](./lib-base.redemptiondetails.fee.md) + +## RedemptionDetails.fee property + +Signature: + +```typescript +fee: Decimal; +``` diff --git a/docs/sdk/lib-base.redemptiondetails.md b/docs/sdk/lib-base.redemptiondetails.md new file mode 100644 index 000000000..32ca2b5ad --- /dev/null +++ b/docs/sdk/lib-base.redemptiondetails.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [RedemptionDetails](./lib-base.redemptiondetails.md) + +## RedemptionDetails interface + +Signature: + +```typescript +export interface RedemptionDetails +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [actualLUSDAmount](./lib-base.redemptiondetails.actuallusdamount.md) | [Decimal](./decimal.decimal.md) | | +| [attemptedLUSDAmount](./lib-base.redemptiondetails.attemptedlusdamount.md) | [Decimal](./decimal.decimal.md) | | +| [collateralReceived](./lib-base.redemptiondetails.collateralreceived.md) | [Decimal](./decimal.decimal.md) | | +| [fee](./lib-base.redemptiondetails.fee.md) | [Decimal](./decimal.decimal.md) | | + diff --git a/docs/sdk/lib-base.sentliquitytransaction.getreceipt.md b/docs/sdk/lib-base.sentliquitytransaction.getreceipt.md new file mode 100644 index 000000000..3de1d6b97 --- /dev/null +++ b/docs/sdk/lib-base.sentliquitytransaction.getreceipt.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [SentLiquityTransaction](./lib-base.sentliquitytransaction.md) > [getReceipt](./lib-base.sentliquitytransaction.getreceipt.md) + +## SentLiquityTransaction.getReceipt() method + +Signature: + +```typescript +getReceipt(): Promise; +``` +Returns: + +Promise<T> + diff --git a/docs/sdk/lib-base.sentliquitytransaction.md b/docs/sdk/lib-base.sentliquitytransaction.md new file mode 100644 index 000000000..2dc0b9395 --- /dev/null +++ b/docs/sdk/lib-base.sentliquitytransaction.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [SentLiquityTransaction](./lib-base.sentliquitytransaction.md) + +## SentLiquityTransaction interface + +Signature: + +```typescript +export interface SentLiquityTransaction +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [rawSentTransaction](./lib-base.sentliquitytransaction.rawsenttransaction.md) | S | | + +## Methods + +| Method | Description | +| --- | --- | +| [getReceipt()](./lib-base.sentliquitytransaction.getreceipt.md) | | +| [waitForReceipt()](./lib-base.sentliquitytransaction.waitforreceipt.md) | | + diff --git a/docs/sdk/lib-base.sentliquitytransaction.rawsenttransaction.md b/docs/sdk/lib-base.sentliquitytransaction.rawsenttransaction.md new file mode 100644 index 000000000..8a42e29b2 --- /dev/null +++ b/docs/sdk/lib-base.sentliquitytransaction.rawsenttransaction.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [SentLiquityTransaction](./lib-base.sentliquitytransaction.md) > [rawSentTransaction](./lib-base.sentliquitytransaction.rawsenttransaction.md) + +## SentLiquityTransaction.rawSentTransaction property + +Signature: + +```typescript +rawSentTransaction: S; +``` diff --git a/docs/sdk/lib-base.sentliquitytransaction.waitforreceipt.md b/docs/sdk/lib-base.sentliquitytransaction.waitforreceipt.md new file mode 100644 index 000000000..2245ca123 --- /dev/null +++ b/docs/sdk/lib-base.sentliquitytransaction.waitforreceipt.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [SentLiquityTransaction](./lib-base.sentliquitytransaction.md) > [waitForReceipt](./lib-base.sentliquitytransaction.waitforreceipt.md) + +## SentLiquityTransaction.waitForReceipt() method + +Signature: + +```typescript +waitForReceipt(): Promise>; +``` +Returns: + +Promise<Extract<T, [MinedReceipt](./lib-base.minedreceipt.md)>> + diff --git a/docs/sdk/lib-base.stabilitydeposit.apply.md b/docs/sdk/lib-base.stabilitydeposit.apply.md new file mode 100644 index 000000000..3f8293387 --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.apply.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [apply](./lib-base.stabilitydeposit.apply.md) + +## StabilityDeposit.apply() method + +Signature: + +```typescript +apply(change: StabilityDepositChange | undefined): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| change | [StabilityDepositChange](./lib-base.stabilitydepositchange.md)<[Decimalish](./decimal.decimalish.md)> \| undefined | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/lib-base.stabilitydeposit.collateralgain.md b/docs/sdk/lib-base.stabilitydeposit.collateralgain.md new file mode 100644 index 000000000..de3cb30c2 --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.collateralgain.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [collateralGain](./lib-base.stabilitydeposit.collateralgain.md) + +## StabilityDeposit.collateralGain property + +Signature: + +```typescript +readonly collateralGain: Decimal; +``` diff --git a/docs/sdk/lib-base.stabilitydeposit.currentlusd.md b/docs/sdk/lib-base.stabilitydeposit.currentlusd.md new file mode 100644 index 000000000..e158da3b3 --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.currentlusd.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [currentLUSD](./lib-base.stabilitydeposit.currentlusd.md) + +## StabilityDeposit.currentLUSD property + +Signature: + +```typescript +readonly currentLUSD: Decimal; +``` diff --git a/docs/sdk/lib-base.stabilitydeposit.equals.md b/docs/sdk/lib-base.stabilitydeposit.equals.md new file mode 100644 index 000000000..587c7807e --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.equals.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [equals](./lib-base.stabilitydeposit.equals.md) + +## StabilityDeposit.equals() method + +Signature: + +```typescript +equals(that: StabilityDeposit): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [StabilityDeposit](./lib-base.stabilitydeposit.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/lib-base.stabilitydeposit.initiallusd.md b/docs/sdk/lib-base.stabilitydeposit.initiallusd.md new file mode 100644 index 000000000..9589635af --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.initiallusd.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [initialLUSD](./lib-base.stabilitydeposit.initiallusd.md) + +## StabilityDeposit.initialLUSD property + +Signature: + +```typescript +readonly initialLUSD: Decimal; +``` diff --git a/docs/sdk/lib-base.stabilitydeposit.isempty.md b/docs/sdk/lib-base.stabilitydeposit.isempty.md new file mode 100644 index 000000000..9ebec4132 --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.isempty.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [isEmpty](./lib-base.stabilitydeposit.isempty.md) + +## StabilityDeposit.isEmpty property + +Signature: + +```typescript +get isEmpty(): boolean; +``` diff --git a/docs/sdk/lib-base.stabilitydeposit.lqtyreward.md b/docs/sdk/lib-base.stabilitydeposit.lqtyreward.md new file mode 100644 index 000000000..3bd52a74d --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.lqtyreward.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [lqtyReward](./lib-base.stabilitydeposit.lqtyreward.md) + +## StabilityDeposit.lqtyReward property + +Signature: + +```typescript +readonly lqtyReward: Decimal; +``` diff --git a/docs/sdk/lib-base.stabilitydeposit.md b/docs/sdk/lib-base.stabilitydeposit.md new file mode 100644 index 000000000..e9101bff7 --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.md @@ -0,0 +1,35 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) + +## StabilityDeposit class + +Signature: + +```typescript +export declare class StabilityDeposit +``` + +## Remarks + +The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `StabilityDeposit` class. + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [collateralGain](./lib-base.stabilitydeposit.collateralgain.md) | | [Decimal](./decimal.decimal.md) | | +| [currentLUSD](./lib-base.stabilitydeposit.currentlusd.md) | | [Decimal](./decimal.decimal.md) | | +| [initialLUSD](./lib-base.stabilitydeposit.initiallusd.md) | | [Decimal](./decimal.decimal.md) | | +| [isEmpty](./lib-base.stabilitydeposit.isempty.md) | | boolean | | +| [lqtyReward](./lib-base.stabilitydeposit.lqtyreward.md) | | [Decimal](./decimal.decimal.md) | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [apply(change)](./lib-base.stabilitydeposit.apply.md) | | | +| [equals(that)](./lib-base.stabilitydeposit.equals.md) | | | +| [toString()](./lib-base.stabilitydeposit.tostring.md) | | | +| [whatChanged(thatLUSD)](./lib-base.stabilitydeposit.whatchanged.md) | | | + diff --git a/docs/sdk/lib-base.stabilitydeposit.tostring.md b/docs/sdk/lib-base.stabilitydeposit.tostring.md new file mode 100644 index 000000000..dcbb9197a --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.tostring.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [toString](./lib-base.stabilitydeposit.tostring.md) + +## StabilityDeposit.toString() method + +Signature: + +```typescript +toString(): string; +``` +Returns: + +string + diff --git a/docs/sdk/lib-base.stabilitydeposit.whatchanged.md b/docs/sdk/lib-base.stabilitydeposit.whatchanged.md new file mode 100644 index 000000000..c9b42fdf3 --- /dev/null +++ b/docs/sdk/lib-base.stabilitydeposit.whatchanged.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDeposit](./lib-base.stabilitydeposit.md) > [whatChanged](./lib-base.stabilitydeposit.whatchanged.md) + +## StabilityDeposit.whatChanged() method + +Signature: + +```typescript +whatChanged(thatLUSD: Decimalish): StabilityDepositChange | undefined; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| thatLUSD | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[StabilityDepositChange](./lib-base.stabilitydepositchange.md)<[Decimal](./decimal.decimal.md)> \| undefined + diff --git a/docs/sdk/lib-base.stabilitydepositchange.md b/docs/sdk/lib-base.stabilitydepositchange.md new file mode 100644 index 000000000..724126e7b --- /dev/null +++ b/docs/sdk/lib-base.stabilitydepositchange.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDepositChange](./lib-base.stabilitydepositchange.md) + +## StabilityDepositChange type + +Signature: + +```typescript +export declare type StabilityDepositChange = { + depositLUSD: T; + withdrawLUSD?: undefined; +} | { + depositLUSD?: undefined; + withdrawLUSD: T; + withdrawAllLUSD: boolean; +}; +``` diff --git a/docs/sdk/lib-base.stabilitydepositchangedetails.change.md b/docs/sdk/lib-base.stabilitydepositchangedetails.change.md new file mode 100644 index 000000000..f82716618 --- /dev/null +++ b/docs/sdk/lib-base.stabilitydepositchangedetails.change.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDepositChangeDetails](./lib-base.stabilitydepositchangedetails.md) > [change](./lib-base.stabilitydepositchangedetails.change.md) + +## StabilityDepositChangeDetails.change property + +Signature: + +```typescript +change: StabilityDepositChange; +``` diff --git a/docs/sdk/lib-base.stabilitydepositchangedetails.md b/docs/sdk/lib-base.stabilitydepositchangedetails.md new file mode 100644 index 000000000..8520106de --- /dev/null +++ b/docs/sdk/lib-base.stabilitydepositchangedetails.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityDepositChangeDetails](./lib-base.stabilitydepositchangedetails.md) + +## StabilityDepositChangeDetails interface + +Signature: + +```typescript +export interface StabilityDepositChangeDetails extends StabilityPoolGainsWithdrawalDetails +``` +Extends: [StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [change](./lib-base.stabilitydepositchangedetails.change.md) | [StabilityDepositChange](./lib-base.stabilitydepositchange.md)<[Decimal](./decimal.decimal.md)> | | + diff --git a/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.collateralgain.md b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.collateralgain.md new file mode 100644 index 000000000..efde49739 --- /dev/null +++ b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.collateralgain.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md) > [collateralGain](./lib-base.stabilitypoolgainswithdrawaldetails.collateralgain.md) + +## StabilityPoolGainsWithdrawalDetails.collateralGain property + +Signature: + +```typescript +collateralGain: Decimal; +``` diff --git a/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.lqtyreward.md b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.lqtyreward.md new file mode 100644 index 000000000..1d559d746 --- /dev/null +++ b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.lqtyreward.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md) > [lqtyReward](./lib-base.stabilitypoolgainswithdrawaldetails.lqtyreward.md) + +## StabilityPoolGainsWithdrawalDetails.lqtyReward property + +Signature: + +```typescript +lqtyReward: Decimal; +``` diff --git a/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.lusdloss.md b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.lusdloss.md new file mode 100644 index 000000000..bdfa65355 --- /dev/null +++ b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.lusdloss.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md) > [lusdLoss](./lib-base.stabilitypoolgainswithdrawaldetails.lusdloss.md) + +## StabilityPoolGainsWithdrawalDetails.lusdLoss property + +Signature: + +```typescript +lusdLoss: Decimal; +``` diff --git a/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.md b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.md new file mode 100644 index 000000000..a7ef5ee0e --- /dev/null +++ b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md) + +## StabilityPoolGainsWithdrawalDetails interface + +Signature: + +```typescript +export interface StabilityPoolGainsWithdrawalDetails +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [collateralGain](./lib-base.stabilitypoolgainswithdrawaldetails.collateralgain.md) | [Decimal](./decimal.decimal.md) | | +| [lqtyReward](./lib-base.stabilitypoolgainswithdrawaldetails.lqtyreward.md) | [Decimal](./decimal.decimal.md) | | +| [lusdLoss](./lib-base.stabilitypoolgainswithdrawaldetails.lusdloss.md) | [Decimal](./decimal.decimal.md) | | +| [newLUSDDeposit](./lib-base.stabilitypoolgainswithdrawaldetails.newlusddeposit.md) | [Decimal](./decimal.decimal.md) | | + diff --git a/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.newlusddeposit.md b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.newlusddeposit.md new file mode 100644 index 000000000..36f0fe589 --- /dev/null +++ b/docs/sdk/lib-base.stabilitypoolgainswithdrawaldetails.newlusddeposit.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md) > [newLUSDDeposit](./lib-base.stabilitypoolgainswithdrawaldetails.newlusddeposit.md) + +## StabilityPoolGainsWithdrawalDetails.newLUSDDeposit property + +Signature: + +```typescript +newLUSDDeposit: Decimal; +``` diff --git a/docs/sdk/lib-base.successfulreceipt.md b/docs/sdk/lib-base.successfulreceipt.md new file mode 100644 index 000000000..111a6fe4b --- /dev/null +++ b/docs/sdk/lib-base.successfulreceipt.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [SuccessfulReceipt](./lib-base.successfulreceipt.md) + +## SuccessfulReceipt type + +Signature: + +```typescript +export declare type SuccessfulReceipt = { + status: "succeeded"; + rawReceipt: R; + details: D; +}; +``` diff --git a/docs/sdk/lib-base.transactableliquity.adjusttrove.md b/docs/sdk/lib-base.transactableliquity.adjusttrove.md new file mode 100644 index 000000000..5a443eab4 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.adjusttrove.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [adjustTrove](./lib-base.transactableliquity.adjusttrove.md) + +## TransactableLiquity.adjustTrove() method + +Signature: + +```typescript +adjustTrove(params: TroveAdjustmentParams): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| params | [TroveAdjustmentParams](./lib-base.troveadjustmentparams.md)<[Decimalish](./decimal.decimalish.md)> | | + +Returns: + +Promise<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.borrowlusd.md b/docs/sdk/lib-base.transactableliquity.borrowlusd.md new file mode 100644 index 000000000..749c8eb15 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.borrowlusd.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [borrowLUSD](./lib-base.transactableliquity.borrowlusd.md) + +## TransactableLiquity.borrowLUSD() method + +Signature: + +```typescript +borrowLUSD(amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.claimcollateralsurplus.md b/docs/sdk/lib-base.transactableliquity.claimcollateralsurplus.md new file mode 100644 index 000000000..5876ea362 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.claimcollateralsurplus.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [claimCollateralSurplus](./lib-base.transactableliquity.claimcollateralsurplus.md) + +## TransactableLiquity.claimCollateralSurplus() method + +Signature: + +```typescript +claimCollateralSurplus(): Promise; +``` +Returns: + +Promise<void> + diff --git a/docs/sdk/lib-base.transactableliquity.closetrove.md b/docs/sdk/lib-base.transactableliquity.closetrove.md new file mode 100644 index 000000000..6735bec5d --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.closetrove.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [closeTrove](./lib-base.transactableliquity.closetrove.md) + +## TransactableLiquity.closeTrove() method + +Signature: + +```typescript +closeTrove(): Promise; +``` +Returns: + +Promise<[TroveClosureDetails](./lib-base.troveclosuredetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.depositcollateral.md b/docs/sdk/lib-base.transactableliquity.depositcollateral.md new file mode 100644 index 000000000..461b87051 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.depositcollateral.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [depositCollateral](./lib-base.transactableliquity.depositcollateral.md) + +## TransactableLiquity.depositCollateral() method + +Signature: + +```typescript +depositCollateral(amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.depositlusdinstabilitypool.md b/docs/sdk/lib-base.transactableliquity.depositlusdinstabilitypool.md new file mode 100644 index 000000000..ecf30b6ee --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.depositlusdinstabilitypool.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [depositLUSDInStabilityPool](./lib-base.transactableliquity.depositlusdinstabilitypool.md) + +## TransactableLiquity.depositLUSDInStabilityPool() method + +Signature: + +```typescript +depositLUSDInStabilityPool(amount: Decimalish, frontendTag?: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| frontendTag | string | | + +Returns: + +Promise<[StabilityDepositChangeDetails](./lib-base.stabilitydepositchangedetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.liquidate.md b/docs/sdk/lib-base.transactableliquity.liquidate.md new file mode 100644 index 000000000..497be5b98 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.liquidate.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [liquidate](./lib-base.transactableliquity.liquidate.md) + +## TransactableLiquity.liquidate() method + +Signature: + +```typescript +liquidate(address: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | + +Returns: + +Promise<[LiquidationDetails](./lib-base.liquidationdetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.liquidateupto.md b/docs/sdk/lib-base.transactableliquity.liquidateupto.md new file mode 100644 index 000000000..00fb7efd5 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.liquidateupto.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [liquidateUpTo](./lib-base.transactableliquity.liquidateupto.md) + +## TransactableLiquity.liquidateUpTo() method + +Signature: + +```typescript +liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| maximumNumberOfTrovesToLiquidate | number | | + +Returns: + +Promise<[LiquidationDetails](./lib-base.liquidationdetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.md b/docs/sdk/lib-base.transactableliquity.md new file mode 100644 index 000000000..78dcf0a9a --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.md @@ -0,0 +1,38 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) + +## TransactableLiquity interface + +Signature: + +```typescript +export interface TransactableLiquity +``` + +## Methods + +| Method | Description | +| --- | --- | +| [adjustTrove(params)](./lib-base.transactableliquity.adjusttrove.md) | | +| [borrowLUSD(amount)](./lib-base.transactableliquity.borrowlusd.md) | | +| [claimCollateralSurplus()](./lib-base.transactableliquity.claimcollateralsurplus.md) | | +| [closeTrove()](./lib-base.transactableliquity.closetrove.md) | | +| [depositCollateral(amount)](./lib-base.transactableliquity.depositcollateral.md) | | +| [depositLUSDInStabilityPool(amount, frontendTag)](./lib-base.transactableliquity.depositlusdinstabilitypool.md) | | +| [liquidate(address)](./lib-base.transactableliquity.liquidate.md) | | +| [liquidateUpTo(maximumNumberOfTrovesToLiquidate)](./lib-base.transactableliquity.liquidateupto.md) | | +| [openTrove(params)](./lib-base.transactableliquity.opentrove.md) | Open a new Trove. | +| [redeemLUSD(amount)](./lib-base.transactableliquity.redeemlusd.md) | | +| [registerFrontend(kickbackRate)](./lib-base.transactableliquity.registerfrontend.md) | | +| [repayLUSD(amount)](./lib-base.transactableliquity.repaylusd.md) | | +| [sendLQTY(toAddress, amount)](./lib-base.transactableliquity.sendlqty.md) | | +| [sendLUSD(toAddress, amount)](./lib-base.transactableliquity.sendlusd.md) | | +| [stakeLQTY(amount)](./lib-base.transactableliquity.stakelqty.md) | | +| [transferCollateralGainToTrove()](./lib-base.transactableliquity.transfercollateralgaintotrove.md) | | +| [unstakeLQTY(amount)](./lib-base.transactableliquity.unstakelqty.md) | | +| [withdrawCollateral(amount)](./lib-base.transactableliquity.withdrawcollateral.md) | | +| [withdrawGainsFromStabilityPool()](./lib-base.transactableliquity.withdrawgainsfromstabilitypool.md) | | +| [withdrawGainsFromStaking()](./lib-base.transactableliquity.withdrawgainsfromstaking.md) | | +| [withdrawLUSDFromStabilityPool(amount)](./lib-base.transactableliquity.withdrawlusdfromstabilitypool.md) | | + diff --git a/docs/sdk/lib-base.transactableliquity.opentrove.md b/docs/sdk/lib-base.transactableliquity.opentrove.md new file mode 100644 index 000000000..a2bdcefb0 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.opentrove.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [openTrove](./lib-base.transactableliquity.opentrove.md) + +## TransactableLiquity.openTrove() method + +Open a new Trove. + +Signature: + +```typescript +openTrove(params: TroveCreationParams): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| params | [TroveCreationParams](./lib-base.trovecreationparams.md)<[Decimalish](./decimal.decimalish.md)> | | + +Returns: + +Promise<[TroveCreationDetails](./lib-base.trovecreationdetails.md)> + +The details of the Trove creation. + diff --git a/docs/sdk/lib-base.transactableliquity.redeemlusd.md b/docs/sdk/lib-base.transactableliquity.redeemlusd.md new file mode 100644 index 000000000..f32fa49d3 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.redeemlusd.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [redeemLUSD](./lib-base.transactableliquity.redeemlusd.md) + +## TransactableLiquity.redeemLUSD() method + +Signature: + +```typescript +redeemLUSD(amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<[RedemptionDetails](./lib-base.redemptiondetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.registerfrontend.md b/docs/sdk/lib-base.transactableliquity.registerfrontend.md new file mode 100644 index 000000000..f116e1240 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.registerfrontend.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [registerFrontend](./lib-base.transactableliquity.registerfrontend.md) + +## TransactableLiquity.registerFrontend() method + +Signature: + +```typescript +registerFrontend(kickbackRate: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| kickbackRate | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<void> + diff --git a/docs/sdk/lib-base.transactableliquity.repaylusd.md b/docs/sdk/lib-base.transactableliquity.repaylusd.md new file mode 100644 index 000000000..729ca1f7a --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.repaylusd.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [repayLUSD](./lib-base.transactableliquity.repaylusd.md) + +## TransactableLiquity.repayLUSD() method + +Signature: + +```typescript +repayLUSD(amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.sendlqty.md b/docs/sdk/lib-base.transactableliquity.sendlqty.md new file mode 100644 index 000000000..30111391b --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.sendlqty.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [sendLQTY](./lib-base.transactableliquity.sendlqty.md) + +## TransactableLiquity.sendLQTY() method + +Signature: + +```typescript +sendLQTY(toAddress: string, amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toAddress | string | | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<void> + diff --git a/docs/sdk/lib-base.transactableliquity.sendlusd.md b/docs/sdk/lib-base.transactableliquity.sendlusd.md new file mode 100644 index 000000000..9f5348f86 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.sendlusd.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [sendLUSD](./lib-base.transactableliquity.sendlusd.md) + +## TransactableLiquity.sendLUSD() method + +Signature: + +```typescript +sendLUSD(toAddress: string, amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toAddress | string | | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<void> + diff --git a/docs/sdk/lib-base.transactableliquity.stakelqty.md b/docs/sdk/lib-base.transactableliquity.stakelqty.md new file mode 100644 index 000000000..7cd7f97ff --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.stakelqty.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [stakeLQTY](./lib-base.transactableliquity.stakelqty.md) + +## TransactableLiquity.stakeLQTY() method + +Signature: + +```typescript +stakeLQTY(amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<void> + diff --git a/docs/sdk/lib-base.transactableliquity.transfercollateralgaintotrove.md b/docs/sdk/lib-base.transactableliquity.transfercollateralgaintotrove.md new file mode 100644 index 000000000..5bc056cf0 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.transfercollateralgaintotrove.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [transferCollateralGainToTrove](./lib-base.transactableliquity.transfercollateralgaintotrove.md) + +## TransactableLiquity.transferCollateralGainToTrove() method + +Signature: + +```typescript +transferCollateralGainToTrove(): Promise; +``` +Returns: + +Promise<[CollateralGainTransferDetails](./lib-base.collateralgaintransferdetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.unstakelqty.md b/docs/sdk/lib-base.transactableliquity.unstakelqty.md new file mode 100644 index 000000000..112bbc4b9 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.unstakelqty.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [unstakeLQTY](./lib-base.transactableliquity.unstakelqty.md) + +## TransactableLiquity.unstakeLQTY() method + +Signature: + +```typescript +unstakeLQTY(amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<void> + diff --git a/docs/sdk/lib-base.transactableliquity.withdrawcollateral.md b/docs/sdk/lib-base.transactableliquity.withdrawcollateral.md new file mode 100644 index 000000000..f45dac1a1 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.withdrawcollateral.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [withdrawCollateral](./lib-base.transactableliquity.withdrawcollateral.md) + +## TransactableLiquity.withdrawCollateral() method + +Signature: + +```typescript +withdrawCollateral(amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.withdrawgainsfromstabilitypool.md b/docs/sdk/lib-base.transactableliquity.withdrawgainsfromstabilitypool.md new file mode 100644 index 000000000..4c9c0a01c --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.withdrawgainsfromstabilitypool.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [withdrawGainsFromStabilityPool](./lib-base.transactableliquity.withdrawgainsfromstabilitypool.md) + +## TransactableLiquity.withdrawGainsFromStabilityPool() method + +Signature: + +```typescript +withdrawGainsFromStabilityPool(): Promise; +``` +Returns: + +Promise<[StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md)> + diff --git a/docs/sdk/lib-base.transactableliquity.withdrawgainsfromstaking.md b/docs/sdk/lib-base.transactableliquity.withdrawgainsfromstaking.md new file mode 100644 index 000000000..499f7fbd1 --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.withdrawgainsfromstaking.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [withdrawGainsFromStaking](./lib-base.transactableliquity.withdrawgainsfromstaking.md) + +## TransactableLiquity.withdrawGainsFromStaking() method + +Signature: + +```typescript +withdrawGainsFromStaking(): Promise; +``` +Returns: + +Promise<void> + diff --git a/docs/sdk/lib-base.transactableliquity.withdrawlusdfromstabilitypool.md b/docs/sdk/lib-base.transactableliquity.withdrawlusdfromstabilitypool.md new file mode 100644 index 000000000..297ec7aee --- /dev/null +++ b/docs/sdk/lib-base.transactableliquity.withdrawlusdfromstabilitypool.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TransactableLiquity](./lib-base.transactableliquity.md) > [withdrawLUSDFromStabilityPool](./lib-base.transactableliquity.withdrawlusdfromstabilitypool.md) + +## TransactableLiquity.withdrawLUSDFromStabilityPool() method + +Signature: + +```typescript +withdrawLUSDFromStabilityPool(amount: Decimalish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +Promise<[StabilityDepositChangeDetails](./lib-base.stabilitydepositchangedetails.md)> + diff --git a/docs/sdk/lib-base.trove.add.md b/docs/sdk/lib-base.trove.add.md new file mode 100644 index 000000000..054ce29d4 --- /dev/null +++ b/docs/sdk/lib-base.trove.add.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [add](./lib-base.trove.add.md) + +## Trove.add() method + +Signature: + +```typescript +add(that: Trove): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Trove](./lib-base.trove.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.addcollateral.md b/docs/sdk/lib-base.trove.addcollateral.md new file mode 100644 index 000000000..084ced4db --- /dev/null +++ b/docs/sdk/lib-base.trove.addcollateral.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [addCollateral](./lib-base.trove.addcollateral.md) + +## Trove.addCollateral() method + +Signature: + +```typescript +addCollateral(collateral: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collateral | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.adddebt.md b/docs/sdk/lib-base.trove.adddebt.md new file mode 100644 index 000000000..18e2d9065 --- /dev/null +++ b/docs/sdk/lib-base.trove.adddebt.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [addDebt](./lib-base.trove.adddebt.md) + +## Trove.addDebt() method + +Signature: + +```typescript +addDebt(debt: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| debt | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.adjust.md b/docs/sdk/lib-base.trove.adjust.md new file mode 100644 index 000000000..385981860 --- /dev/null +++ b/docs/sdk/lib-base.trove.adjust.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [adjust](./lib-base.trove.adjust.md) + +## Trove.adjust() method + +Signature: + +```typescript +adjust(params: TroveAdjustmentParams, borrowingFeeFactor?: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| params | [TroveAdjustmentParams](./lib-base.troveadjustmentparams.md)<[Decimalish](./decimal.decimalish.md)> | | +| borrowingFeeFactor | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.adjustto.md b/docs/sdk/lib-base.trove.adjustto.md new file mode 100644 index 000000000..6a732f0fc --- /dev/null +++ b/docs/sdk/lib-base.trove.adjustto.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [adjustTo](./lib-base.trove.adjustto.md) + +## Trove.adjustTo() method + +Signature: + +```typescript +adjustTo(that: Trove, borrowingFeeFactor?: Decimalish): TroveAdjustmentParams; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Trove](./lib-base.trove.md) | | +| borrowingFeeFactor | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[TroveAdjustmentParams](./lib-base.troveadjustmentparams.md)<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-base.trove.apply.md b/docs/sdk/lib-base.trove.apply.md new file mode 100644 index 000000000..1fc9388e0 --- /dev/null +++ b/docs/sdk/lib-base.trove.apply.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [apply](./lib-base.trove.apply.md) + +## Trove.apply() method + +Signature: + +```typescript +apply(change: TroveChange | undefined, borrowingFeeFactor?: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| change | [TroveChange](./lib-base.trovechange.md)<[Decimalish](./decimal.decimalish.md)> \| undefined | | +| borrowingFeeFactor | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.collateral.md b/docs/sdk/lib-base.trove.collateral.md new file mode 100644 index 000000000..38b9d084e --- /dev/null +++ b/docs/sdk/lib-base.trove.collateral.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [collateral](./lib-base.trove.collateral.md) + +## Trove.collateral property + +Signature: + +```typescript +readonly collateral: Decimal; +``` diff --git a/docs/sdk/lib-base.trove.collateralratio.md b/docs/sdk/lib-base.trove.collateralratio.md new file mode 100644 index 000000000..0e6afa4c1 --- /dev/null +++ b/docs/sdk/lib-base.trove.collateralratio.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [collateralRatio](./lib-base.trove.collateralratio.md) + +## Trove.collateralRatio() method + +Signature: + +```typescript +collateralRatio(price: Decimalish): Decimal; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| price | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Decimal](./decimal.decimal.md) + diff --git a/docs/sdk/lib-base.trove.collateralratioisbelowcritical.md b/docs/sdk/lib-base.trove.collateralratioisbelowcritical.md new file mode 100644 index 000000000..6a5e7cfa1 --- /dev/null +++ b/docs/sdk/lib-base.trove.collateralratioisbelowcritical.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [collateralRatioIsBelowCritical](./lib-base.trove.collateralratioisbelowcritical.md) + +## Trove.collateralRatioIsBelowCritical() method + +Signature: + +```typescript +collateralRatioIsBelowCritical(price: Decimalish): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| price | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/lib-base.trove.collateralratioisbelowminimum.md b/docs/sdk/lib-base.trove.collateralratioisbelowminimum.md new file mode 100644 index 000000000..f305dc9cf --- /dev/null +++ b/docs/sdk/lib-base.trove.collateralratioisbelowminimum.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [collateralRatioIsBelowMinimum](./lib-base.trove.collateralratioisbelowminimum.md) + +## Trove.collateralRatioIsBelowMinimum() method + +Signature: + +```typescript +collateralRatioIsBelowMinimum(price: Decimalish): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| price | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/lib-base.trove.create.md b/docs/sdk/lib-base.trove.create.md new file mode 100644 index 000000000..6e62d8a6b --- /dev/null +++ b/docs/sdk/lib-base.trove.create.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [create](./lib-base.trove.create.md) + +## Trove.create() method + +Signature: + +```typescript +static create(params: TroveCreationParams, borrowingFeeFactor?: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| params | [TroveCreationParams](./lib-base.trovecreationparams.md)<[Decimalish](./decimal.decimalish.md)> | | +| borrowingFeeFactor | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.debt.md b/docs/sdk/lib-base.trove.debt.md new file mode 100644 index 000000000..715887f4f --- /dev/null +++ b/docs/sdk/lib-base.trove.debt.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [debt](./lib-base.trove.debt.md) + +## Trove.debt property + +Signature: + +```typescript +readonly debt: Decimal; +``` diff --git a/docs/sdk/lib-base.trove.equals.md b/docs/sdk/lib-base.trove.equals.md new file mode 100644 index 000000000..0ce2a79d1 --- /dev/null +++ b/docs/sdk/lib-base.trove.equals.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [equals](./lib-base.trove.equals.md) + +## Trove.equals() method + +Signature: + +```typescript +equals(that: Trove): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Trove](./lib-base.trove.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/lib-base.trove.isempty.md b/docs/sdk/lib-base.trove.isempty.md new file mode 100644 index 000000000..230a0c5db --- /dev/null +++ b/docs/sdk/lib-base.trove.isempty.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [isEmpty](./lib-base.trove.isempty.md) + +## Trove.isEmpty property + +Signature: + +```typescript +get isEmpty(): boolean; +``` diff --git a/docs/sdk/lib-base.trove.isopenableinrecoverymode.md b/docs/sdk/lib-base.trove.isopenableinrecoverymode.md new file mode 100644 index 000000000..e7b0a8205 --- /dev/null +++ b/docs/sdk/lib-base.trove.isopenableinrecoverymode.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [isOpenableInRecoveryMode](./lib-base.trove.isopenableinrecoverymode.md) + +## Trove.isOpenableInRecoveryMode() method + +Signature: + +```typescript +isOpenableInRecoveryMode(price: Decimalish): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| price | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/lib-base.trove.md b/docs/sdk/lib-base.trove.md new file mode 100644 index 000000000..90ab1e9b5 --- /dev/null +++ b/docs/sdk/lib-base.trove.md @@ -0,0 +1,51 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) + +## Trove class + +Signature: + +```typescript +export declare class Trove +``` + +## Remarks + +The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `Trove` class. + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [collateral](./lib-base.trove.collateral.md) | | [Decimal](./decimal.decimal.md) | | +| [debt](./lib-base.trove.debt.md) | | [Decimal](./decimal.decimal.md) | | +| [isEmpty](./lib-base.trove.isempty.md) | | boolean | | +| [netDebt](./lib-base.trove.netdebt.md) | | [Decimal](./decimal.decimal.md) | Amount of LUSD that must be repaid to close this Trove. | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(that)](./lib-base.trove.add.md) | | | +| [addCollateral(collateral)](./lib-base.trove.addcollateral.md) | | | +| [addDebt(debt)](./lib-base.trove.adddebt.md) | | | +| [adjust(params, borrowingFeeFactor)](./lib-base.trove.adjust.md) | | | +| [adjustTo(that, borrowingFeeFactor)](./lib-base.trove.adjustto.md) | | | +| [apply(change, borrowingFeeFactor)](./lib-base.trove.apply.md) | | | +| [collateralRatio(price)](./lib-base.trove.collateralratio.md) | | | +| [collateralRatioIsBelowCritical(price)](./lib-base.trove.collateralratioisbelowcritical.md) | | | +| [collateralRatioIsBelowMinimum(price)](./lib-base.trove.collateralratioisbelowminimum.md) | | | +| [create(params, borrowingFeeFactor)](./lib-base.trove.create.md) | static | | +| [equals(that)](./lib-base.trove.equals.md) | | | +| [isOpenableInRecoveryMode(price)](./lib-base.trove.isopenableinrecoverymode.md) | | | +| [multiply(multiplier)](./lib-base.trove.multiply.md) | | | +| [recreate(that, borrowingFeeFactor)](./lib-base.trove.recreate.md) | static | | +| [setCollateral(collateral)](./lib-base.trove.setcollateral.md) | | | +| [setDebt(debt)](./lib-base.trove.setdebt.md) | | | +| [subtract(that)](./lib-base.trove.subtract.md) | | | +| [subtractCollateral(collateral)](./lib-base.trove.subtractcollateral.md) | | | +| [subtractDebt(debt)](./lib-base.trove.subtractdebt.md) | | | +| [toString()](./lib-base.trove.tostring.md) | | | +| [whatChanged(that, borrowingFeeFactor)](./lib-base.trove.whatchanged.md) | | | + diff --git a/docs/sdk/lib-base.trove.multiply.md b/docs/sdk/lib-base.trove.multiply.md new file mode 100644 index 000000000..5b48500ca --- /dev/null +++ b/docs/sdk/lib-base.trove.multiply.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [multiply](./lib-base.trove.multiply.md) + +## Trove.multiply() method + +Signature: + +```typescript +multiply(multiplier: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| multiplier | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.netdebt.md b/docs/sdk/lib-base.trove.netdebt.md new file mode 100644 index 000000000..3da70fdbf --- /dev/null +++ b/docs/sdk/lib-base.trove.netdebt.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [netDebt](./lib-base.trove.netdebt.md) + +## Trove.netDebt property + +Amount of LUSD that must be repaid to close this Trove. + +Signature: + +```typescript +get netDebt(): Decimal; +``` + +## Remarks + +This doesn't include the liquidation reserve, which is refunded in case of normal closure. + diff --git a/docs/sdk/lib-base.trove.recreate.md b/docs/sdk/lib-base.trove.recreate.md new file mode 100644 index 000000000..11f64795e --- /dev/null +++ b/docs/sdk/lib-base.trove.recreate.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [recreate](./lib-base.trove.recreate.md) + +## Trove.recreate() method + +Signature: + +```typescript +static recreate(that: Trove, borrowingFeeFactor?: Decimalish): TroveCreationParams; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Trove](./lib-base.trove.md) | | +| borrowingFeeFactor | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[TroveCreationParams](./lib-base.trovecreationparams.md)<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-base.trove.setcollateral.md b/docs/sdk/lib-base.trove.setcollateral.md new file mode 100644 index 000000000..b4eac93ee --- /dev/null +++ b/docs/sdk/lib-base.trove.setcollateral.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [setCollateral](./lib-base.trove.setcollateral.md) + +## Trove.setCollateral() method + +Signature: + +```typescript +setCollateral(collateral: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collateral | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.setdebt.md b/docs/sdk/lib-base.trove.setdebt.md new file mode 100644 index 000000000..8c9ec89a1 --- /dev/null +++ b/docs/sdk/lib-base.trove.setdebt.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [setDebt](./lib-base.trove.setdebt.md) + +## Trove.setDebt() method + +Signature: + +```typescript +setDebt(debt: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| debt | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.subtract.md b/docs/sdk/lib-base.trove.subtract.md new file mode 100644 index 000000000..f7e29bb0f --- /dev/null +++ b/docs/sdk/lib-base.trove.subtract.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [subtract](./lib-base.trove.subtract.md) + +## Trove.subtract() method + +Signature: + +```typescript +subtract(that: Trove): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Trove](./lib-base.trove.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.subtractcollateral.md b/docs/sdk/lib-base.trove.subtractcollateral.md new file mode 100644 index 000000000..a2de7faf4 --- /dev/null +++ b/docs/sdk/lib-base.trove.subtractcollateral.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [subtractCollateral](./lib-base.trove.subtractcollateral.md) + +## Trove.subtractCollateral() method + +Signature: + +```typescript +subtractCollateral(collateral: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collateral | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.subtractdebt.md b/docs/sdk/lib-base.trove.subtractdebt.md new file mode 100644 index 000000000..baa17614e --- /dev/null +++ b/docs/sdk/lib-base.trove.subtractdebt.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [subtractDebt](./lib-base.trove.subtractdebt.md) + +## Trove.subtractDebt() method + +Signature: + +```typescript +subtractDebt(debt: Decimalish): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| debt | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trove.tostring.md b/docs/sdk/lib-base.trove.tostring.md new file mode 100644 index 000000000..b8c98d8b0 --- /dev/null +++ b/docs/sdk/lib-base.trove.tostring.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [toString](./lib-base.trove.tostring.md) + +## Trove.toString() method + +Signature: + +```typescript +toString(): string; +``` +Returns: + +string + diff --git a/docs/sdk/lib-base.trove.whatchanged.md b/docs/sdk/lib-base.trove.whatchanged.md new file mode 100644 index 000000000..3296d5dc8 --- /dev/null +++ b/docs/sdk/lib-base.trove.whatchanged.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [Trove](./lib-base.trove.md) > [whatChanged](./lib-base.trove.whatchanged.md) + +## Trove.whatChanged() method + +Signature: + +```typescript +whatChanged(that: Trove, borrowingFeeFactor?: Decimalish): TroveChange | undefined; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [Trove](./lib-base.trove.md) | | +| borrowingFeeFactor | [Decimalish](./decimal.decimalish.md) | | + +Returns: + +[TroveChange](./lib-base.trovechange.md)<[Decimal](./decimal.decimal.md)> \| undefined + diff --git a/docs/sdk/lib-base.troveadjustmentdetails.fee.md b/docs/sdk/lib-base.troveadjustmentdetails.fee.md new file mode 100644 index 000000000..e81735624 --- /dev/null +++ b/docs/sdk/lib-base.troveadjustmentdetails.fee.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md) > [fee](./lib-base.troveadjustmentdetails.fee.md) + +## TroveAdjustmentDetails.fee property + +Signature: + +```typescript +fee: Decimal; +``` diff --git a/docs/sdk/lib-base.troveadjustmentdetails.md b/docs/sdk/lib-base.troveadjustmentdetails.md new file mode 100644 index 000000000..5b48495bb --- /dev/null +++ b/docs/sdk/lib-base.troveadjustmentdetails.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md) + +## TroveAdjustmentDetails interface + +Signature: + +```typescript +export interface TroveAdjustmentDetails +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [fee](./lib-base.troveadjustmentdetails.fee.md) | [Decimal](./decimal.decimal.md) | | +| [newTrove](./lib-base.troveadjustmentdetails.newtrove.md) | [Trove](./lib-base.trove.md) | | +| [params](./lib-base.troveadjustmentdetails.params.md) | [TroveAdjustmentParams](./lib-base.troveadjustmentparams.md)<[Decimal](./decimal.decimal.md)> | | + diff --git a/docs/sdk/lib-base.troveadjustmentdetails.newtrove.md b/docs/sdk/lib-base.troveadjustmentdetails.newtrove.md new file mode 100644 index 000000000..986bacf56 --- /dev/null +++ b/docs/sdk/lib-base.troveadjustmentdetails.newtrove.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md) > [newTrove](./lib-base.troveadjustmentdetails.newtrove.md) + +## TroveAdjustmentDetails.newTrove property + +Signature: + +```typescript +newTrove: Trove; +``` diff --git a/docs/sdk/lib-base.troveadjustmentdetails.params.md b/docs/sdk/lib-base.troveadjustmentdetails.params.md new file mode 100644 index 000000000..9db8c7ae3 --- /dev/null +++ b/docs/sdk/lib-base.troveadjustmentdetails.params.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md) > [params](./lib-base.troveadjustmentdetails.params.md) + +## TroveAdjustmentDetails.params property + +Signature: + +```typescript +params: TroveAdjustmentParams; +``` diff --git a/docs/sdk/lib-base.troveadjustmentparams.md b/docs/sdk/lib-base.troveadjustmentparams.md new file mode 100644 index 000000000..1dbadab4f --- /dev/null +++ b/docs/sdk/lib-base.troveadjustmentparams.md @@ -0,0 +1,38 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveAdjustmentParams](./lib-base.troveadjustmentparams.md) + +## TroveAdjustmentParams type + +Parameters of Trove adjustment. + +Signature: + +```typescript +export declare type TroveAdjustmentParams = (_CollateralChange & _NoDebtChange) | (_DebtChange & _NoCollateralChange) | (_CollateralChange & _DebtChange); +``` + +## Remarks + +The type parameter `T` specifies the allowed value type(s) of the particular `TroveAdjustmentParams` object's properties. + +Even though all properties are optional, a valid `TroveAdjustmentParams` object must define at least one. + +Defining both `depositCollateral` and `withdrawCollateral`, or both `borrowLUSD` and `repayLUSD` at the same time is disallowed, and will result in a type-checking error. + +

Properties

+ + + + + + + + + + + + + +
Property Type Description
depositCollateral? T (Optional) The amount of collateral that's deposited.
withdrawCollateral? T (Optional) The amount of collateral that's withdrawn.
borrowLUSD? T (Optional) The amount of LUSD that's borrowed.
repayLUSD? T (Optional) The amount of LUSD that's repaid.
+ diff --git a/docs/sdk/lib-base.trovechange.md b/docs/sdk/lib-base.trovechange.md new file mode 100644 index 000000000..1d372c3eb --- /dev/null +++ b/docs/sdk/lib-base.trovechange.md @@ -0,0 +1,35 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveChange](./lib-base.trovechange.md) + +## TroveChange type + +Represents the change from one Trove to another. + +Signature: + +```typescript +export declare type TroveChange = { + type: "invalidCreation"; + invalidTrove: Trove; + error: TroveCreationError; +} | { + type: "creation"; + params: TroveCreationParams; +} | { + type: "closure"; + params: TroveClosureParams; +} | { + type: "adjustment"; + params: TroveAdjustmentParams; + setToZero?: "collateral" | "debt"; +}; +``` +References: [Trove](./lib-base.trove.md), [TroveCreationError](./lib-base.trovecreationerror.md), [TroveCreationParams](./lib-base.trovecreationparams.md), [TroveClosureParams](./lib-base.troveclosureparams.md), [TroveAdjustmentParams](./lib-base.troveadjustmentparams.md) + +## Remarks + +Returned by [Trove.whatChanged()](./lib-base.trove.whatchanged.md). + +Passed as a parameter to [Trove.apply()](./lib-base.trove.apply.md). + diff --git a/docs/sdk/lib-base.troveclosuredetails.md b/docs/sdk/lib-base.troveclosuredetails.md new file mode 100644 index 000000000..de6548469 --- /dev/null +++ b/docs/sdk/lib-base.troveclosuredetails.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveClosureDetails](./lib-base.troveclosuredetails.md) + +## TroveClosureDetails interface + +Signature: + +```typescript +export interface TroveClosureDetails +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [params](./lib-base.troveclosuredetails.params.md) | [TroveClosureParams](./lib-base.troveclosureparams.md)<[Decimal](./decimal.decimal.md)> | | + diff --git a/docs/sdk/lib-base.troveclosuredetails.params.md b/docs/sdk/lib-base.troveclosuredetails.params.md new file mode 100644 index 000000000..bf3d2acc9 --- /dev/null +++ b/docs/sdk/lib-base.troveclosuredetails.params.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveClosureDetails](./lib-base.troveclosuredetails.md) > [params](./lib-base.troveclosuredetails.params.md) + +## TroveClosureDetails.params property + +Signature: + +```typescript +params: TroveClosureParams; +``` diff --git a/docs/sdk/lib-base.troveclosureparams.md b/docs/sdk/lib-base.troveclosureparams.md new file mode 100644 index 000000000..2ab6c38e2 --- /dev/null +++ b/docs/sdk/lib-base.troveclosureparams.md @@ -0,0 +1,30 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveClosureParams](./lib-base.troveclosureparams.md) + +## TroveClosureParams type + +Parameters of Trove closure. + +Signature: + +```typescript +export declare type TroveClosureParams = _CollateralWithdrawal & _NoCollateralDeposit & Partial<_LUSDRepayment> & _NoLUSDBorrowing; +``` + +## Remarks + +The type parameter `T` specifies the allowed value type(s) of the particular `TroveClosureParams` object's properties. + +

Properties

+ + + + + + + + + +
Property Type Description
withdrawCollateral T The amount of collateral that's withdrawn.
repayLUSD? T (Optional) The amount of LUSD that's repaid.
+ diff --git a/docs/sdk/lib-base.trovecreationdetails.fee.md b/docs/sdk/lib-base.trovecreationdetails.fee.md new file mode 100644 index 000000000..200c63a8f --- /dev/null +++ b/docs/sdk/lib-base.trovecreationdetails.fee.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveCreationDetails](./lib-base.trovecreationdetails.md) > [fee](./lib-base.trovecreationdetails.fee.md) + +## TroveCreationDetails.fee property + +Signature: + +```typescript +fee: Decimal; +``` diff --git a/docs/sdk/lib-base.trovecreationdetails.md b/docs/sdk/lib-base.trovecreationdetails.md new file mode 100644 index 000000000..e2d2aff94 --- /dev/null +++ b/docs/sdk/lib-base.trovecreationdetails.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveCreationDetails](./lib-base.trovecreationdetails.md) + +## TroveCreationDetails interface + +Signature: + +```typescript +export interface TroveCreationDetails +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [fee](./lib-base.trovecreationdetails.fee.md) | [Decimal](./decimal.decimal.md) | | +| [newTrove](./lib-base.trovecreationdetails.newtrove.md) | [Trove](./lib-base.trove.md) | | +| [params](./lib-base.trovecreationdetails.params.md) | [TroveCreationParams](./lib-base.trovecreationparams.md)<[Decimal](./decimal.decimal.md)> | | + diff --git a/docs/sdk/lib-base.trovecreationdetails.newtrove.md b/docs/sdk/lib-base.trovecreationdetails.newtrove.md new file mode 100644 index 000000000..f2a7966e7 --- /dev/null +++ b/docs/sdk/lib-base.trovecreationdetails.newtrove.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveCreationDetails](./lib-base.trovecreationdetails.md) > [newTrove](./lib-base.trovecreationdetails.newtrove.md) + +## TroveCreationDetails.newTrove property + +Signature: + +```typescript +newTrove: Trove; +``` diff --git a/docs/sdk/lib-base.trovecreationdetails.params.md b/docs/sdk/lib-base.trovecreationdetails.params.md new file mode 100644 index 000000000..c917a825e --- /dev/null +++ b/docs/sdk/lib-base.trovecreationdetails.params.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveCreationDetails](./lib-base.trovecreationdetails.md) > [params](./lib-base.trovecreationdetails.params.md) + +## TroveCreationDetails.params property + +Signature: + +```typescript +params: TroveCreationParams; +``` diff --git a/docs/sdk/lib-base.trovecreationerror.md b/docs/sdk/lib-base.trovecreationerror.md new file mode 100644 index 000000000..f116e57ce --- /dev/null +++ b/docs/sdk/lib-base.trovecreationerror.md @@ -0,0 +1,30 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveCreationError](./lib-base.trovecreationerror.md) + +## TroveCreationError type + +Describes why a Trove could not be created. + +Signature: + +```typescript +export declare type TroveCreationError = "missingLiquidationReserve"; +``` + +## Remarks + +See [TroveChange](./lib-base.trovechange.md). + +

Possible values

+ + + + + + + +
Value Reason
"missingLiquidationReserve" A Trove's debt cannot be less than the liquidation reserve.
+ +More errors may be added in the future. + diff --git a/docs/sdk/lib-base.trovecreationparams.md b/docs/sdk/lib-base.trovecreationparams.md new file mode 100644 index 000000000..e5f8590ea --- /dev/null +++ b/docs/sdk/lib-base.trovecreationparams.md @@ -0,0 +1,30 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveCreationParams](./lib-base.trovecreationparams.md) + +## TroveCreationParams type + +Parameters of Trove creation. + +Signature: + +```typescript +export declare type TroveCreationParams = _CollateralDeposit & _NoCollateralWithdrawal & Partial<_LUSDBorrowing> & _NoLUSDRepayment; +``` + +## Remarks + +The type parameter `T` specifies the allowed value type(s) of the particular `TroveCreationParams` object's properties. + +

Properties

+ + + + + + + + + +
Property Type Description
depositCollateral T The amount of collateral that's deposited.
borrowLUSD? T (Optional) The amount of LUSD that's borrowed.
+ diff --git a/docs/sdk/lib-base.trovewithpendingrewards._constructor_.md b/docs/sdk/lib-base.trovewithpendingrewards._constructor_.md new file mode 100644 index 000000000..bd21f2c58 --- /dev/null +++ b/docs/sdk/lib-base.trovewithpendingrewards._constructor_.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) > [(constructor)](./lib-base.trovewithpendingrewards._constructor_.md) + +## TroveWithPendingRewards.(constructor) + +Constructs a new instance of the `TroveWithPendingRewards` class + +Signature: + +```typescript +constructor(collateral?: Decimal, debt?: Decimal, stake?: Decimal, snapshotOfTotalRedistributed?: Trove); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collateral | [Decimal](./decimal.decimal.md) | | +| debt | [Decimal](./decimal.decimal.md) | | +| stake | [Decimal](./decimal.decimal.md) | | +| snapshotOfTotalRedistributed | [Trove](./lib-base.trove.md) | | + diff --git a/docs/sdk/lib-base.trovewithpendingrewards.applyrewards.md b/docs/sdk/lib-base.trovewithpendingrewards.applyrewards.md new file mode 100644 index 000000000..c906ec05e --- /dev/null +++ b/docs/sdk/lib-base.trovewithpendingrewards.applyrewards.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) > [applyRewards](./lib-base.trovewithpendingrewards.applyrewards.md) + +## TroveWithPendingRewards.applyRewards() method + +Signature: + +```typescript +applyRewards(totalRedistributed: Trove): Trove; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| totalRedistributed | [Trove](./lib-base.trove.md) | | + +Returns: + +[Trove](./lib-base.trove.md) + diff --git a/docs/sdk/lib-base.trovewithpendingrewards.equals.md b/docs/sdk/lib-base.trovewithpendingrewards.equals.md new file mode 100644 index 000000000..ec62cda50 --- /dev/null +++ b/docs/sdk/lib-base.trovewithpendingrewards.equals.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) > [equals](./lib-base.trovewithpendingrewards.equals.md) + +## TroveWithPendingRewards.equals() method + +Signature: + +```typescript +equals(that: TroveWithPendingRewards): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| that | [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) | | + +Returns: + +boolean + diff --git a/docs/sdk/lib-base.trovewithpendingrewards.md b/docs/sdk/lib-base.trovewithpendingrewards.md new file mode 100644 index 000000000..93bede760 --- /dev/null +++ b/docs/sdk/lib-base.trovewithpendingrewards.md @@ -0,0 +1,34 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) + +## TroveWithPendingRewards class + + +Signature: + +```typescript +export declare class TroveWithPendingRewards extends Trove +``` +Extends: [Trove](./lib-base.trove.md) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(collateral, debt, stake, snapshotOfTotalRedistributed)](./lib-base.trovewithpendingrewards._constructor_.md) | | Constructs a new instance of the TroveWithPendingRewards class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [snapshotOfTotalRedistributed](./lib-base.trovewithpendingrewards.snapshotoftotalredistributed.md) | | [Trove](./lib-base.trove.md) | | +| [stake](./lib-base.trovewithpendingrewards.stake.md) | | [Decimal](./decimal.decimal.md) | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [applyRewards(totalRedistributed)](./lib-base.trovewithpendingrewards.applyrewards.md) | | | +| [equals(that)](./lib-base.trovewithpendingrewards.equals.md) | | | + diff --git a/docs/sdk/lib-base.trovewithpendingrewards.snapshotoftotalredistributed.md b/docs/sdk/lib-base.trovewithpendingrewards.snapshotoftotalredistributed.md new file mode 100644 index 000000000..023206a87 --- /dev/null +++ b/docs/sdk/lib-base.trovewithpendingrewards.snapshotoftotalredistributed.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) > [snapshotOfTotalRedistributed](./lib-base.trovewithpendingrewards.snapshotoftotalredistributed.md) + +## TroveWithPendingRewards.snapshotOfTotalRedistributed property + +Signature: + +```typescript +readonly snapshotOfTotalRedistributed: Trove; +``` diff --git a/docs/sdk/lib-base.trovewithpendingrewards.stake.md b/docs/sdk/lib-base.trovewithpendingrewards.stake.md new file mode 100644 index 000000000..e74d64b38 --- /dev/null +++ b/docs/sdk/lib-base.trovewithpendingrewards.stake.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-base](./lib-base.md) > [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md) > [stake](./lib-base.trovewithpendingrewards.stake.md) + +## TroveWithPendingRewards.stake property + +Signature: + +```typescript +readonly stake: Decimal; +``` diff --git a/docs/sdk/lib-ethers.addressesof.md b/docs/sdk/lib-ethers.addressesof.md new file mode 100644 index 000000000..3cfee638a --- /dev/null +++ b/docs/sdk/lib-ethers.addressesof.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [addressesOf](./lib-ethers.addressesof.md) + +## addressesOf variable + +Signature: + +```typescript +addressesOf: (contracts: LiquityContracts) => LiquityContractAddresses +``` diff --git a/docs/sdk/lib-ethers.blockpolledliquitystore._constructor_.md b/docs/sdk/lib-ethers.blockpolledliquitystore._constructor_.md new file mode 100644 index 000000000..223e5a395 --- /dev/null +++ b/docs/sdk/lib-ethers.blockpolledliquitystore._constructor_.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [BlockPolledLiquityStore](./lib-ethers.blockpolledliquitystore.md) > [(constructor)](./lib-ethers.blockpolledliquitystore._constructor_.md) + +## BlockPolledLiquityStore.(constructor) + +Constructs a new instance of the `BlockPolledLiquityStore` class + +Signature: + +```typescript +constructor(provider: Provider, account: string, liquity: ReadableEthersLiquity, frontendTag?: string); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| provider | Provider | | +| account | string | | +| liquity | [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) | | +| frontendTag | string | | + diff --git a/docs/sdk/lib-ethers.blockpolledliquitystore._dostart.md b/docs/sdk/lib-ethers.blockpolledliquitystore._dostart.md new file mode 100644 index 000000000..cb14560a2 --- /dev/null +++ b/docs/sdk/lib-ethers.blockpolledliquitystore._dostart.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [BlockPolledLiquityStore](./lib-ethers.blockpolledliquitystore.md) > [\_doStart](./lib-ethers.blockpolledliquitystore._dostart.md) + +## BlockPolledLiquityStore.\_doStart() method + + +Signature: + +```typescript +/** @override */ +protected _doStart(): () => void; +``` +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.blockpolledliquitystore._reduceextra.md b/docs/sdk/lib-ethers.blockpolledliquitystore._reduceextra.md new file mode 100644 index 000000000..2cbaaafa7 --- /dev/null +++ b/docs/sdk/lib-ethers.blockpolledliquitystore._reduceextra.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [BlockPolledLiquityStore](./lib-ethers.blockpolledliquitystore.md) > [\_reduceExtra](./lib-ethers.blockpolledliquitystore._reduceextra.md) + +## BlockPolledLiquityStore.\_reduceExtra() method + + +Signature: + +```typescript +/** @override */ +protected _reduceExtra(oldState: BlockPolledLiquityStoreExtraState, stateUpdate: Partial): BlockPolledLiquityStoreExtraState; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| oldState | [BlockPolledLiquityStoreExtraState](./lib-ethers.blockpolledliquitystoreextrastate.md) | | +| stateUpdate | Partial<[BlockPolledLiquityStoreExtraState](./lib-ethers.blockpolledliquitystoreextrastate.md)> | | + +Returns: + +[BlockPolledLiquityStoreExtraState](./lib-ethers.blockpolledliquitystoreextrastate.md) + diff --git a/docs/sdk/lib-ethers.blockpolledliquitystore.md b/docs/sdk/lib-ethers.blockpolledliquitystore.md new file mode 100644 index 000000000..f7351f8a1 --- /dev/null +++ b/docs/sdk/lib-ethers.blockpolledliquitystore.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [BlockPolledLiquityStore](./lib-ethers.blockpolledliquitystore.md) + +## BlockPolledLiquityStore class + +Signature: + +```typescript +export declare class BlockPolledLiquityStore extends LiquityStore +``` +Extends: [LiquityStore](./lib-base.liquitystore.md)<[BlockPolledLiquityStoreExtraState](./lib-ethers.blockpolledliquitystoreextrastate.md)> + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(provider, account, liquity, frontendTag)](./lib-ethers.blockpolledliquitystore._constructor_.md) | | Constructs a new instance of the BlockPolledLiquityStore class | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [\_doStart()](./lib-ethers.blockpolledliquitystore._dostart.md) | | | +| [\_reduceExtra(oldState, stateUpdate)](./lib-ethers.blockpolledliquitystore._reduceextra.md) | | | + diff --git a/docs/sdk/lib-ethers.blockpolledliquitystoreextrastate.md b/docs/sdk/lib-ethers.blockpolledliquitystoreextrastate.md new file mode 100644 index 000000000..5a6d5ad0d --- /dev/null +++ b/docs/sdk/lib-ethers.blockpolledliquitystoreextrastate.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [BlockPolledLiquityStoreExtraState](./lib-ethers.blockpolledliquitystoreextrastate.md) + +## BlockPolledLiquityStoreExtraState type + +Signature: + +```typescript +export declare type BlockPolledLiquityStoreExtraState = { + blockTag?: number; +}; +``` diff --git a/docs/sdk/lib-ethers.blockpolledliquitystorestate.md b/docs/sdk/lib-ethers.blockpolledliquitystorestate.md new file mode 100644 index 000000000..3148f042d --- /dev/null +++ b/docs/sdk/lib-ethers.blockpolledliquitystorestate.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [BlockPolledLiquityStoreState](./lib-ethers.blockpolledliquitystorestate.md) + +## BlockPolledLiquityStoreState type + +Signature: + +```typescript +export declare type BlockPolledLiquityStoreState = LiquityStoreState; +``` +References: [LiquityStoreState](./lib-base.liquitystorestate.md), [BlockPolledLiquityStoreExtraState](./lib-ethers.blockpolledliquitystoreextrastate.md) + diff --git a/docs/sdk/lib-ethers.connecttocontracts.md b/docs/sdk/lib-ethers.connecttocontracts.md new file mode 100644 index 000000000..7858b7e93 --- /dev/null +++ b/docs/sdk/lib-ethers.connecttocontracts.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [connectToContracts](./lib-ethers.connecttocontracts.md) + +## connectToContracts variable + +Signature: + +```typescript +connectToContracts: (addresses: LiquityContractAddresses, priceFeedIsTestnet: boolean, signerOrProvider: Signer | Provider) => LiquityContracts +``` diff --git a/docs/sdk/lib-ethers.deploymentonnetwork.md b/docs/sdk/lib-ethers.deploymentonnetwork.md new file mode 100644 index 000000000..d01cc7138 --- /dev/null +++ b/docs/sdk/lib-ethers.deploymentonnetwork.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [deploymentOnNetwork](./lib-ethers.deploymentonnetwork.md) + +## deploymentOnNetwork variable + +Signature: + +```typescript +deploymentOnNetwork: { + [network: string]: LiquityDeployment; + [chainId: number]: LiquityDeployment; +} +``` diff --git a/docs/sdk/lib-ethers.dev_chain_id.md b/docs/sdk/lib-ethers.dev_chain_id.md new file mode 100644 index 000000000..37faafbc3 --- /dev/null +++ b/docs/sdk/lib-ethers.dev_chain_id.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [DEV\_CHAIN\_ID](./lib-ethers.dev_chain_id.md) + +## DEV\_CHAIN\_ID variable + +Signature: + +```typescript +DEV_CHAIN_ID = 17 +``` diff --git a/docs/sdk/lib-ethers.etherscalloverrides.md b/docs/sdk/lib-ethers.etherscalloverrides.md new file mode 100644 index 000000000..b04a285ce --- /dev/null +++ b/docs/sdk/lib-ethers.etherscalloverrides.md @@ -0,0 +1,16 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) + +## EthersCallOverrides type + +Signature: + +```typescript +export declare type EthersCallOverrides = Partial>; +``` +References: [Promisable](./lib-ethers.promisable.md) + diff --git a/docs/sdk/lib-ethers.ethersliquity._constructor_.md b/docs/sdk/lib-ethers.ethersliquity._constructor_.md new file mode 100644 index 000000000..6ff38cac7 --- /dev/null +++ b/docs/sdk/lib-ethers.ethersliquity._constructor_.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [EthersLiquity](./lib-ethers.ethersliquity.md) > [(constructor)](./lib-ethers.ethersliquity._constructor_.md) + +## EthersLiquity.(constructor) + +Constructs a new instance of the `EthersLiquity` class + +Signature: + +```typescript +constructor(readable: ReadableEthersLiquity, observable: ObservableEthersLiquity, populatable: PopulatableEthersLiquity); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| readable | [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) | | +| observable | [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) | | +| populatable | [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) | | + diff --git a/docs/sdk/lib-ethers.ethersliquity.connect.md b/docs/sdk/lib-ethers.ethersliquity.connect.md new file mode 100644 index 000000000..dbee070ce --- /dev/null +++ b/docs/sdk/lib-ethers.ethersliquity.connect.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [EthersLiquity](./lib-ethers.ethersliquity.md) > [connect](./lib-ethers.ethersliquity.connect.md) + +## EthersLiquity.connect() method + +Signature: + +```typescript +static connect(deployment: LiquityDeployment, signer: Signer): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| deployment | [LiquityDeployment](./lib-ethers.liquitydeployment.md) | | +| signer | Signer | | + +Returns: + +Promise<[EthersLiquity](./lib-ethers.ethersliquity.md)> + diff --git a/docs/sdk/lib-ethers.ethersliquity.from.md b/docs/sdk/lib-ethers.ethersliquity.from.md new file mode 100644 index 000000000..68dd43965 --- /dev/null +++ b/docs/sdk/lib-ethers.ethersliquity.from.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [EthersLiquity](./lib-ethers.ethersliquity.md) > [from](./lib-ethers.ethersliquity.from.md) + +## EthersLiquity.from() method + +Signature: + +```typescript +static from(contracts: LiquityContracts, signer: Signer, userAddress?: string): EthersLiquity; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| contracts | [LiquityContracts](./lib-ethers.liquitycontracts.md) | | +| signer | Signer | | +| userAddress | string | | + +Returns: + +[EthersLiquity](./lib-ethers.ethersliquity.md) + diff --git a/docs/sdk/lib-ethers.ethersliquity.md b/docs/sdk/lib-ethers.ethersliquity.md new file mode 100644 index 000000000..7e20c121e --- /dev/null +++ b/docs/sdk/lib-ethers.ethersliquity.md @@ -0,0 +1,33 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [EthersLiquity](./lib-ethers.ethersliquity.md) + +## EthersLiquity class + +Signature: + +```typescript +export declare class EthersLiquity extends GluedEthersLiquity +``` +Extends: GluedEthersLiquity + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(readable, observable, populatable)](./lib-ethers.ethersliquity._constructor_.md) | | Constructs a new instance of the EthersLiquity class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [populate](./lib-ethers.ethersliquity.populate.md) | | [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) | | +| [send](./lib-ethers.ethersliquity.send.md) | | [SendableEthersLiquity](./lib-ethers.sendableethersliquity.md) | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [connect(deployment, signer)](./lib-ethers.ethersliquity.connect.md) | static | | +| [from(contracts, signer, userAddress)](./lib-ethers.ethersliquity.from.md) | static | | + diff --git a/docs/sdk/lib-ethers.ethersliquity.populate.md b/docs/sdk/lib-ethers.ethersliquity.populate.md new file mode 100644 index 000000000..c0f39624b --- /dev/null +++ b/docs/sdk/lib-ethers.ethersliquity.populate.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [EthersLiquity](./lib-ethers.ethersliquity.md) > [populate](./lib-ethers.ethersliquity.populate.md) + +## EthersLiquity.populate property + +Signature: + +```typescript +readonly populate: PopulatableEthersLiquity; +``` diff --git a/docs/sdk/lib-ethers.ethersliquity.send.md b/docs/sdk/lib-ethers.ethersliquity.send.md new file mode 100644 index 000000000..924195837 --- /dev/null +++ b/docs/sdk/lib-ethers.ethersliquity.send.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [EthersLiquity](./lib-ethers.ethersliquity.md) > [send](./lib-ethers.ethersliquity.send.md) + +## EthersLiquity.send property + +Signature: + +```typescript +readonly send: SendableEthersLiquity; +``` diff --git a/docs/sdk/lib-ethers.etherstransactionoverrides.md b/docs/sdk/lib-ethers.etherstransactionoverrides.md new file mode 100644 index 000000000..836c9b922 --- /dev/null +++ b/docs/sdk/lib-ethers.etherstransactionoverrides.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) + +## EthersTransactionOverrides type + +Signature: + +```typescript +export declare type EthersTransactionOverrides = Partial>; +``` +References: [Promisable](./lib-ethers.promisable.md) + diff --git a/docs/sdk/lib-ethers.liquitycontractabis.md b/docs/sdk/lib-ethers.liquitycontractabis.md new file mode 100644 index 000000000..bb5bc6f43 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontractabis.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContractAbis](./lib-ethers.liquitycontractabis.md) + +## LiquityContractAbis type + +Signature: + +```typescript +export declare type LiquityContractAbis = Record; +``` +References: [LiquityContractsKey](./lib-ethers.liquitycontractskey.md) + diff --git a/docs/sdk/lib-ethers.liquitycontractaddresses.md b/docs/sdk/lib-ethers.liquitycontractaddresses.md new file mode 100644 index 000000000..c867da68f --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontractaddresses.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContractAddresses](./lib-ethers.liquitycontractaddresses.md) + +## LiquityContractAddresses type + +Signature: + +```typescript +export declare type LiquityContractAddresses = Record; +``` +References: [LiquityContractsKey](./lib-ethers.liquitycontractskey.md) + diff --git a/docs/sdk/lib-ethers.liquitycontracts.activepool.md b/docs/sdk/lib-ethers.liquitycontracts.activepool.md new file mode 100644 index 000000000..98da6a24f --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.activepool.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [activePool](./lib-ethers.liquitycontracts.activepool.md) + +## LiquityContracts.activePool property + +Signature: + +```typescript +activePool: ActivePool; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.borroweroperations.md b/docs/sdk/lib-ethers.liquitycontracts.borroweroperations.md new file mode 100644 index 000000000..0a3e702ba --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.borroweroperations.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [borrowerOperations](./lib-ethers.liquitycontracts.borroweroperations.md) + +## LiquityContracts.borrowerOperations property + +Signature: + +```typescript +borrowerOperations: BorrowerOperations; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.collsurpluspool.md b/docs/sdk/lib-ethers.liquitycontracts.collsurpluspool.md new file mode 100644 index 000000000..cb288e32b --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.collsurpluspool.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [collSurplusPool](./lib-ethers.liquitycontracts.collsurpluspool.md) + +## LiquityContracts.collSurplusPool property + +Signature: + +```typescript +collSurplusPool: CollSurplusPool; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.communityissuance.md b/docs/sdk/lib-ethers.liquitycontracts.communityissuance.md new file mode 100644 index 000000000..ffc4dfa9f --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.communityissuance.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [communityIssuance](./lib-ethers.liquitycontracts.communityissuance.md) + +## LiquityContracts.communityIssuance property + +Signature: + +```typescript +communityIssuance: CommunityIssuance; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.defaultpool.md b/docs/sdk/lib-ethers.liquitycontracts.defaultpool.md new file mode 100644 index 000000000..fcacda632 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.defaultpool.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [defaultPool](./lib-ethers.liquitycontracts.defaultpool.md) + +## LiquityContracts.defaultPool property + +Signature: + +```typescript +defaultPool: DefaultPool; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.gaspool.md b/docs/sdk/lib-ethers.liquitycontracts.gaspool.md new file mode 100644 index 000000000..e6572f0fa --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.gaspool.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [gasPool](./lib-ethers.liquitycontracts.gaspool.md) + +## LiquityContracts.gasPool property + +Signature: + +```typescript +gasPool: GasPool; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.hinthelpers.md b/docs/sdk/lib-ethers.liquitycontracts.hinthelpers.md new file mode 100644 index 000000000..defbd2a0d --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.hinthelpers.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [hintHelpers](./lib-ethers.liquitycontracts.hinthelpers.md) + +## LiquityContracts.hintHelpers property + +Signature: + +```typescript +hintHelpers: HintHelpers; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.lockupcontractfactory.md b/docs/sdk/lib-ethers.liquitycontracts.lockupcontractfactory.md new file mode 100644 index 000000000..9dcd33ada --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.lockupcontractfactory.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [lockupContractFactory](./lib-ethers.liquitycontracts.lockupcontractfactory.md) + +## LiquityContracts.lockupContractFactory property + +Signature: + +```typescript +lockupContractFactory: LockupContractFactory; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.lqtystaking.md b/docs/sdk/lib-ethers.liquitycontracts.lqtystaking.md new file mode 100644 index 000000000..789d80ce2 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.lqtystaking.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [lqtyStaking](./lib-ethers.liquitycontracts.lqtystaking.md) + +## LiquityContracts.lqtyStaking property + +Signature: + +```typescript +lqtyStaking: LQTYStaking; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.lqtytoken.md b/docs/sdk/lib-ethers.liquitycontracts.lqtytoken.md new file mode 100644 index 000000000..ae1756894 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.lqtytoken.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [lqtyToken](./lib-ethers.liquitycontracts.lqtytoken.md) + +## LiquityContracts.lqtyToken property + +Signature: + +```typescript +lqtyToken: LQTYToken; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.lusdtoken.md b/docs/sdk/lib-ethers.liquitycontracts.lusdtoken.md new file mode 100644 index 000000000..145c0b2bd --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.lusdtoken.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [lusdToken](./lib-ethers.liquitycontracts.lusdtoken.md) + +## LiquityContracts.lusdToken property + +Signature: + +```typescript +lusdToken: LUSDToken; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.md b/docs/sdk/lib-ethers.liquitycontracts.md new file mode 100644 index 000000000..1fbfc5fc0 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.md @@ -0,0 +1,33 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) + +## LiquityContracts interface + +Signature: + +```typescript +export interface LiquityContracts +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [activePool](./lib-ethers.liquitycontracts.activepool.md) | ActivePool | | +| [borrowerOperations](./lib-ethers.liquitycontracts.borroweroperations.md) | BorrowerOperations | | +| [collSurplusPool](./lib-ethers.liquitycontracts.collsurpluspool.md) | CollSurplusPool | | +| [communityIssuance](./lib-ethers.liquitycontracts.communityissuance.md) | CommunityIssuance | | +| [defaultPool](./lib-ethers.liquitycontracts.defaultpool.md) | DefaultPool | | +| [gasPool](./lib-ethers.liquitycontracts.gaspool.md) | GasPool | | +| [hintHelpers](./lib-ethers.liquitycontracts.hinthelpers.md) | HintHelpers | | +| [lockupContractFactory](./lib-ethers.liquitycontracts.lockupcontractfactory.md) | LockupContractFactory | | +| [lqtyStaking](./lib-ethers.liquitycontracts.lqtystaking.md) | LQTYStaking | | +| [lqtyToken](./lib-ethers.liquitycontracts.lqtytoken.md) | LQTYToken | | +| [lusdToken](./lib-ethers.liquitycontracts.lusdtoken.md) | LUSDToken | | +| [multiTroveGetter](./lib-ethers.liquitycontracts.multitrovegetter.md) | MultiTroveGetter | | +| [priceFeed](./lib-ethers.liquitycontracts.pricefeed.md) | PriceFeed \| PriceFeedTestnet | | +| [sortedTroves](./lib-ethers.liquitycontracts.sortedtroves.md) | SortedTroves | | +| [stabilityPool](./lib-ethers.liquitycontracts.stabilitypool.md) | StabilityPool | | +| [troveManager](./lib-ethers.liquitycontracts.trovemanager.md) | TroveManager | | + diff --git a/docs/sdk/lib-ethers.liquitycontracts.multitrovegetter.md b/docs/sdk/lib-ethers.liquitycontracts.multitrovegetter.md new file mode 100644 index 000000000..fe6d8e476 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.multitrovegetter.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [multiTroveGetter](./lib-ethers.liquitycontracts.multitrovegetter.md) + +## LiquityContracts.multiTroveGetter property + +Signature: + +```typescript +multiTroveGetter: MultiTroveGetter; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.pricefeed.md b/docs/sdk/lib-ethers.liquitycontracts.pricefeed.md new file mode 100644 index 000000000..9c5d42c1f --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.pricefeed.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [priceFeed](./lib-ethers.liquitycontracts.pricefeed.md) + +## LiquityContracts.priceFeed property + +Signature: + +```typescript +priceFeed: PriceFeed | PriceFeedTestnet; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.sortedtroves.md b/docs/sdk/lib-ethers.liquitycontracts.sortedtroves.md new file mode 100644 index 000000000..2e9eba7f5 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.sortedtroves.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [sortedTroves](./lib-ethers.liquitycontracts.sortedtroves.md) + +## LiquityContracts.sortedTroves property + +Signature: + +```typescript +sortedTroves: SortedTroves; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.stabilitypool.md b/docs/sdk/lib-ethers.liquitycontracts.stabilitypool.md new file mode 100644 index 000000000..6af4e47fe --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.stabilitypool.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [stabilityPool](./lib-ethers.liquitycontracts.stabilitypool.md) + +## LiquityContracts.stabilityPool property + +Signature: + +```typescript +stabilityPool: StabilityPool; +``` diff --git a/docs/sdk/lib-ethers.liquitycontracts.trovemanager.md b/docs/sdk/lib-ethers.liquitycontracts.trovemanager.md new file mode 100644 index 000000000..f5061ba21 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontracts.trovemanager.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContracts](./lib-ethers.liquitycontracts.md) > [troveManager](./lib-ethers.liquitycontracts.trovemanager.md) + +## LiquityContracts.troveManager property + +Signature: + +```typescript +troveManager: TroveManager; +``` diff --git a/docs/sdk/lib-ethers.liquitycontractskey.md b/docs/sdk/lib-ethers.liquitycontractskey.md new file mode 100644 index 000000000..bb11a9032 --- /dev/null +++ b/docs/sdk/lib-ethers.liquitycontractskey.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityContractsKey](./lib-ethers.liquitycontractskey.md) + +## LiquityContractsKey type + +Signature: + +```typescript +export declare type LiquityContractsKey = keyof LiquityContracts; +``` +References: [LiquityContracts](./lib-ethers.liquitycontracts.md) + diff --git a/docs/sdk/lib-ethers.liquitydeployment.md b/docs/sdk/lib-ethers.liquitydeployment.md new file mode 100644 index 000000000..98c646b9a --- /dev/null +++ b/docs/sdk/lib-ethers.liquitydeployment.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [LiquityDeployment](./lib-ethers.liquitydeployment.md) + +## LiquityDeployment type + +Signature: + +```typescript +export declare type LiquityDeployment = { + addresses: LiquityContractAddresses; + priceFeedIsTestnet: boolean; + version: string; + deploymentDate: number; +}; +``` +References: [LiquityContractAddresses](./lib-ethers.liquitycontractaddresses.md) + diff --git a/docs/sdk/lib-ethers.md b/docs/sdk/lib-ethers.md new file mode 100644 index 000000000..a9a254829 --- /dev/null +++ b/docs/sdk/lib-ethers.md @@ -0,0 +1,56 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) + +## lib-ethers package + +## Classes + +| Class | Description | +| --- | --- | +| [BlockPolledLiquityStore](./lib-ethers.blockpolledliquitystore.md) | | +| [EthersLiquity](./lib-ethers.ethersliquity.md) | | +| [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) | | +| [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) | | +| [PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md) | | +| [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) | | +| [SentEthersTransaction](./lib-ethers.sentetherstransaction.md) | | + +## Interfaces + +| Interface | Description | +| --- | --- | +| [LiquityContracts](./lib-ethers.liquitycontracts.md) | | +| [TypedLogDescription](./lib-ethers.typedlogdescription.md) | | + +## Variables + +| Variable | Description | +| --- | --- | +| [addressesOf](./lib-ethers.addressesof.md) | | +| [connectToContracts](./lib-ethers.connecttocontracts.md) | | +| [deploymentOnNetwork](./lib-ethers.deploymentonnetwork.md) | | +| [DEV\_CHAIN\_ID](./lib-ethers.dev_chain_id.md) | | +| [priceFeedIsTestnet](./lib-ethers.pricefeedistestnet.md) | | +| [redeemMaxIterations](./lib-ethers.redeemmaxiterations.md) | | +| [SendableEthersLiquity](./lib-ethers.sendableethersliquity.md) | | +| [TransactableEthersLiquity](./lib-ethers.transactableethersliquity.md) | | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [BlockPolledLiquityStoreExtraState](./lib-ethers.blockpolledliquitystoreextrastate.md) | | +| [BlockPolledLiquityStoreState](./lib-ethers.blockpolledliquitystorestate.md) | | +| [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | +| [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | +| [LiquityContractAbis](./lib-ethers.liquitycontractabis.md) | | +| [LiquityContractAddresses](./lib-ethers.liquitycontractaddresses.md) | | +| [LiquityContractsKey](./lib-ethers.liquitycontractskey.md) | | +| [LiquityDeployment](./lib-ethers.liquitydeployment.md) | | +| [Promisable](./lib-ethers.promisable.md) | | +| [SendableEthersLiquity](./lib-ethers.sendableethersliquity.md) | | +| [TransactableEthersLiquity](./lib-ethers.transactableethersliquity.md) | | +| [TypedContract](./lib-ethers.typedcontract.md) | | +| [TypedLiquityContract](./lib-ethers.typedliquitycontract.md) | | + diff --git a/docs/sdk/lib-ethers.observableethersliquity._constructor_.md b/docs/sdk/lib-ethers.observableethersliquity._constructor_.md new file mode 100644 index 000000000..21c30b55b --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity._constructor_.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [(constructor)](./lib-ethers.observableethersliquity._constructor_.md) + +## ObservableEthersLiquity.(constructor) + +Constructs a new instance of the `ObservableEthersLiquity` class + +Signature: + +```typescript +constructor(contracts: LiquityContracts, readableLiquity: ReadableEthersLiquity, userAddress?: string); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| contracts | [LiquityContracts](./lib-ethers.liquitycontracts.md) | | +| readableLiquity | [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) | | +| userAddress | string | | + diff --git a/docs/sdk/lib-ethers.observableethersliquity.md b/docs/sdk/lib-ethers.observableethersliquity.md new file mode 100644 index 000000000..1b17e2ee5 --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.md @@ -0,0 +1,34 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) + +## ObservableEthersLiquity class + +Signature: + +```typescript +export declare class ObservableEthersLiquity extends EthersLiquityBase implements ObservableLiquity +``` +Extends: EthersLiquityBase + +Implements: ObservableLiquity + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(contracts, readableLiquity, userAddress)](./lib-ethers.observableethersliquity._constructor_.md) | | Constructs a new instance of the ObservableEthersLiquity class | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [watchLUSDBalance(onLUSDBalanceChanged, address)](./lib-ethers.observableethersliquity.watchlusdbalance.md) | | | +| [watchLUSDInStabilityPool(onLUSDInStabilityPoolChanged)](./lib-ethers.observableethersliquity.watchlusdinstabilitypool.md) | | | +| [watchNumberOfTroves(onNumberOfTrovesChanged)](./lib-ethers.observableethersliquity.watchnumberoftroves.md) | | | +| [watchPrice(onPriceChanged)](./lib-ethers.observableethersliquity.watchprice.md) | | | +| [watchStabilityDeposit(onStabilityDepositChanged, address)](./lib-ethers.observableethersliquity.watchstabilitydeposit.md) | | | +| [watchTotal(onTotalChanged)](./lib-ethers.observableethersliquity.watchtotal.md) | | | +| [watchTotalRedistributed(onTotalRedistributedChanged)](./lib-ethers.observableethersliquity.watchtotalredistributed.md) | | | +| [watchTroveWithoutRewards(onTroveChanged, address)](./lib-ethers.observableethersliquity.watchtrovewithoutrewards.md) | | | + diff --git a/docs/sdk/lib-ethers.observableethersliquity.watchlusdbalance.md b/docs/sdk/lib-ethers.observableethersliquity.watchlusdbalance.md new file mode 100644 index 000000000..602fe8b9e --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.watchlusdbalance.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [watchLUSDBalance](./lib-ethers.observableethersliquity.watchlusdbalance.md) + +## ObservableEthersLiquity.watchLUSDBalance() method + +Signature: + +```typescript +watchLUSDBalance(onLUSDBalanceChanged: (balance: Decimal) => void, address?: string): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| onLUSDBalanceChanged | (balance: [Decimal](./decimal.decimal.md)) => void | | +| address | string | | + +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.observableethersliquity.watchlusdinstabilitypool.md b/docs/sdk/lib-ethers.observableethersliquity.watchlusdinstabilitypool.md new file mode 100644 index 000000000..d79576e6c --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.watchlusdinstabilitypool.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [watchLUSDInStabilityPool](./lib-ethers.observableethersliquity.watchlusdinstabilitypool.md) + +## ObservableEthersLiquity.watchLUSDInStabilityPool() method + +Signature: + +```typescript +watchLUSDInStabilityPool(onLUSDInStabilityPoolChanged: (lusdInStabilityPool: Decimal) => void): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| onLUSDInStabilityPoolChanged | (lusdInStabilityPool: [Decimal](./decimal.decimal.md)) => void | | + +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.observableethersliquity.watchnumberoftroves.md b/docs/sdk/lib-ethers.observableethersliquity.watchnumberoftroves.md new file mode 100644 index 000000000..c9b5b2085 --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.watchnumberoftroves.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [watchNumberOfTroves](./lib-ethers.observableethersliquity.watchnumberoftroves.md) + +## ObservableEthersLiquity.watchNumberOfTroves() method + +Signature: + +```typescript +watchNumberOfTroves(onNumberOfTrovesChanged: (numberOfTroves: number) => void): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| onNumberOfTrovesChanged | (numberOfTroves: number) => void | | + +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.observableethersliquity.watchprice.md b/docs/sdk/lib-ethers.observableethersliquity.watchprice.md new file mode 100644 index 000000000..d668cbe61 --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.watchprice.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [watchPrice](./lib-ethers.observableethersliquity.watchprice.md) + +## ObservableEthersLiquity.watchPrice() method + +Signature: + +```typescript +watchPrice(onPriceChanged: (price: Decimal) => void): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| onPriceChanged | (price: [Decimal](./decimal.decimal.md)) => void | | + +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.observableethersliquity.watchstabilitydeposit.md b/docs/sdk/lib-ethers.observableethersliquity.watchstabilitydeposit.md new file mode 100644 index 000000000..a521b6ce3 --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.watchstabilitydeposit.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [watchStabilityDeposit](./lib-ethers.observableethersliquity.watchstabilitydeposit.md) + +## ObservableEthersLiquity.watchStabilityDeposit() method + +Signature: + +```typescript +watchStabilityDeposit(onStabilityDepositChanged: (deposit: StabilityDeposit) => void, address?: string): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| onStabilityDepositChanged | (deposit: [StabilityDeposit](./lib-base.stabilitydeposit.md)) => void | | +| address | string | | + +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.observableethersliquity.watchtotal.md b/docs/sdk/lib-ethers.observableethersliquity.watchtotal.md new file mode 100644 index 000000000..c8cdaac26 --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.watchtotal.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [watchTotal](./lib-ethers.observableethersliquity.watchtotal.md) + +## ObservableEthersLiquity.watchTotal() method + +Signature: + +```typescript +watchTotal(onTotalChanged: (total: Trove) => void): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| onTotalChanged | (total: [Trove](./lib-base.trove.md)) => void | | + +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.observableethersliquity.watchtotalredistributed.md b/docs/sdk/lib-ethers.observableethersliquity.watchtotalredistributed.md new file mode 100644 index 000000000..3b7d23e51 --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.watchtotalredistributed.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [watchTotalRedistributed](./lib-ethers.observableethersliquity.watchtotalredistributed.md) + +## ObservableEthersLiquity.watchTotalRedistributed() method + +Signature: + +```typescript +watchTotalRedistributed(onTotalRedistributedChanged: (totalRedistributed: Trove) => void): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| onTotalRedistributedChanged | (totalRedistributed: [Trove](./lib-base.trove.md)) => void | | + +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.observableethersliquity.watchtrovewithoutrewards.md b/docs/sdk/lib-ethers.observableethersliquity.watchtrovewithoutrewards.md new file mode 100644 index 000000000..7c4136b6b --- /dev/null +++ b/docs/sdk/lib-ethers.observableethersliquity.watchtrovewithoutrewards.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ObservableEthersLiquity](./lib-ethers.observableethersliquity.md) > [watchTroveWithoutRewards](./lib-ethers.observableethersliquity.watchtrovewithoutrewards.md) + +## ObservableEthersLiquity.watchTroveWithoutRewards() method + +Signature: + +```typescript +watchTroveWithoutRewards(onTroveChanged: (trove: TroveWithPendingRewards) => void, address?: string): () => void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| onTroveChanged | (trove: [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md)) => void | | +| address | string | | + +Returns: + +() => void + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.adjusttrove.md b/docs/sdk/lib-ethers.populatableethersliquity.adjusttrove.md new file mode 100644 index 000000000..26d1b215c --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.adjusttrove.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [adjustTrove](./lib-ethers.populatableethersliquity.adjusttrove.md) + +## PopulatableEthersLiquity.adjustTrove() method + +Signature: + +```typescript +adjustTrove(params: TroveAdjustmentParams, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| params | [TroveAdjustmentParams](./lib-base.troveadjustmentparams.md)<[Decimalish](./decimal.decimalish.md)> | | +| optionalParams | \_TroveAdjustmentOptionalParams | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.borrowlusd.md b/docs/sdk/lib-ethers.populatableethersliquity.borrowlusd.md new file mode 100644 index 000000000..af7fa990b --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.borrowlusd.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [borrowLUSD](./lib-ethers.populatableethersliquity.borrowlusd.md) + +## PopulatableEthersLiquity.borrowLUSD() method + +Signature: + +```typescript +borrowLUSD(amount: Decimalish, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| optionalParams | \_TroveAdjustmentOptionalParams | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.claimcollateralsurplus.md b/docs/sdk/lib-ethers.populatableethersliquity.claimcollateralsurplus.md new file mode 100644 index 000000000..7c99cf6d7 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.claimcollateralsurplus.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [claimCollateralSurplus](./lib-ethers.populatableethersliquity.claimcollateralsurplus.md) + +## PopulatableEthersLiquity.claimCollateralSurplus() method + +Signature: + +```typescript +claimCollateralSurplus(overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<void>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.closetrove.md b/docs/sdk/lib-ethers.populatableethersliquity.closetrove.md new file mode 100644 index 000000000..28703adf8 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.closetrove.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [closeTrove](./lib-ethers.populatableethersliquity.closetrove.md) + +## PopulatableEthersLiquity.closeTrove() method + +Signature: + +```typescript +closeTrove(overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[TroveClosureDetails](./lib-base.troveclosuredetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.depositcollateral.md b/docs/sdk/lib-ethers.populatableethersliquity.depositcollateral.md new file mode 100644 index 000000000..bbfdcd8ac --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.depositcollateral.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [depositCollateral](./lib-ethers.populatableethersliquity.depositcollateral.md) + +## PopulatableEthersLiquity.depositCollateral() method + +Signature: + +```typescript +depositCollateral(amount: Decimalish, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| optionalParams | \_TroveAdjustmentOptionalParams | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.depositlusdinstabilitypool.md b/docs/sdk/lib-ethers.populatableethersliquity.depositlusdinstabilitypool.md new file mode 100644 index 000000000..c0dae7368 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.depositlusdinstabilitypool.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [depositLUSDInStabilityPool](./lib-ethers.populatableethersliquity.depositlusdinstabilitypool.md) + +## PopulatableEthersLiquity.depositLUSDInStabilityPool() method + +Signature: + +```typescript +depositLUSDInStabilityPool(amount: Decimalish, frontendTag?: string, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| frontendTag | string | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[StabilityDepositChangeDetails](./lib-base.stabilitydepositchangedetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.liquidate.md b/docs/sdk/lib-ethers.populatableethersliquity.liquidate.md new file mode 100644 index 000000000..ee2abfa51 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.liquidate.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [liquidate](./lib-ethers.populatableethersliquity.liquidate.md) + +## PopulatableEthersLiquity.liquidate() method + +Signature: + +```typescript +liquidate(address: string, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[LiquidationDetails](./lib-base.liquidationdetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.liquidateupto.md b/docs/sdk/lib-ethers.populatableethersliquity.liquidateupto.md new file mode 100644 index 000000000..84b28989d --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.liquidateupto.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [liquidateUpTo](./lib-ethers.populatableethersliquity.liquidateupto.md) + +## PopulatableEthersLiquity.liquidateUpTo() method + +Signature: + +```typescript +liquidateUpTo(maximumNumberOfTrovesToLiquidate: number, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| maximumNumberOfTrovesToLiquidate | number | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[LiquidationDetails](./lib-base.liquidationdetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.md b/docs/sdk/lib-ethers.populatableethersliquity.md new file mode 100644 index 000000000..91b53fcaf --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.md @@ -0,0 +1,42 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) + +## PopulatableEthersLiquity class + +Signature: + +```typescript +export declare class PopulatableEthersLiquity extends PopulatableEthersLiquityBase implements _Populatable<_Hinted, TransactionReceipt, TransactionResponse, PopulatedTransaction> +``` +Extends: PopulatableEthersLiquityBase + +Implements: \_Populatable<\_Hinted<[TransactableLiquity](./lib-base.transactableliquity.md)>, TransactionReceipt, TransactionResponse, PopulatedTransaction> + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [adjustTrove(params, optionalParams, overrides)](./lib-ethers.populatableethersliquity.adjusttrove.md) | | | +| [borrowLUSD(amount, optionalParams, overrides)](./lib-ethers.populatableethersliquity.borrowlusd.md) | | | +| [claimCollateralSurplus(overrides)](./lib-ethers.populatableethersliquity.claimcollateralsurplus.md) | | | +| [closeTrove(overrides)](./lib-ethers.populatableethersliquity.closetrove.md) | | | +| [depositCollateral(amount, optionalParams, overrides)](./lib-ethers.populatableethersliquity.depositcollateral.md) | | | +| [depositLUSDInStabilityPool(amount, frontendTag, overrides)](./lib-ethers.populatableethersliquity.depositlusdinstabilitypool.md) | | | +| [liquidate(address, overrides)](./lib-ethers.populatableethersliquity.liquidate.md) | | | +| [liquidateUpTo(maximumNumberOfTrovesToLiquidate, overrides)](./lib-ethers.populatableethersliquity.liquidateupto.md) | | | +| [openTrove(params, optionalParams, overrides)](./lib-ethers.populatableethersliquity.opentrove.md) | | Open a new Trove. | +| [redeemLUSD(amount, optionalParams, overrides)](./lib-ethers.populatableethersliquity.redeemlusd.md) | | | +| [registerFrontend(kickbackRate, overrides)](./lib-ethers.populatableethersliquity.registerfrontend.md) | | | +| [repayLUSD(amount, optionalParams, overrides)](./lib-ethers.populatableethersliquity.repaylusd.md) | | | +| [sendLQTY(toAddress, amount, overrides)](./lib-ethers.populatableethersliquity.sendlqty.md) | | | +| [sendLUSD(toAddress, amount, overrides)](./lib-ethers.populatableethersliquity.sendlusd.md) | | | +| [setPrice(price, overrides)](./lib-ethers.populatableethersliquity.setprice.md) | | | +| [stakeLQTY(amount, overrides)](./lib-ethers.populatableethersliquity.stakelqty.md) | | | +| [transferCollateralGainToTrove(optionalParams, overrides)](./lib-ethers.populatableethersliquity.transfercollateralgaintotrove.md) | | | +| [unstakeLQTY(amount, overrides)](./lib-ethers.populatableethersliquity.unstakelqty.md) | | | +| [withdrawCollateral(amount, optionalParams, overrides)](./lib-ethers.populatableethersliquity.withdrawcollateral.md) | | | +| [withdrawGainsFromStabilityPool(overrides)](./lib-ethers.populatableethersliquity.withdrawgainsfromstabilitypool.md) | | | +| [withdrawGainsFromStaking(overrides)](./lib-ethers.populatableethersliquity.withdrawgainsfromstaking.md) | | | +| [withdrawLUSDFromStabilityPool(amount, overrides)](./lib-ethers.populatableethersliquity.withdrawlusdfromstabilitypool.md) | | | + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.opentrove.md b/docs/sdk/lib-ethers.populatableethersliquity.opentrove.md new file mode 100644 index 000000000..3eca6b1a6 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.opentrove.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [openTrove](./lib-ethers.populatableethersliquity.opentrove.md) + +## PopulatableEthersLiquity.openTrove() method + +Open a new Trove. + +Signature: + +```typescript +openTrove(params: TroveCreationParams, optionalParams?: _TroveCreationOptionalParams, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| params | [TroveCreationParams](./lib-base.trovecreationparams.md)<[Decimalish](./decimal.decimalish.md)> | | +| optionalParams | \_TroveCreationOptionalParams | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[TroveCreationDetails](./lib-base.trovecreationdetails.md)>> + +The details of the Trove creation. + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.redeemlusd.md b/docs/sdk/lib-ethers.populatableethersliquity.redeemlusd.md new file mode 100644 index 000000000..5a73b6f2a --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.redeemlusd.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [redeemLUSD](./lib-ethers.populatableethersliquity.redeemlusd.md) + +## PopulatableEthersLiquity.redeemLUSD() method + +Signature: + +```typescript +redeemLUSD(amount: Decimalish, optionalParams?: _RedemptionOptionalParams, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| optionalParams | \_RedemptionOptionalParams | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[RedemptionDetails](./lib-base.redemptiondetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.registerfrontend.md b/docs/sdk/lib-ethers.populatableethersliquity.registerfrontend.md new file mode 100644 index 000000000..5ee0c38ba --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.registerfrontend.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [registerFrontend](./lib-ethers.populatableethersliquity.registerfrontend.md) + +## PopulatableEthersLiquity.registerFrontend() method + +Signature: + +```typescript +registerFrontend(kickbackRate: Decimalish, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| kickbackRate | [Decimalish](./decimal.decimalish.md) | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<void>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.repaylusd.md b/docs/sdk/lib-ethers.populatableethersliquity.repaylusd.md new file mode 100644 index 000000000..131159f97 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.repaylusd.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [repayLUSD](./lib-ethers.populatableethersliquity.repaylusd.md) + +## PopulatableEthersLiquity.repayLUSD() method + +Signature: + +```typescript +repayLUSD(amount: Decimalish, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| optionalParams | \_TroveAdjustmentOptionalParams | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.sendlqty.md b/docs/sdk/lib-ethers.populatableethersliquity.sendlqty.md new file mode 100644 index 000000000..f5870dd56 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.sendlqty.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [sendLQTY](./lib-ethers.populatableethersliquity.sendlqty.md) + +## PopulatableEthersLiquity.sendLQTY() method + +Signature: + +```typescript +sendLQTY(toAddress: string, amount: Decimalish, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toAddress | string | | +| amount | [Decimalish](./decimal.decimalish.md) | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<void>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.sendlusd.md b/docs/sdk/lib-ethers.populatableethersliquity.sendlusd.md new file mode 100644 index 000000000..de5465719 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.sendlusd.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [sendLUSD](./lib-ethers.populatableethersliquity.sendlusd.md) + +## PopulatableEthersLiquity.sendLUSD() method + +Signature: + +```typescript +sendLUSD(toAddress: string, amount: Decimalish, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toAddress | string | | +| amount | [Decimalish](./decimal.decimalish.md) | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<void>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.setprice.md b/docs/sdk/lib-ethers.populatableethersliquity.setprice.md new file mode 100644 index 000000000..b6918ac04 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.setprice.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [setPrice](./lib-ethers.populatableethersliquity.setprice.md) + +## PopulatableEthersLiquity.setPrice() method + +Signature: + +```typescript +setPrice(price: Decimalish, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| price | [Decimalish](./decimal.decimalish.md) | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<void>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.stakelqty.md b/docs/sdk/lib-ethers.populatableethersliquity.stakelqty.md new file mode 100644 index 000000000..5815bf405 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.stakelqty.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [stakeLQTY](./lib-ethers.populatableethersliquity.stakelqty.md) + +## PopulatableEthersLiquity.stakeLQTY() method + +Signature: + +```typescript +stakeLQTY(amount: Decimalish, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<void>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.transfercollateralgaintotrove.md b/docs/sdk/lib-ethers.populatableethersliquity.transfercollateralgaintotrove.md new file mode 100644 index 000000000..dc627cbe4 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.transfercollateralgaintotrove.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [transferCollateralGainToTrove](./lib-ethers.populatableethersliquity.transfercollateralgaintotrove.md) + +## PopulatableEthersLiquity.transferCollateralGainToTrove() method + +Signature: + +```typescript +transferCollateralGainToTrove(optionalParams?: _CollateralGainTransferOptionalParams, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| optionalParams | \_CollateralGainTransferOptionalParams | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[CollateralGainTransferDetails](./lib-base.collateralgaintransferdetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.unstakelqty.md b/docs/sdk/lib-ethers.populatableethersliquity.unstakelqty.md new file mode 100644 index 000000000..e55f8f07b --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.unstakelqty.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [unstakeLQTY](./lib-ethers.populatableethersliquity.unstakelqty.md) + +## PopulatableEthersLiquity.unstakeLQTY() method + +Signature: + +```typescript +unstakeLQTY(amount: Decimalish, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<void>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.withdrawcollateral.md b/docs/sdk/lib-ethers.populatableethersliquity.withdrawcollateral.md new file mode 100644 index 000000000..da12a0e43 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.withdrawcollateral.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [withdrawCollateral](./lib-ethers.populatableethersliquity.withdrawcollateral.md) + +## PopulatableEthersLiquity.withdrawCollateral() method + +Signature: + +```typescript +withdrawCollateral(amount: Decimalish, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| optionalParams | \_TroveAdjustmentOptionalParams | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[TroveAdjustmentDetails](./lib-base.troveadjustmentdetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.withdrawgainsfromstabilitypool.md b/docs/sdk/lib-ethers.populatableethersliquity.withdrawgainsfromstabilitypool.md new file mode 100644 index 000000000..5fb79c0c6 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.withdrawgainsfromstabilitypool.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [withdrawGainsFromStabilityPool](./lib-ethers.populatableethersliquity.withdrawgainsfromstabilitypool.md) + +## PopulatableEthersLiquity.withdrawGainsFromStabilityPool() method + +Signature: + +```typescript +withdrawGainsFromStabilityPool(overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[StabilityPoolGainsWithdrawalDetails](./lib-base.stabilitypoolgainswithdrawaldetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.withdrawgainsfromstaking.md b/docs/sdk/lib-ethers.populatableethersliquity.withdrawgainsfromstaking.md new file mode 100644 index 000000000..32363a2d2 --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.withdrawgainsfromstaking.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [withdrawGainsFromStaking](./lib-ethers.populatableethersliquity.withdrawgainsfromstaking.md) + +## PopulatableEthersLiquity.withdrawGainsFromStaking() method + +Signature: + +```typescript +withdrawGainsFromStaking(overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<void>> + diff --git a/docs/sdk/lib-ethers.populatableethersliquity.withdrawlusdfromstabilitypool.md b/docs/sdk/lib-ethers.populatableethersliquity.withdrawlusdfromstabilitypool.md new file mode 100644 index 000000000..3f008548e --- /dev/null +++ b/docs/sdk/lib-ethers.populatableethersliquity.withdrawlusdfromstabilitypool.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) > [withdrawLUSDFromStabilityPool](./lib-ethers.populatableethersliquity.withdrawlusdfromstabilitypool.md) + +## PopulatableEthersLiquity.withdrawLUSDFromStabilityPool() method + +Signature: + +```typescript +withdrawLUSDFromStabilityPool(amount: Decimalish, overrides?: EthersTransactionOverrides): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| amount | [Decimalish](./decimal.decimalish.md) | | +| overrides | [EthersTransactionOverrides](./lib-ethers.etherstransactionoverrides.md) | | + +Returns: + +Promise<[PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md)<[StabilityDepositChangeDetails](./lib-base.stabilitydepositchangedetails.md)>> + diff --git a/docs/sdk/lib-ethers.populatedetherstransaction._constructor_.md b/docs/sdk/lib-ethers.populatedetherstransaction._constructor_.md new file mode 100644 index 000000000..712becd2d --- /dev/null +++ b/docs/sdk/lib-ethers.populatedetherstransaction._constructor_.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md) > [(constructor)](./lib-ethers.populatedetherstransaction._constructor_.md) + +## PopulatedEthersTransaction.(constructor) + +Constructs a new instance of the `PopulatedEthersTransaction` class + +Signature: + +```typescript +constructor(rawPopulatedTransaction: PopulatedTransaction, parse: (rawReceipt: TransactionReceipt) => T, signer: Signer, contracts: LiquityContracts); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| rawPopulatedTransaction | PopulatedTransaction | | +| parse | (rawReceipt: TransactionReceipt) => T | | +| signer | Signer | | +| contracts | [LiquityContracts](./lib-ethers.liquitycontracts.md) | | + diff --git a/docs/sdk/lib-ethers.populatedetherstransaction.md b/docs/sdk/lib-ethers.populatedetherstransaction.md new file mode 100644 index 000000000..2c18e2848 --- /dev/null +++ b/docs/sdk/lib-ethers.populatedetherstransaction.md @@ -0,0 +1,31 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md) + +## PopulatedEthersTransaction class + +Signature: + +```typescript +export declare class PopulatedEthersTransaction implements PopulatedLiquityTransaction> +``` +Implements: [PopulatedLiquityTransaction](./lib-base.populatedliquitytransaction.md)<PopulatedTransaction, [SentEthersTransaction](./lib-ethers.sentetherstransaction.md)<T>> + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(rawPopulatedTransaction, parse, signer, contracts)](./lib-ethers.populatedetherstransaction._constructor_.md) | | Constructs a new instance of the PopulatedEthersTransaction class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [rawPopulatedTransaction](./lib-ethers.populatedetherstransaction.rawpopulatedtransaction.md) | | PopulatedTransaction | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [send()](./lib-ethers.populatedetherstransaction.send.md) | | | + diff --git a/docs/sdk/lib-ethers.populatedetherstransaction.rawpopulatedtransaction.md b/docs/sdk/lib-ethers.populatedetherstransaction.rawpopulatedtransaction.md new file mode 100644 index 000000000..903b53a91 --- /dev/null +++ b/docs/sdk/lib-ethers.populatedetherstransaction.rawpopulatedtransaction.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md) > [rawPopulatedTransaction](./lib-ethers.populatedetherstransaction.rawpopulatedtransaction.md) + +## PopulatedEthersTransaction.rawPopulatedTransaction property + +Signature: + +```typescript +readonly rawPopulatedTransaction: PopulatedTransaction; +``` diff --git a/docs/sdk/lib-ethers.populatedetherstransaction.send.md b/docs/sdk/lib-ethers.populatedetherstransaction.send.md new file mode 100644 index 000000000..710c0f9fc --- /dev/null +++ b/docs/sdk/lib-ethers.populatedetherstransaction.send.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [PopulatedEthersTransaction](./lib-ethers.populatedetherstransaction.md) > [send](./lib-ethers.populatedetherstransaction.send.md) + +## PopulatedEthersTransaction.send() method + +Signature: + +```typescript +send(): Promise>; +``` +Returns: + +Promise<[SentEthersTransaction](./lib-ethers.sentetherstransaction.md)<T>> + diff --git a/docs/sdk/lib-ethers.pricefeedistestnet.md b/docs/sdk/lib-ethers.pricefeedistestnet.md new file mode 100644 index 000000000..2f663ed3c --- /dev/null +++ b/docs/sdk/lib-ethers.pricefeedistestnet.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [priceFeedIsTestnet](./lib-ethers.pricefeedistestnet.md) + +## priceFeedIsTestnet variable + +Signature: + +```typescript +priceFeedIsTestnet: (priceFeed: PriceFeed | PriceFeedTestnet) => priceFeed is PriceFeedTestnet +``` diff --git a/docs/sdk/lib-ethers.promisable.md b/docs/sdk/lib-ethers.promisable.md new file mode 100644 index 000000000..80eba3368 --- /dev/null +++ b/docs/sdk/lib-ethers.promisable.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [Promisable](./lib-ethers.promisable.md) + +## Promisable type + +Signature: + +```typescript +export declare type Promisable = { + [P in keyof T]: T[P] | Promise; +}; +``` diff --git a/docs/sdk/lib-ethers.readableethersliquity.getcollateralsurplusbalance.md b/docs/sdk/lib-ethers.readableethersliquity.getcollateralsurplusbalance.md new file mode 100644 index 000000000..fb7dfcdb9 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getcollateralsurplusbalance.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getCollateralSurplusBalance](./lib-ethers.readableethersliquity.getcollateralsurplusbalance.md) + +## ReadableEthersLiquity.getCollateralSurplusBalance() method + +Signature: + +```typescript +getCollateralSurplusBalance(address?: string, overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getfees.md b/docs/sdk/lib-ethers.readableethersliquity.getfees.md new file mode 100644 index 000000000..752e32476 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getfees.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getFees](./lib-ethers.readableethersliquity.getfees.md) + +## ReadableEthersLiquity.getFees() method + +Signature: + +```typescript +getFees(overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Fees](./lib-base.fees.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getfirsttroves.md b/docs/sdk/lib-ethers.readableethersliquity.getfirsttroves.md new file mode 100644 index 000000000..1aac578c7 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getfirsttroves.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getFirstTroves](./lib-ethers.readableethersliquity.getfirsttroves.md) + +## ReadableEthersLiquity.getFirstTroves() method + +Signature: + +```typescript +getFirstTroves(startIdx: number, numberOfTroves: number, overrides?: EthersCallOverrides): Promise<[string, TroveWithPendingRewards][]>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| startIdx | number | | +| numberOfTroves | number | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<\[string, [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md)\]\[\]> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getfrontendstatus.md b/docs/sdk/lib-ethers.readableethersliquity.getfrontendstatus.md new file mode 100644 index 000000000..b199e5643 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getfrontendstatus.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getFrontendStatus](./lib-ethers.readableethersliquity.getfrontendstatus.md) + +## ReadableEthersLiquity.getFrontendStatus() method + +Signature: + +```typescript +getFrontendStatus(address?: string, overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[FrontendStatus](./lib-base.frontendstatus.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getlasttroves.md b/docs/sdk/lib-ethers.readableethersliquity.getlasttroves.md new file mode 100644 index 000000000..e081239d2 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getlasttroves.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getLastTroves](./lib-ethers.readableethersliquity.getlasttroves.md) + +## ReadableEthersLiquity.getLastTroves() method + +Signature: + +```typescript +getLastTroves(startIdx: number, numberOfTroves: number, overrides?: EthersCallOverrides): Promise<[string, TroveWithPendingRewards][]>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| startIdx | number | | +| numberOfTroves | number | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<\[string, [TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md)\]\[\]> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getlqtybalance.md b/docs/sdk/lib-ethers.readableethersliquity.getlqtybalance.md new file mode 100644 index 000000000..6c18f7c85 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getlqtybalance.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getLQTYBalance](./lib-ethers.readableethersliquity.getlqtybalance.md) + +## ReadableEthersLiquity.getLQTYBalance() method + +Signature: + +```typescript +getLQTYBalance(address?: string, overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getlqtystake.md b/docs/sdk/lib-ethers.readableethersliquity.getlqtystake.md new file mode 100644 index 000000000..f806e7a53 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getlqtystake.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getLQTYStake](./lib-ethers.readableethersliquity.getlqtystake.md) + +## ReadableEthersLiquity.getLQTYStake() method + +Signature: + +```typescript +getLQTYStake(address?: string, overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[LQTYStake](./lib-base.lqtystake.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getlusdbalance.md b/docs/sdk/lib-ethers.readableethersliquity.getlusdbalance.md new file mode 100644 index 000000000..1157e7dd1 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getlusdbalance.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getLUSDBalance](./lib-ethers.readableethersliquity.getlusdbalance.md) + +## ReadableEthersLiquity.getLUSDBalance() method + +Signature: + +```typescript +getLUSDBalance(address?: string, overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getlusdinstabilitypool.md b/docs/sdk/lib-ethers.readableethersliquity.getlusdinstabilitypool.md new file mode 100644 index 000000000..e3a5772c7 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getlusdinstabilitypool.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getLUSDInStabilityPool](./lib-ethers.readableethersliquity.getlusdinstabilitypool.md) + +## ReadableEthersLiquity.getLUSDInStabilityPool() method + +Signature: + +```typescript +getLUSDInStabilityPool(overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getnumberoftroves.md b/docs/sdk/lib-ethers.readableethersliquity.getnumberoftroves.md new file mode 100644 index 000000000..e50fe1b23 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getnumberoftroves.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getNumberOfTroves](./lib-ethers.readableethersliquity.getnumberoftroves.md) + +## ReadableEthersLiquity.getNumberOfTroves() method + +Signature: + +```typescript +getNumberOfTroves(overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<number> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getprice.md b/docs/sdk/lib-ethers.readableethersliquity.getprice.md new file mode 100644 index 000000000..502e88c03 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getprice.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getPrice](./lib-ethers.readableethersliquity.getprice.md) + +## ReadableEthersLiquity.getPrice() method + +Signature: + +```typescript +getPrice(overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.getstabilitydeposit.md b/docs/sdk/lib-ethers.readableethersliquity.getstabilitydeposit.md new file mode 100644 index 000000000..711fc28a4 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.getstabilitydeposit.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getStabilityDeposit](./lib-ethers.readableethersliquity.getstabilitydeposit.md) + +## ReadableEthersLiquity.getStabilityDeposit() method + +Signature: + +```typescript +getStabilityDeposit(address?: string, overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[StabilityDeposit](./lib-base.stabilitydeposit.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.gettotal.md b/docs/sdk/lib-ethers.readableethersliquity.gettotal.md new file mode 100644 index 000000000..e9475a7a1 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.gettotal.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getTotal](./lib-ethers.readableethersliquity.gettotal.md) + +## ReadableEthersLiquity.getTotal() method + +Signature: + +```typescript +getTotal(overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Trove](./lib-base.trove.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.gettotalredistributed.md b/docs/sdk/lib-ethers.readableethersliquity.gettotalredistributed.md new file mode 100644 index 000000000..256a7421a --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.gettotalredistributed.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getTotalRedistributed](./lib-ethers.readableethersliquity.gettotalredistributed.md) + +## ReadableEthersLiquity.getTotalRedistributed() method + +Signature: + +```typescript +getTotalRedistributed(overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Trove](./lib-base.trove.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.gettotalstakedlqty.md b/docs/sdk/lib-ethers.readableethersliquity.gettotalstakedlqty.md new file mode 100644 index 000000000..840d00f88 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.gettotalstakedlqty.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getTotalStakedLQTY](./lib-ethers.readableethersliquity.gettotalstakedlqty.md) + +## ReadableEthersLiquity.getTotalStakedLQTY() method + +Signature: + +```typescript +getTotalStakedLQTY(overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Decimal](./decimal.decimal.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.gettrove.md b/docs/sdk/lib-ethers.readableethersliquity.gettrove.md new file mode 100644 index 000000000..7001aa90b --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.gettrove.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getTrove](./lib-ethers.readableethersliquity.gettrove.md) + +## ReadableEthersLiquity.getTrove() method + +Signature: + +```typescript +getTrove(address?: string, overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[Trove](./lib-base.trove.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.gettrovewithoutrewards.md b/docs/sdk/lib-ethers.readableethersliquity.gettrovewithoutrewards.md new file mode 100644 index 000000000..ccb50d6a3 --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.gettrovewithoutrewards.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) > [getTroveWithoutRewards](./lib-ethers.readableethersliquity.gettrovewithoutrewards.md) + +## ReadableEthersLiquity.getTroveWithoutRewards() method + +Signature: + +```typescript +getTroveWithoutRewards(address?: string, overrides?: EthersCallOverrides): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| address | string | | +| overrides | [EthersCallOverrides](./lib-ethers.etherscalloverrides.md) | | + +Returns: + +Promise<[TroveWithPendingRewards](./lib-base.trovewithpendingrewards.md)> + diff --git a/docs/sdk/lib-ethers.readableethersliquity.md b/docs/sdk/lib-ethers.readableethersliquity.md new file mode 100644 index 000000000..18cf495ee --- /dev/null +++ b/docs/sdk/lib-ethers.readableethersliquity.md @@ -0,0 +1,37 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [ReadableEthersLiquity](./lib-ethers.readableethersliquity.md) + +## ReadableEthersLiquity class + +Signature: + +```typescript +export declare class ReadableEthersLiquity extends EthersLiquityBase implements ReadableLiquity +``` +Extends: EthersLiquityBase + +Implements: [ReadableLiquity](./lib-base.readableliquity.md) + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [getCollateralSurplusBalance(address, overrides)](./lib-ethers.readableethersliquity.getcollateralsurplusbalance.md) | | | +| [getFees(overrides)](./lib-ethers.readableethersliquity.getfees.md) | | | +| [getFirstTroves(startIdx, numberOfTroves, overrides)](./lib-ethers.readableethersliquity.getfirsttroves.md) | | | +| [getFrontendStatus(address, overrides)](./lib-ethers.readableethersliquity.getfrontendstatus.md) | | | +| [getLastTroves(startIdx, numberOfTroves, overrides)](./lib-ethers.readableethersliquity.getlasttroves.md) | | | +| [getLQTYBalance(address, overrides)](./lib-ethers.readableethersliquity.getlqtybalance.md) | | | +| [getLQTYStake(address, overrides)](./lib-ethers.readableethersliquity.getlqtystake.md) | | | +| [getLUSDBalance(address, overrides)](./lib-ethers.readableethersliquity.getlusdbalance.md) | | | +| [getLUSDInStabilityPool(overrides)](./lib-ethers.readableethersliquity.getlusdinstabilitypool.md) | | | +| [getNumberOfTroves(overrides)](./lib-ethers.readableethersliquity.getnumberoftroves.md) | | | +| [getPrice(overrides)](./lib-ethers.readableethersliquity.getprice.md) | | | +| [getStabilityDeposit(address, overrides)](./lib-ethers.readableethersliquity.getstabilitydeposit.md) | | | +| [getTotal(overrides)](./lib-ethers.readableethersliquity.gettotal.md) | | | +| [getTotalRedistributed(overrides)](./lib-ethers.readableethersliquity.gettotalredistributed.md) | | | +| [getTotalStakedLQTY(overrides)](./lib-ethers.readableethersliquity.gettotalstakedlqty.md) | | | +| [getTrove(address, overrides)](./lib-ethers.readableethersliquity.gettrove.md) | | | +| [getTroveWithoutRewards(address, overrides)](./lib-ethers.readableethersliquity.gettrovewithoutrewards.md) | | | + diff --git a/docs/sdk/lib-ethers.redeemmaxiterations.md b/docs/sdk/lib-ethers.redeemmaxiterations.md new file mode 100644 index 000000000..7a044d442 --- /dev/null +++ b/docs/sdk/lib-ethers.redeemmaxiterations.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [redeemMaxIterations](./lib-ethers.redeemmaxiterations.md) + +## redeemMaxIterations variable + +Signature: + +```typescript +redeemMaxIterations = 68 +``` diff --git a/docs/sdk/lib-ethers.sendableethersliquity.md b/docs/sdk/lib-ethers.sendableethersliquity.md new file mode 100644 index 000000000..194082989 --- /dev/null +++ b/docs/sdk/lib-ethers.sendableethersliquity.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [SendableEthersLiquity](./lib-ethers.sendableethersliquity.md) + +## SendableEthersLiquity variable + +Signature: + +```typescript +SendableEthersLiquity: new (populatable: PopulatableEthersLiquity) => SendableEthersLiquity +``` diff --git a/docs/sdk/lib-ethers.sentetherstransaction._constructor_.md b/docs/sdk/lib-ethers.sentetherstransaction._constructor_.md new file mode 100644 index 000000000..f11a1a7df --- /dev/null +++ b/docs/sdk/lib-ethers.sentetherstransaction._constructor_.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [SentEthersTransaction](./lib-ethers.sentetherstransaction.md) > [(constructor)](./lib-ethers.sentetherstransaction._constructor_.md) + +## SentEthersTransaction.(constructor) + +Constructs a new instance of the `SentEthersTransaction` class + +Signature: + +```typescript +constructor(rawSentTransaction: TransactionResponse, parse: (rawReceipt: TransactionReceipt) => T, provider: Provider, contracts: LiquityContracts); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| rawSentTransaction | TransactionResponse | | +| parse | (rawReceipt: TransactionReceipt) => T | | +| provider | Provider | | +| contracts | [LiquityContracts](./lib-ethers.liquitycontracts.md) | | + diff --git a/docs/sdk/lib-ethers.sentetherstransaction.getreceipt.md b/docs/sdk/lib-ethers.sentetherstransaction.getreceipt.md new file mode 100644 index 000000000..fb473b2be --- /dev/null +++ b/docs/sdk/lib-ethers.sentetherstransaction.getreceipt.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [SentEthersTransaction](./lib-ethers.sentetherstransaction.md) > [getReceipt](./lib-ethers.sentetherstransaction.getreceipt.md) + +## SentEthersTransaction.getReceipt() method + +Signature: + +```typescript +getReceipt(): Promise>; +``` +Returns: + +Promise<[LiquityReceipt](./lib-base.liquityreceipt.md)<TransactionReceipt, T>> + diff --git a/docs/sdk/lib-ethers.sentetherstransaction.md b/docs/sdk/lib-ethers.sentetherstransaction.md new file mode 100644 index 000000000..e01e9aa31 --- /dev/null +++ b/docs/sdk/lib-ethers.sentetherstransaction.md @@ -0,0 +1,32 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [SentEthersTransaction](./lib-ethers.sentetherstransaction.md) + +## SentEthersTransaction class + +Signature: + +```typescript +export declare class SentEthersTransaction implements SentLiquityTransaction> +``` +Implements: [SentLiquityTransaction](./lib-base.sentliquitytransaction.md)<TransactionResponse, [LiquityReceipt](./lib-base.liquityreceipt.md)<TransactionReceipt, T>> + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(rawSentTransaction, parse, provider, contracts)](./lib-ethers.sentetherstransaction._constructor_.md) | | Constructs a new instance of the SentEthersTransaction class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [rawSentTransaction](./lib-ethers.sentetherstransaction.rawsenttransaction.md) | | TransactionResponse | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [getReceipt()](./lib-ethers.sentetherstransaction.getreceipt.md) | | | +| [waitForReceipt()](./lib-ethers.sentetherstransaction.waitforreceipt.md) | | | + diff --git a/docs/sdk/lib-ethers.sentetherstransaction.rawsenttransaction.md b/docs/sdk/lib-ethers.sentetherstransaction.rawsenttransaction.md new file mode 100644 index 000000000..cd9e4a3d5 --- /dev/null +++ b/docs/sdk/lib-ethers.sentetherstransaction.rawsenttransaction.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [SentEthersTransaction](./lib-ethers.sentetherstransaction.md) > [rawSentTransaction](./lib-ethers.sentetherstransaction.rawsenttransaction.md) + +## SentEthersTransaction.rawSentTransaction property + +Signature: + +```typescript +readonly rawSentTransaction: TransactionResponse; +``` diff --git a/docs/sdk/lib-ethers.sentetherstransaction.waitforreceipt.md b/docs/sdk/lib-ethers.sentetherstransaction.waitforreceipt.md new file mode 100644 index 000000000..74e196d31 --- /dev/null +++ b/docs/sdk/lib-ethers.sentetherstransaction.waitforreceipt.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [SentEthersTransaction](./lib-ethers.sentetherstransaction.md) > [waitForReceipt](./lib-ethers.sentetherstransaction.waitforreceipt.md) + +## SentEthersTransaction.waitForReceipt() method + +Signature: + +```typescript +waitForReceipt(): Promise>; +``` +Returns: + +Promise<[MinedReceipt](./lib-base.minedreceipt.md)<TransactionReceipt, T>> + diff --git a/docs/sdk/lib-ethers.transactableethersliquity.md b/docs/sdk/lib-ethers.transactableethersliquity.md new file mode 100644 index 000000000..4b6d358b8 --- /dev/null +++ b/docs/sdk/lib-ethers.transactableethersliquity.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [TransactableEthersLiquity](./lib-ethers.transactableethersliquity.md) + +## TransactableEthersLiquity variable + +Signature: + +```typescript +TransactableEthersLiquity: new (sendable: SendableEthersLiquity) => TransactableEthersLiquity +``` diff --git a/docs/sdk/lib-ethers.typedcontract.md b/docs/sdk/lib-ethers.typedcontract.md new file mode 100644 index 000000000..48e8d45c3 --- /dev/null +++ b/docs/sdk/lib-ethers.typedcontract.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [TypedContract](./lib-ethers.typedcontract.md) + +## TypedContract type + +Signature: + +```typescript +export declare type TypedContract = TypeSafeContract & U & { + readonly estimateAndPopulate: { + [P in keyof U]: U[P] extends (...args: [...infer A, infer O | undefined]) => unknown ? EstimatedContractFunction : never; + }; +}; +``` diff --git a/docs/sdk/lib-ethers.typedliquitycontract.md b/docs/sdk/lib-ethers.typedliquitycontract.md new file mode 100644 index 000000000..e77e8ca7a --- /dev/null +++ b/docs/sdk/lib-ethers.typedliquitycontract.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [TypedLiquityContract](./lib-ethers.typedliquitycontract.md) + +## TypedLiquityContract type + +Signature: + +```typescript +export declare type TypedLiquityContract = TypedContract; +``` +References: [TypedContract](./lib-ethers.typedcontract.md) + diff --git a/docs/sdk/lib-ethers.typedlogdescription.args.md b/docs/sdk/lib-ethers.typedlogdescription.args.md new file mode 100644 index 000000000..73af93901 --- /dev/null +++ b/docs/sdk/lib-ethers.typedlogdescription.args.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [TypedLogDescription](./lib-ethers.typedlogdescription.md) > [args](./lib-ethers.typedlogdescription.args.md) + +## TypedLogDescription.args property + +Signature: + +```typescript +args: T; +``` diff --git a/docs/sdk/lib-ethers.typedlogdescription.md b/docs/sdk/lib-ethers.typedlogdescription.md new file mode 100644 index 000000000..88cfe9e7d --- /dev/null +++ b/docs/sdk/lib-ethers.typedlogdescription.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@liquity/lib-ethers](./lib-ethers.md) > [TypedLogDescription](./lib-ethers.typedlogdescription.md) + +## TypedLogDescription interface + +Signature: + +```typescript +export interface TypedLogDescription extends Omit +``` +Extends: Omit<LogDescription, "args"> + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [args](./lib-ethers.typedlogdescription.args.md) | T | | + diff --git a/package.json b/package.json index ce9b1d6be..15ad7fcf2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "deploy": "yarn workspace @liquity/lib-ethers hardhat deploy", "docs": "run-s docs:*", "docs:collect-sdk-apis": "node scripts/collect-sdk-apis.js", - "docs:api-documenter": "api-documenter markdown -i temp/sdk-apis -o docs/sdk", + "docs:api-documenter": "api-documenter generate -i temp/sdk-apis -o docs/sdk", "fuzzer": "yarn workspace @liquity/fuzzer fuzzer", "prepare": "run-s prepare:*", "prepare:contracts": "yarn workspace @liquity/contracts prepare", diff --git a/packages/decimal/api-extractor.json b/packages/decimal/api-extractor.json new file mode 100644 index 000000000..2069b8ac3 --- /dev/null +++ b/packages/decimal/api-extractor.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "extends": "../../api-extractor.base.json" +} diff --git a/packages/decimal/etc/decimal.api.md b/packages/decimal/etc/decimal.api.md new file mode 100644 index 000000000..1b2854be7 --- /dev/null +++ b/packages/decimal/etc/decimal.api.md @@ -0,0 +1,127 @@ +## API Report File for "@liquity/decimal" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { BigNumber } from '@ethersproject/bignumber'; +import { BigNumberish } from '@ethersproject/bignumber'; + +// @public (undocumented) +export class Decimal { + constructor(bigNumber: BigNumber); + // (undocumented) + get absoluteValue(): this; + // (undocumented) + add(addend: Decimalish): Decimal; + // (undocumented) + readonly bigNumber: BigNumber; + // (undocumented) + static bigNumberFrom(decimalish: Decimalish): BigNumber; + // (undocumented) + static readonly DIGITS: BigNumber; + // (undocumented) + div(divider: Decimalish): Decimal; + // (undocumented) + eq(that: Decimalish): boolean; + // (undocumented) + get finite(): this | undefined; + // (undocumented) + static from(decimalish: Decimalish): Decimal; + // (undocumented) + gt(that: Decimalish): boolean; + // (undocumented) + gte(that: Decimalish): boolean; + // (undocumented) + static readonly HALF: Decimal; + // (undocumented) + get infinite(): this | undefined; + // (undocumented) + static readonly INFINITY: Decimal; + // (undocumented) + get isZero(): boolean; + // (undocumented) + lt(that: Decimalish): boolean; + // (undocumented) + lte(that: Decimalish): boolean; + // (undocumented) + mul(multiplier: Decimalish): Decimal; + // (undocumented) + mulDiv(multiplier: Decimalish, divider: Decimalish): Decimal; + // (undocumented) + get nonZero(): this | undefined; + // (undocumented) + static readonly ONE: Decimal; + // (undocumented) + pow(exponent: number): Decimal; + // (undocumented) + static readonly PRECISION = 18; + // (undocumented) + prettify(precision?: number): string; + // (undocumented) + static prettify(bigNumberish: BigNumberish): string; + // (undocumented) + shorten(): string; + // (undocumented) + static shorten(bigNumber: BigNumber): string; + // (undocumented) + sub(subtrahend: Decimalish): Decimal; + // (undocumented) + toString(precision?: number): string; + // (undocumented) + static readonly ZERO: Decimal; + // (undocumented) + get zero(): this | undefined; +} + +// @public (undocumented) +export type Decimalish = Decimal | number | string; + +// @alpha (undocumented) +export class Difference { + // (undocumented) + get absoluteValue(): Decimal | undefined; + // (undocumented) + static between(d1: Decimalish | undefined, d2: Decimalish | undefined): Difference; + // (undocumented) + get bigNumber(): BigNumber | undefined; + // (undocumented) + get finite(): this | undefined; + // (undocumented) + get infinite(): this | undefined; + // (undocumented) + mul(multiplier: Decimalish): Difference; + // (undocumented) + get negative(): this | undefined; + // (undocumented) + get nonZero(): this | undefined; + // (undocumented) + get positive(): this | undefined; + // (undocumented) + prettify(precision?: number): string; + // (undocumented) + toString(precision?: number): string; +} + +// @alpha (undocumented) +export class Percent { + constructor(ratio: T); + // (undocumented) + nonZeroish(precision: number): this | undefined; + // (undocumented) + prettify(): string; + // (undocumented) + toString(precision: number): string; +} + + +// (No @packageDocumentation comment for this package) + +``` diff --git a/packages/decimal/package.json b/packages/decimal/package.json index 76cd83d4f..9b03eccf1 100644 --- a/packages/decimal/package.json +++ b/packages/decimal/package.json @@ -5,16 +5,20 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "prepare": "tsc --project tsconfig.dist.json", + "prepare": "run-s prepare:*", + "prepare:tsc": "tsc --project tsconfig.dist.json", + "prepare:api": "api-extractor run --local", "test": "mocha --require ts-node/register" }, "devDependencies": { "@ethersproject/bignumber": "^5.0.0", + "@microsoft/api-extractor": "^7.13.0", "@types/chai": "^4.2.9", "@types/mocha": "^8.0.3", "chai": "^4.2.0", "fast-check": "^2.7.0", "mocha": "^8.0.1", + "npm-run-all": "^4.1.5", "ts-node": "^9.0.0", "typescript": "^4.0.3" }, diff --git a/packages/decimal/src/Decimal.ts b/packages/decimal/src/Decimal.ts index 1481110ec..34b83bcf2 100644 --- a/packages/decimal/src/Decimal.ts +++ b/packages/decimal/src/Decimal.ts @@ -7,16 +7,22 @@ const MAX_UINT_256 = BigNumber.from( ); const TEN = BigNumber.from(10); +const getDigits = (numDigits: number) => TEN.pow(numDigits); +/** @public */ export type Decimalish = Decimal | number | string; +const stringRepresentationFormat = /^[0-9]*(\.[0-9]*)?(e[-+]?[0-9]+)?$/; +const trailingZeros = /0*$/; +const magnitudes = ["", "K", "M", "B", "T"]; + +const roundedMul = (x: BigNumber, y: BigNumber) => + x.mul(y).add(Decimal.HALF.bigNumber).div(Decimal.DIGITS); + +/** @public */ export class Decimal { static readonly PRECISION = 18; - static readonly DIGITS = Decimal.getDigits(Decimal.PRECISION); - - private static readonly stringRepresentationFormat = /^[0-9]*(\.[0-9]*)?(e[-+]?[0-9]+)?$/; - private static readonly trailingZeros = /0*$/; - private static readonly magnitudes = ["", "K", "M", "B", "T"]; + static readonly DIGITS = getDigits(Decimal.PRECISION); static readonly INFINITY = new Decimal(MAX_UINT_256); static readonly ZERO = Decimal.from(0); @@ -33,12 +39,8 @@ export class Decimal { this.bigNumber = bigNumber; } - private static getDigits(numDigits: number) { - return TEN.pow(numDigits); - } - - private static fromString(representation: string): Decimal { - if (!representation || !representation.match(Decimal.stringRepresentationFormat)) { + private static _fromString(representation: string): Decimal { + if (!representation || !representation.match(stringRepresentationFormat)) { throw new Error("bad decimal format"); } @@ -47,7 +49,7 @@ export class Decimal { if (exponent.startsWith("-")) { return new Decimal( - Decimal.fromString(coefficient).bigNumber.div(TEN.pow(BigNumber.from(exponent.substr(1)))) + Decimal._fromString(coefficient).bigNumber.div(TEN.pow(BigNumber.from(exponent.substr(1)))) ); } @@ -56,7 +58,7 @@ export class Decimal { } return new Decimal( - Decimal.fromString(coefficient).bigNumber.mul(TEN.pow(BigNumber.from(exponent))) + Decimal._fromString(coefficient).bigNumber.mul(TEN.pow(BigNumber.from(exponent))) ); } @@ -84,9 +86,9 @@ export class Decimal { case "object": return decimalish; case "string": - return Decimal.fromString(decimalish); + return Decimal._fromString(decimalish); case "number": - return Decimal.fromString(decimalish.toString()); + return Decimal._fromString(decimalish.toString()); } } @@ -94,7 +96,7 @@ export class Decimal { return Decimal.from(decimalish).bigNumber; } - private toStringWithAutomaticPrecision() { + private _toStringWithAutomaticPrecision() { const characteristic = this.bigNumber.div(Decimal.DIGITS); const mantissa = this.bigNumber.mod(Decimal.DIGITS); @@ -102,22 +104,22 @@ export class Decimal { return characteristic.toString(); } else { const paddedMantissa = mantissa.toString().padStart(Decimal.PRECISION, "0"); - const trimmedMantissa = paddedMantissa.replace(Decimal.trailingZeros, ""); + const trimmedMantissa = paddedMantissa.replace(trailingZeros, ""); return characteristic.toString() + "." + trimmedMantissa; } } - private roundUp(precision: number) { - const halfDigit = Decimal.getDigits(Decimal.PRECISION - 1 - precision).mul(5); + private _roundUp(precision: number) { + const halfDigit = getDigits(Decimal.PRECISION - 1 - precision).mul(5); return this.bigNumber.add(halfDigit); } - private toStringWithPrecision(precision: number) { + private _toStringWithPrecision(precision: number) { if (precision < 0) { throw new Error("precision must not be negative"); } - const value = precision < Decimal.PRECISION ? this.roundUp(precision) : this.bigNumber; + const value = precision < Decimal.PRECISION ? this._roundUp(precision) : this.bigNumber; const characteristic = value.div(Decimal.DIGITS); const mantissa = value.mod(Decimal.DIGITS); @@ -134,9 +136,9 @@ export class Decimal { if (this.infinite) { return "∞"; } else if (precision !== undefined) { - return this.toStringWithPrecision(precision); + return this._toStringWithPrecision(precision); } else { - return this.toStringWithAutomaticPrecision(); + return this._toStringWithAutomaticPrecision(); } } @@ -153,15 +155,12 @@ export class Decimal { shorten() { const characteristicLength = this.toString(0).length; - const magnitude = Math.min( - Math.floor((characteristicLength - 1) / 3), - Decimal.magnitudes.length - 1 - ); + const magnitude = Math.min(Math.floor((characteristicLength - 1) / 3), magnitudes.length - 1); const precision = Math.max(3 * (magnitude + 1) - characteristicLength, 0); - const normalized = this.div(new Decimal(Decimal.getDigits(Decimal.PRECISION + 3 * magnitude))); + const normalized = this.div(new Decimal(getDigits(Decimal.PRECISION + 3 * magnitude))); - return normalized.prettify(precision) + Decimal.magnitudes[magnitude]; + return normalized.prettify(precision) + magnitudes[magnitude]; } static shorten(bigNumber: BigNumber) { @@ -201,10 +200,6 @@ export class Decimal { return new Decimal(this.bigNumber.mul(multiplier.bigNumber).div(divider.bigNumber)); } - private static roundedMul(x: BigNumber, y: BigNumber) { - return x.mul(y).add(Decimal.HALF.bigNumber).div(Decimal.DIGITS); - } - pow(exponent: number) { assert(Number.isInteger(exponent)); assert(0 <= exponent && exponent <= 0xffffffff); // Ensure we're safe to use bitwise ops @@ -222,13 +217,13 @@ export class Decimal { for (; exponent > 1; exponent >>>= 1) { if (exponent & 1) { - y = Decimal.roundedMul(x, y); + y = roundedMul(x, y); } - x = Decimal.roundedMul(x, x); + x = roundedMul(x, x); } - return new Decimal(Decimal.roundedMul(x, y)); + return new Decimal(roundedMul(x, y)); } get isZero() { @@ -286,11 +281,12 @@ export class Decimal { type DifferenceRepresentation = { sign: "" | "+" | "-"; absoluteValue: Decimal }; +/** @alpha */ export class Difference { - private number?: DifferenceRepresentation; + private _number?: DifferenceRepresentation; private constructor(number?: DifferenceRepresentation) { - this.number = number; + this._number = number; } static between(d1: Decimalish | undefined, d2: Decimalish | undefined) { @@ -317,61 +313,62 @@ export class Difference { } toString(precision?: number) { - if (!this.number) { + if (!this._number) { return "N/A"; } - return this.number.sign + this.number.absoluteValue.toString(precision); + return this._number.sign + this._number.absoluteValue.toString(precision); } prettify(precision?: number) { - if (!this.number) { + if (!this._number) { return this.toString(); } - return this.number.sign + this.number.absoluteValue.prettify(precision); + return this._number.sign + this._number.absoluteValue.prettify(precision); } mul(multiplier: Decimalish) { return new Difference( - this.number && { - sign: this.number.sign, - absoluteValue: this.number.absoluteValue.mul(multiplier) + this._number && { + sign: this._number.sign, + absoluteValue: this._number.absoluteValue.mul(multiplier) } ); } get bigNumber() { - return this.number?.sign === "-" - ? this.number.absoluteValue.bigNumber.mul(-1) - : this.number?.absoluteValue.bigNumber; + return this._number?.sign === "-" + ? this._number.absoluteValue.bigNumber.mul(-1) + : this._number?.absoluteValue.bigNumber; } get nonZero() { - return this.number?.absoluteValue.nonZero && this; + return this._number?.absoluteValue.nonZero && this; } get positive() { - return this.number?.sign === "+" ? this : undefined; + return this._number?.sign === "+" ? this : undefined; } get negative() { - return this.number?.sign === "-" ? this : undefined; + return this._number?.sign === "-" ? this : undefined; } get absoluteValue() { - return this.number?.absoluteValue; + return this._number?.absoluteValue; } get infinite() { - return this.number?.absoluteValue.infinite && this; + return this._number?.absoluteValue.infinite && this; } get finite() { - return this.number?.absoluteValue.finite && this; + return this._number?.absoluteValue.finite && this; } } +/** @alpha */ export class Percent< T extends { infinite?: T | undefined; @@ -383,31 +380,31 @@ export class Percent< gte(n: string): boolean; } > { - private percent: T; + private _percent: T; public constructor(ratio: T) { - this.percent = ratio.infinite || (ratio.mul && ratio.mul(100)) || ratio; + this._percent = ratio.infinite || (ratio.mul && ratio.mul(100)) || ratio; } nonZeroish(precision: number) { const zeroish = `0.${"0".repeat(precision)}5`; - if (this.percent.absoluteValue?.gte(zeroish)) { + if (this._percent.absoluteValue?.gte(zeroish)) { return this; } } toString(precision: number) { return ( - this.percent.toString(precision) + - (this.percent.absoluteValue && !this.percent.infinite ? "%" : "") + this._percent.toString(precision) + + (this._percent.absoluteValue && !this._percent.infinite ? "%" : "") ); } prettify() { - if (this.percent.absoluteValue?.gte("1000")) { + if (this._percent.absoluteValue?.gte("1000")) { return this.toString(0); - } else if (this.percent.absoluteValue?.gte("10")) { + } else if (this._percent.absoluteValue?.gte("10")) { return this.toString(1); } else { return this.toString(2); diff --git a/packages/dev-frontend/src/App.tsx b/packages/dev-frontend/src/App.tsx index 59f746f11..42e93ef1b 100644 --- a/packages/dev-frontend/src/App.tsx +++ b/packages/dev-frontend/src/App.tsx @@ -66,6 +66,7 @@ const LiquityFrontend: React.FC = ({ loader }) => { } = useLiquity(); const store = new BlockPolledLiquityStore(provider, account, liquity, frontendTag); + store.logging = true; // For console tinkering ;-) Object.assign(window, { diff --git a/packages/dev-frontend/src/components/RiskiestTroves.tsx b/packages/dev-frontend/src/components/RiskiestTroves.tsx index 19076388c..f8a5738e4 100644 --- a/packages/dev-frontend/src/components/RiskiestTroves.tsx +++ b/packages/dev-frontend/src/components/RiskiestTroves.tsx @@ -3,7 +3,7 @@ import CopyToClipboard from "react-copy-to-clipboard"; import { Card, Button, Text, Box, Heading, Flex } from "theme-ui"; import { Percent } from "@liquity/decimal"; -import { Trove } from "@liquity/lib-base"; +import { MINIMUM_COLLATERAL_RATIO, CRITICAL_COLLATERAL_RATIO } from "@liquity/lib-base"; import { BlockPolledLiquityStoreState } from "@liquity/lib-ethers"; import { useLiquitySelector } from "@liquity/lib-react"; @@ -260,9 +260,9 @@ export const RiskiestTroves: React.FC = ({ pageSize }) => { {(collateralRatio => ( ({ trove, lusdBalance, numberOfTroves, - frontendTag: frontend.status === "registered" ? frontendTag : undefined, + frontendRegistered: frontend.status === "registered", noOwnFrontend: ownFrontend.status === "unregistered" }); @@ -41,14 +40,21 @@ const StabilityDepositAction: React.FC = ({ changePending, dispatch }) => { - const { trove, lusdBalance, numberOfTroves, frontendTag, noOwnFrontend } = useLiquitySelector( - select - ); + const { + trove, + lusdBalance, + numberOfTroves, + frontendRegistered, + noOwnFrontend + } = useLiquitySelector(select); const { + config, liquity: { send: liquity } } = useLiquity(); + const frontendTag = frontendRegistered ? config.frontendTag : undefined; + const myTransactionId = "stability-deposit"; const myTransactionState = useMyTransactionState(/^stability-deposit-/); diff --git a/packages/dev-frontend/src/components/TroveAction.tsx b/packages/dev-frontend/src/components/TroveAction.tsx index 87ddb0c79..39056f992 100644 --- a/packages/dev-frontend/src/components/TroveAction.tsx +++ b/packages/dev-frontend/src/components/TroveAction.tsx @@ -2,7 +2,15 @@ import React, { useEffect } from "react"; import { Button, Flex, Spinner } from "theme-ui"; import { Decimal, Percent } from "@liquity/decimal"; -import { LiquityStoreState, Trove, TroveAdjustment, TroveChange } from "@liquity/lib-base"; +import { + MINIMUM_COLLATERAL_RATIO, + CRITICAL_COLLATERAL_RATIO, + LUSD_LIQUIDATION_RESERVE, + LiquityStoreState, + Trove, + TroveAdjustmentParams, + TroveChange +} from "@liquity/lib-base"; import { useLiquitySelector } from "@liquity/lib-react"; import { useLiquity } from "../hooks/LiquityContext"; @@ -19,15 +27,15 @@ type TroveActionProps = { dispatch: (action: { type: "startChange" | "finishChange" }) => void; }; -const mcrPercent = new Percent(Trove.MINIMUM_COLLATERAL_RATIO).toString(0); -const ccrPercent = new Percent(Trove.CRITICAL_COLLATERAL_RATIO).toString(0); +const mcrPercent = new Percent(MINIMUM_COLLATERAL_RATIO).toString(0); +const ccrPercent = new Percent(CRITICAL_COLLATERAL_RATIO).toString(0); const describeAdjustment = ({ depositCollateral, withdrawCollateral, borrowLUSD, repayLUSD -}: TroveAdjustment) => +}: TroveAdjustmentParams) => depositCollateral && borrowLUSD ? `Deposit ${depositCollateral.prettify()} ETH & borrow ${borrowLUSD.prettify()} ${COIN}` : repayLUSD && withdrawCollateral @@ -89,7 +97,7 @@ export const TroveAction: React.FC = ({ {}) as any} > @@ -155,8 +163,8 @@ export const TroveAction: React.FC = ({ id={myTransactionId} requires={[ [ - edited.isEmpty || edited.debt.gte(Trove.GAS_COMPENSATION_DEPOSIT), - `Need at least ${Trove.GAS_COMPENSATION_DEPOSIT} ${COIN} for gas compensation` + edited.isEmpty || edited.debt.gte(LUSD_LIQUIDATION_RESERVE), + `Need at least ${LUSD_LIQUIDATION_RESERVE} ${COIN} for gas compensation` ], [ !( diff --git a/packages/dev-frontend/src/components/TroveEditor.tsx b/packages/dev-frontend/src/components/TroveEditor.tsx index c86bc3cb2..42c4e28d9 100644 --- a/packages/dev-frontend/src/components/TroveEditor.tsx +++ b/packages/dev-frontend/src/components/TroveEditor.tsx @@ -2,7 +2,13 @@ import React, { useState } from "react"; import { Heading, Box, Card, Button } from "theme-ui"; import { Percent, Difference, Decimalish, Decimal } from "@liquity/decimal"; -import { Trove, LiquityStoreState, TroveChange } from "@liquity/lib-base"; +import { + CRITICAL_COLLATERAL_RATIO, + MINIMUM_COLLATERAL_RATIO, + Trove, + LiquityStoreState, + TroveChange +} from "@liquity/lib-base"; import { useLiquitySelector } from "@liquity/lib-react"; import { COIN } from "../strings"; @@ -121,11 +127,11 @@ export const TroveEditor: React.FC = ({ : collateralRatioPct.prettify() } color={ - collateralRatio?.gt(Trove.CRITICAL_COLLATERAL_RATIO) + collateralRatio?.gt(CRITICAL_COLLATERAL_RATIO) ? "success" - : collateralRatio?.gt(Trove.MINIMUM_COLLATERAL_RATIO) + : collateralRatio?.gt(MINIMUM_COLLATERAL_RATIO) ? "warning" - : collateralRatio?.lte(Trove.MINIMUM_COLLATERAL_RATIO) + : collateralRatio?.lte(MINIMUM_COLLATERAL_RATIO) ? "danger" : "muted" } diff --git a/packages/dev-frontend/src/components/TroveManager.tsx b/packages/dev-frontend/src/components/TroveManager.tsx index daa06d30e..a66107e2a 100644 --- a/packages/dev-frontend/src/components/TroveManager.tsx +++ b/packages/dev-frontend/src/components/TroveManager.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Decimal, Decimalish } from "@liquity/decimal"; -import { LiquityStoreState, Trove } from "@liquity/lib-base"; +import { LUSD_LIQUIDATION_RESERVE, LiquityStoreState } from "@liquity/lib-base"; import { LiquityStoreUpdate, useLiquityReducer, useLiquitySelector } from "@liquity/lib-react"; import { TroveEditor } from "./TroveEditor"; @@ -74,7 +74,7 @@ const reduce = (state: TroveManagerState, action: TroveManagerAction): TroveMana case "addDebtCompensation": return { ...state, - edited: edited.setDebt(Trove.GAS_COMPENSATION_DEPOSIT), + edited: edited.setDebt(LUSD_LIQUIDATION_RESERVE), addedGasCompensation: true }; diff --git a/packages/dev-frontend/src/config/index.ts b/packages/dev-frontend/src/config/index.ts index 41aa0625c..bd392a02b 100644 --- a/packages/dev-frontend/src/config/index.ts +++ b/packages/dev-frontend/src/config/index.ts @@ -1,16 +1,21 @@ +import { AddressZero } from "@ethersproject/constants"; import { isAddress, getAddress } from "@ethersproject/address"; -export type LiquityFrontendConfig = Partial<{ +export type LiquityFrontendConfig = { frontendTag: string; - infuraApiKey: string; -}>; + infuraApiKey?: string; +}; + +const defaultConfig: LiquityFrontendConfig = { + frontendTag: AddressZero +}; function hasKey(o: object, k: K): o is Record { return k in o; } const parseConfig = (json: unknown): LiquityFrontendConfig => { - const config: LiquityFrontendConfig = {}; + const config = { ...defaultConfig }; if (typeof json === "object" && json !== null) { if (hasKey(json, "frontendTag") && json.frontendTag !== "") { @@ -57,7 +62,7 @@ const fetchConfig = async () => { return parseConfig(await response.json()); } catch (err) { console.error(err); - return {}; + return { ...defaultConfig }; } }; diff --git a/packages/dev-frontend/src/pages/PageSwitcher.tsx b/packages/dev-frontend/src/pages/PageSwitcher.tsx index a5c376f66..d17e12b29 100644 --- a/packages/dev-frontend/src/pages/PageSwitcher.tsx +++ b/packages/dev-frontend/src/pages/PageSwitcher.tsx @@ -11,18 +11,19 @@ import { UnregisteredFrontend } from "./UnregisteredFrontend"; import { FrontendRegistration } from "./FrontendRegistration"; import { FrontendRegistrationSuccess } from "./FrontendRegistrationSuccess"; -const select = ({ frontend, frontendTag }: LiquityStoreState) => ({ - frontend, - frontendTag -}); +const selectFrontend = ({ frontend }: LiquityStoreState) => frontend; export const PageSwitcher: React.FC = () => { - const { account } = useLiquity(); - const { frontend, frontendTag } = useLiquitySelector(select); - const [registering, setRegistering] = useState(false); + const { + account, + config: { frontendTag } + } = useLiquity(); + const frontend = useLiquitySelector(selectFrontend); const unregistered = frontendTag !== AddressZero && frontend.status === "unregistered"; + const [registering, setRegistering] = useState(false); + useEffect(() => { if (unregistered) { setRegistering(true); diff --git a/packages/dev-frontend/src/pages/UnregisteredFrontend.tsx b/packages/dev-frontend/src/pages/UnregisteredFrontend.tsx index e25590c6d..4cb3c1b6c 100644 --- a/packages/dev-frontend/src/pages/UnregisteredFrontend.tsx +++ b/packages/dev-frontend/src/pages/UnregisteredFrontend.tsx @@ -1,15 +1,13 @@ import { Box, Flex, Heading, Paragraph } from "theme-ui"; -import { useLiquitySelector } from "@liquity/lib-react"; -import { LiquityStoreState } from "@liquity/lib-base"; - import { shortenAddress } from "../utils/shortenAddress"; import { Icon } from "../components/Icon"; - -const selectFrontendTag = ({ frontendTag }: LiquityStoreState) => frontendTag; +import { useLiquity } from "../hooks/LiquityContext"; export const UnregisteredFrontend: React.FC = () => { - const frontendTag = useLiquitySelector(selectFrontendTag); + const { + config: { frontendTag } + } = useLiquity(); return ( = { + [P in K]: T[P] extends (...args: infer A) => infer R ? (...args: [...A, ...U]) => R : never; +}; + +// @internal (undocumented) +export type _CollateralChange = (_CollateralDeposit & _NoCollateralWithdrawal) | (_CollateralWithdrawal & _NoCollateralDeposit); + +// @internal (undocumented) +export type _CollateralDeposit = { + depositCollateral: T; }; // @public (undocumented) -export type CollateralGainTransferOptionalParams = FeelessTroveAdjustmentOptionalParams & { +export interface CollateralGainTransferDetails extends StabilityPoolGainsWithdrawalDetails { + // (undocumented) + newTrove: Trove; +} + +// @internal (undocumented) +export type _CollateralGainTransferMethod = "transferCollateralGainToTrove"; + +// @internal (undocumented) +export type _CollateralGainTransferOptionalParams = _FeelessTroveAdjustmentOptionalParams & { deposit?: StabilityDeposit; }; -// @public (undocumented) -export const emptyTrove: Trove; +// @internal (undocumented) +export type _CollateralWithdrawal = { + withdrawCollateral: T; +}; + +// @public +export const CRITICAL_COLLATERAL_RATIO: Decimal; + +// @internal (undocumented) +export type _DebtChange = (_LUSDBorrowing & _NoLUSDRepayment) | (_LUSDRepayment & _NoLUSDBorrowing); + +// @internal (undocumented) +export const _emptyTrove: Trove; // @public (undocumented) export type FailedReceipt = { @@ -26,30 +54,31 @@ export type FailedReceipt = { rawReceipt: R; }; -// @public (undocumented) -export const failedReceipt: (rawReceipt: R) => FailedReceipt; +// @internal (undocumented) +export const _failedReceipt: (rawReceipt: R) => FailedReceipt; -// @public (undocumented) -export type FeelessTroveAdjustmentOptionalParams = HintedMethodOptionalParams & { +// @internal (undocumented) +export type _FeelessTroveAdjustmentMethod = "depositCollateral" | "withdrawCollateral" | "repayLUSD"; + +// @internal (undocumented) +export type _FeelessTroveAdjustmentOptionalParams = _HintedMethodOptionalParams & { trove?: Trove; }; -// @public (undocumented) +// @public export class Fees { + // @internal constructor(lastFeeOperation: Date, baseRateWithoutDecay: Decimalish, minuteDecayFactor: Decimalish, beta: Decimalish); - // (undocumented) + // @internal (undocumented) baseRate(when: Date): Decimal; - // (undocumented) - borrowingFeeFactor(when?: Date): Decimal; - // (undocumented) + borrowingFeeFactor(): Decimal; equals(that: Fees): boolean; - // (undocumented) - redemptionFeeFactor(redeemedFractionOfSupply?: Decimalish, when?: Date): Decimal; - // (undocumented) + redemptionFeeFactor(redeemedFractionOfSupply?: Decimalish): Decimal; + // @internal (undocumented) toString(): string; } -// @public (undocumented) +// @public export type FrontendStatus = { status: "unregistered"; } | { @@ -57,160 +86,179 @@ export type FrontendStatus = { kickbackRate: Decimal; }; -// @public (undocumented) -export function glue(t: new (...args: never[]) => T, u: new (...args: never[]) => U): new (t: T, u: U) => T & U; +// @internal (undocumented) +export function _glue(t: new (...args: never[]) => T, u: new (...args: never[]) => U): new (t: T, u: U) => T & U; -// @public (undocumented) -export function glue(t: new (...args: never[]) => T, u: new (...args: never[]) => U, v: new (...args: never[]) => V): new (t: T, u: U, v: V) => T & U & V; +// @internal (undocumented) +export function _glue(t: new (...args: never[]) => T, u: new (...args: never[]) => U, v: new (...args: never[]) => V): new (t: T, u: U, v: V) => T & U & V; -// @public (undocumented) -export function glue(t: new (...args: never[]) => T, u: new (...args: never[]) => U, v: new (...args: never[]) => V, w: new (...args: never[]) => W): new (t: T, u: U, v: V, w: W) => T & U & V & W; - -// Warning: (ae-forgotten-export) The symbol "Hintable" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "AddParams" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "TroveCreationMethod" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "FeelessTroveAdjustmentMethod" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "TroveAdjustmentMethod" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "CollateralGainTransferMethod" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "RedemptionMethod" needs to be exported by the entry point index.d.ts -// -// @public (undocumented) -export type Hinted = T & AddParams & AddParams & AddParams & AddParams & AddParams; +// @internal (undocumented) +export function _glue(t: new (...args: never[]) => T, u: new (...args: never[]) => U, v: new (...args: never[]) => V, w: new (...args: never[]) => W): new (t: T, u: U, v: V, w: W) => T & U & V & W; -// @public (undocumented) -export type HintedMethodOptionalParams = { - numberOfTroves?: number; +// @internal (undocumented) +export type _Hintable = { + [P in _HintedMethod]: (...args: never[]) => unknown; }; -// @public (undocumented) -export const invalidTroveCreation: (invalidTrove: Trove, error: TroveCreationError) => TaggedInvalidTroveCreation; +// @internal (undocumented) +export type _Hinted = T & _AddParams & _AddParams & _AddParams & _AddParams & _AddParams; + +// @internal (undocumented) +export type _HintedMethod = _TroveCreationMethod | _FeelessTroveAdjustmentMethod | _TroveAdjustmentMethod | _CollateralGainTransferMethod | _RedemptionMethod; + +// @internal (undocumented) +export type _HintedMethodOptionalParams = { + numberOfTroves?: number; +}; // @public (undocumented) -export type LiquidationDetails = { +export interface LiquidationDetails { + // (undocumented) + collateralGasCompensation: Decimal; + // (undocumented) liquidatedAddresses: string[]; - totalLiquidated: Trove; + // (undocumented) lusdGasCompensation: Decimal; - collateralGasCompensation: Decimal; -}; + // (undocumented) + totalLiquidated: Trove; +} // @public (undocumented) export type LiquityReceipt = PendingReceipt | MinedReceipt; -// @public (undocumented) +// @public export abstract class LiquityStore { - constructor(constants: LiquityStoreConstants); - // (undocumented) - protected constants: LiquityStoreConstants; - // (undocumented) - abstract doStart(): () => void; - // (undocumented) - protected load(baseState: LiquityStoreBaseState, extraState?: T): void; - // (undocumented) - protected loaded: boolean; - // (undocumented) + // @internal (undocumented) + protected abstract _doStart(): () => void; + // @internal (undocumented) + protected _load(baseState: LiquityStoreBaseState, extraState?: T): void; + // @internal (undocumented) + protected _loaded: boolean; logging: boolean; - // (undocumented) - protected logUpdate(name: string, next: U, show?: (next: U) => string): U; - // (undocumented) onLoaded?: () => void; - // (undocumented) - protected abstract reduceExtra(extraState: T, extraStateUpdate: Partial): T; - // (undocumented) - protected silentlyUpdateIfChanged(equals: (a: U, b: U) => boolean, prev: U, next?: U): U; - // (undocumented) + // @internal (undocumented) + protected abstract _reduceExtra(extraState: T, extraStateUpdate: Partial): T; start(): () => void; - // (undocumented) get state(): LiquityStoreState; - // (undocumented) - subscribe(listener: LiquityStoreListener): () => void; - // (undocumented) - protected update(baseStateUpdate?: Partial, extraStateUpdate?: Partial): void; - // (undocumented) - protected updateIfChanged(equals: (a: U, b: U) => boolean, name: string, prev: U, next?: U, show?: (next: U) => string): U; + subscribe(listener: (params: LiquityStoreListenerParams) => void): () => void; + // @internal (undocumented) + protected _update(baseStateUpdate?: Partial, extraStateUpdate?: Partial): void; } -// @public (undocumented) -export type LiquityStoreBaseState = { - frontend: FrontendStatus; - ownFrontend: FrontendStatus; - numberOfTroves: number; +// @public +export interface LiquityStoreBaseState { accountBalance: Decimal; - lusdBalance: Decimal; - lqtyBalance: Decimal; collateralSurplusBalance: Decimal; - price: Decimal; - lusdInStabilityPool: Decimal; - total: Trove; - totalRedistributed: Trove; - troveWithoutRewards: TroveWithPendingRewards; deposit: StabilityDeposit; fees: Fees; + frontend: FrontendStatus; + lqtyBalance: Decimal; lqtyStake: LQTYStake; + lusdBalance: Decimal; + lusdInStabilityPool: Decimal; + numberOfTroves: number; + ownFrontend: FrontendStatus; + price: Decimal; + total: Trove; + totalRedistributed: Trove; totalStakedLQTY: Decimal; -}; - -// @public (undocumented) -export type LiquityStoreConstants = { - frontendTag: string; -}; + troveWithoutRewards: TroveWithPendingRewards; +} -// @public (undocumented) -export type LiquityStoreDerivedState = { - trove: Trove; +// @public +export interface LiquityStoreDerivedState { borrowingFeeFactor: Decimal; redemptionFeeFactor: Decimal; -}; + trove: Trove; +} -// @public (undocumented) -export type LiquityStoreListener = (params: { +// @public +export interface LiquityStoreListenerParams { newState: LiquityStoreState; oldState: LiquityStoreState; stateChange: Partial>; -}) => void; +} -// @public (undocumented) -export type LiquityStoreState = T & LiquityStoreConstants & LiquityStoreBaseState & LiquityStoreDerivedState; +// @public +export type LiquityStoreState = LiquityStoreBaseState & LiquityStoreDerivedState & T; -// @public (undocumented) +// @public export class LQTYStake { - // Warning: (ae-forgotten-export) The symbol "LQTYStakish" needs to be exported by the entry point index.d.ts - constructor({ stakedLQTY, collateralGain, lusdGain }: LQTYStakish); - // (undocumented) + // @internal + constructor(stakedLQTY?: Decimal, collateralGain?: Decimal, lusdGain?: Decimal); apply(change: LQTYStakeChange | undefined): Decimal; - // (undocumented) readonly collateralGain: Decimal; - // (undocumented) equals(that: LQTYStake): boolean; // (undocumented) get isEmpty(): boolean; - // (undocumented) readonly lusdGain: Decimal; - // (undocumented) readonly stakedLQTY: Decimal; - // (undocumented) + // @internal (undocumented) toString(): string; - // Warning: (ae-forgotten-export) The symbol "LQTYStakeChange" needs to be exported by the entry point index.d.ts - // - // (undocumented) whatChanged(thatStakedLQTY: Decimalish): LQTYStakeChange | undefined; } // @public (undocumented) -export type MinedReceipt = FailedReceipt | SuccessfulReceipt; +export type LQTYStakeChange = { + stakeLQTY: T; + unstakeLQTY?: undefined; +} | { + stakeLQTY?: undefined; + unstakeLQTY: T; + unstakeAllLQTY: boolean; +}; -// Warning: (ae-forgotten-export) The symbol "Normalizer" needs to be exported by the entry point index.d.ts -// -// @public (undocumented) -export const normalizeTroveAdjustment: Normalizer, TroveAdjustment>; +// @public +export const LUSD_LIQUIDATION_RESERVE: Decimal; -// @public (undocumented) -export const normalizeTroveCreation: Normalizer, TroveCreation>; +// @internal (undocumented) +export type _LUSDBorrowing = { + borrowLUSD: T; +}; + +// @internal (undocumented) +export type _LUSDRepayment = { + repayLUSD: T; +}; // @public (undocumented) +export type MinedReceipt = FailedReceipt | SuccessfulReceipt; + +// @public +export const MINIMUM_COLLATERAL_RATIO: Decimal; + +// @internal (undocumented) +export type _NoCollateralChange = _NoCollateralDeposit & _NoCollateralWithdrawal; + +// @internal (undocumented) +export type _NoCollateralDeposit = Partial<_CollateralDeposit>; + +// @internal (undocumented) +export type _NoCollateralWithdrawal = Partial<_CollateralWithdrawal>; + +// @internal (undocumented) +export type _NoDebtChange = _NoLUSDBorrowing & _NoLUSDRepayment; + +// @internal (undocumented) +export type _NoLUSDBorrowing = Partial<_LUSDBorrowing>; + +// @internal (undocumented) +export type _NoLUSDRepayment = Partial<_LUSDRepayment>; + +// @internal (undocumented) +export type _Normalizer = (params: T) => U; + +// @internal (undocumented) +export const _normalizeTroveAdjustment: _Normalizer, TroveAdjustmentParams>; + +// @internal (undocumented) +export const _normalizeTroveCreation: _Normalizer, TroveCreationParams>; + +// @alpha (undocumented) export interface ObservableLiquity { // (undocumented) watchLUSDBalance(onLUSDBalanceChanged: (balance: Decimal) => void, address?: string): () => void; @@ -235,22 +283,24 @@ export type PendingReceipt = { status: "pending"; }; -// @public (undocumented) -export const pendingReceipt: PendingReceipt; +// @internal (undocumented) +export const _pendingReceipt: PendingReceipt; -// @public (undocumented) -export type Populatable = { - [M in keyof T]: T[M] extends (...args: infer A) => Promise ? PopulateMethod>>> : never; +// @internal (undocumented) +export type _Populatable = { + [M in keyof T]: T[M] extends (...args: infer A) => Promise ? _PopulateMethod>>> : never; }; // @public (undocumented) -export type PopulatedLiquityTransaction

= { +export interface PopulatedLiquityTransaction

{ + // (undocumented) rawPopulatedTransaction: P; + // (undocumented) send(): Promise; -}; +} -// @public (undocumented) -export type PopulateMethod = (...args: A) => Promise; +// @internal (undocumented) +export type _PopulateMethod = (...args: A) => Promise; // @public (undocumented) export interface ReadableLiquity { @@ -280,7 +330,6 @@ export interface ReadableLiquity { getStabilityDeposit(address?: string): Promise; // (undocumented) getTotal(): Promise; - // (undocumented) getTotalRedistributed(): Promise; // (undocumented) getTotalStakedLQTY(): Promise; @@ -291,45 +340,55 @@ export interface ReadableLiquity { } // @public (undocumented) -export type RedemptionDetails = { - attemptedLUSDAmount: Decimal; +export interface RedemptionDetails { + // (undocumented) actualLUSDAmount: Decimal; + // (undocumented) + attemptedLUSDAmount: Decimal; + // (undocumented) collateralReceived: Decimal; + // (undocumented) fee: Decimal; -}; +} -// @public (undocumented) -export type RedemptionOptionalParams = HintedMethodOptionalParams & { +// @internal (undocumented) +export type _RedemptionMethod = "redeemLUSD"; + +// @internal (undocumented) +export type _RedemptionOptionalParams = _HintedMethodOptionalParams & { price?: Decimal; }; -// @public (undocumented) -export type Sendable = { - [M in keyof T]: T[M] extends (...args: infer A) => Promise ? SendMethod>> : never; +// @internal (undocumented) +export type _Sendable = { + [M in keyof T]: T[M] extends (...args: infer A) => Promise ? _SendMethod>> : never; }; -// @public (undocumented) -export type SendableFrom = { - [M in keyof T]: T[M] extends PopulateMethod> ? SendMethod : never; +// @internal (undocumented) +export type _SendableFrom = { + [M in keyof T]: T[M] extends _PopulateMethod> ? _SendMethod : never; }; -// @public (undocumented) -export const sendableFrom: >(Populatable: new (...args: never[]) => U) => new (populatable: U) => SendableFrom; +// @internal (undocumented) +export const _sendableFrom: >(_Populatable: new (...args: never[]) => U) => new (populatable: U) => _SendableFrom; -// @public (undocumented) -export type SendMethod = (...args: A) => Promise; +// @internal (undocumented) +export type _SendMethod = (...args: A) => Promise; // @public (undocumented) -export type SentLiquityTransaction = { - rawSentTransaction: S; +export interface SentLiquityTransaction { + // (undocumented) getReceipt(): Promise; + // (undocumented) + rawSentTransaction: S; + // (undocumented) waitForReceipt(): Promise>; -}; +} // @public (undocumented) export class StabilityDeposit { - // Warning: (ae-forgotten-export) The symbol "StabilityDepositish" needs to be exported by the entry point index.d.ts - constructor({ initialLUSD, currentLUSD, collateralGain, lqtyReward }: StabilityDepositish); + // @internal + constructor(initialLUSD?: Decimal, currentLUSD?: Decimal, collateralGain?: Decimal, lqtyReward?: Decimal); // (undocumented) apply(change: StabilityDepositChange | undefined): Decimal; // (undocumented) @@ -361,17 +420,22 @@ export type StabilityDepositChange = { }; // @public (undocumented) -export type StabilityDepositChangeDetails = StabilityPoolGainsWithdrawalDetails & { +export interface StabilityDepositChangeDetails extends StabilityPoolGainsWithdrawalDetails { + // (undocumented) change: StabilityDepositChange; -}; +} // @public (undocumented) -export type StabilityPoolGainsWithdrawalDetails = { - lusdLoss: Decimal; - newLUSDDeposit: Decimal; +export interface StabilityPoolGainsWithdrawalDetails { + // (undocumented) collateralGain: Decimal; + // (undocumented) lqtyReward: Decimal; -}; + // (undocumented) + lusdLoss: Decimal; + // (undocumented) + newLUSDDeposit: Decimal; +} // @public (undocumented) export type SuccessfulReceipt = { @@ -380,47 +444,21 @@ export type SuccessfulReceipt = { details: D; }; -// @public (undocumented) -export const successfulReceipt: (rawReceipt: R, details: D, toString?: (() => string) | undefined) => SuccessfulReceipt; +// @internal (undocumented) +export const _successfulReceipt: (rawReceipt: R, details: D, toString?: (() => string) | undefined) => SuccessfulReceipt; -// @public (undocumented) -export type TaggedInvalidTroveCreation = { - type: "invalidCreation"; - invalidTrove: Trove; - error: TroveCreationError; +// @internal (undocumented) +export type _TransactableFrom = { + [M in keyof T]: T[M] extends _SendMethod>> ? (...args: A) => Promise : never; }; -// @public (undocumented) -export type TaggedTroveAdjustment = { - type: "adjustment"; - params: TroveAdjustment; - setToZero?: "collateral" | "debt"; -}; - -// @public (undocumented) -export type TaggedTroveClosure = { - type: "closure"; - params: TroveClosure; -}; - -// @public (undocumented) -export type TaggedTroveCreation = { - type: "creation"; - params: TroveCreation; -}; - -// @public (undocumented) -export type TransactableFrom = { - [M in keyof T]: T[M] extends SendMethod>> ? (...args: A) => Promise : never; -}; - -// @public (undocumented) -export const transactableFrom: >(Sendable: new (...args: never[]) => U) => new (sendable: U) => TransactableFrom; +// @internal (undocumented) +export const _transactableFrom: >(_Sendable: new (...args: never[]) => U) => new (sendable: U) => _TransactableFrom; // @public (undocumented) export interface TransactableLiquity { // (undocumented) - adjustTrove(params: TroveAdjustment): Promise; + adjustTrove(params: TroveAdjustmentParams): Promise; // (undocumented) borrowLUSD(amount: Decimalish): Promise; // (undocumented) @@ -435,8 +473,7 @@ export interface TransactableLiquity { liquidate(address: string): Promise; // (undocumented) liquidateUpTo(maximumNumberOfTrovesToLiquidate: number): Promise; - // (undocumented) - openTrove(params: TroveCreation): Promise; + openTrove(params: TroveCreationParams): Promise; // (undocumented) redeemLUSD(amount: Decimalish): Promise; // (undocumented) @@ -447,7 +484,7 @@ export interface TransactableLiquity { sendLQTY(toAddress: string, amount: Decimalish): Promise; // (undocumented) sendLUSD(toAddress: string, amount: Decimalish): Promise; - // (undocumented) + // @internal (undocumented) setPrice(price: Decimalish): Promise; // (undocumented) stakeLQTY(amount: Decimalish): Promise; @@ -467,17 +504,18 @@ export interface TransactableLiquity { // @public (undocumented) export class Trove { - constructor({ collateral, debt }?: Trovish); + // @internal + constructor(collateral?: Decimal, debt?: Decimal); // (undocumented) - add({ collateral, debt }: Trovish): Trove; + add(that: Trove): Trove; // (undocumented) addCollateral(collateral: Decimalish): Trove; // (undocumented) addDebt(debt: Decimalish): Trove; // (undocumented) - adjust(params: TroveAdjustment, borrowingFeeFactor?: Decimalish): Trove; + adjust(params: TroveAdjustmentParams, borrowingFeeFactor?: Decimalish): Trove; // (undocumented) - adjustTo(that: Trove, borrowingFeeFactor?: Decimalish): TroveAdjustment; + adjustTo(that: Trove, borrowingFeeFactor?: Decimalish): TroveAdjustmentParams; // (undocumented) apply(change: TroveChange | undefined, borrowingFeeFactor?: Decimalish): Trove; // (undocumented) @@ -489,34 +527,28 @@ export class Trove { // (undocumented) collateralRatioIsBelowMinimum(price: Decimalish): boolean; // (undocumented) - static create(params: TroveCreation, borrowingFeeFactor?: Decimalish): Trove; - // (undocumented) - static readonly CRITICAL_COLLATERAL_RATIO: Decimal; + static create(params: TroveCreationParams, borrowingFeeFactor?: Decimalish): Trove; // (undocumented) readonly debt: Decimal; // (undocumented) equals(that: Trove): boolean; - static readonly GAS_COMPENSATION_DEPOSIT: Decimal; // (undocumented) get isEmpty(): boolean; // (undocumented) isOpenableInRecoveryMode(price: Decimalish): boolean; // (undocumented) - static readonly MINIMUM_COLLATERAL_RATIO: Decimal; - // (undocumented) multiply(multiplier: Decimalish): Trove; - // (undocumented) get netDebt(): Decimal; + // @internal (undocumented) + get _nominalCollateralRatio(): Decimal; // (undocumented) - get nominalCollateralRatio(): Decimal; - // (undocumented) - static recreate(that: Trove, borrowingFeeFactor?: Decimalish): TroveCreation; + static recreate(that: Trove, borrowingFeeFactor?: Decimalish): TroveCreationParams; // (undocumented) setCollateral(collateral: Decimalish): Trove; // (undocumented) setDebt(debt: Decimalish): Trove; // (undocumented) - subtract(that: Trovish): Trove; + subtract(that: Trove): Trove; // (undocumented) subtractCollateral(collateral: Decimalish): Trove; // (undocumented) @@ -527,77 +559,95 @@ export class Trove { whatChanged(that: Trove, borrowingFeeFactor?: Decimalish): TroveChange | undefined; } -// Warning: (ae-forgotten-export) The symbol "CollateralChange" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "NoDebtChange" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "DebtChange" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "NoCollateralChange" needs to be exported by the entry point index.d.ts -// -// @public (undocumented) -export type TroveAdjustment = (CollateralChange & NoDebtChange) | (DebtChange & NoCollateralChange) | (CollateralChange & DebtChange); - // @public (undocumented) -export const troveAdjustment: (params: TroveAdjustment, setToZero?: "collateral" | "debt" | undefined) => TaggedTroveAdjustment; +export interface TroveAdjustmentDetails { + // (undocumented) + fee: Decimal; + // (undocumented) + newTrove: Trove; + // (undocumented) + params: TroveAdjustmentParams; +} -// @public (undocumented) -export type TroveAdjustmentDetails = TroveChangeWithFees>; +// @internal (undocumented) +export type _TroveAdjustmentMethod = "borrowLUSD" | "adjustTrove"; -// @public (undocumented) -export type TroveAdjustmentOptionalParams = FeelessTroveAdjustmentOptionalParams & { +// @internal (undocumented) +export type _TroveAdjustmentOptionalParams = _FeelessTroveAdjustmentOptionalParams & { fees?: Fees; }; -// @public (undocumented) -export type TroveChange = TaggedInvalidTroveCreation | TaggedTroveCreation | TaggedTroveClosure | TaggedTroveAdjustment; - -// @public (undocumented) -export type TroveChangeWithFees = { - params: T; - newTrove: Trove; - fee: Decimal; -}; - -// Warning: (ae-forgotten-export) The symbol "CollateralWithdrawal" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "NoCollateralDeposit" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "LUSDRepayment" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "NoLUSDBorrowing" needs to be exported by the entry point index.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "TroveAdjustmentParams" is marked as @public, but its signature references "_CollateralChange" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveAdjustmentParams" is marked as @public, but its signature references "_NoDebtChange" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveAdjustmentParams" is marked as @public, but its signature references "_DebtChange" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveAdjustmentParams" is marked as @public, but its signature references "_NoCollateralChange" which is marked as @internal // -// @public (undocumented) -export type TroveClosure = CollateralWithdrawal & NoCollateralDeposit & Partial> & NoLUSDBorrowing; +// @public +export type TroveAdjustmentParams = (_CollateralChange & _NoDebtChange) | (_DebtChange & _NoCollateralChange) | (_CollateralChange & _DebtChange); -// @public (undocumented) -export const troveClosure: (params: TroveClosure) => TaggedTroveClosure; +// @public +export type TroveChange = { + type: "invalidCreation"; + invalidTrove: Trove; + error: TroveCreationError; +} | { + type: "creation"; + params: TroveCreationParams; +} | { + type: "closure"; + params: TroveClosureParams; +} | { + type: "adjustment"; + params: TroveAdjustmentParams; + setToZero?: "collateral" | "debt"; +}; // @public (undocumented) -export type TroveClosureDetails = { - params: TroveClosure; -}; +export interface TroveClosureDetails { + // (undocumented) + params: TroveClosureParams; +} -// Warning: (ae-forgotten-export) The symbol "CollateralDeposit" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "NoCollateralWithdrawal" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "LUSDBorrowing" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "NoLUSDRepayment" needs to be exported by the entry point index.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "TroveClosureParams" is marked as @public, but its signature references "_CollateralWithdrawal" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveClosureParams" is marked as @public, but its signature references "_NoCollateralDeposit" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveClosureParams" is marked as @public, but its signature references "_LUSDRepayment" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveClosureParams" is marked as @public, but its signature references "_NoLUSDBorrowing" which is marked as @internal // -// @public (undocumented) -export type TroveCreation = CollateralDeposit & NoCollateralWithdrawal & Partial> & NoLUSDRepayment; +// @public +export type TroveClosureParams = _CollateralWithdrawal & _NoCollateralDeposit & Partial<_LUSDRepayment> & _NoLUSDBorrowing; // @public (undocumented) -export const troveCreation: (params: TroveCreation) => TaggedTroveCreation; +export interface TroveCreationDetails { + // (undocumented) + fee: Decimal; + // (undocumented) + newTrove: Trove; + // (undocumented) + params: TroveCreationParams; +} -// @public (undocumented) -export type TroveCreationDetails = TroveChangeWithFees>; +// @public +export type TroveCreationError = "missingLiquidationReserve"; -// @public (undocumented) -export type TroveCreationError = "missingGasDeposit"; +// @internal (undocumented) +export type _TroveCreationMethod = "openTrove"; -// @public (undocumented) -export type TroveCreationOptionalParams = HintedMethodOptionalParams & { +// @internal (undocumented) +export type _TroveCreationOptionalParams = _HintedMethodOptionalParams & { fees?: Fees; }; +// Warning: (ae-incompatible-release-tags) The symbol "TroveCreationParams" is marked as @public, but its signature references "_CollateralDeposit" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveCreationParams" is marked as @public, but its signature references "_NoCollateralWithdrawal" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveCreationParams" is marked as @public, but its signature references "_LUSDBorrowing" which is marked as @internal +// Warning: (ae-incompatible-release-tags) The symbol "TroveCreationParams" is marked as @public, but its signature references "_NoLUSDRepayment" which is marked as @internal +// +// @public +export type TroveCreationParams = _CollateralDeposit & _NoCollateralWithdrawal & Partial<_LUSDBorrowing> & _NoLUSDRepayment; + // @public (undocumented) export class TroveWithPendingRewards extends Trove { - // Warning: (ae-forgotten-export) The symbol "TrovishWithPendingRewards" needs to be exported by the entry point index.d.ts - constructor({ collateral, debt, stake, snapshotOfTotalRedistributed }?: TrovishWithPendingRewards); + constructor(collateral?: Decimal, debt?: Decimal, stake?: Decimal, snapshotOfTotalRedistributed?: Trove); // (undocumented) applyRewards(totalRedistributed: Trove): Trove; // (undocumented) @@ -608,14 +658,6 @@ export class TroveWithPendingRewards extends Trove { readonly stake: Decimal; } -// @public (undocumented) -export interface Trovish { - // (undocumented) - readonly collateral?: Decimalish; - // (undocumented) - readonly debt?: Decimalish; -} - // (No @packageDocumentation comment for this package) diff --git a/packages/lib-base/index.ts b/packages/lib-base/index.ts index 265f1867f..530b09636 100644 --- a/packages/lib-base/index.ts +++ b/packages/lib-base/index.ts @@ -1,5 +1,6 @@ -export { glue } from "./src/utils"; +export { _glue } from "./src/utils"; +export * from "./src/constants"; export * from "./src/Trove"; export * from "./src/StabilityDeposit"; export * from "./src/LQTYStake"; diff --git a/packages/lib-base/package.json b/packages/lib-base/package.json index cdc91a827..66bcd4a91 100644 --- a/packages/lib-base/package.json +++ b/packages/lib-base/package.json @@ -22,6 +22,7 @@ "@typescript-eslint/eslint-plugin": "^4.4.1", "@typescript-eslint/parser": "^4.4.1", "eslint": "^7.11.0", + "eslint-plugin-tsdoc": "^0.2.11", "fast-check": "^2.7.0", "mocha": "^8.2.1", "npm-run-all": "^4.1.5", diff --git a/packages/lib-base/src/Fees.ts b/packages/lib-base/src/Fees.ts index 4fd3d8d76..e98ad3cc4 100644 --- a/packages/lib-base/src/Fees.ts +++ b/packages/lib-base/src/Fees.ts @@ -2,67 +2,118 @@ import assert from "assert"; import { Decimal, Decimalish } from "@liquity/decimal"; +/** + * Calculator for fees. + * + * @remarks + * Returned by the {@link ReadableLiquity.getFees | getFees()} function. + * + * @public + */ export class Fees { - private readonly baseRateWithoutDecay: Decimal; - private readonly minuteDecayFactor: Decimal; - private readonly beta: Decimal; - private readonly lastFeeOperation: Date; + private readonly _baseRateWithoutDecay: Decimal; + private readonly _minuteDecayFactor: Decimal; + private readonly _beta: Decimal; + private readonly _lastFeeOperation: Date; + /** @internal */ constructor( lastFeeOperation: Date, baseRateWithoutDecay: Decimalish, minuteDecayFactor: Decimalish, beta: Decimalish ) { - this.lastFeeOperation = lastFeeOperation; - this.baseRateWithoutDecay = Decimal.from(baseRateWithoutDecay); - this.minuteDecayFactor = Decimal.from(minuteDecayFactor); - this.beta = Decimal.from(beta); + this._lastFeeOperation = lastFeeOperation; + this._baseRateWithoutDecay = Decimal.from(baseRateWithoutDecay); + this._minuteDecayFactor = Decimal.from(minuteDecayFactor); + this._beta = Decimal.from(beta); - assert(this.minuteDecayFactor.lt(1)); + assert(this._minuteDecayFactor.lt(1)); } + /** + * Compare to another instance of `Fees`. + */ equals(that: Fees): boolean { return ( - this.baseRateWithoutDecay.eq(that.baseRateWithoutDecay) && - this.minuteDecayFactor.eq(that.minuteDecayFactor) && - this.beta.eq(that.beta) && - this.lastFeeOperation.getTime() === that.lastFeeOperation.getTime() + this._baseRateWithoutDecay.eq(that._baseRateWithoutDecay) && + this._minuteDecayFactor.eq(that._minuteDecayFactor) && + this._beta.eq(that._beta) && + this._lastFeeOperation.getTime() === that._lastFeeOperation.getTime() ); } + /** @internal */ toString(): string { return ( - `{ baseRateWithoutDecay: ${this.baseRateWithoutDecay}` + - `, lastFeeOperation: "${this.lastFeeOperation.toLocaleString()}" } ` + `{ baseRateWithoutDecay: ${this._baseRateWithoutDecay}` + + `, lastFeeOperation: "${this._lastFeeOperation.toLocaleString()}" } ` ); } + /** @internal */ baseRate(when: Date): Decimal { const millisecondsSinceLastFeeOperation = Math.max( - when.getTime() - this.lastFeeOperation.getTime(), + when.getTime() - this._lastFeeOperation.getTime(), 0 // Clamp negative elapsed time to 0, in case the client's time is in the past. // We will calculate slightly higher than actual fees, which is fine. ); const minutesSinceLastFeeOperation = Math.floor(millisecondsSinceLastFeeOperation / 60000); - return this.minuteDecayFactor.pow(minutesSinceLastFeeOperation).mul(this.baseRateWithoutDecay); + return this._minuteDecayFactor.pow(minutesSinceLastFeeOperation).mul(this._baseRateWithoutDecay); } - borrowingFeeFactor(when = new Date()): Decimal { - return this.baseRate(when); + /** + * Calculate the current borrowing fee factor. + * + * @remarks + * To calculate the borrowing fee in LUSD, multiply the borrowed LUSD amount with the borrowing + * fee factor. + * + * @example + * ```typescript + * const fees = await liquity.getFees(); + * + * const borrowedLUSDAmount = 100; + * const borrowingFeeFactor = fees.borrowingFeeFactor(); + * const borrowingFeeLUSD = borrowingFeeFactor.mul(borrowedLUSDAmount); + * ``` + */ + borrowingFeeFactor(): Decimal { + return this.baseRate(new Date()); } - redemptionFeeFactor( - redeemedFractionOfSupply: Decimalish = Decimal.ZERO, - when = new Date() - ): Decimal { + /** + * Calculate the current redemption fee factor. + * + * @remarks + * Unlike the borrowing fee factor, the redemption fee factor depends on the amount being redeemed. + * To be more precise, it depends on the fraction of the redeemed amount compared to the total + * LUSD supply, which must be passed as a parameter. + * + * To calculate the redemption fee in LUSD, multiply the redeemed LUSD amount with the redemption + * fee factor. + * + * @example + * ```typescript + * const fees = await liquity.getFees(); + * const total = await liquity.getTotal(); + * + * const redeemedLUSDAmount = Decimal.from(100); + * const redeemedFractionOfSupply = redeemedLUSDAmount.div(total.debt); + * const redemptionFeeFactor = fees.redemptionFeeFactor(redeemedFractionOfSupply); + * const redemptionFeeLUSD = redemptionFeeFactor.mul(redeemedLUSDAmount); + * ``` + * + * @param redeemedFractionOfSupply - the amount of LUSD being redeemed divided by the total supply + */ + redemptionFeeFactor(redeemedFractionOfSupply: Decimalish = Decimal.ZERO): Decimal { redeemedFractionOfSupply = Decimal.from(redeemedFractionOfSupply); - let baseRate = this.baseRate(when); + let baseRate = this.baseRate(new Date()); if (redeemedFractionOfSupply.nonZero) { - baseRate = redeemedFractionOfSupply.div(this.beta).add(baseRate); + baseRate = redeemedFractionOfSupply.div(this._beta).add(baseRate); } return baseRate.lt(Decimal.ONE) ? baseRate : Decimal.ONE; diff --git a/packages/lib-base/src/Hinted.ts b/packages/lib-base/src/Hinted.ts index f4db4956c..578542ad1 100644 --- a/packages/lib-base/src/Hinted.ts +++ b/packages/lib-base/src/Hinted.ts @@ -4,60 +4,73 @@ import { Trove } from "./Trove"; import { StabilityDeposit } from "./StabilityDeposit"; import { Fees } from "./Fees"; -export type HintedMethodOptionalParams = { +/** @internal */ +export type _HintedMethodOptionalParams = { numberOfTroves?: number; }; -export type TroveCreationOptionalParams = HintedMethodOptionalParams & { +/** @internal */ +export type _TroveCreationOptionalParams = _HintedMethodOptionalParams & { fees?: Fees; }; -export type FeelessTroveAdjustmentOptionalParams = HintedMethodOptionalParams & { +/** @internal */ +export type _FeelessTroveAdjustmentOptionalParams = _HintedMethodOptionalParams & { trove?: Trove; }; -export type TroveAdjustmentOptionalParams = FeelessTroveAdjustmentOptionalParams & { +/** @internal */ +export type _TroveAdjustmentOptionalParams = _FeelessTroveAdjustmentOptionalParams & { fees?: Fees; }; -export type CollateralGainTransferOptionalParams = FeelessTroveAdjustmentOptionalParams & { +/** @internal */ +export type _CollateralGainTransferOptionalParams = _FeelessTroveAdjustmentOptionalParams & { deposit?: StabilityDeposit; }; -export type RedemptionOptionalParams = HintedMethodOptionalParams & { +/** @internal */ +export type _RedemptionOptionalParams = _HintedMethodOptionalParams & { price?: Decimal; }; -type AddParams = { +/** @internal */ +export type _AddParams = { [P in K]: T[P] extends (...args: infer A) => infer R ? (...args: [...A, ...U]) => R : never; }; -type TroveCreationMethod = "openTrove"; -type FeelessTroveAdjustmentMethod = "depositCollateral" | "withdrawCollateral" | "repayLUSD"; -type TroveAdjustmentMethod = "borrowLUSD" | "adjustTrove"; -type CollateralGainTransferMethod = "transferCollateralGainToTrove"; -type RedemptionMethod = "redeemLUSD"; +/** @internal */ export type _TroveCreationMethod = "openTrove"; +/** @internal */ export type _FeelessTroveAdjustmentMethod = + | "depositCollateral" + | "withdrawCollateral" + | "repayLUSD"; +/** @internal */ export type _TroveAdjustmentMethod = "borrowLUSD" | "adjustTrove"; +/** @internal */ export type _CollateralGainTransferMethod = "transferCollateralGainToTrove"; +/** @internal */ export type _RedemptionMethod = "redeemLUSD"; -type HintedMethod = - | TroveCreationMethod - | FeelessTroveAdjustmentMethod - | TroveAdjustmentMethod - | CollateralGainTransferMethod - | RedemptionMethod; +/** @internal */ +export type _HintedMethod = + | _TroveCreationMethod + | _FeelessTroveAdjustmentMethod + | _TroveAdjustmentMethod + | _CollateralGainTransferMethod + | _RedemptionMethod; -type Hintable = { [P in HintedMethod]: (...args: never[]) => unknown }; +/** @internal */ +export type _Hintable = { [P in _HintedMethod]: (...args: never[]) => unknown }; -export type Hinted = T & - AddParams & - AddParams< +/** @internal */ +export type _Hinted = T & + _AddParams & + _AddParams< T, - FeelessTroveAdjustmentMethod, - [optionalParams?: FeelessTroveAdjustmentOptionalParams] + _FeelessTroveAdjustmentMethod, + [optionalParams?: _FeelessTroveAdjustmentOptionalParams] > & - AddParams & - AddParams< + _AddParams & + _AddParams< T, - CollateralGainTransferMethod, - [optionalParams?: CollateralGainTransferOptionalParams] + _CollateralGainTransferMethod, + [optionalParams?: _CollateralGainTransferOptionalParams] > & - AddParams; + _AddParams; diff --git a/packages/lib-base/src/LQTYStake.ts b/packages/lib-base/src/LQTYStake.ts index 833ec0133..60385faa0 100644 --- a/packages/lib-base/src/LQTYStake.ts +++ b/packages/lib-base/src/LQTYStake.ts @@ -1,31 +1,40 @@ import { Decimal, Decimalish } from "@liquity/decimal"; -// now, this is silly... -interface LQTYStakish { - readonly stakedLQTY?: Decimalish; - readonly collateralGain?: Decimalish; - readonly lusdGain?: Decimalish; -} - -type LQTYStakeChange = +/** @public */ +export type LQTYStakeChange = | { stakeLQTY: T; unstakeLQTY?: undefined } | { stakeLQTY?: undefined; unstakeLQTY: T; unstakeAllLQTY: boolean }; +/** + * Represents a user's LQTY stake and accrued gains. + * + * @remarks + * Returned by the {@link ReadableLiquity.getLQTYStake | getLQTYStake()} function. + + * @public + */ export class LQTYStake { + /** The amount of LQTY that's staked. */ readonly stakedLQTY: Decimal; + + /** Collateral gain available to withdraw. */ readonly collateralGain: Decimal; + + /** LUSD gain available to withdraw. */ readonly lusdGain: Decimal; - constructor({ stakedLQTY = 0, collateralGain = 0, lusdGain = 0 }: LQTYStakish) { - this.stakedLQTY = Decimal.from(stakedLQTY); - this.collateralGain = Decimal.from(collateralGain); - this.lusdGain = Decimal.from(lusdGain); + /** @internal */ + constructor(stakedLQTY = Decimal.ZERO, collateralGain = Decimal.ZERO, lusdGain = Decimal.ZERO) { + this.stakedLQTY = stakedLQTY; + this.collateralGain = collateralGain; + this.lusdGain = lusdGain; } get isEmpty(): boolean { return this.stakedLQTY.isZero && this.collateralGain.isZero && this.lusdGain.isZero; } + /** @internal */ toString(): string { return ( `{ stakedLQTY: ${this.stakedLQTY}` + @@ -34,6 +43,9 @@ export class LQTYStake { ); } + /** + * Compare to another instance of `LQTYStake`. + */ equals(that: LQTYStake): boolean { return ( this.stakedLQTY.eq(that.stakedLQTY) && @@ -42,6 +54,9 @@ export class LQTYStake { ); } + /** + * Calculate the difference between this `LQTYStake` and `thatStakedLQTY`. + */ whatChanged(thatStakedLQTY: Decimalish): LQTYStakeChange | undefined { thatStakedLQTY = Decimal.from(thatStakedLQTY); @@ -57,6 +72,11 @@ export class LQTYStake { } } + /** + * Apply a stake change to this `LQTYStake`. + * + * @returns The new staked LQTY amount. + */ apply(change: LQTYStakeChange | undefined): Decimal { if (!change) { return this.stakedLQTY; diff --git a/packages/lib-base/src/LiquityStore.ts b/packages/lib-base/src/LiquityStore.ts index 0ff1e1b97..d9ca10ea5 100644 --- a/packages/lib-base/src/LiquityStore.ts +++ b/packages/lib-base/src/LiquityStore.ts @@ -7,45 +7,134 @@ import { Fees } from "./Fees"; import { LQTYStake } from "./LQTYStake"; import { FrontendStatus } from "./ReadableLiquity"; -export type LiquityStoreConstants = { - frontendTag: string; -}; - -export type LiquityStoreBaseState = { +/** + * State variables read from the blockchain. + * + * @public + */ +export interface LiquityStoreBaseState { + /** Status of currently used frontend. */ frontend: FrontendStatus; + + /** Status of user's own frontend. */ ownFrontend: FrontendStatus; + + /** Number of Troves that are currently open. */ numberOfTroves: number; + + /** User's native currency balance (e.g. Ether). */ accountBalance: Decimal; + + /** User's LUSD token balance. */ lusdBalance: Decimal; + + /** User's LQTY token balance. */ lqtyBalance: Decimal; + + /** + * Amount of leftover collateral available for withdrawal to the user. + * + * @remarks + * When the user's Trove gets liquidated or redeemed, any collateral they have above 110% (in case + * of liquidation) or 100% collateralization (in case of redemption) gets sent to a pool, where it + * can be withdrawn from using + * {@link TransactableLiquity.claimCollateralSurplus | claimCollateralSurplus()}. + */ collateralSurplusBalance: Decimal; + + /** Current price of the native currency (e.g. Ether) in USD. */ price: Decimal; + + /** Total amount of LUSD currently deposited in the Stability Pool. */ lusdInStabilityPool: Decimal; + + /** Total collateral and debt in the Liquity system. */ total: Trove; + + /** + * Total collateral and debt per stake that has been liquidated through redistribution. + * + * @remarks + * Needed when dealing with instances of {@link TroveWithPendingRewards}. + */ totalRedistributed: Trove; + + /** + * User's Trove in its state after the last direct modification. + * + * @remarks + * The current state of the user's Trove can be found as + * {@link LiquityStoreDerivedState.trove | trove}. + */ troveWithoutRewards: TroveWithPendingRewards; + + /** User's stability deposit. */ deposit: StabilityDeposit; + + /** Calculator for current fees. */ fees: Fees; + + /** User's LQTY stake. */ lqtyStake: LQTYStake; + + /** Total amount of LQTY currently staked. */ totalStakedLQTY: Decimal; -}; +} -export type LiquityStoreDerivedState = { +/** + * State variables derived from {@link LiquityStoreBaseState}. + * + * @public + */ +export interface LiquityStoreDerivedState { + /** Current state of user's Trove */ trove: Trove; + + /** Current borrowing fee factor. */ borrowingFeeFactor: Decimal; - redemptionFeeFactor: Decimal; -}; -export type LiquityStoreState = T & - LiquityStoreConstants & - LiquityStoreBaseState & - LiquityStoreDerivedState; + /** + * Current redemption fee factor. + * + * @remarks + * Note that the actual redemption fee will depend on the amount of LUSD being redeemed. + * + * Use {@link Fees.redemptionFeeFactor} to calculate a precise redemption fee factor. + */ + redemptionFeeFactor: Decimal; +} -export type LiquityStoreListener = (params: { +/** + * Type of {@link LiquityStore}'s {@link LiquityStore.state | state}. + * + * @remarks + * It combines all properties of {@link LiquityStoreBaseState} and {@link LiquityStoreDerivedState} + * with optional extra state added by the particular `LiquityStore` implementation. + * + * The type parameter `T` may be used to type the extra state. + * + * @public + */ +export type LiquityStoreState = LiquityStoreBaseState & LiquityStoreDerivedState & T; + +/** + * Parameters passed to {@link LiquityStore} listeners. + * + * @remarks + * Use the {@link LiquityStore.subscribe | subscribe()} function to register a listener. + + * @public + */ +export interface LiquityStoreListenerParams { + /** The entire previous state. */ newState: LiquityStoreState; + + /** The entire new state. */ oldState: LiquityStoreState; + + /** Only the state variables that have changed. */ stateChange: Partial>; -}) => void; +} const strictEquals = (a: T, b: T) => a === b; const eq = (a: T, b: T) => a.eq(b); @@ -63,59 +152,97 @@ const showFrontendStatus = (x: FrontendStatus) => const wrap = (f: (...args: A) => R) => (...args: A) => f(...args); -const difference = >(a: T, b: T) => - Object.fromEntries(Object.entries(a).filter(([key, value]) => value !== b[key])) as Partial; - +const difference = (a: T, b: T) => + Object.fromEntries( + Object.entries(a).filter(([key, value]) => value !== (b as Record)[key]) + ) as Partial; + +/** + * Abstract base class of Liquity data store implementations. + * + * @remarks + * The type parameter `T` may be used to type extra state added to {@link LiquityStoreState} by the + * subclass. + * + * Currently, the only implementation is {@link @liquity/lib-ethers#BlockPolledLiquityStore}. + * + * @public + */ export abstract class LiquityStore { - logging = true; + /** Turn console logging on/off. */ + logging = false; + + /** + * Called after the state is fetched for the first time. + * + * @remarks + * See {@link LiquityStore.start | start()}. + */ onLoaded?: () => void; - protected constants: LiquityStoreConstants; - protected loaded = false; - - private baseState?: LiquityStoreBaseState; - private derivedState?: LiquityStoreDerivedState; - private extraState?: T; - - private updateTimeoutId: ReturnType | undefined; - private listeners = new Set>(); - - constructor(constants: LiquityStoreConstants) { - this.constants = constants; - } - + /** @internal */ + protected _loaded = false; + + private _baseState?: LiquityStoreBaseState; + private _derivedState?: LiquityStoreDerivedState; + private _extraState?: T; + + private _updateTimeoutId: ReturnType | undefined; + private _listeners = new Set<(params: LiquityStoreListenerParams) => void>(); + + /** + * The current store state. + * + * @remarks + * Should not be accessed before the store is loaded. Assign a function to + * {@link LiquityStore.onLoaded | onLoaded} to get a callback when this happens. + * + * See {@link LiquityStoreState} for the list of properties returned. + */ get state(): LiquityStoreState { - return Object.assign({}, this.constants, this.baseState, this.derivedState, this.extraState); + return Object.assign({}, this._baseState, this._derivedState, this._extraState); } - abstract doStart(): () => void; - + /** @internal */ + protected abstract _doStart(): () => void; + + /** + * Start monitoring the blockchain for Liquity state changes. + * + * @remarks + * The {@link LiquityStore.onLoaded | onLoaded} callback will be called after the state is fetched + * for the first time. + * + * Use the {@link LiquityStore.subscribe | subscribe()} function to register listeners. + * + * @returns Function to stop the monitoring. + */ start(): () => void { - const doStop = this.doStart(); + const doStop = this._doStart(); return () => { doStop(); - this.cancelUpdateIfScheduled(); + this._cancelUpdateIfScheduled(); }; } - private cancelUpdateIfScheduled() { - if (this.updateTimeoutId !== undefined) { - clearTimeout(this.updateTimeoutId); + private _cancelUpdateIfScheduled() { + if (this._updateTimeoutId !== undefined) { + clearTimeout(this._updateTimeoutId); } } - private scheduleUpdate() { - this.cancelUpdateIfScheduled(); + private _scheduleUpdate() { + this._cancelUpdateIfScheduled(); - this.updateTimeoutId = setTimeout(() => { - this.updateTimeoutId = undefined; - this.update(); + this._updateTimeoutId = setTimeout(() => { + this._updateTimeoutId = undefined; + this._update(); }, 30000); } - protected logUpdate(name: string, next: U, show?: (next: U) => string): U { + private _logUpdate(name: string, next: U, show?: (next: U) => string): U { if (this.logging) { console.log(`${name} updated to ${show ? show(next) : next}`); } @@ -123,26 +250,26 @@ export abstract class LiquityStore { return next; } - protected updateIfChanged( + private _updateIfChanged( equals: (a: U, b: U) => boolean, name: string, prev: U, next?: U, show?: (next: U) => string ): U { - return next !== undefined && !equals(prev, next) ? this.logUpdate(name, next, show) : prev; + return next !== undefined && !equals(prev, next) ? this._logUpdate(name, next, show) : prev; } - protected silentlyUpdateIfChanged(equals: (a: U, b: U) => boolean, prev: U, next?: U): U { + private _silentlyUpdateIfChanged(equals: (a: U, b: U) => boolean, prev: U, next?: U): U { return next !== undefined && !equals(prev, next) ? next : prev; } - private reduce( + private _reduce( baseState: LiquityStoreBaseState, baseStateUpdate: Partial ): LiquityStoreBaseState { return { - frontend: this.updateIfChanged( + frontend: this._updateIfChanged( frontendStatusEquals, "frontend", baseState.frontend, @@ -150,7 +277,7 @@ export abstract class LiquityStore { showFrontendStatus ), - ownFrontend: this.updateIfChanged( + ownFrontend: this._updateIfChanged( frontendStatusEquals, "ownFrontend", baseState.ownFrontend, @@ -158,78 +285,78 @@ export abstract class LiquityStore { showFrontendStatus ), - numberOfTroves: this.updateIfChanged( + numberOfTroves: this._updateIfChanged( strictEquals, "numberOfTroves", baseState.numberOfTroves, baseStateUpdate.numberOfTroves ), - accountBalance: this.updateIfChanged( + accountBalance: this._updateIfChanged( eq, "accountBalance", baseState.accountBalance, baseStateUpdate.accountBalance ), - lusdBalance: this.updateIfChanged( + lusdBalance: this._updateIfChanged( eq, "lusdBalance", baseState.lusdBalance, baseStateUpdate.lusdBalance ), - lqtyBalance: this.updateIfChanged( + lqtyBalance: this._updateIfChanged( eq, "lqtyBalance", baseState.lqtyBalance, baseStateUpdate.lqtyBalance ), - collateralSurplusBalance: this.updateIfChanged( + collateralSurplusBalance: this._updateIfChanged( eq, "collateralSurplusBalance", baseState.collateralSurplusBalance, baseStateUpdate.collateralSurplusBalance ), - price: this.updateIfChanged(eq, "price", baseState.price, baseStateUpdate.price), + price: this._updateIfChanged(eq, "price", baseState.price, baseStateUpdate.price), - lusdInStabilityPool: this.updateIfChanged( + lusdInStabilityPool: this._updateIfChanged( eq, "lusdInStabilityPool", baseState.lusdInStabilityPool, baseStateUpdate.lusdInStabilityPool ), - total: this.updateIfChanged(equals, "total", baseState.total, baseStateUpdate.total), + total: this._updateIfChanged(equals, "total", baseState.total, baseStateUpdate.total), - totalRedistributed: this.updateIfChanged( + totalRedistributed: this._updateIfChanged( equals, "totalRedistributed", baseState.totalRedistributed, baseStateUpdate.totalRedistributed ), - troveWithoutRewards: this.updateIfChanged( + troveWithoutRewards: this._updateIfChanged( equals, "troveWithoutRewards", baseState.troveWithoutRewards, baseStateUpdate.troveWithoutRewards ), - deposit: this.updateIfChanged(equals, "deposit", baseState.deposit, baseStateUpdate.deposit), + deposit: this._updateIfChanged(equals, "deposit", baseState.deposit, baseStateUpdate.deposit), - fees: this.updateIfChanged(equals, "fees", baseState.fees, baseStateUpdate.fees), + fees: this._updateIfChanged(equals, "fees", baseState.fees, baseStateUpdate.fees), - lqtyStake: this.updateIfChanged( + lqtyStake: this._updateIfChanged( equals, "lqtyStake", baseState.lqtyStake, baseStateUpdate.lqtyStake ), - totalStakedLQTY: this.updateIfChanged( + totalStakedLQTY: this._updateIfChanged( eq, "totalStakedLQTY", baseState.totalStakedLQTY, @@ -238,7 +365,7 @@ export abstract class LiquityStore { }; } - private derive({ + private _derive({ troveWithoutRewards, totalRedistributed, fees @@ -250,20 +377,20 @@ export abstract class LiquityStore { }; } - private reduceDerived( + private _reduceDerived( derivedState: LiquityStoreDerivedState, derivedStateUpdate: LiquityStoreDerivedState ): LiquityStoreDerivedState { return { - trove: this.updateIfChanged(equals, "trove", derivedState.trove, derivedStateUpdate.trove), + trove: this._updateIfChanged(equals, "trove", derivedState.trove, derivedStateUpdate.trove), - borrowingFeeFactor: this.silentlyUpdateIfChanged( + borrowingFeeFactor: this._silentlyUpdateIfChanged( eq, derivedState.borrowingFeeFactor, derivedStateUpdate.borrowingFeeFactor ), - redemptionFeeFactor: this.silentlyUpdateIfChanged( + redemptionFeeFactor: this._silentlyUpdateIfChanged( eq, derivedState.redemptionFeeFactor, derivedStateUpdate.redemptionFeeFactor @@ -271,60 +398,69 @@ export abstract class LiquityStore { }; } - protected abstract reduceExtra(extraState: T, extraStateUpdate: Partial): T; + /** @internal */ + protected abstract _reduceExtra(extraState: T, extraStateUpdate: Partial): T; - private notify(...args: Parameters>) { - [...this.listeners].forEach(listener => listener(...args)); + private _notify(params: LiquityStoreListenerParams) { + [...this._listeners].forEach(listener => listener(params)); } - subscribe(listener: LiquityStoreListener): () => void { + /** + * Register a state change listener. + * + * @param listener - Function that will be called whenever state changes. + * @returns Function to unregister this listener. + */ + subscribe(listener: (params: LiquityStoreListenerParams) => void): () => void { const uniqueListener = wrap(listener); - this.listeners.add(uniqueListener); + this._listeners.add(uniqueListener); return () => { - this.listeners.delete(uniqueListener); + this._listeners.delete(uniqueListener); }; } - protected load(baseState: LiquityStoreBaseState, extraState?: T): void { - assert(!this.loaded); + /** @internal */ + protected _load(baseState: LiquityStoreBaseState, extraState?: T): void { + assert(!this._loaded); - this.baseState = baseState; - this.derivedState = this.derive(baseState); - this.extraState = extraState; - this.loaded = true; + this._baseState = baseState; + this._derivedState = this._derive(baseState); + this._extraState = extraState; + this._loaded = true; - this.scheduleUpdate(); + this._scheduleUpdate(); if (this.onLoaded) { this.onLoaded(); } } - protected update( + /** @internal */ + protected _update( baseStateUpdate?: Partial, extraStateUpdate?: Partial ): void { - assert(this.baseState && this.derivedState); + assert(this._baseState && this._derivedState); const oldState = this.state; if (baseStateUpdate) { - this.baseState = this.reduce(this.baseState, baseStateUpdate); + this._baseState = this._reduce(this._baseState, baseStateUpdate); } // Always running this lets us derive state based on passage of time, like baseRate decay - this.derivedState = this.reduceDerived(this.derivedState, this.derive(this.baseState)); + this._derivedState = this._reduceDerived(this._derivedState, this._derive(this._baseState)); if (extraStateUpdate) { - assert(this.extraState); - this.extraState = this.reduceExtra(this.extraState, extraStateUpdate); + assert(this._extraState); + this._extraState = this._reduceExtra(this._extraState, extraStateUpdate); } - this.scheduleUpdate(); + this._scheduleUpdate(); - this.notify({ + this._notify({ newState: this.state, oldState, stateChange: difference(this.state, oldState) diff --git a/packages/lib-base/src/ObservableLiquity.ts b/packages/lib-base/src/ObservableLiquity.ts index 8e92b4551..1c8f77acd 100644 --- a/packages/lib-base/src/ObservableLiquity.ts +++ b/packages/lib-base/src/ObservableLiquity.ts @@ -3,6 +3,7 @@ import { Decimal } from "@liquity/decimal"; import { Trove, TroveWithPendingRewards } from "./Trove"; import { StabilityDeposit } from "./StabilityDeposit"; +/** @alpha */ export interface ObservableLiquity { watchTotalRedistributed( onTotalRedistributedChanged: (totalRedistributed: Trove) => void diff --git a/packages/lib-base/src/ReadableLiquity.ts b/packages/lib-base/src/ReadableLiquity.ts index ebf27b7ea..5457f4ecf 100644 --- a/packages/lib-base/src/ReadableLiquity.ts +++ b/packages/lib-base/src/ReadableLiquity.ts @@ -5,11 +5,32 @@ import { StabilityDeposit } from "./StabilityDeposit"; import { Fees } from "./Fees"; import { LQTYStake } from "./LQTYStake"; +/** + * Represents whether an address has been registered as a Liquity frontend. + * + * @remarks + * Returned by the {@link ReadableLiquity.getFrontendStatus | getFrontendStatus()} function. + * + * When `status` is `"registered"`, `kickbackRate` gives the frontend's kickback rate as a + * {@link @liquity/decimal#Decimal} between 0 and 1. + * + * @public + */ export type FrontendStatus = | { status: "unregistered" } | { status: "registered"; kickbackRate: Decimal }; +/** @public */ export interface ReadableLiquity { + /** + * Get the total collateral and debt per stake that has been liquidated through redistribution. + * + * @remarks + * Needed when dealing with instances of {@link TroveWithPendingRewards}. + * + * @example + * See {@link ReadableLiquity.getLastTroves | getLastTroves()} for an example of how it's used. + */ getTotalRedistributed(): Promise; getTroveWithoutRewards(address?: string): Promise; diff --git a/packages/lib-base/src/StabilityDeposit.ts b/packages/lib-base/src/StabilityDeposit.ts index 17a42b55b..4613fd3e0 100644 --- a/packages/lib-base/src/StabilityDeposit.ts +++ b/packages/lib-base/src/StabilityDeposit.ts @@ -1,13 +1,5 @@ import { Decimal, Decimalish } from "@liquity/decimal"; -// yeah, sounds stupid... -interface StabilityDepositish { - readonly initialLUSD?: Decimalish; - readonly currentLUSD?: Decimalish; - readonly collateralGain?: Decimalish; - readonly lqtyReward?: Decimalish; -} - export type StabilityDepositChange = | { depositLUSD: T; withdrawLUSD?: undefined } | { depositLUSD?: undefined; withdrawLUSD: T; withdrawAllLUSD: boolean }; @@ -18,16 +10,17 @@ export class StabilityDeposit { readonly collateralGain: Decimal; readonly lqtyReward: Decimal; - constructor({ - initialLUSD = 0, + /** @internal */ + constructor( + initialLUSD = Decimal.ZERO, currentLUSD = initialLUSD, - collateralGain = 0, - lqtyReward = 0 - }: StabilityDepositish) { - this.initialLUSD = Decimal.from(initialLUSD); - this.currentLUSD = Decimal.from(currentLUSD); - this.collateralGain = Decimal.from(collateralGain); - this.lqtyReward = Decimal.from(lqtyReward); + collateralGain = Decimal.ZERO, + lqtyReward = Decimal.ZERO + ) { + this.initialLUSD = initialLUSD; + this.currentLUSD = currentLUSD; + this.collateralGain = collateralGain; + this.lqtyReward = lqtyReward; if (this.currentLUSD.gt(this.initialLUSD)) { throw new Error("currentLUSD can't be greater than initialLUSD"); diff --git a/packages/lib-base/src/TransactableLiquity.ts b/packages/lib-base/src/TransactableLiquity.ts index 7b8563a06..733f47c24 100644 --- a/packages/lib-base/src/TransactableLiquity.ts +++ b/packages/lib-base/src/TransactableLiquity.ts @@ -1,32 +1,34 @@ import { Decimal, Decimalish } from "@liquity/decimal"; import { proxify } from "./utils"; -import { Trove, TroveAdjustment, TroveClosure, TroveCreation } from "./Trove"; +import { Trove, TroveAdjustmentParams, TroveClosureParams, TroveCreationParams } from "./Trove"; import { StabilityDepositChange } from "./StabilityDeposit"; -export type PopulatedLiquityTransaction< +export interface PopulatedLiquityTransaction< P = unknown, T extends SentLiquityTransaction = SentLiquityTransaction -> = { +> { rawPopulatedTransaction: P; send(): Promise; -}; +} -export type SentLiquityTransaction = { +export interface SentLiquityTransaction { rawSentTransaction: S; getReceipt(): Promise; waitForReceipt(): Promise>; -}; +} export type PendingReceipt = { status: "pending" }; -export const pendingReceipt: PendingReceipt = { status: "pending" }; +/** @internal */ +export const _pendingReceipt: PendingReceipt = { status: "pending" }; export type FailedReceipt = { status: "failed"; rawReceipt: R }; -export const failedReceipt = (rawReceipt: R): FailedReceipt => ({ +/** @internal */ +export const _failedReceipt = (rawReceipt: R): FailedReceipt => ({ status: "failed", rawReceipt }); @@ -37,7 +39,8 @@ export type SuccessfulReceipt = { details: D; }; -export const successfulReceipt = ( +/** @internal */ +export const _successfulReceipt = ( rawReceipt: R, details: D, toString?: () => string @@ -51,59 +54,68 @@ export const successfulReceipt = ( export type MinedReceipt = FailedReceipt | SuccessfulReceipt; export type LiquityReceipt = PendingReceipt | MinedReceipt; -export type TroveChangeWithFees = { - params: T; +export interface TroveCreationDetails { + params: TroveCreationParams; newTrove: Trove; fee: Decimal; -}; +} -export type TroveCreationDetails = TroveChangeWithFees>; -export type TroveAdjustmentDetails = TroveChangeWithFees>; +export interface TroveAdjustmentDetails { + params: TroveAdjustmentParams; + newTrove: Trove; + fee: Decimal; +} -export type TroveClosureDetails = { - params: TroveClosure; -}; +export interface TroveClosureDetails { + params: TroveClosureParams; +} -export type LiquidationDetails = { +export interface LiquidationDetails { liquidatedAddresses: string[]; totalLiquidated: Trove; lusdGasCompensation: Decimal; collateralGasCompensation: Decimal; -}; +} -export type RedemptionDetails = { +export interface RedemptionDetails { attemptedLUSDAmount: Decimal; actualLUSDAmount: Decimal; collateralReceived: Decimal; fee: Decimal; -}; +} -export type StabilityPoolGainsWithdrawalDetails = { +export interface StabilityPoolGainsWithdrawalDetails { lusdLoss: Decimal; newLUSDDeposit: Decimal; collateralGain: Decimal; lqtyReward: Decimal; -}; +} -export type StabilityDepositChangeDetails = StabilityPoolGainsWithdrawalDetails & { +export interface StabilityDepositChangeDetails extends StabilityPoolGainsWithdrawalDetails { change: StabilityDepositChange; -}; +} -export type CollateralGainTransferDetails = StabilityPoolGainsWithdrawalDetails & { +export interface CollateralGainTransferDetails extends StabilityPoolGainsWithdrawalDetails { newTrove: Trove; -}; +} export interface TransactableLiquity { - openTrove(params: TroveCreation): Promise; + /** + * Open a new Trove. + * + * @returns The details of the Trove creation. + */ + openTrove(params: TroveCreationParams): Promise; closeTrove(): Promise; depositCollateral(amount: Decimalish): Promise; withdrawCollateral(amount: Decimalish): Promise; borrowLUSD(amount: Decimalish): Promise; repayLUSD(amount: Decimalish): Promise; - adjustTrove(params: TroveAdjustment): Promise; + adjustTrove(params: TroveAdjustmentParams): Promise; + /** @internal */ setPrice(price: Decimalish): Promise; liquidate(address: string): Promise; @@ -130,39 +142,48 @@ export interface TransactableLiquity { registerFrontend(kickbackRate: Decimalish): Promise; } -export type SendMethod = ( +/** @internal */ +export type _SendMethod = ( ...args: A ) => Promise; -export type Sendable = { +/** @internal */ +export type _Sendable = { [M in keyof T]: T[M] extends (...args: infer A) => Promise - ? SendMethod>> + ? _SendMethod>> : never; }; -export type PopulateMethod = ( +/** @internal */ +export type _PopulateMethod = ( ...args: A ) => Promise; -export type Populatable = { +/** @internal */ +export type _Populatable = { [M in keyof T]: T[M] extends (...args: infer A) => Promise - ? PopulateMethod< + ? _PopulateMethod< A, PopulatedLiquityTransaction>> > : never; }; -export type SendableFrom = { - [M in keyof T]: T[M] extends PopulateMethod> - ? SendMethod +/** @internal */ +export type _SendableFrom = { + [M in keyof T]: T[M] extends _PopulateMethod< + infer A, + PopulatedLiquityTransaction + > + ? _SendMethod : never; }; -export const sendableFrom = >( - Populatable: new (...args: never[]) => U -): new (populatable: U) => SendableFrom => { - const Sendable = class { +/** @internal */ +export const _sendableFrom = >( + _Populatable: new (...args: never[]) => U +): new (populatable: U) => _SendableFrom => { + const _Sendable = class { _populatable: U; constructor(populatable: U) { @@ -171,19 +192,20 @@ export const sendableFrom = >( }; proxify( - Sendable, - Populatable, + _Sendable, + _Populatable, method => async function (...args) { return (await this._populatable[method].call(this._populatable, ...args)).send(); } ); - return (Sendable as unknown) as new (populatable: U) => SendableFrom; + return (_Sendable as unknown) as new (populatable: U) => _SendableFrom; }; -export type TransactableFrom = { - [M in keyof T]: T[M] extends SendMethod< +/** @internal */ +export type _TransactableFrom = { + [M in keyof T]: T[M] extends _SendMethod< infer A, SentLiquityTransaction> > @@ -191,9 +213,10 @@ export type TransactableFrom = { : never; }; -export const transactableFrom = >( - Sendable: new (...args: never[]) => U -): new (sendable: U) => TransactableFrom => { +/** @internal */ +export const _transactableFrom = >( + _Sendable: new (...args: never[]) => U +): new (sendable: U) => _TransactableFrom => { const Transactable = class { _sendable: U; @@ -204,7 +227,7 @@ export const transactableFrom = >( proxify( Transactable, - Sendable, + _Sendable, method => async function (...args) { const tx = await this._sendable[method].call(this._sendable, ...args); @@ -218,5 +241,5 @@ export const transactableFrom = >( } ); - return (Transactable as unknown) as new (sendable: U) => TransactableFrom; + return (Transactable as unknown) as new (sendable: U) => _TransactableFrom; }; diff --git a/packages/lib-base/src/Trove.ts b/packages/lib-base/src/Trove.ts index 555240126..38a720e0e 100644 --- a/packages/lib-base/src/Trove.ts +++ b/packages/lib-base/src/Trove.ts @@ -2,107 +2,248 @@ import assert from "assert"; import { Decimal, Decimalish } from "@liquity/decimal"; -export interface Trovish { - readonly collateral?: Decimalish; - readonly debt?: Decimalish; -} - -type CollateralDeposit = { - depositCollateral: T; -}; - -type CollateralWithdrawal = { - withdrawCollateral: T; -}; - -type LUSDBorrowing = { - borrowLUSD: T; -}; - -type LUSDRepayment = { - repayLUSD: T; -}; - -type NoCollateralDeposit = Partial>; -type NoCollateralWithdrawal = Partial>; -type NoLUSDBorrowing = Partial>; -type NoLUSDRepayment = Partial>; - -type CollateralChange = - | (CollateralDeposit & NoCollateralWithdrawal) - | (CollateralWithdrawal & NoCollateralDeposit); -type NoCollateralChange = NoCollateralDeposit & NoCollateralWithdrawal; - -type DebtChange = (LUSDBorrowing & NoLUSDRepayment) | (LUSDRepayment & NoLUSDBorrowing); -type NoDebtChange = NoLUSDBorrowing & NoLUSDRepayment; - -export type TroveCreation = CollateralDeposit & - NoCollateralWithdrawal & - Partial> & - NoLUSDRepayment; - -export type TroveClosure = CollateralWithdrawal & - NoCollateralDeposit & - Partial> & - NoLUSDBorrowing; - -export type TroveAdjustment = - | (CollateralChange & NoDebtChange) - | (DebtChange & NoCollateralChange) - | (CollateralChange & DebtChange); - -export type TroveCreationError = "missingGasDeposit"; - -export type TaggedInvalidTroveCreation = { - type: "invalidCreation"; - invalidTrove: Trove; - error: TroveCreationError; -}; - -export type TaggedTroveCreation = { type: "creation"; params: TroveCreation }; - -export type TaggedTroveClosure = { type: "closure"; params: TroveClosure }; - -export type TaggedTroveAdjustment = { - type: "adjustment"; - params: TroveAdjustment; - setToZero?: "collateral" | "debt"; -}; - -export const invalidTroveCreation = ( +import { + MINIMUM_COLLATERAL_RATIO, + CRITICAL_COLLATERAL_RATIO, + LUSD_LIQUIDATION_RESERVE +} from "./constants"; + +/** @internal */ export type _CollateralDeposit = { depositCollateral: T }; +/** @internal */ export type _CollateralWithdrawal = { withdrawCollateral: T }; +/** @internal */ export type _LUSDBorrowing = { borrowLUSD: T }; +/** @internal */ export type _LUSDRepayment = { repayLUSD: T }; + +/** @internal */ export type _NoCollateralDeposit = Partial<_CollateralDeposit>; +/** @internal */ export type _NoCollateralWithdrawal = Partial<_CollateralWithdrawal>; +/** @internal */ export type _NoLUSDBorrowing = Partial<_LUSDBorrowing>; +/** @internal */ export type _NoLUSDRepayment = Partial<_LUSDRepayment>; + +/** @internal */ +export type _CollateralChange = + | (_CollateralDeposit & _NoCollateralWithdrawal) + | (_CollateralWithdrawal & _NoCollateralDeposit); + +/** @internal */ +export type _NoCollateralChange = _NoCollateralDeposit & _NoCollateralWithdrawal; + +/** @internal */ +export type _DebtChange = + | (_LUSDBorrowing & _NoLUSDRepayment) + | (_LUSDRepayment & _NoLUSDBorrowing); + +/** @internal */ +export type _NoDebtChange = _NoLUSDBorrowing & _NoLUSDRepayment; + +/** + * Parameters of Trove creation. + * + * @remarks + * The type parameter `T` specifies the allowed value type(s) of the particular `TroveCreationParams` + * object's properties. + * + *

Properties

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Property Type Description
depositCollateral T The amount of collateral that's deposited.
borrowLUSD? T (Optional) The amount of LUSD that's borrowed.
+ * + * @public + */ +export type TroveCreationParams = _CollateralDeposit & + _NoCollateralWithdrawal & + Partial<_LUSDBorrowing> & + _NoLUSDRepayment; + +/** + * Parameters of Trove closure. + * + * @remarks + * The type parameter `T` specifies the allowed value type(s) of the particular `TroveClosureParams` + * object's properties. + * + *

Properties

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Property Type Description
withdrawCollateral T The amount of collateral that's withdrawn.
repayLUSD? T (Optional) The amount of LUSD that's repaid.
+ * + * @public + */ +export type TroveClosureParams = _CollateralWithdrawal & + _NoCollateralDeposit & + Partial<_LUSDRepayment> & + _NoLUSDBorrowing; + +/** + * Parameters of Trove adjustment. + * + * @remarks + * The type parameter `T` specifies the allowed value type(s) of the particular + * `TroveAdjustmentParams` object's properties. + * + * Even though all properties are optional, a valid `TroveAdjustmentParams` object must define at + * least one. + * + * Defining both `depositCollateral` and `withdrawCollateral`, or both `borrowLUSD` and `repayLUSD` + * at the same time is disallowed, and will result in a type-checking error. + * + *

Properties

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Property Type Description
depositCollateral? T (Optional) The amount of collateral that's deposited.
withdrawCollateral? T (Optional) The amount of collateral that's withdrawn.
borrowLUSD? T (Optional) The amount of LUSD that's borrowed.
repayLUSD? T (Optional) The amount of LUSD that's repaid.
+ * + * @public + */ +export type TroveAdjustmentParams = + | (_CollateralChange & _NoDebtChange) + | (_DebtChange & _NoCollateralChange) + | (_CollateralChange & _DebtChange); + +/** + * Describes why a Trove could not be created. + * + * @remarks + * See {@link TroveChange}. + * + *

Possible values

+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
Value Reason
"missingLiquidationReserve" A Trove's debt cannot be less than the liquidation reserve.
+ * + * More errors may be added in the future. + * + * @public + */ +export type TroveCreationError = "missingLiquidationReserve"; + +/** + * Represents the change from one Trove to another. + * + * @remarks + * Returned by {@link Trove.whatChanged | Trove.whatChanged()}. + * + * Passed as a parameter to {@link Trove.apply | Trove.apply()}. + * + * @public + */ +export type TroveChange = + | { type: "invalidCreation"; invalidTrove: Trove; error: TroveCreationError } + | { type: "creation"; params: TroveCreationParams } + | { type: "closure"; params: TroveClosureParams } + | { type: "adjustment"; params: TroveAdjustmentParams; setToZero?: "collateral" | "debt" }; + +// This might seem backwards, but this way we avoid spamming the .d.ts and generated docs +type InvalidTroveCreation = Extract, { type: "invalidCreation" }>; +type TroveCreation = Extract, { type: "creation" }>; +type TroveClosure = Extract, { type: "closure" }>; +type TroveAdjustment = Extract, { type: "adjustment" }>; + +const invalidTroveCreation = ( invalidTrove: Trove, error: TroveCreationError -): TaggedInvalidTroveCreation => ({ +): InvalidTroveCreation => ({ type: "invalidCreation", invalidTrove, error }); -export const troveCreation = (params: TroveCreation): TaggedTroveCreation => ({ +const troveCreation = (params: TroveCreationParams): TroveCreation => ({ type: "creation", params }); -export const troveClosure = (params: TroveClosure): TaggedTroveClosure => ({ +const troveClosure = (params: TroveClosureParams): TroveClosure => ({ type: "closure", params }); -export const troveAdjustment = ( - params: TroveAdjustment, +const troveAdjustment = ( + params: TroveAdjustmentParams, setToZero?: "collateral" | "debt" -): TaggedTroveAdjustment => ({ +): TroveAdjustment => ({ type: "adjustment", params, setToZero }); -export type TroveChange = - | TaggedInvalidTroveCreation - | TaggedTroveCreation - | TaggedTroveClosure - | TaggedTroveAdjustment; - const normalize = (params: Record): Record => Object.fromEntries( Object.entries(params) @@ -111,16 +252,18 @@ const normalize = (params: Record): Record v.nonZero) ); -type Normalizer = (params: T) => U; +/** @internal */ export type _Normalizer = (params: T) => U; -export const normalizeTroveCreation = (normalize as unknown) as Normalizer< - TroveCreation, - TroveCreation +/** @internal */ +export const _normalizeTroveCreation = (normalize as unknown) as _Normalizer< + TroveCreationParams, + TroveCreationParams >; -export const normalizeTroveAdjustment = (normalize as unknown) as Normalizer< - TroveAdjustment, - TroveAdjustment +/** @internal */ +export const _normalizeTroveAdjustment = (normalize as unknown) as _Normalizer< + TroveAdjustmentParams, + TroveAdjustmentParams >; const applyFee = (borrowingFeeFactor: Decimalish, debtIncrease: Decimalish) => @@ -131,36 +274,37 @@ const unapplyFee = (borrowingFeeFactor: Decimalish, debtIncrease: Decimalish) => const NOMINAL_COLLATERAL_RATIO_PRECISION = Decimal.from(100); +/** @public */ export class Trove { - public static readonly CRITICAL_COLLATERAL_RATIO: Decimal = Decimal.from(1.5); - public static readonly MINIMUM_COLLATERAL_RATIO: Decimal = Decimal.from(1.1); - /** - * Amount automatically minted and assigned to gas compensation pool for each Trove opened, - * it counts towards collateral ratio (lowers it). - */ - public static readonly GAS_COMPENSATION_DEPOSIT: Decimal = Decimal.from(10); - readonly collateral: Decimal; readonly debt: Decimal; - constructor({ collateral = 0, debt = 0 }: Trovish = {}) { - this.collateral = Decimal.from(collateral); - this.debt = Decimal.from(debt); + /** @internal */ + constructor(collateral = Decimal.ZERO, debt = Decimal.ZERO) { + this.collateral = collateral; + this.debt = debt; } get isEmpty(): boolean { return this.collateral.isZero && this.debt.isZero; } + /** + * Amount of LUSD that must be repaid to close this Trove. + * + * @remarks + * This doesn't include the liquidation reserve, which is refunded in case of normal closure. + */ get netDebt(): Decimal { - if (this.debt.lt(Trove.GAS_COMPENSATION_DEPOSIT)) { - throw new Error(`netDebt should not be used when debt < ${Trove.GAS_COMPENSATION_DEPOSIT}`); + if (this.debt.lt(LUSD_LIQUIDATION_RESERVE)) { + throw new Error(`netDebt should not be used when debt < ${LUSD_LIQUIDATION_RESERVE}`); } - return this.debt.sub(Trove.GAS_COMPENSATION_DEPOSIT); + return this.debt.sub(LUSD_LIQUIDATION_RESERVE); } - get nominalCollateralRatio(): Decimal { + /** @internal */ + get _nominalCollateralRatio(): Decimal { return this.collateral.mulDiv(NOMINAL_COLLATERAL_RATIO_PRECISION, this.debt); } @@ -169,15 +313,15 @@ export class Trove { } collateralRatioIsBelowMinimum(price: Decimalish): boolean { - return this.collateralRatio(price).lt(Trove.MINIMUM_COLLATERAL_RATIO); + return this.collateralRatio(price).lt(MINIMUM_COLLATERAL_RATIO); } collateralRatioIsBelowCritical(price: Decimalish): boolean { - return this.collateralRatio(price).lt(Trove.CRITICAL_COLLATERAL_RATIO); + return this.collateralRatio(price).lt(CRITICAL_COLLATERAL_RATIO); } isOpenableInRecoveryMode(price: Decimalish): boolean { - return this.collateralRatio(price).gte(Trove.CRITICAL_COLLATERAL_RATIO); + return this.collateralRatio(price).gte(CRITICAL_COLLATERAL_RATIO); } toString(): string { @@ -188,66 +332,57 @@ export class Trove { return this.collateral.eq(that.collateral) && this.debt.eq(that.debt); } - add({ collateral = 0, debt = 0 }: Trovish): Trove { - return new Trove({ - collateral: this.collateral.add(collateral), - debt: this.debt.add(debt) - }); + add(that: Trove): Trove { + return new Trove(this.collateral.add(that.collateral), this.debt.add(that.debt)); } addCollateral(collateral: Decimalish): Trove { - return this.add({ collateral }); + return new Trove(this.collateral.add(collateral), this.debt); } addDebt(debt: Decimalish): Trove { - return this.add({ debt }); + return new Trove(this.collateral, this.debt.add(debt)); } - subtract(that: Trovish): Trove { - const { collateral, debt } = new Trove(that); + subtract(that: Trove): Trove { + const { collateral, debt } = that; - return new Trove({ - collateral: this.collateral.gt(collateral) ? this.collateral.sub(collateral) : 0, - debt: this.debt.gt(debt) ? this.debt.sub(debt) : 0 - }); + return new Trove( + this.collateral.gt(collateral) ? this.collateral.sub(collateral) : Decimal.ZERO, + this.debt.gt(debt) ? this.debt.sub(debt) : Decimal.ZERO + ); } subtractCollateral(collateral: Decimalish): Trove { - return this.subtract({ collateral }); + return new Trove( + this.collateral.gt(collateral) ? this.collateral.sub(collateral) : Decimal.ZERO, + this.debt + ); } subtractDebt(debt: Decimalish): Trove { - return this.subtract({ debt }); + return new Trove(this.collateral, this.debt.gt(debt) ? this.debt.sub(debt) : Decimal.ZERO); } multiply(multiplier: Decimalish): Trove { - return new Trove({ - collateral: this.collateral.mul(multiplier), - debt: this.debt.mul(multiplier) - }); + return new Trove(this.collateral.mul(multiplier), this.debt.mul(multiplier)); } setCollateral(collateral: Decimalish): Trove { - return new Trove({ - collateral, - debt: this.debt - }); + return new Trove(Decimal.from(collateral), this.debt); } setDebt(debt: Decimalish): Trove { - return new Trove({ - collateral: this.collateral, - debt - }); + return new Trove(this.collateral, Decimal.from(debt)); } - private debtChange({ debt }: Trove, borrowingFeeFactor: Decimalish): DebtChange { + private _debtChange({ debt }: Trove, borrowingFeeFactor: Decimalish): _DebtChange { return debt.gt(this.debt) ? { borrowLUSD: unapplyFee(borrowingFeeFactor, debt.sub(this.debt)) } : { repayLUSD: this.debt.sub(debt) }; } - private collateralChange({ collateral }: Trove): CollateralChange { + private _collateralChange({ collateral }: Trove): _CollateralChange { return collateral.gt(this.collateral) ? { depositCollateral: collateral.sub(this.collateral) } : { withdrawCollateral: this.collateral.sub(collateral) }; @@ -262,8 +397,8 @@ export class Trove { } if (this.isEmpty) { - if (that.debt.lt(Trove.GAS_COMPENSATION_DEPOSIT)) { - return invalidTroveCreation(that, "missingGasDeposit"); + if (that.debt.lt(LUSD_LIQUIDATION_RESERVE)) { + return invalidTroveCreation(that, "missingLiquidationReserve"); } return troveCreation( @@ -285,13 +420,16 @@ export class Trove { } return this.collateral.eq(that.collateral) - ? troveAdjustment(this.debtChange(that, borrowingFeeFactor), that.debt.zero && "debt") + ? troveAdjustment( + this._debtChange(that, borrowingFeeFactor), + that.debt.zero && "debt" + ) : this.debt.eq(that.debt) - ? troveAdjustment(this.collateralChange(that), that.collateral.zero && "collateral") + ? troveAdjustment(this._collateralChange(that), that.collateral.zero && "collateral") : troveAdjustment( { - ...this.debtChange(that, borrowingFeeFactor), - ...this.collateralChange(that) + ...this._debtChange(that, borrowingFeeFactor), + ...this._collateralChange(that) }, (that.debt.zero && "debt") ?? (that.collateral.zero && "collateral") ); @@ -320,12 +458,12 @@ export class Trove { const { depositCollateral, borrowLUSD } = change.params; - return new Trove({ - collateral: depositCollateral, - debt: borrowLUSD - ? Trove.GAS_COMPENSATION_DEPOSIT.add(applyFee(borrowingFeeFactor, borrowLUSD)) - : Trove.GAS_COMPENSATION_DEPOSIT - }); + return new Trove( + Decimal.from(depositCollateral), + borrowLUSD + ? LUSD_LIQUIDATION_RESERVE.add(applyFee(borrowingFeeFactor, borrowLUSD)) + : LUSD_LIQUIDATION_RESERVE + ); } case "closure": @@ -333,7 +471,7 @@ export class Trove { throw new Error("Can't close empty Trove"); } - return emptyTrove; + return _emptyTrove; case "adjustment": { const { @@ -341,68 +479,61 @@ export class Trove { params: { depositCollateral, withdrawCollateral, borrowLUSD, repayLUSD } } = change; - const collateralDecrease = { collateral: withdrawCollateral }; - const collateralIncrease = { collateral: depositCollateral }; - const debtDecrease = { debt: repayLUSD }; - const debtIncrease = { debt: borrowLUSD && applyFee(borrowingFeeFactor, borrowLUSD) }; + const collateralDecrease = Decimal.from(withdrawCollateral ?? 0); + const collateralIncrease = Decimal.from(depositCollateral ?? 0); + const debtDecrease = Decimal.from(repayLUSD ?? 0); + const debtIncrease = borrowLUSD ? applyFee(borrowingFeeFactor, borrowLUSD) : Decimal.ZERO; return setToZero === "collateral" - ? this.setCollateral(0).add(debtIncrease).subtract(debtDecrease) + ? this.setCollateral(0).addDebt(debtIncrease).subtractDebt(debtDecrease) : setToZero === "debt" - ? this.setDebt(0).add(collateralIncrease).subtract(collateralDecrease) - : this.add({ - ...collateralIncrease, - ...debtIncrease - }).subtract({ - ...collateralDecrease, - ...debtDecrease - }); + ? this.setDebt(0).addCollateral(collateralIncrease).subtractCollateral(collateralDecrease) + : this.add(new Trove(collateralIncrease, debtIncrease)).subtract( + new Trove(collateralDecrease, debtDecrease) + ); } } } - static create(params: TroveCreation, borrowingFeeFactor?: Decimalish): Trove { - return emptyTrove.apply(troveCreation(params), borrowingFeeFactor); + static create(params: TroveCreationParams, borrowingFeeFactor?: Decimalish): Trove { + return _emptyTrove.apply(troveCreation(params), borrowingFeeFactor); } - static recreate(that: Trove, borrowingFeeFactor?: Decimalish): TroveCreation { - const change = emptyTrove.whatChanged(that, borrowingFeeFactor); + static recreate(that: Trove, borrowingFeeFactor?: Decimalish): TroveCreationParams { + const change = _emptyTrove.whatChanged(that, borrowingFeeFactor); assert(change?.type === "creation"); return change.params; } - adjust(params: TroveAdjustment, borrowingFeeFactor?: Decimalish): Trove { + adjust(params: TroveAdjustmentParams, borrowingFeeFactor?: Decimalish): Trove { return this.apply(troveAdjustment(params), borrowingFeeFactor); } - adjustTo(that: Trove, borrowingFeeFactor?: Decimalish): TroveAdjustment { + adjustTo(that: Trove, borrowingFeeFactor?: Decimalish): TroveAdjustmentParams { const change = this.whatChanged(that, borrowingFeeFactor); assert(change?.type === "adjustment"); return change.params; } } -export const emptyTrove = new Trove({ collateral: 0, debt: 0 }); - -interface TrovishWithPendingRewards extends Trovish { - readonly stake?: Decimalish; - readonly snapshotOfTotalRedistributed?: Trovish; -} +/** @internal */ +export const _emptyTrove = new Trove(); +/** @public */ export class TroveWithPendingRewards extends Trove { readonly stake: Decimal; readonly snapshotOfTotalRedistributed: Trove; - constructor({ - collateral = 0, - debt = 0, - stake = 0, - snapshotOfTotalRedistributed - }: TrovishWithPendingRewards = {}) { - super({ collateral, debt }); + constructor( + collateral?: Decimal, + debt?: Decimal, + stake = Decimal.ZERO, + snapshotOfTotalRedistributed = _emptyTrove + ) { + super(collateral, debt); - this.stake = Decimal.from(stake); - this.snapshotOfTotalRedistributed = new Trove({ ...snapshotOfTotalRedistributed }); + this.stake = stake; + this.snapshotOfTotalRedistributed = snapshotOfTotalRedistributed; } applyRewards(totalRedistributed: Trove): Trove { diff --git a/packages/lib-base/src/constants.ts b/packages/lib-base/src/constants.ts new file mode 100644 index 000000000..838c7855d --- /dev/null +++ b/packages/lib-base/src/constants.ts @@ -0,0 +1,22 @@ +import { Decimal } from "@liquity/decimal"; + +/** + * Total collateral ratio below which recovery mode is triggered. + * + * @public + */ +export const CRITICAL_COLLATERAL_RATIO: Decimal = Decimal.from(1.5); + +/** + * Collateral ratio below which a Trove can be liquidated in normal mode. + * + * @public + */ +export const MINIMUM_COLLATERAL_RATIO: Decimal = Decimal.from(1.1); + +/** + * Amount of LUSD that's reserved for compensating the liquidator of a Trove. + * + * @public + */ +export const LUSD_LIQUIDATION_RESERVE: Decimal = Decimal.from(10); diff --git a/packages/lib-base/src/utils.ts b/packages/lib-base/src/utils.ts index eb8c9402e..1ac017880 100644 --- a/packages/lib-base/src/utils.ts +++ b/packages/lib-base/src/utils.ts @@ -1,3 +1,4 @@ +/** @internal */ export const proxify = ( t: new (...args: never[]) => T, u: new (...args: never[]) => U, @@ -15,25 +16,29 @@ export const proxify = ( type BunchOfMethods = Record unknown>; -export function glue( +/** @internal */ +export function _glue( t: new (...args: never[]) => T, u: new (...args: never[]) => U ): new (t: T, u: U) => T & U; -export function glue( +/** @internal */ +export function _glue( t: new (...args: never[]) => T, u: new (...args: never[]) => U, v: new (...args: never[]) => V ): new (t: T, u: U, v: V) => T & U & V; -export function glue( +/** @internal */ +export function _glue( t: new (...args: never[]) => T, u: new (...args: never[]) => U, v: new (...args: never[]) => V, w: new (...args: never[]) => W ): new (t: T, u: U, v: V, w: W) => T & U & V & W; -export function glue( +/** @internal */ +export function _glue( ...constructors: (new (...args: never[]) => BunchOfMethods)[] ): new (...instances: BunchOfMethods[]) => unknown { const Glued = class { diff --git a/packages/lib-base/test/LQTYStake.test.ts b/packages/lib-base/test/LQTYStake.test.ts index 6d717886f..bf1bafe73 100644 --- a/packages/lib-base/test/LQTYStake.test.ts +++ b/packages/lib-base/test/LQTYStake.test.ts @@ -1,12 +1,14 @@ import { describe, it } from "mocha"; import fc from "fast-check"; +import { Decimal } from "@liquity/decimal"; + import { LQTYStake } from "../src/LQTYStake"; const arbitraryStake = () => fc - .record({ stakedLQTY: fc.float(), collateralGain: fc.float(), lusdGain: fc.float() }) - .map(stakish => new LQTYStake(stakish)); + .tuple(fc.float(), fc.float(), fc.float()) + .map(([a, b, c]) => new LQTYStake(Decimal.from(a), Decimal.from(b), Decimal.from(c))); const nonZeroStake = () => arbitraryStake().filter(({ stakedLQTY }) => !stakedLQTY.isZero); diff --git a/packages/lib-base/test/StabilityDeposit.test.ts b/packages/lib-base/test/StabilityDeposit.test.ts index c44661239..7ae71fe1f 100644 --- a/packages/lib-base/test/StabilityDeposit.test.ts +++ b/packages/lib-base/test/StabilityDeposit.test.ts @@ -1,18 +1,18 @@ import { describe, it } from "mocha"; import fc from "fast-check"; +import { Decimal } from "@liquity/decimal"; + import { StabilityDeposit } from "../src/StabilityDeposit"; const arbitraryDeposit = () => fc - .record({ - initialLUSD: fc.float(), - currentLUSD: fc.float(), - collateralGain: fc.float(), - lqtyReward: fc.float() - }) - .filter(({ initialLUSD, currentLUSD }) => initialLUSD >= currentLUSD) - .map(depositish => new StabilityDeposit(depositish)); + .tuple(fc.float(), fc.float(), fc.float(), fc.float()) + .filter(([initialLUSD, currentLUSD]) => initialLUSD >= currentLUSD) + .map( + ([a, b, c, d]) => + new StabilityDeposit(Decimal.from(a), Decimal.from(b), Decimal.from(c), Decimal.from(d)) + ); const nonZeroDeposit = () => arbitraryDeposit().filter(({ currentLUSD }) => !currentLUSD.isZero); diff --git a/packages/lib-base/test/Trove.test.ts b/packages/lib-base/test/Trove.test.ts index 69b59c3c7..8494bb117 100644 --- a/packages/lib-base/test/Trove.test.ts +++ b/packages/lib-base/test/Trove.test.ts @@ -2,30 +2,36 @@ import assert from "assert"; import { describe, it } from "mocha"; import fc from "fast-check"; -import { Trove, Trovish, emptyTrove } from "../src/Trove"; +import { Decimal } from "@liquity/decimal"; -const trove = (t: Trovish) => new Trove(t); +import { LUSD_LIQUIDATION_RESERVE } from "../src/constants"; +import { Trove, _emptyTrove } from "../src/Trove"; + +const minDebt = Number(LUSD_LIQUIDATION_RESERVE); + +const trove = ({ collateral = 0, debt = 0 }) => + new Trove(Decimal.from(collateral), Decimal.from(debt)); const onlyCollateral = () => fc.record({ collateral: fc.float({ min: 0.1 }) }).map(trove); -const onlyDebt = () => fc.record({ debt: fc.float({ min: 10, max: 100 }) }).map(trove); +const onlyDebt = () => fc.record({ debt: fc.float({ min: minDebt, max: 100 }) }).map(trove); const bothCollateralAndDebt = () => fc - .record({ collateral: fc.float({ min: 0.1 }), debt: fc.float({ min: 10, max: 100 }) }) + .record({ collateral: fc.float({ min: 0.1 }), debt: fc.float({ min: minDebt, max: 100 }) }) .map(trove); const arbitraryTrove = () => fc.record({ collateral: fc.float(), debt: fc.float({ max: 100 }) }).map(trove); const validTrove = () => - fc.record({ collateral: fc.float(), debt: fc.float({ min: 10, max: 100 }) }).map(trove); + fc.record({ collateral: fc.float(), debt: fc.float({ min: minDebt, max: 100 }) }).map(trove); const validNonEmptyTrove = () => validTrove().filter(t => !t.isEmpty); describe("Trove", () => { it("applying undefined diff should yield the same Trove", () => { - const trove = new Trove({ collateral: 1, debt: 111 }); + const trove = new Trove(Decimal.from(1), Decimal.from(111)); assert(trove.apply(undefined) === trove); }); @@ -33,7 +39,7 @@ describe("Trove", () => { it("applying diff of empty from `b` to `a` should always yield empty", () => { fc.assert( fc.property(validNonEmptyTrove(), validNonEmptyTrove(), (a, b) => - a.apply(b.whatChanged(emptyTrove)).equals(emptyTrove) + a.apply(b.whatChanged(_emptyTrove)).equals(_emptyTrove) ) ); }); diff --git a/packages/lib-ethers/.eslintrc.json b/packages/lib-ethers/.eslintrc.json index 1c5d173f2..b8f143899 100644 --- a/packages/lib-ethers/.eslintrc.json +++ b/packages/lib-ethers/.eslintrc.json @@ -10,6 +10,8 @@ "ecmaVersion": 2021, "sourceType": "module" }, - "plugins": ["@typescript-eslint"], - "rules": {} + "plugins": ["@typescript-eslint", "eslint-plugin-tsdoc"], + "rules": { + "tsdoc/syntax": "warn" + } } diff --git a/packages/lib-ethers/etc/lib-ethers.api.md b/packages/lib-ethers/etc/lib-ethers.api.md index b06d16a47..3f908cad3 100644 --- a/packages/lib-ethers/etc/lib-ethers.api.md +++ b/packages/lib-ethers/etc/lib-ethers.api.md @@ -10,7 +10,7 @@ import { BlockTag } from '@ethersproject/abstract-provider'; import { BytesLike } from '@ethersproject/bytes'; import { CallOverrides } from '@ethersproject/contracts'; import { CollateralGainTransferDetails } from '@liquity/lib-base'; -import { CollateralGainTransferOptionalParams } from '@liquity/lib-base'; +import { _CollateralGainTransferOptionalParams } from '@liquity/lib-base'; import { Contract } from '@ethersproject/contracts'; import { ContractInterface } from '@ethersproject/contracts'; import { ContractTransaction } from '@ethersproject/contracts'; @@ -19,8 +19,8 @@ import { Decimalish } from '@liquity/decimal'; import { EventFilter } from '@ethersproject/contracts'; import { Fees } from '@liquity/lib-base'; import { FrontendStatus } from '@liquity/lib-base'; -import { Hinted } from '@liquity/lib-base'; -import { HintedMethodOptionalParams } from '@liquity/lib-base'; +import { _Hinted } from '@liquity/lib-base'; +import { _HintedMethodOptionalParams } from '@liquity/lib-base'; import { JsonFragment } from '@ethersproject/abi'; import { LiquidationDetails } from '@liquity/lib-base'; import { LiquityReceipt } from '@liquity/lib-base'; @@ -33,32 +33,31 @@ import { MinedReceipt } from '@liquity/lib-base'; import { ObservableLiquity } from '@liquity/lib-base'; import { Overrides } from '@ethersproject/contracts'; import { PayableOverrides } from '@ethersproject/contracts'; -import { Populatable } from '@liquity/lib-base'; +import { _Populatable } from '@liquity/lib-base'; import { PopulatedLiquityTransaction } from '@liquity/lib-base'; import { PopulatedTransaction } from '@ethersproject/contracts'; import { Provider } from '@ethersproject/abstract-provider'; import { ReadableLiquity } from '@liquity/lib-base'; import { RedemptionDetails } from '@liquity/lib-base'; -import { RedemptionOptionalParams } from '@liquity/lib-base'; -import { SendableFrom } from '@liquity/lib-base'; +import { _RedemptionOptionalParams } from '@liquity/lib-base'; +import { _SendableFrom } from '@liquity/lib-base'; import { SentLiquityTransaction } from '@liquity/lib-base'; import { Signer } from '@ethersproject/abstract-signer'; import { StabilityDeposit } from '@liquity/lib-base'; import { StabilityDepositChangeDetails } from '@liquity/lib-base'; import { StabilityPoolGainsWithdrawalDetails } from '@liquity/lib-base'; -import { TransactableFrom } from '@liquity/lib-base'; +import { _TransactableFrom } from '@liquity/lib-base'; import { TransactableLiquity } from '@liquity/lib-base'; import { TransactionReceipt } from '@ethersproject/abstract-provider'; import { TransactionResponse } from '@ethersproject/abstract-provider'; import { Trove } from '@liquity/lib-base'; -import { TroveAdjustment } from '@liquity/lib-base'; import { TroveAdjustmentDetails } from '@liquity/lib-base'; -import { TroveAdjustmentOptionalParams } from '@liquity/lib-base'; -import { TroveChangeWithFees } from '@liquity/lib-base'; +import { _TroveAdjustmentOptionalParams } from '@liquity/lib-base'; +import { TroveAdjustmentParams } from '@liquity/lib-base'; import { TroveClosureDetails } from '@liquity/lib-base'; -import { TroveCreation } from '@liquity/lib-base'; import { TroveCreationDetails } from '@liquity/lib-base'; -import { TroveCreationOptionalParams } from '@liquity/lib-base'; +import { _TroveCreationOptionalParams } from '@liquity/lib-base'; +import { TroveCreationParams } from '@liquity/lib-base'; import { TroveWithPendingRewards } from '@liquity/lib-base'; // @public (undocumented) @@ -67,10 +66,10 @@ export const addressesOf: (contracts: LiquityContracts) => LiquityContractAddres // @public (undocumented) export class BlockPolledLiquityStore extends LiquityStore { constructor(provider: Provider, account: string, liquity: ReadableEthersLiquity, frontendTag?: string); - // (undocumented) - doStart(): () => void; - // (undocumented) - protected reduceExtra(oldState: BlockPolledLiquityStoreExtraState, stateUpdate: Partial): BlockPolledLiquityStoreExtraState; + // @override (undocumented) + protected _doStart(): () => void; + // @override (undocumented) + protected _reduceExtra(oldState: BlockPolledLiquityStoreExtraState, stateUpdate: Partial): BlockPolledLiquityStoreExtraState; } // @public (undocumented) @@ -233,17 +232,17 @@ export class ObservableEthersLiquity extends EthersLiquityBase implements Observ // Warning: (ae-forgotten-export) The symbol "PopulatableEthersLiquityBase" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export class PopulatableEthersLiquity extends PopulatableEthersLiquityBase implements Populatable, TransactionReceipt, TransactionResponse, PopulatedTransaction> { +export class PopulatableEthersLiquity extends PopulatableEthersLiquityBase implements _Populatable<_Hinted, TransactionReceipt, TransactionResponse, PopulatedTransaction> { // (undocumented) - adjustTrove(params: TroveAdjustment, optionalParams?: TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; + adjustTrove(params: TroveAdjustmentParams, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) - borrowLUSD(amount: Decimalish, optionalParams?: TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; + borrowLUSD(amount: Decimalish, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) claimCollateralSurplus(overrides?: EthersTransactionOverrides): Promise>; // (undocumented) closeTrove(overrides?: EthersTransactionOverrides): Promise>; // (undocumented) - depositCollateral(amount: Decimalish, optionalParams?: TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; + depositCollateral(amount: Decimalish, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) depositLUSDInStabilityPool(amount: Decimalish, frontendTag?: string, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) @@ -251,13 +250,13 @@ export class PopulatableEthersLiquity extends PopulatableEthersLiquityBase imple // (undocumented) liquidateUpTo(maximumNumberOfTrovesToLiquidate: number, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) - openTrove(params: TroveCreation, optionalParams?: TroveCreationOptionalParams, overrides?: EthersTransactionOverrides): Promise>; + openTrove(params: TroveCreationParams, optionalParams?: _TroveCreationOptionalParams, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) - redeemLUSD(amount: Decimalish, optionalParams?: RedemptionOptionalParams, overrides?: EthersTransactionOverrides): Promise>; + redeemLUSD(amount: Decimalish, optionalParams?: _RedemptionOptionalParams, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) registerFrontend(kickbackRate: Decimalish, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) - repayLUSD(amount: Decimalish, optionalParams?: TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; + repayLUSD(amount: Decimalish, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) sendLQTY(toAddress: string, amount: Decimalish, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) @@ -267,11 +266,11 @@ export class PopulatableEthersLiquity extends PopulatableEthersLiquityBase imple // (undocumented) stakeLQTY(amount: Decimalish, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) - transferCollateralGainToTrove(optionalParams?: CollateralGainTransferOptionalParams, overrides?: EthersTransactionOverrides): Promise>; + transferCollateralGainToTrove(optionalParams?: _CollateralGainTransferOptionalParams, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) unstakeLQTY(amount: Decimalish, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) - withdrawCollateral(amount: Decimalish, optionalParams?: TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; + withdrawCollateral(amount: Decimalish, optionalParams?: _TroveAdjustmentOptionalParams, overrides?: EthersTransactionOverrides): Promise>; // (undocumented) withdrawGainsFromStabilityPool(overrides?: EthersTransactionOverrides): Promise>; // (undocumented) @@ -339,7 +338,7 @@ export class ReadableEthersLiquity extends EthersLiquityBase implements Readable export const redeemMaxIterations = 68; // @public (undocumented) -export type SendableEthersLiquity = SendableFrom; +export type SendableEthersLiquity = _SendableFrom; // @public (undocumented) export const SendableEthersLiquity: new (populatable: PopulatableEthersLiquity) => SendableEthersLiquity; @@ -356,7 +355,7 @@ export class SentEthersTransaction implements SentLiquityTransactio } // @public (undocumented) -export type TransactableEthersLiquity = TransactableFrom; +export type TransactableEthersLiquity = _TransactableFrom; // @public (undocumented) export const TransactableEthersLiquity: new (sendable: SendableEthersLiquity) => TransactableEthersLiquity; diff --git a/packages/lib-ethers/package.json b/packages/lib-ethers/package.json index 20e58eedd..d72a7e37c 100644 --- a/packages/lib-ethers/package.json +++ b/packages/lib-ethers/package.json @@ -46,6 +46,7 @@ "cross-env": "^7.0.2", "dotenv": "^8.2.0", "eslint": "^7.18.0", + "eslint-plugin-tsdoc": "^0.2.11", "ethers": "^5.0.0", "fs-extra": "^9.0.1", "hardhat": "^2.0.3", diff --git a/packages/lib-ethers/src/BlockPolledLiquityStore.ts b/packages/lib-ethers/src/BlockPolledLiquityStore.ts index ecb409d91..a66611b70 100644 --- a/packages/lib-ethers/src/BlockPolledLiquityStore.ts +++ b/packages/lib-ethers/src/BlockPolledLiquityStore.ts @@ -27,9 +27,10 @@ const promiseAllValues = (object: T) => { const decimalify = (bigNumber: BigNumber) => new Decimal(bigNumber); export class BlockPolledLiquityStore extends LiquityStore { - private provider: Provider; - private account: string; - private liquity: ReadableEthersLiquity; + private _provider: Provider; + private _account: string; + private _liquity: ReadableEthersLiquity; + private _frontendTag: string; constructor( provider: Provider, @@ -37,59 +38,64 @@ export class BlockPolledLiquityStore extends LiquityStore { + private _get(blockTag?: number): Promise { return promiseAllValues({ - frontend: this.liquity.getFrontendStatus(this.constants.frontendTag, { blockTag }), - ownFrontend: this.liquity.getFrontendStatus(this.account, { blockTag }), - accountBalance: this.provider.getBalance(this.account, blockTag).then(decimalify), - lusdBalance: this.liquity.getLUSDBalance(this.account, { blockTag }), - lqtyBalance: this.liquity.getLQTYBalance(this.account, { blockTag }), - collateralSurplusBalance: this.liquity.getCollateralSurplusBalance(this.account, { blockTag }), - price: this.liquity.getPrice({ blockTag }), - numberOfTroves: this.liquity.getNumberOfTroves({ blockTag }), - troveWithoutRewards: this.liquity.getTroveWithoutRewards(this.account, { blockTag }), - totalRedistributed: this.liquity.getTotalRedistributed({ blockTag }), - deposit: this.liquity.getStabilityDeposit(this.account, { blockTag }), - total: this.liquity.getTotal({ blockTag }), - lusdInStabilityPool: this.liquity.getLUSDInStabilityPool({ blockTag }), - fees: this.liquity.getFees({ blockTag }), - lqtyStake: this.liquity.getLQTYStake(this.account, { blockTag }), - totalStakedLQTY: this.liquity.getTotalStakedLQTY({ blockTag }) + frontend: this._liquity.getFrontendStatus(this._frontendTag, { blockTag }), + ownFrontend: this._liquity.getFrontendStatus(this._account, { blockTag }), + accountBalance: this._provider.getBalance(this._account, blockTag).then(decimalify), + lusdBalance: this._liquity.getLUSDBalance(this._account, { blockTag }), + lqtyBalance: this._liquity.getLQTYBalance(this._account, { blockTag }), + collateralSurplusBalance: this._liquity.getCollateralSurplusBalance(this._account, { + blockTag + }), + price: this._liquity.getPrice({ blockTag }), + numberOfTroves: this._liquity.getNumberOfTroves({ blockTag }), + troveWithoutRewards: this._liquity.getTroveWithoutRewards(this._account, { blockTag }), + totalRedistributed: this._liquity.getTotalRedistributed({ blockTag }), + deposit: this._liquity.getStabilityDeposit(this._account, { blockTag }), + total: this._liquity.getTotal({ blockTag }), + lusdInStabilityPool: this._liquity.getLUSDInStabilityPool({ blockTag }), + fees: this._liquity.getFees({ blockTag }), + lqtyStake: this._liquity.getLQTYStake(this._account, { blockTag }), + totalStakedLQTY: this._liquity.getTotalStakedLQTY({ blockTag }) }); } - doStart(): () => void { - this.get().then(state => { - if (!this.loaded) { - this.load(state, {}); + /** @override */ + protected _doStart(): () => void { + this._get().then(state => { + if (!this._loaded) { + this._load(state, {}); } }); const blockListener = async (blockTag: number) => { - const state = await this.get(blockTag); + const state = await this._get(blockTag); - if (this.loaded) { - this.update(state, { blockTag }); + if (this._loaded) { + this._update(state, { blockTag }); } else { - this.load(state, { blockTag }); + this._load(state, { blockTag }); } }; - this.provider.on("block", blockListener); + this._provider.on("block", blockListener); return () => { - this.provider.off("block", blockListener); + this._provider.off("block", blockListener); }; } - protected reduceExtra( + /** @override */ + protected _reduceExtra( oldState: BlockPolledLiquityStoreExtraState, stateUpdate: Partial ): BlockPolledLiquityStoreExtraState { diff --git a/packages/lib-ethers/src/EthersLiquity.ts b/packages/lib-ethers/src/EthersLiquity.ts index 5318bcbcd..7d0e74a0f 100644 --- a/packages/lib-ethers/src/EthersLiquity.ts +++ b/packages/lib-ethers/src/EthersLiquity.ts @@ -1,6 +1,6 @@ import { Signer } from "@ethersproject/abstract-signer"; -import { glue } from "@liquity/lib-base"; +import { _glue } from "@liquity/lib-base"; import { connectToContracts, LiquityContracts, LiquityDeployment } from "./contracts"; import { @@ -19,7 +19,7 @@ const GluedEthersLiquity: new ( transactable: TransactableEthersLiquity, readable: ReadableEthersLiquity, observable: ObservableEthersLiquity -) => GluedEthersLiquity = glue( +) => GluedEthersLiquity = _glue( TransactableEthersLiquity, ReadableEthersLiquity, ObservableEthersLiquity diff --git a/packages/lib-ethers/src/EthersLiquityBase.ts b/packages/lib-ethers/src/EthersLiquityBase.ts index 8a029bf8d..2c9beec14 100644 --- a/packages/lib-ethers/src/EthersLiquityBase.ts +++ b/packages/lib-ethers/src/EthersLiquityBase.ts @@ -1,19 +1,19 @@ import { LiquityContracts } from "./contracts"; export class EthersLiquityBase { - protected readonly contracts: LiquityContracts; - private readonly userAddress?: string; + protected readonly _contracts: LiquityContracts; + private readonly _userAddress?: string; constructor(contracts: LiquityContracts, userAddress?: string) { - this.contracts = contracts; - this.userAddress = userAddress; + this._contracts = contracts; + this._userAddress = userAddress; } - protected requireAddress(): string { - if (!this.userAddress) { + protected _requireAddress(): string { + if (!this._userAddress) { throw Error("An address is required"); } - return this.userAddress; + return this._userAddress; } } diff --git a/packages/lib-ethers/src/ObservableEthersLiquity.ts b/packages/lib-ethers/src/ObservableEthersLiquity.ts index 10f1bb329..79d52c8f1 100644 --- a/packages/lib-ethers/src/ObservableEthersLiquity.ts +++ b/packages/lib-ethers/src/ObservableEthersLiquity.ts @@ -38,7 +38,7 @@ const debounce = (listener: (latestBlock: number) => void) => { }; export class ObservableEthersLiquity extends EthersLiquityBase implements ObservableLiquity { - private readableLiquity: ReadableEthersLiquity; + private _readableLiquity: ReadableEthersLiquity; constructor( contracts: LiquityContracts, @@ -47,63 +47,63 @@ export class ObservableEthersLiquity extends EthersLiquityBase implements Observ ) { super(contracts, userAddress); - this.readableLiquity = readableLiquity; + this._readableLiquity = readableLiquity; } watchTotalRedistributed( onTotalRedistributedChanged: (totalRedistributed: Trove) => void ): () => void { - const etherSent = this.contracts.activePool.filters.EtherSent(); + const etherSent = this._contracts.activePool.filters.EtherSent(); const redistributionListener = debounce((blockTag: number) => { - this.readableLiquity.getTotalRedistributed({ blockTag }).then(onTotalRedistributedChanged); + this._readableLiquity.getTotalRedistributed({ blockTag }).then(onTotalRedistributedChanged); }); const etherSentListener = (toAddress: string, _amount: BigNumber, event: Event) => { - if (toAddress === this.contracts.defaultPool.address) { + if (toAddress === this._contracts.defaultPool.address) { redistributionListener(event); } }; - this.contracts.activePool.on(etherSent, etherSentListener); + this._contracts.activePool.on(etherSent, etherSentListener); return () => { - this.contracts.activePool.removeListener(etherSent, etherSentListener); + this._contracts.activePool.removeListener(etherSent, etherSentListener); }; } watchTroveWithoutRewards( onTroveChanged: (trove: TroveWithPendingRewards) => void, - address = this.requireAddress() + address = this._requireAddress() ): () => void { - const { TroveCreated, TroveUpdated } = this.contracts.troveManager.filters; + const { TroveCreated, TroveUpdated } = this._contracts.troveManager.filters; const troveEventFilters = [TroveCreated(address), TroveUpdated(address)]; const troveListener = debounce((blockTag: number) => { - this.readableLiquity.getTroveWithoutRewards(address, { blockTag }).then(onTroveChanged); + this._readableLiquity.getTroveWithoutRewards(address, { blockTag }).then(onTroveChanged); }); - troveEventFilters.forEach(filter => this.contracts.troveManager.on(filter, troveListener)); + troveEventFilters.forEach(filter => this._contracts.troveManager.on(filter, troveListener)); return () => { troveEventFilters.forEach(filter => - this.contracts.troveManager.removeListener(filter, troveListener) + this._contracts.troveManager.removeListener(filter, troveListener) ); }; } watchNumberOfTroves(onNumberOfTrovesChanged: (numberOfTroves: number) => void): () => void { - const { TroveUpdated } = this.contracts.troveManager.filters; + const { TroveUpdated } = this._contracts.troveManager.filters; const troveUpdated = TroveUpdated(); const troveUpdatedListener = debounce((blockTag: number) => { - this.readableLiquity.getNumberOfTroves({ blockTag }).then(onNumberOfTrovesChanged); + this._readableLiquity.getNumberOfTroves({ blockTag }).then(onNumberOfTrovesChanged); }); - this.contracts.troveManager.on(troveUpdated, troveUpdatedListener); + this._contracts.troveManager.on(troveUpdated, troveUpdatedListener); return () => { - this.contracts.troveManager.removeListener(troveUpdated, troveUpdatedListener); + this._contracts.troveManager.removeListener(troveUpdated, troveUpdatedListener); }; } @@ -116,96 +116,98 @@ export class ObservableEthersLiquity extends EthersLiquityBase implements Observ } watchTotal(onTotalChanged: (total: Trove) => void): () => void { - const { TroveUpdated } = this.contracts.troveManager.filters; + const { TroveUpdated } = this._contracts.troveManager.filters; const troveUpdated = TroveUpdated(); const totalListener = debounce((blockTag: number) => { - this.readableLiquity.getTotal({ blockTag }).then(onTotalChanged); + this._readableLiquity.getTotal({ blockTag }).then(onTotalChanged); }); - this.contracts.troveManager.on(troveUpdated, totalListener); + this._contracts.troveManager.on(troveUpdated, totalListener); return () => { - this.contracts.troveManager.removeListener(troveUpdated, totalListener); + this._contracts.troveManager.removeListener(troveUpdated, totalListener); }; } watchStabilityDeposit( onStabilityDepositChanged: (deposit: StabilityDeposit) => void, - address = this.requireAddress() + address = this._requireAddress() ): () => void { - const { UserDepositChanged } = this.contracts.stabilityPool.filters; - const { EtherSent } = this.contracts.activePool.filters; + const { UserDepositChanged } = this._contracts.stabilityPool.filters; + const { EtherSent } = this._contracts.activePool.filters; const userDepositChanged = UserDepositChanged(address); const etherSent = EtherSent(); const depositListener = debounce((blockTag: number) => { - this.readableLiquity + this._readableLiquity .getStabilityDeposit(address, { blockTag }) .then(onStabilityDepositChanged); }); const etherSentListener = (toAddress: string, _amount: BigNumber, event: Event) => { - if (toAddress === this.contracts.stabilityPool.address) { + if (toAddress === this._contracts.stabilityPool.address) { // Liquidation while Stability Pool has some deposits // There may be new gains depositListener(event); } }; - this.contracts.stabilityPool.on(userDepositChanged, depositListener); - this.contracts.activePool.on(etherSent, etherSentListener); + this._contracts.stabilityPool.on(userDepositChanged, depositListener); + this._contracts.activePool.on(etherSent, etherSentListener); return () => { - this.contracts.stabilityPool.removeListener(userDepositChanged, depositListener); - this.contracts.activePool.removeListener(etherSent, etherSentListener); + this._contracts.stabilityPool.removeListener(userDepositChanged, depositListener); + this._contracts.activePool.removeListener(etherSent, etherSentListener); }; } watchLUSDInStabilityPool( onLUSDInStabilityPoolChanged: (lusdInStabilityPool: Decimal) => void ): () => void { - const { Transfer } = this.contracts.lusdToken.filters; + const { Transfer } = this._contracts.lusdToken.filters; - const transferLUSDFromStabilityPool = Transfer(this.contracts.stabilityPool.address); - const transferLUSDToStabilityPool = Transfer(null, this.contracts.stabilityPool.address); + const transferLUSDFromStabilityPool = Transfer(this._contracts.stabilityPool.address); + const transferLUSDToStabilityPool = Transfer(null, this._contracts.stabilityPool.address); const stabilityPoolLUSDFilters = [transferLUSDFromStabilityPool, transferLUSDToStabilityPool]; const stabilityPoolLUSDListener = debounce((blockTag: number) => { - this.readableLiquity.getLUSDInStabilityPool({ blockTag }).then(onLUSDInStabilityPoolChanged); + this._readableLiquity.getLUSDInStabilityPool({ blockTag }).then(onLUSDInStabilityPoolChanged); }); stabilityPoolLUSDFilters.forEach(filter => - this.contracts.lusdToken.on(filter, stabilityPoolLUSDListener) + this._contracts.lusdToken.on(filter, stabilityPoolLUSDListener) ); return () => stabilityPoolLUSDFilters.forEach(filter => - this.contracts.lusdToken.removeListener(filter, stabilityPoolLUSDListener) + this._contracts.lusdToken.removeListener(filter, stabilityPoolLUSDListener) ); } watchLUSDBalance( onLUSDBalanceChanged: (balance: Decimal) => void, - address = this.requireAddress() + address = this._requireAddress() ): () => void { - const { Transfer } = this.contracts.lusdToken.filters; + const { Transfer } = this._contracts.lusdToken.filters; const transferLUSDFromUser = Transfer(address); const transferLUSDToUser = Transfer(null, address); const lusdTransferFilters = [transferLUSDFromUser, transferLUSDToUser]; const lusdTransferListener = debounce((blockTag: number) => { - this.readableLiquity.getLUSDBalance(address, { blockTag }).then(onLUSDBalanceChanged); + this._readableLiquity.getLUSDBalance(address, { blockTag }).then(onLUSDBalanceChanged); }); - lusdTransferFilters.forEach(filter => this.contracts.lusdToken.on(filter, lusdTransferListener)); + lusdTransferFilters.forEach(filter => + this._contracts.lusdToken.on(filter, lusdTransferListener) + ); return () => lusdTransferFilters.forEach(filter => - this.contracts.lusdToken.removeListener(filter, lusdTransferListener) + this._contracts.lusdToken.removeListener(filter, lusdTransferListener) ); } } diff --git a/packages/lib-ethers/src/PopulatableEthersLiquity.ts b/packages/lib-ethers/src/PopulatableEthersLiquity.ts index a878bbdca..be4fd21b8 100644 --- a/packages/lib-ethers/src/PopulatableEthersLiquity.ts +++ b/packages/lib-ethers/src/PopulatableEthersLiquity.ts @@ -16,39 +16,38 @@ import { Decimal, Decimalish } from "@liquity/decimal"; import { Trove, TroveWithPendingRewards, - TroveAdjustment, + TroveAdjustmentParams, ReadableLiquity, - HintedMethodOptionalParams, - TroveAdjustmentOptionalParams, - CollateralGainTransferOptionalParams, - Hinted, + _HintedMethodOptionalParams, + _TroveAdjustmentOptionalParams, + _CollateralGainTransferOptionalParams, + _Hinted, LiquityReceipt, SentLiquityTransaction, LiquidationDetails, RedemptionDetails, - Populatable, + _Populatable, TransactableLiquity, PopulatedLiquityTransaction, - sendableFrom, - transactableFrom, - normalizeTroveAdjustment, - TroveCreation, - normalizeTroveCreation, - TroveCreationOptionalParams, - TroveChangeWithFees, + _sendableFrom, + _transactableFrom, + _normalizeTroveAdjustment, + TroveCreationParams, + _normalizeTroveCreation, + _TroveCreationOptionalParams, TroveClosureDetails, CollateralGainTransferDetails, - RedemptionOptionalParams, - failedReceipt, - pendingReceipt, - successfulReceipt, + _RedemptionOptionalParams, + _failedReceipt, + _pendingReceipt, + _successfulReceipt, StabilityPoolGainsWithdrawalDetails, StabilityDepositChangeDetails, MinedReceipt, TroveCreationDetails, TroveAdjustmentDetails, - SendableFrom, - TransactableFrom + _SendableFrom, + _TransactableFrom } from "@liquity/lib-base"; import { LiquityContracts, priceFeedIsTestnet } from "./contracts"; @@ -111,9 +110,9 @@ export class SentEthersTransaction implements SentLiquityTransaction> { readonly rawSentTransaction: TransactionResponse; - private readonly parse: (rawReceipt: TransactionReceipt) => T; - private readonly provider: Provider; - private readonly contracts: LiquityContracts; + private readonly _parse: (rawReceipt: TransactionReceipt) => T; + private readonly _provider: Provider; + private readonly _contracts: LiquityContracts; constructor( rawSentTransaction: TransactionResponse, @@ -122,28 +121,30 @@ export class SentEthersTransaction contracts: LiquityContracts ) { this.rawSentTransaction = rawSentTransaction; - this.parse = parse; - this.provider = provider; - this.contracts = contracts; + this._parse = parse; + this._provider = provider; + this._contracts = contracts; } - private receiptFrom(rawReceipt: TransactionReceipt | null) { + private _receiptFrom(rawReceipt: TransactionReceipt | null) { return rawReceipt ? rawReceipt.status - ? successfulReceipt(rawReceipt, this.parse(rawReceipt), () => - logsToString(rawReceipt, (this.contracts as unknown) as Record) + ? _successfulReceipt(rawReceipt, this._parse(rawReceipt), () => + logsToString(rawReceipt, (this._contracts as unknown) as Record) ) - : failedReceipt(rawReceipt) - : pendingReceipt; + : _failedReceipt(rawReceipt) + : _pendingReceipt; } async getReceipt(): Promise> { - return this.receiptFrom(await this.provider.getTransactionReceipt(this.rawSentTransaction.hash)); + return this._receiptFrom( + await this._provider.getTransactionReceipt(this.rawSentTransaction.hash) + ); } async waitForReceipt(): Promise> { - const receipt = this.receiptFrom( - await this.provider.waitForTransaction(this.rawSentTransaction.hash) + const receipt = this._receiptFrom( + await this._provider.waitForTransaction(this.rawSentTransaction.hash) ); assert(receipt.status !== "pending"); @@ -155,9 +156,9 @@ export class PopulatedEthersTransaction implements PopulatedLiquityTransaction> { readonly rawPopulatedTransaction: PopulatedTransaction; - private readonly parse: (rawReceipt: TransactionReceipt) => T; - private readonly signer: Signer; - private readonly contracts: LiquityContracts; + private readonly _parse: (rawReceipt: TransactionReceipt) => T; + private readonly _signer: Signer; + private readonly _contracts: LiquityContracts; constructor( rawPopulatedTransaction: PopulatedTransaction, @@ -166,58 +167,61 @@ export class PopulatedEthersTransaction contracts: LiquityContracts ) { this.rawPopulatedTransaction = rawPopulatedTransaction; - this.parse = parse; - this.signer = signer; - this.contracts = contracts; + this._parse = parse; + this._signer = signer; + this._contracts = contracts; } async send(): Promise> { - if (!this.signer.provider) { + if (!this._signer.provider) { throw new Error("Signer must have a Provider"); } return new SentEthersTransaction( - await this.signer.sendTransaction(this.rawPopulatedTransaction), - this.parse, - this.signer.provider, - this.contracts + await this._signer.sendTransaction(this.rawPopulatedTransaction), + this._parse, + this._signer.provider, + this._contracts ); } } +interface TroveChangeWithFees { + params: T; + newTrove: Trove; + fee: Decimal; +} + class PopulatableEthersLiquityBase extends EthersLiquityBase { - protected readonly readableLiquity: ReadableLiquity; - protected readonly signer: Signer; + protected readonly _readableLiquity: ReadableLiquity; + protected readonly _signer: Signer; constructor(contracts: LiquityContracts, readableLiquity: ReadableLiquity, signer: Signer) { super(contracts); - this.readableLiquity = readableLiquity; - this.signer = signer; + this._readableLiquity = readableLiquity; + this._signer = signer; } - protected wrapSimpleTransaction(rawPopulatedTransaction: PopulatedTransaction) { + protected _wrapSimpleTransaction(rawPopulatedTransaction: PopulatedTransaction) { return new PopulatedEthersTransaction( rawPopulatedTransaction, noDetails, - this.signer, - this.contracts + this._signer, + this._contracts ); } - protected wrapTroveChangeWithFees(params: T, rawPopulatedTransaction: PopulatedTransaction) { + protected _wrapTroveChangeWithFees(params: T, rawPopulatedTransaction: PopulatedTransaction) { return new PopulatedEthersTransaction>( rawPopulatedTransaction, ({ logs }) => { - const [newTrove] = this.contracts.borrowerOperations + const [newTrove] = this._contracts.borrowerOperations .extractEvents(logs, "TroveUpdated") - .map( - ({ args: { _coll, _debt } }) => - new Trove({ collateral: new Decimal(_coll), debt: new Decimal(_debt) }) - ); + .map(({ args: { _coll, _debt } }) => new Trove(new Decimal(_coll), new Decimal(_debt))); - const [fee] = this.contracts.borrowerOperations + const [fee] = this._contracts.borrowerOperations .extractEvents(logs, "LUSDBorrowingFeePaid") .map(({ args: { _LUSDFee } }) => new Decimal(_LUSDFee)); @@ -228,24 +232,24 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { }; }, - this.signer, - this.contracts + this._signer, + this._contracts ); } - protected async wrapTroveClosure(rawPopulatedTransaction: PopulatedTransaction) { - const userAddress = await this.signer.getAddress(); + protected async _wrapTroveClosure(rawPopulatedTransaction: PopulatedTransaction) { + const userAddress = await this._signer.getAddress(); return new PopulatedEthersTransaction( rawPopulatedTransaction, ({ logs }) => { - const [repayLUSD] = this.contracts.lusdToken + const [repayLUSD] = this._contracts.lusdToken .extractEvents(logs, "Transfer") .filter(({ args: { from, to } }) => from === userAddress && to === AddressZero) .map(({ args: { value } }) => new Decimal(value)); - const [withdrawCollateral] = this.contracts.activePool + const [withdrawCollateral] = this._contracts.activePool .extractEvents(logs, "EtherSent") .filter(({ args: { _to } }) => _to === userAddress) .map(({ args: { _amount } }) => new Decimal(_amount)); @@ -255,21 +259,21 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { }; }, - this.signer, - this.contracts + this._signer, + this._contracts ); } - protected wrapLiquidation(rawPopulatedTransaction: PopulatedTransaction) { + protected _wrapLiquidation(rawPopulatedTransaction: PopulatedTransaction) { return new PopulatedEthersTransaction( rawPopulatedTransaction, ({ logs }) => { - const liquidatedAddresses = this.contracts.troveManager + const liquidatedAddresses = this._contracts.troveManager .extractEvents(logs, "TroveLiquidated") .map(({ args: { _borrower } }) => _borrower); - const [totals] = this.contracts.troveManager + const [totals] = this._contracts.troveManager .extractEvents(logs, "Liquidation") .map( ({ @@ -277,11 +281,7 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { }) => ({ collateralGasCompensation: new Decimal(_collGasCompensation), lusdGasCompensation: new Decimal(_LUSDGasCompensation), - - totalLiquidated: new Trove({ - collateral: new Decimal(_liquidatedColl), - debt: new Decimal(_liquidatedDebt) - }) + totalLiquidated: new Trove(new Decimal(_liquidatedColl), new Decimal(_liquidatedDebt)) }) ); @@ -291,17 +291,17 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { }; }, - this.signer, - this.contracts + this._signer, + this._contracts ); } - protected wrapRedemption(rawPopulatedTransaction: PopulatedTransaction) { + protected _wrapRedemption(rawPopulatedTransaction: PopulatedTransaction) { return new PopulatedEthersTransaction( rawPopulatedTransaction, ({ logs }) => - this.contracts.troveManager + this._contracts.troveManager .extractEvents(logs, "Redemption") .map(({ args: { _ETHSent, _ETHFee, _actualLUSDAmount, _attemptedLUSDAmount } }) => ({ attemptedLUSDAmount: new Decimal(_attemptedLUSDAmount), @@ -310,23 +310,23 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { fee: new Decimal(_ETHFee) }))[0], - this.signer, - this.contracts + this._signer, + this._contracts ); } - private extractStabilityPoolGainsWithdrawalDetails( + private _extractStabilityPoolGainsWithdrawalDetails( logs: Log[] ): StabilityPoolGainsWithdrawalDetails { - const [newLUSDDeposit] = this.contracts.stabilityPool + const [newLUSDDeposit] = this._contracts.stabilityPool .extractEvents(logs, "UserDepositChanged") .map(({ args: { _newDeposit } }) => new Decimal(_newDeposit)); - const [[collateralGain, lusdLoss]] = this.contracts.stabilityPool + const [[collateralGain, lusdLoss]] = this._contracts.stabilityPool .extractEvents(logs, "ETHGainWithdrawn") .map(({ args: { _ETH, _LUSDLoss } }) => [new Decimal(_ETH), new Decimal(_LUSDLoss)]); - const [lqtyReward] = this.contracts.stabilityPool + const [lqtyReward] = this._contracts.stabilityPool .extractEvents(logs, "LQTYPaidToDepositor") .map(({ args: { _LQTY } }) => new Decimal(_LQTY)); @@ -338,16 +338,16 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { }; } - protected wrapStabilityPoolGainsWithdrawal(rawPopulatedTransaction: PopulatedTransaction) { + protected _wrapStabilityPoolGainsWithdrawal(rawPopulatedTransaction: PopulatedTransaction) { return new PopulatedEthersTransaction( rawPopulatedTransaction, - ({ logs }) => this.extractStabilityPoolGainsWithdrawalDetails(logs), - this.signer, - this.contracts + ({ logs }) => this._extractStabilityPoolGainsWithdrawalDetails(logs), + this._signer, + this._contracts ); } - protected wrapStabilityDepositTopup( + protected _wrapStabilityDepositTopup( change: { depositLUSD: Decimal }, rawPopulatedTransaction: PopulatedTransaction ) { @@ -355,29 +355,29 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { rawPopulatedTransaction, ({ logs }) => ({ - ...this.extractStabilityPoolGainsWithdrawalDetails(logs), + ...this._extractStabilityPoolGainsWithdrawalDetails(logs), change }), - this.signer, - this.contracts + this._signer, + this._contracts ); } - protected async wrapStabilityDepositWithdrawal(rawPopulatedTransaction: PopulatedTransaction) { - const userAddress = await this.signer.getAddress(); + protected async _wrapStabilityDepositWithdrawal(rawPopulatedTransaction: PopulatedTransaction) { + const userAddress = await this._signer.getAddress(); return new PopulatedEthersTransaction( rawPopulatedTransaction, ({ logs }) => { - const gainsWithdrawalDetails = this.extractStabilityPoolGainsWithdrawalDetails(logs); + const gainsWithdrawalDetails = this._extractStabilityPoolGainsWithdrawalDetails(logs); - const [withdrawLUSD] = this.contracts.lusdToken + const [withdrawLUSD] = this._contracts.lusdToken .extractEvents(logs, "Transfer") .filter( ({ args: { from, to } }) => - from === this.contracts.stabilityPool.address && to === userAddress + from === this._contracts.stabilityPool.address && to === userAddress ) .map(({ args: { value } }) => new Decimal(value)); @@ -387,47 +387,44 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { }; }, - this.signer, - this.contracts + this._signer, + this._contracts ); } - protected wrapCollateralGainTransfer(rawPopulatedTransaction: PopulatedTransaction) { + protected _wrapCollateralGainTransfer(rawPopulatedTransaction: PopulatedTransaction) { return new PopulatedEthersTransaction( rawPopulatedTransaction, ({ logs }) => { - const [newTrove] = this.contracts.borrowerOperations + const [newTrove] = this._contracts.borrowerOperations .extractEvents(logs, "TroveUpdated") - .map( - ({ args: { _coll, _debt } }) => - new Trove({ collateral: new Decimal(_coll), debt: new Decimal(_debt) }) - ); + .map(({ args: { _coll, _debt } }) => new Trove(new Decimal(_coll), new Decimal(_debt))); return { - ...this.extractStabilityPoolGainsWithdrawalDetails(logs), + ...this._extractStabilityPoolGainsWithdrawalDetails(logs), newTrove }; }, - this.signer, - this.contracts + this._signer, + this._contracts ); } - private async findHintForNominalCollateralRatio( + private async _findHintForNominalCollateralRatio( nominalCollateralRatio: Decimal, - optionalParams: HintedMethodOptionalParams + optionalParams: _HintedMethodOptionalParams ): Promise<[string, string]> { const numberOfTroves = - optionalParams.numberOfTroves ?? (await this.readableLiquity.getNumberOfTroves()); + optionalParams.numberOfTroves ?? (await this._readableLiquity.getNumberOfTroves()); if (!numberOfTroves) { return [AddressZero, AddressZero]; } if (nominalCollateralRatio.infinite) { - return [AddressZero, await this.contracts.sortedTroves.getFirst()]; + return [AddressZero, await this._contracts.sortedTroves.getFirst()]; } const totalNumberOfTrials = Math.ceil(10 * Math.sqrt(numberOfTroves)); @@ -443,7 +440,7 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { }, numberOfTrials: number ) => - this.contracts.hintHelpers + this._contracts.hintHelpers .getApproxHint(nominalCollateralRatio.bigNumber, numberOfTrials, latestRandomSeed) .then(({ latestRandomSeed, ...result }) => ({ latestRandomSeed, @@ -457,31 +454,31 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { const { hintAddress } = results.reduce((a, b) => (a.diff.lt(b.diff) ? a : b)); - return this.contracts.sortedTroves.findInsertPosition( + return this._contracts.sortedTroves.findInsertPosition( nominalCollateralRatio.bigNumber, hintAddress, hintAddress ); } - protected async findHint(trove: Trove, optionalParams: HintedMethodOptionalParams = {}) { + protected async _findHint(trove: Trove, optionalParams: _HintedMethodOptionalParams = {}) { if (trove instanceof TroveWithPendingRewards) { throw new Error("Rewards must be applied to this Trove"); } - return this.findHintForNominalCollateralRatio(trove.nominalCollateralRatio, optionalParams); + return this._findHintForNominalCollateralRatio(trove._nominalCollateralRatio, optionalParams); } - protected async findRedemptionHints( + protected async _findRedemptionHints( amount: Decimal, - { price, ...hintOptionalParams }: RedemptionOptionalParams = {} + { price, ...hintOptionalParams }: _RedemptionOptionalParams = {} ): Promise<[string, string, string, Decimal]> { - price ??= await this.readableLiquity.getPrice(); + price ??= await this._readableLiquity.getPrice(); const { firstRedemptionHint, partialRedemptionHintNICR - } = await this.contracts.hintHelpers.getRedemptionHints( + } = await this._contracts.hintHelpers.getRedemptionHints( amount.bigNumber, price.bigNumber, redeemMaxIterations @@ -490,7 +487,7 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { const collateralRatio = new Decimal(partialRedemptionHintNICR); const [upperHint, lowerHint] = collateralRatio.nonZero - ? await this.findHintForNominalCollateralRatio(collateralRatio, hintOptionalParams) + ? await this._findHintForNominalCollateralRatio(collateralRatio, hintOptionalParams) : [AddressZero, AddressZero]; return [firstRedemptionHint, upperHint, lowerHint, collateralRatio]; @@ -500,31 +497,32 @@ class PopulatableEthersLiquityBase extends EthersLiquityBase { export class PopulatableEthersLiquity extends PopulatableEthersLiquityBase implements - Populatable< - Hinted, + _Populatable< + _Hinted, TransactionReceipt, TransactionResponse, PopulatedTransaction > { + /** {@inheritDoc @liquity/lib-base#TransactableLiquity.openTrove} */ async openTrove( - params: TroveCreation, - optionalParams: TroveCreationOptionalParams = {}, + params: TroveCreationParams, + optionalParams: _TroveCreationOptionalParams = {}, overrides?: EthersTransactionOverrides ): Promise> { - const normalized = normalizeTroveCreation(params); + const normalized = _normalizeTroveCreation(params); const { depositCollateral, borrowLUSD } = normalized; - const fees = borrowLUSD && (optionalParams.fees ?? (await this.readableLiquity.getFees())); + const fees = borrowLUSD && (optionalParams.fees ?? (await this._readableLiquity.getFees())); const newTrove = Trove.create(normalized, fees?.borrowingFeeFactor()); - return this.wrapTroveChangeWithFees( + return this._wrapTroveChangeWithFees( normalized, - await this.contracts.borrowerOperations.estimateAndPopulate.openTrove( + await this._contracts.borrowerOperations.estimateAndPopulate.openTrove( { value: depositCollateral.bigNumber, ...overrides }, compose(addGasForPotentialLastFeeOperationTimeUpdate, addGasForPotentialListTraversal), 0, borrowLUSD?.bigNumber ?? 0, - ...(await this.findHint(newTrove, optionalParams)) + ...(await this._findHint(newTrove, optionalParams)) ) ); } @@ -532,14 +530,14 @@ export class PopulatableEthersLiquity async closeTrove( overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapTroveClosure( - await this.contracts.borrowerOperations.estimateAndPopulate.closeTrove({ ...overrides }, id) + return this._wrapTroveClosure( + await this._contracts.borrowerOperations.estimateAndPopulate.closeTrove({ ...overrides }, id) ); } depositCollateral( amount: Decimalish, - optionalParams: TroveAdjustmentOptionalParams = {}, + optionalParams: _TroveAdjustmentOptionalParams = {}, overrides?: EthersTransactionOverrides ): Promise> { return this.adjustTrove({ depositCollateral: amount }, optionalParams, overrides); @@ -547,7 +545,7 @@ export class PopulatableEthersLiquity withdrawCollateral( amount: Decimalish, - optionalParams: TroveAdjustmentOptionalParams = {}, + optionalParams: _TroveAdjustmentOptionalParams = {}, overrides?: EthersTransactionOverrides ): Promise> { return this.adjustTrove({ withdrawCollateral: amount }, optionalParams, overrides); @@ -555,7 +553,7 @@ export class PopulatableEthersLiquity borrowLUSD( amount: Decimalish, - optionalParams: TroveAdjustmentOptionalParams = {}, + optionalParams: _TroveAdjustmentOptionalParams = {}, overrides?: EthersTransactionOverrides ): Promise> { return this.adjustTrove({ borrowLUSD: amount }, optionalParams, overrides); @@ -563,30 +561,30 @@ export class PopulatableEthersLiquity repayLUSD( amount: Decimalish, - optionalParams: TroveAdjustmentOptionalParams = {}, + optionalParams: _TroveAdjustmentOptionalParams = {}, overrides?: EthersTransactionOverrides ): Promise> { return this.adjustTrove({ repayLUSD: amount }, optionalParams, overrides); } async adjustTrove( - params: TroveAdjustment, - optionalParams: TroveAdjustmentOptionalParams = {}, + params: TroveAdjustmentParams, + optionalParams: _TroveAdjustmentOptionalParams = {}, overrides?: EthersTransactionOverrides ): Promise> { - const normalized = normalizeTroveAdjustment(params); + const normalized = _normalizeTroveAdjustment(params); const { depositCollateral, withdrawCollateral, borrowLUSD, repayLUSD } = normalized; const [trove, fees] = await Promise.all([ - optionalParams.trove ?? this.readableLiquity.getTrove(), - borrowLUSD && (optionalParams.fees ?? this.readableLiquity.getFees()) + optionalParams.trove ?? this._readableLiquity.getTrove(), + borrowLUSD && (optionalParams.fees ?? this._readableLiquity.getFees()) ]); const finalTrove = trove.adjust(normalized, fees?.borrowingFeeFactor()); - return this.wrapTroveChangeWithFees( + return this._wrapTroveChangeWithFees( normalized, - await this.contracts.borrowerOperations.estimateAndPopulate.adjustTrove( + await this._contracts.borrowerOperations.estimateAndPopulate.adjustTrove( { value: depositCollateral?.bigNumber, ...overrides }, compose( borrowLUSD ? addGasForPotentialLastFeeOperationTimeUpdate : id, @@ -596,7 +594,7 @@ export class PopulatableEthersLiquity withdrawCollateral?.bigNumber ?? 0, (borrowLUSD ?? repayLUSD)?.bigNumber ?? 0, !!borrowLUSD, - ...(await this.findHint(finalTrove, optionalParams)) + ...(await this._findHint(finalTrove, optionalParams)) ) ); } @@ -604,8 +602,8 @@ export class PopulatableEthersLiquity async claimCollateralSurplus( overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapSimpleTransaction( - await this.contracts.borrowerOperations.estimateAndPopulate.claimCollateral( + return this._wrapSimpleTransaction( + await this._contracts.borrowerOperations.estimateAndPopulate.claimCollateral( { ...overrides }, id ) @@ -616,12 +614,12 @@ export class PopulatableEthersLiquity price: Decimalish, overrides?: EthersTransactionOverrides ): Promise> { - if (!priceFeedIsTestnet(this.contracts.priceFeed)) { + if (!priceFeedIsTestnet(this._contracts.priceFeed)) { throw new Error("setPrice() unavailable on this deployment of Liquity"); } - return this.wrapSimpleTransaction( - await this.contracts.priceFeed.estimateAndPopulate.setPrice( + return this._wrapSimpleTransaction( + await this._contracts.priceFeed.estimateAndPopulate.setPrice( { ...overrides }, id, Decimal.from(price).bigNumber @@ -633,8 +631,8 @@ export class PopulatableEthersLiquity address: string, overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapLiquidation( - await this.contracts.troveManager.estimateAndPopulate.liquidate( + return this._wrapLiquidation( + await this._contracts.troveManager.estimateAndPopulate.liquidate( { ...overrides }, addGasForLQTYIssuance, address @@ -646,8 +644,8 @@ export class PopulatableEthersLiquity maximumNumberOfTrovesToLiquidate: number, overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapLiquidation( - await this.contracts.troveManager.estimateAndPopulate.liquidateTroves( + return this._wrapLiquidation( + await this._contracts.troveManager.estimateAndPopulate.liquidateTroves( { ...overrides }, addGasForLQTYIssuance, maximumNumberOfTrovesToLiquidate @@ -662,9 +660,9 @@ export class PopulatableEthersLiquity ): Promise> { const depositLUSD = Decimal.from(amount); - return this.wrapStabilityDepositTopup( + return this._wrapStabilityDepositTopup( { depositLUSD }, - await this.contracts.stabilityPool.estimateAndPopulate.provideToSP( + await this._contracts.stabilityPool.estimateAndPopulate.provideToSP( { ...overrides }, addGasForLQTYIssuance, depositLUSD.bigNumber, @@ -677,8 +675,8 @@ export class PopulatableEthersLiquity amount: Decimalish, overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapStabilityDepositWithdrawal( - await this.contracts.stabilityPool.estimateAndPopulate.withdrawFromSP( + return this._wrapStabilityDepositWithdrawal( + await this._contracts.stabilityPool.estimateAndPopulate.withdrawFromSP( { ...overrides }, addGasForLQTYIssuance, Decimal.from(amount).bigNumber @@ -689,8 +687,8 @@ export class PopulatableEthersLiquity async withdrawGainsFromStabilityPool( overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapStabilityPoolGainsWithdrawal( - await this.contracts.stabilityPool.estimateAndPopulate.withdrawFromSP( + return this._wrapStabilityPoolGainsWithdrawal( + await this._contracts.stabilityPool.estimateAndPopulate.withdrawFromSP( { ...overrides }, addGasForLQTYIssuance, Decimal.ZERO.bigNumber @@ -699,20 +697,20 @@ export class PopulatableEthersLiquity } async transferCollateralGainToTrove( - optionalParams: CollateralGainTransferOptionalParams = {}, + optionalParams: _CollateralGainTransferOptionalParams = {}, overrides?: EthersTransactionOverrides ): Promise> { const { deposit, trove, ...hintOptionalParams } = optionalParams; - const initialTrove = trove ?? (await this.readableLiquity.getTrove()); + const initialTrove = trove ?? (await this._readableLiquity.getTrove()); const finalTrove = initialTrove.addCollateral( - (deposit ?? (await this.readableLiquity.getStabilityDeposit())).collateralGain + (deposit ?? (await this._readableLiquity.getStabilityDeposit())).collateralGain ); - return this.wrapCollateralGainTransfer( - await this.contracts.stabilityPool.estimateAndPopulate.withdrawETHGainToTrove( + return this._wrapCollateralGainTransfer( + await this._contracts.stabilityPool.estimateAndPopulate.withdrawETHGainToTrove( { ...overrides }, compose(addGasForPotentialListTraversal, addGasForLQTYIssuance), - ...(await this.findHint(finalTrove, hintOptionalParams)) + ...(await this._findHint(finalTrove, hintOptionalParams)) ) ); } @@ -722,8 +720,8 @@ export class PopulatableEthersLiquity amount: Decimalish, overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapSimpleTransaction( - await this.contracts.lusdToken.estimateAndPopulate.transfer( + return this._wrapSimpleTransaction( + await this._contracts.lusdToken.estimateAndPopulate.transfer( { ...overrides }, id, toAddress, @@ -737,8 +735,8 @@ export class PopulatableEthersLiquity amount: Decimalish, overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapSimpleTransaction( - await this.contracts.lqtyToken.estimateAndPopulate.transfer( + return this._wrapSimpleTransaction( + await this._contracts.lqtyToken.estimateAndPopulate.transfer( { ...overrides }, id, toAddress, @@ -749,7 +747,7 @@ export class PopulatableEthersLiquity async redeemLUSD( amount: Decimalish, - optionalParams: RedemptionOptionalParams = {}, + optionalParams: _RedemptionOptionalParams = {}, overrides?: EthersTransactionOverrides ): Promise> { amount = Decimal.from(amount); @@ -759,10 +757,10 @@ export class PopulatableEthersLiquity upperPartialRedemptionHint, lowerPartialRedemptionHint, partialRedemptionHintNICR - ] = await this.findRedemptionHints(amount, optionalParams); + ] = await this._findRedemptionHints(amount, optionalParams); - return this.wrapRedemption( - await this.contracts.troveManager.estimateAndPopulate.redeemCollateral( + return this._wrapRedemption( + await this._contracts.troveManager.estimateAndPopulate.redeemCollateral( { ...overrides }, addGasForPotentialLastFeeOperationTimeUpdate, amount.bigNumber, @@ -780,8 +778,8 @@ export class PopulatableEthersLiquity amount: Decimalish, overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapSimpleTransaction( - await this.contracts.lqtyStaking.estimateAndPopulate.stake( + return this._wrapSimpleTransaction( + await this._contracts.lqtyStaking.estimateAndPopulate.stake( { ...overrides }, id, Decimal.from(amount).bigNumber @@ -793,8 +791,8 @@ export class PopulatableEthersLiquity amount: Decimalish, overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapSimpleTransaction( - await this.contracts.lqtyStaking.estimateAndPopulate.unstake( + return this._wrapSimpleTransaction( + await this._contracts.lqtyStaking.estimateAndPopulate.unstake( { ...overrides }, id, Decimal.from(amount).bigNumber @@ -812,8 +810,8 @@ export class PopulatableEthersLiquity kickbackRate: Decimalish, overrides?: EthersTransactionOverrides ): Promise> { - return this.wrapSimpleTransaction( - await this.contracts.stabilityPool.estimateAndPopulate.registerFrontEnd( + return this._wrapSimpleTransaction( + await this._contracts.stabilityPool.estimateAndPopulate.registerFrontEnd( { ...overrides }, id, Decimal.from(kickbackRate).bigNumber @@ -822,14 +820,14 @@ export class PopulatableEthersLiquity } } -export type SendableEthersLiquity = SendableFrom; +export type SendableEthersLiquity = _SendableFrom; export const SendableEthersLiquity: new ( populatable: PopulatableEthersLiquity -) => SendableEthersLiquity = sendableFrom(PopulatableEthersLiquity); +) => SendableEthersLiquity = _sendableFrom(PopulatableEthersLiquity); -export type TransactableEthersLiquity = TransactableFrom; +export type TransactableEthersLiquity = _TransactableFrom; export const TransactableEthersLiquity: new ( sendable: SendableEthersLiquity -) => TransactableEthersLiquity = transactableFrom(SendableEthersLiquity); +) => TransactableEthersLiquity = _transactableFrom(SendableEthersLiquity); diff --git a/packages/lib-ethers/src/ReadableEthersLiquity.ts b/packages/lib-ethers/src/ReadableEthersLiquity.ts index d8913b622..1dc6566e7 100644 --- a/packages/lib-ethers/src/ReadableEthersLiquity.ts +++ b/packages/lib-ethers/src/ReadableEthersLiquity.ts @@ -32,39 +32,35 @@ const decimalify = (bigNumber: BigNumber) => new Decimal(bigNumber); export class ReadableEthersLiquity extends EthersLiquityBase implements ReadableLiquity { async getTotalRedistributed(overrides?: EthersCallOverrides): Promise { const [collateral, debt] = await Promise.all([ - this.contracts.troveManager.L_ETH({ ...overrides }).then(decimalify), - this.contracts.troveManager.L_LUSDDebt({ ...overrides }).then(decimalify) + this._contracts.troveManager.L_ETH({ ...overrides }).then(decimalify), + this._contracts.troveManager.L_LUSDDebt({ ...overrides }).then(decimalify) ]); - return new Trove({ collateral, debt }); + return new Trove(collateral, debt); } async getTroveWithoutRewards( - address = this.requireAddress(), + address = this._requireAddress(), overrides?: EthersCallOverrides ): Promise { const [trove, snapshot] = await Promise.all([ - this.contracts.troveManager.Troves(address, { ...overrides }), - this.contracts.troveManager.rewardSnapshots(address, { ...overrides }) + this._contracts.troveManager.Troves(address, { ...overrides }), + this._contracts.troveManager.rewardSnapshots(address, { ...overrides }) ]); if (trove.status === TroveStatus.active) { - return new TroveWithPendingRewards({ - collateral: new Decimal(trove.coll), - debt: new Decimal(trove.debt), - stake: new Decimal(trove.stake), - - snapshotOfTotalRedistributed: { - collateral: new Decimal(snapshot.ETH), - debt: new Decimal(snapshot.LUSDDebt) - } - }); + return new TroveWithPendingRewards( + new Decimal(trove.coll), + new Decimal(trove.debt), + new Decimal(trove.stake), + new Trove(new Decimal(snapshot.ETH), new Decimal(snapshot.LUSDDebt)) + ); } else { return new TroveWithPendingRewards(); } } - async getTrove(address = this.requireAddress(), overrides?: EthersCallOverrides): Promise { + async getTrove(address = this._requireAddress(), overrides?: EthersCallOverrides): Promise { const [trove, totalRedistributed] = await Promise.all([ this.getTroveWithoutRewards(address, { ...overrides }), this.getTotalRedistributed({ ...overrides }) @@ -74,69 +70,66 @@ export class ReadableEthersLiquity extends EthersLiquityBase implements Readable } async getNumberOfTroves(overrides?: EthersCallOverrides): Promise { - return (await this.contracts.troveManager.getTroveOwnersCount({ ...overrides })).toNumber(); + return (await this._contracts.troveManager.getTroveOwnersCount({ ...overrides })).toNumber(); } async getPrice(overrides?: EthersCallOverrides): Promise { - return new Decimal(await this.contracts.priceFeed.getPrice({ ...overrides })); + return new Decimal(await this._contracts.priceFeed.getPrice({ ...overrides })); } async getTotal(overrides?: EthersCallOverrides): Promise { const [activeCollateral, activeDebt, liquidatedCollateral, closedDebt] = await Promise.all( [ - this.contracts.activePool.getETH({ ...overrides }), - this.contracts.activePool.getLUSDDebt({ ...overrides }), - this.contracts.defaultPool.getETH({ ...overrides }), - this.contracts.defaultPool.getLUSDDebt({ ...overrides }) + this._contracts.activePool.getETH({ ...overrides }), + this._contracts.activePool.getLUSDDebt({ ...overrides }), + this._contracts.defaultPool.getETH({ ...overrides }), + this._contracts.defaultPool.getLUSDDebt({ ...overrides }) ].map(getBigNumber => getBigNumber.then(decimalify)) ); - return new Trove({ - collateral: activeCollateral.add(liquidatedCollateral), - debt: activeDebt.add(closedDebt) - }); + return new Trove(activeCollateral.add(liquidatedCollateral), activeDebt.add(closedDebt)); } async getStabilityDeposit( - address = this.requireAddress(), + address = this._requireAddress(), overrides?: EthersCallOverrides ): Promise { const [initialLUSD, currentLUSD, collateralGain, lqtyReward] = await Promise.all( [ - this.contracts.stabilityPool.deposits(address, { ...overrides }).then(d => d.initialValue), - this.contracts.stabilityPool.getCompoundedLUSDDeposit(address, { ...overrides }), - this.contracts.stabilityPool.getDepositorETHGain(address, { ...overrides }), - this.contracts.stabilityPool.getDepositorLQTYGain(address, { ...overrides }) + this._contracts.stabilityPool.deposits(address, { ...overrides }).then(d => d.initialValue), + this._contracts.stabilityPool.getCompoundedLUSDDeposit(address, { ...overrides }), + this._contracts.stabilityPool.getDepositorETHGain(address, { ...overrides }), + this._contracts.stabilityPool.getDepositorLQTYGain(address, { ...overrides }) ].map(getBigNumber => getBigNumber.then(decimalify)) ); - return new StabilityDeposit({ initialLUSD, currentLUSD, collateralGain, lqtyReward }); + return new StabilityDeposit(initialLUSD, currentLUSD, collateralGain, lqtyReward); } async getLUSDInStabilityPool(overrides?: EthersCallOverrides): Promise { - return new Decimal(await this.contracts.stabilityPool.getTotalLUSDDeposits({ ...overrides })); + return new Decimal(await this._contracts.stabilityPool.getTotalLUSDDeposits({ ...overrides })); } async getLUSDBalance( - address = this.requireAddress(), + address = this._requireAddress(), overrides?: EthersCallOverrides ): Promise { - return new Decimal(await this.contracts.lusdToken.balanceOf(address, { ...overrides })); + return new Decimal(await this._contracts.lusdToken.balanceOf(address, { ...overrides })); } async getLQTYBalance( - address = this.requireAddress(), + address = this._requireAddress(), overrides?: EthersCallOverrides ): Promise { - return new Decimal(await this.contracts.lqtyToken.balanceOf(address, { ...overrides })); + return new Decimal(await this._contracts.lqtyToken.balanceOf(address, { ...overrides })); } async getCollateralSurplusBalance( - address = this.requireAddress(), + address = this._requireAddress(), overrides?: EthersCallOverrides ): Promise { return new Decimal( - await this.contracts.collSurplusPool.getCollateral(address, { ...overrides }) + await this._contracts.collSurplusPool.getCollateral(address, { ...overrides }) ); } @@ -145,7 +138,7 @@ export class ReadableEthersLiquity extends EthersLiquityBase implements Readable numberOfTroves: number, overrides?: EthersCallOverrides ): Promise<[string, TroveWithPendingRewards][]> { - const troves = await this.contracts.multiTroveGetter.getMultipleSortedTroves( + const troves = await this._contracts.multiTroveGetter.getMultipleSortedTroves( -(startIdx + 1), numberOfTroves, { ...overrides } @@ -159,7 +152,7 @@ export class ReadableEthersLiquity extends EthersLiquityBase implements Readable numberOfTroves: number, overrides?: EthersCallOverrides ): Promise<[string, TroveWithPendingRewards][]> { - const troves = await this.contracts.multiTroveGetter.getMultipleSortedTroves( + const troves = await this._contracts.multiTroveGetter.getMultipleSortedTroves( startIdx, numberOfTroves, { ...overrides } @@ -170,8 +163,8 @@ export class ReadableEthersLiquity extends EthersLiquityBase implements Readable async getFees(overrides?: EthersCallOverrides): Promise { const [lastFeeOperationTime, baseRateWithoutDecay] = await Promise.all([ - this.contracts.troveManager.lastFeeOperationTime({ ...overrides }), - this.contracts.troveManager.baseRate({ ...overrides }).then(decimalify) + this._contracts.troveManager.lastFeeOperationTime({ ...overrides }), + this._contracts.troveManager.baseRate({ ...overrides }).then(decimalify) ]); const lastFeeOperation = new Date(1000 * lastFeeOperationTime.toNumber()); @@ -180,29 +173,29 @@ export class ReadableEthersLiquity extends EthersLiquityBase implements Readable } async getLQTYStake( - address = this.requireAddress(), + address = this._requireAddress(), overrides?: EthersCallOverrides ): Promise { const [stakedLQTY, collateralGain, lusdGain] = await Promise.all( [ - this.contracts.lqtyStaking.stakes(address, { ...overrides }), - this.contracts.lqtyStaking.getPendingETHGain(address, { ...overrides }), - this.contracts.lqtyStaking.getPendingLUSDGain(address, { ...overrides }) + this._contracts.lqtyStaking.stakes(address, { ...overrides }), + this._contracts.lqtyStaking.getPendingETHGain(address, { ...overrides }), + this._contracts.lqtyStaking.getPendingLUSDGain(address, { ...overrides }) ].map(getBigNumber => getBigNumber.then(decimalify)) ); - return new LQTYStake({ stakedLQTY, collateralGain, lusdGain }); + return new LQTYStake(stakedLQTY, collateralGain, lusdGain); } async getTotalStakedLQTY(overrides?: EthersCallOverrides): Promise { - return new Decimal(await this.contracts.lqtyStaking.totalLQTYStaked({ ...overrides })); + return new Decimal(await this._contracts.lqtyStaking.totalLQTYStaked({ ...overrides })); } async getFrontendStatus( - address = this.requireAddress(), + address = this._requireAddress(), overrides?: EthersCallOverrides ): Promise { - const { registered, kickbackRate } = await this.contracts.stabilityPool.frontEnds(address, { + const { registered, kickbackRate } = await this._contracts.stabilityPool.frontEnds(address, { ...overrides }); @@ -221,14 +214,10 @@ const mapMultipleSortedTrovesToTroves = ( troves.map(({ owner, coll, debt, stake, snapshotLUSDDebt, snapshotETH }) => [ owner, - new TroveWithPendingRewards({ - collateral: new Decimal(coll), - debt: new Decimal(debt), - stake: new Decimal(stake), - - snapshotOfTotalRedistributed: { - collateral: new Decimal(snapshotETH), - debt: new Decimal(snapshotLUSDDebt) - } - }) + new TroveWithPendingRewards( + new Decimal(coll), + new Decimal(debt), + new Decimal(stake), + new Trove(new Decimal(snapshotETH), new Decimal(snapshotLUSDDebt)) + ) ]); diff --git a/packages/lib-ethers/test/Liquity.test.ts b/packages/lib-ethers/test/Liquity.test.ts index 32956529d..1a67b4924 100644 --- a/packages/lib-ethers/test/Liquity.test.ts +++ b/packages/lib-ethers/test/Liquity.test.ts @@ -13,8 +13,9 @@ import { SuccessfulReceipt, SentLiquityTransaction, ReadableLiquity, - TroveCreation, - Fees + TroveCreationParams, + Fees, + LUSD_LIQUIDATION_RESERVE } from "@liquity/lib-base"; import { HintHelpers } from "../types"; @@ -78,7 +79,7 @@ describe("EthersLiquity", () => { const connectUsers = (users: Signer[]) => Promise.all(users.map(user => EthersLiquity.connect(deployment, user))); - const openTroves = (users: Signer[], params: TroveCreation[]) => + const openTroves = (users: Signer[], params: TroveCreationParams[]) => params .map((params, i) => () => Promise.all([ @@ -183,7 +184,7 @@ describe("EthersLiquity", () => { const params = { depositCollateral: 0.75, borrowLUSD: 90 }; const trove = Trove.create(params); - expect(`${trove.nominalCollateralRatio}`).to.equal(`${nominalCollateralRatio}`); + expect(`${trove._nominalCollateralRatio}`).to.equal(`${nominalCollateralRatio}`); await fakeLiquity.openTrove(params, { numberOfTroves: 1000000, // 10 * sqrt(1M) / 2500 = 4 expected getApproxHint calls @@ -222,9 +223,11 @@ describe("EthersLiquity", () => { await expect(liquity.openTrove({ depositCollateral: 0.05 })).to.eventually.be.rejected; }); + const withoutBorrowing = { depositCollateral: 1 }; + it("should create a Trove without borrowing", async () => { - const { newTrove } = await liquity.openTrove({ depositCollateral: 1 }); - expect(newTrove).to.deep.equal(new Trove({ collateral: 1, debt: 10 })); + const { newTrove } = await liquity.openTrove(withoutBorrowing); + expect(newTrove).to.deep.equal(Trove.create(withoutBorrowing)); const trove = await liquity.getTrove(); expect(trove).to.deep.equal(newTrove); @@ -232,7 +235,10 @@ describe("EthersLiquity", () => { it("should withdraw some of the collateral", async () => { const { newTrove } = await liquity.withdrawCollateral(0.5); - expect(newTrove).to.deep.equal(new Trove({ collateral: 0.5, debt: 10 })); + + expect(newTrove).to.deep.equal( + Trove.create(withoutBorrowing).adjust({ withdrawCollateral: 0.5 }) + ); }); it("should fail to close the Trove when there are no other Troves", async () => { @@ -253,9 +259,11 @@ describe("EthersLiquity", () => { expect(trove.isEmpty).to.be.true; }); + const withSomeBorrowing = { depositCollateral: 1, borrowLUSD: 90 }; + it("should create a Trove with some borrowing", async () => { - const { newTrove } = await liquity.openTrove({ depositCollateral: 1, borrowLUSD: 90 }); - expect(newTrove).to.deep.equal(new Trove({ collateral: 1, debt: 100 })); + const { newTrove } = await liquity.openTrove(withSomeBorrowing); + expect(newTrove).to.deep.equal(Trove.create(withSomeBorrowing)); }); it("should fail to withdraw all the collateral while the Trove has debt", async () => { @@ -264,43 +272,65 @@ describe("EthersLiquity", () => { await expect(liquity.withdrawCollateral(trove.collateral)).to.eventually.be.rejected; }); + const repaySomeDebt = { repayLUSD: 10 }; + it("should repay some debt", async () => { - const { newTrove } = await liquity.repayLUSD(10); - expect(newTrove).to.deep.equal(new Trove({ collateral: 1, debt: 90 })); + const { newTrove } = await liquity.repayLUSD(repaySomeDebt.repayLUSD); + expect(newTrove).to.deep.equal(Trove.create(withSomeBorrowing).adjust(repaySomeDebt)); }); + const borrowSomeMore = { borrowLUSD: 20 }; + it("should borrow some more", async () => { - const { newTrove } = await liquity.borrowLUSD(20); - expect(newTrove).to.deep.equal(new Trove({ collateral: 1, debt: 110 })); + const { newTrove } = await liquity.borrowLUSD(borrowSomeMore.borrowLUSD); + expect(newTrove).to.deep.equal( + Trove.create(withSomeBorrowing).adjust(repaySomeDebt).adjust(borrowSomeMore) + ); }); + const depositMoreCollateral = { depositCollateral: 1 }; + it("should deposit more collateral", async () => { - const { newTrove } = await liquity.depositCollateral(1); - expect(newTrove).to.deep.equal(new Trove({ collateral: 2, debt: 110 })); + const { newTrove } = await liquity.depositCollateral(depositMoreCollateral.depositCollateral); + expect(newTrove).to.deep.equal( + Trove.create(withSomeBorrowing) + .adjust(repaySomeDebt) + .adjust(borrowSomeMore) + .adjust(depositMoreCollateral) + ); }); + const repayAndWithdraw = { repayLUSD: 60, withdrawCollateral: 0.5 }; + it("should repay some debt and withdraw some collateral at the same time", async () => { - const { newTrove } = await liquity.adjustTrove( - { repayLUSD: 60, withdrawCollateral: 0.5 }, - {}, - { gasPrice: 0 } + const { newTrove } = await liquity.adjustTrove(repayAndWithdraw, {}, { gasPrice: 0 }); + + expect(newTrove).to.deep.equal( + Trove.create(withSomeBorrowing) + .adjust(repaySomeDebt) + .adjust(borrowSomeMore) + .adjust(depositMoreCollateral) + .adjust(repayAndWithdraw) ); - expect(newTrove).to.deep.equal(new Trove({ collateral: 1.5, debt: 50 })); - const ethBalance = new Decimal(await user.getBalance()); expect(`${ethBalance}`).to.equal("100.5"); }); + const borrowAndDeposit = { borrowLUSD: 60, depositCollateral: 0.5 }; + it("should borrow more and deposit some collateral at the same time", async () => { - const { newTrove } = await liquity.adjustTrove( - { borrowLUSD: 60, depositCollateral: 0.5 }, - {}, - { gasPrice: 0 } + const { newTrove } = await liquity.adjustTrove(borrowAndDeposit, {}, { gasPrice: 0 }); + + expect(newTrove).to.deep.equal( + Trove.create(withSomeBorrowing) + .adjust(repaySomeDebt) + .adjust(borrowSomeMore) + .adjust(depositMoreCollateral) + .adjust(repayAndWithdraw) + .adjust(borrowAndDeposit) ); - expect(newTrove).to.deep.equal(new Trove({ collateral: 2, debt: 110 })); - const ethBalance = new Decimal(await user.getBalance()); expect(`${ethBalance}`).to.equal("99.5"); }); @@ -388,12 +418,12 @@ describe("EthersLiquity", () => { liquidatedAddresses: [await otherUsers[0].getAddress()], collateralGasCompensation: Decimal.from(0.0011165), // 0.5% - lusdGasCompensation: Decimal.from(10), + lusdGasCompensation: LUSD_LIQUIDATION_RESERVE, - totalLiquidated: new Trove({ - collateral: Decimal.from(0.2221835), // -0.5% - debt: Decimal.from(39) - }) + totalLiquidated: new Trove( + Decimal.from(0.2221835), // -0.5% + Decimal.from(39) + ) }); const otherTrove = await otherLiquities[0].getTrove(); @@ -404,11 +434,11 @@ describe("EthersLiquity", () => { const deposit = await liquity.getStabilityDeposit(); expect(deposit).to.deep.equal( - new StabilityDeposit({ - initialLUSD: 10, - currentLUSD: 0, - collateralGain: "0.0569701282051282" // multiplied by 0.995 - }) + new StabilityDeposit( + Decimal.from(10), + Decimal.ZERO, + Decimal.from("0.0569701282051282") // multiplied by 0.995 + ) ); }); @@ -416,10 +446,7 @@ describe("EthersLiquity", () => { const trove = await liquity.getTrove(); expect(trove).to.deep.equal( - new Trove({ - collateral: "1.165213371794871795", - debt: 129 - }) + new Trove(Decimal.from("1.165213371794871795"), Decimal.from(129)) ); }); @@ -442,10 +469,10 @@ describe("EthersLiquity", () => { collateralGain: Decimal.from("0.0569701282051282"), lqtyReward: Decimal.from(0), - newTrove: new Trove({ - collateral: "1.222183499999999995", // ~ 1 + 0.2233 * 0.995 - debt: 129 - }) + newTrove: new Trove( + Decimal.from("1.222183499999999995"), // ~ 1 + 0.2233 * 0.995 + Decimal.from(129) + ) }); const deposit = await liquity.getStabilityDeposit(); @@ -600,7 +627,9 @@ describe("EthersLiquity", () => { it("borrowing should have a fee now", async () => { const { fee, newTrove } = await liquity.borrowLUSD(10); expect(`${fee}`).to.equal("1.52777777777777777"); - expect(newTrove).to.deep.equal(new Trove({ collateral: 20, debt: fee.add(120) })); + expect(newTrove).to.deep.equal( + Trove.create({ depositCollateral: 20, borrowLUSD: 110 }).addDebt(fee) + ); }); }); diff --git a/packages/lib-subgraph/src/SubgraphLiquity.ts b/packages/lib-subgraph/src/SubgraphLiquity.ts index 85f6212cd..abfd88b53 100644 --- a/packages/lib-subgraph/src/SubgraphLiquity.ts +++ b/packages/lib-subgraph/src/SubgraphLiquity.ts @@ -12,7 +12,7 @@ import { ObservableLiquity, TroveWithPendingRewards, Trove, - emptyTrove, + _emptyTrove, StabilityDeposit, Fees, LQTYStake, @@ -64,12 +64,12 @@ const totalRedistributed = new Query(queryGlobal, ({ data: { glob if (global) { const { rawTotalRedistributedCollateral, rawTotalRedistributedDebt } = global; - return new Trove({ - collateral: decimalify(rawTotalRedistributedCollateral), - debt: decimalify(rawTotalRedistributedDebt) - }); + return new Trove( + decimalify(rawTotalRedistributedCollateral), + decimalify(rawTotalRedistributedDebt) + ); } else { - return emptyTrove; + return _emptyTrove; } }); @@ -81,12 +81,9 @@ const total = new Query(queryGlobal, ({ data: { global } }) => { if (global?.currentSystemState) { const { totalCollateral, totalDebt } = global.currentSystemState; - return new Trove({ - collateral: totalCollateral, - debt: totalDebt - }); + return new Trove(totalCollateral, totalDebt); } else { - return emptyTrove; + return _emptyTrove; } }); @@ -111,16 +108,16 @@ const troveFromRawFields = ({ rawSnapshotOfTotalRedistributedCollateral, rawSnapshotOfTotalRedistributedDebt }: TroveRawFields) => - new TroveWithPendingRewards({ - collateral: decimalify(rawCollateral), - debt: decimalify(rawDebt), - stake: decimalify(rawStake), - - snapshotOfTotalRedistributed: { - collateral: decimalify(rawSnapshotOfTotalRedistributedCollateral), - debt: decimalify(rawSnapshotOfTotalRedistributedDebt) - } - }); + new TroveWithPendingRewards( + decimalify(rawCollateral), + decimalify(rawDebt), + decimalify(rawStake), + + new Trove( + decimalify(rawSnapshotOfTotalRedistributedCollateral), + decimalify(rawSnapshotOfTotalRedistributedDebt) + ) + ); const troveWithoutRewards = new Query< TroveWithPendingRewards, diff --git a/scripts/collect-sdk-apis.js b/scripts/collect-sdk-apis.js index 4f3621bb2..482ab81b2 100644 --- a/scripts/collect-sdk-apis.js +++ b/scripts/collect-sdk-apis.js @@ -2,6 +2,7 @@ const fs = require("fs-extra"); const path = require("path"); const filesToCollect = [ + "packages/decimal/temp/decimal.api.json", "packages/lib-base/temp/lib-base.api.json", "packages/lib-ethers/temp/lib-ethers.api.json" ]; diff --git a/yarn.lock b/yarn.lock index 7641c5179..c3c9933da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2082,11 +2082,26 @@ source-map "~0.6.1" typescript "~4.1.3" +"@microsoft/tsdoc-config@0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@microsoft/tsdoc-config/-/tsdoc-config-0.14.0.tgz#fbad7dd69edabc3623a5ee3b99c9b832aa78c5c2" + integrity sha512-KSj15FwyaxMCGJkC320rvNXxuJNCOVO02pNqIEdf5cbLakvHK8afoHTmcjdBEWl0cfBFZlMu/1DhL4VCzZq0rQ== + dependencies: + "@microsoft/tsdoc" "0.13.0" + ajv "~6.12.6" + jju "~1.4.0" + resolve "~1.19.0" + "@microsoft/tsdoc@0.12.24": version "0.12.24" resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.12.24.tgz#30728e34ebc90351dd3aff4e18d038eed2c3e098" integrity sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg== +"@microsoft/tsdoc@0.13.0": + version "0.13.0" + resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.13.0.tgz#f05c6315bc3dfd18cdca70f28cd40d28da643249" + integrity sha512-/8J+4DdvexBH1Qh1yR8VZ6bPay2DL/TDdmSIypAa3dAghJzsdaiZG8COvzpYIML6HV2UVN0g4qbuqzjG4YKgWg== + "@nodelib/fs.scandir@2.1.4": version "2.1.4" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69" @@ -3983,7 +3998,7 @@ ajv-keywords@^3.1.0, ajv-keywords@^3.4.1, ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: +ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5, ajv@~6.12.6: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -7620,6 +7635,14 @@ eslint-plugin-testing-library@^3.9.2: dependencies: "@typescript-eslint/experimental-utils" "^3.10.1" +eslint-plugin-tsdoc@^0.2.11: + version "0.2.11" + resolved "https://registry.yarnpkg.com/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.11.tgz#dda92e69d88fd7f9f0a604438dca837a3341aaee" + integrity sha512-vEjGANpmBfrvpKj9rwePGhA+gIe1mp+dhDZsrkxlHqPVOZvzVdFSV9fxu/o3eppmxhybI8brD88jOrLEAIB9Gw== + dependencies: + "@microsoft/tsdoc" "0.13.0" + "@microsoft/tsdoc-config" "0.14.0" + eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" @@ -15661,7 +15684,7 @@ resolve@1.18.1: is-core-module "^2.0.0" path-parse "^1.0.6" -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.8.1: +resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.8.1, resolve@~1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c" integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==