@morpho-org/blue-sdk 2.0.0-test.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +46 -26
- package/lib/addresses.d.ts +59 -55
- package/lib/addresses.js +42 -43
- package/lib/chain.d.ts +1 -1
- package/lib/chain.js +3 -3
- package/lib/errors.d.ts +7 -8
- package/lib/errors.js +21 -19
- package/lib/holding/AssetBalances.d.ts +3 -3
- package/lib/holding/Holding.d.ts +10 -5
- package/lib/holding/Holding.js +14 -4
- package/lib/holding/index.d.ts +2 -2
- package/lib/holding/index.js +2 -2
- package/lib/index.d.ts +12 -25
- package/lib/index.js +12 -38
- package/lib/market/Market.d.ts +48 -34
- package/lib/market/Market.js +76 -57
- package/lib/market/{MarketConfig.d.ts → MarketParams.d.ts} +8 -7
- package/lib/market/{MarketConfig.js → MarketParams.js} +20 -21
- package/lib/market/MarketUtils.d.ts +94 -42
- package/lib/market/MarketUtils.js +145 -67
- package/lib/market/index.d.ts +3 -3
- package/lib/market/index.js +3 -3
- package/lib/{maths → math}/AdaptiveCurveIrmLib.d.ts +1 -1
- package/lib/{maths → math}/AdaptiveCurveIrmLib.js +20 -20
- package/lib/{maths → math}/MathLib.d.ts +24 -42
- package/lib/{maths → math}/MathLib.js +41 -54
- package/lib/{maths → math}/SharesMath.d.ts +2 -2
- package/lib/{maths → math}/SharesMath.js +3 -3
- package/lib/math/index.d.ts +3 -0
- package/lib/{helpers/format → math}/index.js +3 -1
- package/lib/position/Position.d.ts +35 -25
- package/lib/position/Position.js +46 -44
- package/lib/position/index.d.ts +1 -1
- package/lib/position/index.js +1 -1
- package/lib/token/ConstantWrappedToken.d.ts +6 -7
- package/lib/token/ConstantWrappedToken.js +8 -10
- package/lib/token/ExchangeRateWrappedToken.d.ts +5 -5
- package/lib/token/ExchangeRateWrappedToken.js +5 -5
- package/lib/token/Token.d.ts +18 -18
- package/lib/token/Token.js +24 -27
- package/lib/token/VaultToken.d.ts +20 -11
- package/lib/token/VaultToken.js +15 -7
- package/lib/token/WrappedToken.d.ts +4 -4
- package/lib/token/WrappedToken.js +7 -7
- package/lib/token/index.d.ts +5 -5
- package/lib/token/index.js +5 -5
- package/lib/types.d.ts +3 -6
- package/lib/user/User.d.ts +1 -1
- package/lib/user/index.d.ts +1 -1
- package/lib/user/index.js +1 -1
- package/lib/vault/Vault.d.ts +22 -28
- package/lib/vault/Vault.js +43 -51
- package/lib/vault/VaultConfig.d.ts +6 -7
- package/lib/vault/VaultConfig.js +5 -5
- package/lib/vault/VaultMarketAllocation.d.ts +8 -8
- package/lib/vault/VaultMarketAllocation.js +3 -3
- package/lib/vault/VaultMarketConfig.d.ts +10 -10
- package/lib/vault/VaultMarketPublicAllocatorConfig.d.ts +6 -6
- package/lib/vault/VaultUser.d.ts +26 -0
- package/lib/vault/VaultUser.js +28 -0
- package/lib/vault/VaultUtils.d.ts +4 -6
- package/lib/vault/VaultUtils.js +6 -6
- package/lib/vault/index.d.ts +7 -6
- package/lib/vault/index.js +7 -6
- package/package.json +25 -56
- package/lib/chain.test.d.ts +0 -1
- package/lib/chain.test.js +0 -21
- package/lib/helpers/format/format.d.ts +0 -122
- package/lib/helpers/format/format.js +0 -286
- package/lib/helpers/format/format.test.d.ts +0 -1
- package/lib/helpers/format/format.test.js +0 -255
- package/lib/helpers/format/index.d.ts +0 -1
- package/lib/helpers/index.d.ts +0 -2
- package/lib/helpers/index.js +0 -18
- package/lib/helpers/locale.d.ts +0 -46
- package/lib/helpers/locale.js +0 -96
- package/lib/market/MarketUtils.test.d.ts +0 -1
- package/lib/market/MarketUtils.test.js +0 -38
- package/lib/maths/index.d.ts +0 -3
- package/lib/maths/index.js +0 -19
- package/lib/tests/mocks/markets.d.ts +0 -19
- package/lib/tests/mocks/markets.js +0 -121
package/lib/holding/Holding.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address } from "../types";
|
|
1
|
+
import type { Address, BigIntish } from "../types.js";
|
|
2
2
|
export declare const ERC20_ALLOWANCE_RECIPIENTS: readonly ["morpho", "permit2", "bundler"];
|
|
3
3
|
export declare const PERMIT2_ALLOWANCE_RECIPIENTS: readonly ["morpho", "bundler"];
|
|
4
4
|
export type Erc20AllowanceRecipient = (typeof ERC20_ALLOWANCE_RECIPIENTS)[number];
|
|
@@ -8,20 +8,25 @@ export interface Permit2Allowance {
|
|
|
8
8
|
expiration: bigint;
|
|
9
9
|
nonce: bigint;
|
|
10
10
|
}
|
|
11
|
-
export interface
|
|
11
|
+
export interface IPermit2Allowance {
|
|
12
|
+
amount: BigIntish;
|
|
13
|
+
expiration: BigIntish;
|
|
14
|
+
nonce: BigIntish;
|
|
15
|
+
}
|
|
16
|
+
export interface IHolding {
|
|
12
17
|
user: Address;
|
|
13
18
|
token: Address;
|
|
14
19
|
erc20Allowances: {
|
|
15
20
|
[key in Erc20AllowanceRecipient]: bigint;
|
|
16
21
|
};
|
|
17
22
|
permit2Allowances: {
|
|
18
|
-
[key in Permit2AllowanceRecipient]:
|
|
23
|
+
[key in Permit2AllowanceRecipient]: IPermit2Allowance;
|
|
19
24
|
};
|
|
20
25
|
erc2612Nonce?: bigint;
|
|
21
26
|
canTransfer?: boolean;
|
|
22
27
|
balance: bigint;
|
|
23
28
|
}
|
|
24
|
-
export declare class Holding implements
|
|
29
|
+
export declare class Holding implements IHolding {
|
|
25
30
|
/**
|
|
26
31
|
* The user of this holding.
|
|
27
32
|
*/
|
|
@@ -55,5 +60,5 @@ export declare class Holding implements InputHolding {
|
|
|
55
60
|
* `undefined` if the token does not support ERC-2612.
|
|
56
61
|
*/
|
|
57
62
|
erc2612Nonce?: bigint;
|
|
58
|
-
constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer, }:
|
|
63
|
+
constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer, }: IHolding);
|
|
59
64
|
}
|
package/lib/holding/Holding.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Holding = exports.PERMIT2_ALLOWANCE_RECIPIENTS = exports.ERC20_ALLOWANCE_RECIPIENTS = void 0;
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
|
-
const addresses_1 = require("../addresses");
|
|
6
5
|
exports.ERC20_ALLOWANCE_RECIPIENTS = [
|
|
7
6
|
"morpho",
|
|
8
7
|
"permit2",
|
|
@@ -42,16 +41,27 @@ class Holding {
|
|
|
42
41
|
* `undefined` if the token does not support ERC-2612.
|
|
43
42
|
*/
|
|
44
43
|
erc2612Nonce;
|
|
45
|
-
constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer
|
|
44
|
+
constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer, }) {
|
|
46
45
|
this.user = user;
|
|
47
46
|
this.token = token;
|
|
48
47
|
this.balance = balance;
|
|
49
|
-
this.canTransfer =
|
|
48
|
+
this.canTransfer = canTransfer;
|
|
50
49
|
this.erc20Allowances = (0, morpho_ts_1.fromEntries)((0, morpho_ts_1.entries)(erc20Allowances).map(([address, allowance]) => [
|
|
51
50
|
address,
|
|
52
51
|
allowance,
|
|
53
52
|
]));
|
|
54
|
-
this.permit2Allowances =
|
|
53
|
+
this.permit2Allowances = {
|
|
54
|
+
morpho: {
|
|
55
|
+
amount: BigInt(permit2Allowances.morpho.amount),
|
|
56
|
+
expiration: BigInt(permit2Allowances.morpho.expiration),
|
|
57
|
+
nonce: BigInt(permit2Allowances.morpho.nonce),
|
|
58
|
+
},
|
|
59
|
+
bundler: {
|
|
60
|
+
amount: BigInt(permit2Allowances.bundler.amount),
|
|
61
|
+
expiration: BigInt(permit2Allowances.bundler.expiration),
|
|
62
|
+
nonce: BigInt(permit2Allowances.bundler.nonce),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
55
65
|
if (erc2612Nonce != null)
|
|
56
66
|
this.erc2612Nonce = erc2612Nonce;
|
|
57
67
|
}
|
package/lib/holding/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./Holding";
|
|
2
|
-
export * from "./AssetBalances";
|
|
1
|
+
export * from "./Holding.js";
|
|
2
|
+
export * from "./AssetBalances.js";
|
package/lib/holding/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Holding"), exports);
|
|
18
|
-
__exportStar(require("./AssetBalances"), exports);
|
|
17
|
+
__exportStar(require("./Holding.js"), exports);
|
|
18
|
+
__exportStar(require("./AssetBalances.js"), exports);
|
package/lib/index.d.ts
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
export * from "./addresses";
|
|
2
|
-
export * from "./constants";
|
|
3
|
-
export * from "./errors";
|
|
4
|
-
export * from "./market";
|
|
5
|
-
export * from "./chain";
|
|
6
|
-
export * from "./token";
|
|
7
|
-
export * from "./types";
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./user";
|
|
10
|
-
export * from "./holding";
|
|
11
|
-
export * from "./position";
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./vault";
|
|
14
|
-
export * as constants from "./constants";
|
|
15
|
-
export * as errors from "./errors";
|
|
16
|
-
export * as market from "./market";
|
|
17
|
-
export * as chain from "./chain";
|
|
18
|
-
export * as token from "./token";
|
|
19
|
-
export * as position from "./position";
|
|
20
|
-
export * as holding from "./holding";
|
|
21
|
-
export * as types from "./types";
|
|
22
|
-
export * as maths from "./maths";
|
|
23
|
-
export * as user from "./user";
|
|
24
|
-
export * as helpers from "./helpers";
|
|
25
|
-
export * as vault from "./vault";
|
|
1
|
+
export * from "./addresses.js";
|
|
2
|
+
export * from "./constants.js";
|
|
3
|
+
export * from "./errors.js";
|
|
4
|
+
export * from "./market/index.js";
|
|
5
|
+
export * from "./chain.js";
|
|
6
|
+
export * from "./token/index.js";
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export * from "./math/index.js";
|
|
9
|
+
export * from "./user/index.js";
|
|
10
|
+
export * from "./holding/index.js";
|
|
11
|
+
export * from "./position/index.js";
|
|
12
|
+
export * from "./vault/index.js";
|
package/lib/index.js
CHANGED
|
@@ -10,45 +10,19 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
15
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
|
|
30
|
-
__exportStar(require("./
|
|
31
|
-
__exportStar(require("./
|
|
32
|
-
__exportStar(require("./
|
|
33
|
-
__exportStar(require("./
|
|
34
|
-
__exportStar(require("./
|
|
35
|
-
__exportStar(require("./
|
|
36
|
-
__exportStar(require("./
|
|
37
|
-
__exportStar(require("./
|
|
38
|
-
__exportStar(require("./
|
|
39
|
-
__exportStar(require("./
|
|
40
|
-
__exportStar(require("./
|
|
41
|
-
__exportStar(require("./helpers"), exports);
|
|
42
|
-
__exportStar(require("./vault"), exports);
|
|
43
|
-
exports.constants = __importStar(require("./constants"));
|
|
44
|
-
exports.errors = __importStar(require("./errors"));
|
|
45
|
-
exports.market = __importStar(require("./market"));
|
|
46
|
-
exports.chain = __importStar(require("./chain"));
|
|
47
|
-
exports.token = __importStar(require("./token"));
|
|
48
|
-
exports.position = __importStar(require("./position"));
|
|
49
|
-
exports.holding = __importStar(require("./holding"));
|
|
50
|
-
exports.types = __importStar(require("./types"));
|
|
51
|
-
exports.maths = __importStar(require("./maths"));
|
|
52
|
-
exports.user = __importStar(require("./user"));
|
|
53
|
-
exports.helpers = __importStar(require("./helpers"));
|
|
54
|
-
exports.vault = __importStar(require("./vault"));
|
|
17
|
+
__exportStar(require("./addresses.js"), exports);
|
|
18
|
+
__exportStar(require("./constants.js"), exports);
|
|
19
|
+
__exportStar(require("./errors.js"), exports);
|
|
20
|
+
__exportStar(require("./market/index.js"), exports);
|
|
21
|
+
__exportStar(require("./chain.js"), exports);
|
|
22
|
+
__exportStar(require("./token/index.js"), exports);
|
|
23
|
+
__exportStar(require("./types.js"), exports);
|
|
24
|
+
__exportStar(require("./math/index.js"), exports);
|
|
25
|
+
__exportStar(require("./user/index.js"), exports);
|
|
26
|
+
__exportStar(require("./holding/index.js"), exports);
|
|
27
|
+
__exportStar(require("./position/index.js"), exports);
|
|
28
|
+
__exportStar(require("./vault/index.js"), exports);
|
package/lib/market/Market.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RoundingDirection } from "../
|
|
2
|
-
import { BigIntish } from "../types";
|
|
3
|
-
import {
|
|
1
|
+
import { type RoundingDirection } from "../math/index.js";
|
|
2
|
+
import type { BigIntish } from "../types.js";
|
|
3
|
+
import type { MarketParams } from "./MarketParams.js";
|
|
4
4
|
export declare enum CapacityLimitReason {
|
|
5
5
|
liquidity = "Liquidity",
|
|
6
6
|
balance = "Balance",
|
|
@@ -21,30 +21,30 @@ export interface MaxWithdrawCollateralOptions {
|
|
|
21
21
|
export interface MaxPositionCapacities {
|
|
22
22
|
supply: CapacityLimit;
|
|
23
23
|
withdraw: CapacityLimit;
|
|
24
|
-
borrow: CapacityLimit;
|
|
24
|
+
borrow: CapacityLimit | undefined;
|
|
25
25
|
repay: CapacityLimit;
|
|
26
26
|
supplyCollateral: CapacityLimit;
|
|
27
|
-
withdrawCollateral: CapacityLimit;
|
|
27
|
+
withdrawCollateral: CapacityLimit | undefined;
|
|
28
28
|
}
|
|
29
|
-
export interface
|
|
30
|
-
|
|
29
|
+
export interface IMarket {
|
|
30
|
+
params: MarketParams;
|
|
31
31
|
totalSupplyAssets: bigint;
|
|
32
32
|
totalBorrowAssets: bigint;
|
|
33
33
|
totalSupplyShares: bigint;
|
|
34
34
|
totalBorrowShares: bigint;
|
|
35
35
|
lastUpdate: bigint;
|
|
36
36
|
fee: bigint;
|
|
37
|
-
price
|
|
37
|
+
price?: bigint;
|
|
38
38
|
rateAtTarget?: bigint;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Represents a lending market on Morpho Blue.
|
|
42
42
|
*/
|
|
43
|
-
export declare class Market implements
|
|
43
|
+
export declare class Market implements IMarket {
|
|
44
44
|
/**
|
|
45
|
-
* The market's
|
|
45
|
+
* The market's params.
|
|
46
46
|
*/
|
|
47
|
-
readonly
|
|
47
|
+
readonly params: MarketParams;
|
|
48
48
|
/**
|
|
49
49
|
* The amount of loan assets supplied in total on the market.
|
|
50
50
|
*/
|
|
@@ -71,18 +71,19 @@ export declare class Market implements InputMarket {
|
|
|
71
71
|
fee: bigint;
|
|
72
72
|
/**
|
|
73
73
|
* The price as returned by the market's oracle.
|
|
74
|
+
* `undefined` if the oracle is undefined or reverts.
|
|
74
75
|
*/
|
|
75
|
-
price
|
|
76
|
+
price?: bigint;
|
|
76
77
|
/**
|
|
77
78
|
* If the market uses the Adaptive Curve IRM, the rate at target utilization.
|
|
78
79
|
* Undefined otherwise.
|
|
79
80
|
*/
|
|
80
81
|
rateAtTarget?: bigint;
|
|
81
|
-
constructor({
|
|
82
|
+
constructor({ params, totalSupplyAssets, totalBorrowAssets, totalSupplyShares, totalBorrowShares, lastUpdate, fee, price, rateAtTarget, }: IMarket);
|
|
82
83
|
/**
|
|
83
84
|
* The market's hex-encoded id, defined as the hash of the market params.
|
|
84
85
|
*/
|
|
85
|
-
get id(): import("../types").MarketId;
|
|
86
|
+
get id(): import("../types.js").MarketId;
|
|
86
87
|
/**
|
|
87
88
|
* Whether the market satisfies the canonical definition of an idle market (i.e. collateral token is the zero address).
|
|
88
89
|
*/
|
|
@@ -101,21 +102,21 @@ export declare class Market implements InputMarket {
|
|
|
101
102
|
*/
|
|
102
103
|
get apyAtTarget(): bigint | undefined;
|
|
103
104
|
/**
|
|
104
|
-
* Returns the rate at which interest accrued
|
|
105
|
+
* Returns the rate at which interest accrued for suppliers of this market,
|
|
105
106
|
* since the last time the market was updated (scaled by WAD).
|
|
106
107
|
*/
|
|
107
108
|
get supplyRate(): bigint;
|
|
108
109
|
/**
|
|
109
|
-
* Returns the rate at which interest accrued
|
|
110
|
+
* Returns the rate at which interest accrued for borrowers of this market,
|
|
110
111
|
* since the last time the market was updated (scaled by WAD).
|
|
111
112
|
*/
|
|
112
113
|
get borrowRate(): bigint;
|
|
113
114
|
/**
|
|
114
|
-
* The market's supply Annual Percentage Yield (APY) (scaled by WAD).
|
|
115
|
+
* The market's supply-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
115
116
|
*/
|
|
116
117
|
get supplyApy(): bigint;
|
|
117
118
|
/**
|
|
118
|
-
* The market's borrow Annual Percentage Yield (APY) (scaled by WAD).
|
|
119
|
+
* The market's borrow-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
119
120
|
*/
|
|
120
121
|
get borrowApy(): bigint;
|
|
121
122
|
/**
|
|
@@ -189,57 +190,65 @@ export declare class Market implements InputMarket {
|
|
|
189
190
|
getRepayToUtilization(utilization: bigint): bigint;
|
|
190
191
|
/**
|
|
191
192
|
* Returns the value of a given amount of collateral quoted in loan assets.
|
|
193
|
+
* `undefined` iff the market's oracle is undefined or reverts.
|
|
192
194
|
* @param collateral The amount of collateral to quote.
|
|
193
195
|
*/
|
|
194
|
-
getCollateralValue(collateral: bigint): bigint;
|
|
196
|
+
getCollateralValue(collateral: bigint): bigint | undefined;
|
|
195
197
|
/**
|
|
196
198
|
* Returns the maximum debt allowed given a certain amount of collateral.
|
|
199
|
+
* `undefined` iff the market's oracle is undefined or reverts.
|
|
197
200
|
* To calculate the amount of loan assets that can be borrowed, use `getMaxBorrowableAssets`.
|
|
198
201
|
* @param collateral The amount of collateral to consider.
|
|
199
202
|
*/
|
|
200
|
-
getMaxBorrowAssets(collateral: bigint, { maxLtv }?: MaxBorrowOptions): bigint;
|
|
203
|
+
getMaxBorrowAssets(collateral: bigint, { maxLtv }?: MaxBorrowOptions): bigint | undefined;
|
|
201
204
|
/**
|
|
202
205
|
* Returns the maximum amount of loan assets that can be borrowed given a certain borrow position.
|
|
206
|
+
* `undefined` iff the market's oracle is undefined or reverts.
|
|
203
207
|
* @param position The borrow position to consider.
|
|
204
208
|
*/
|
|
205
209
|
getMaxBorrowableAssets(position: {
|
|
206
210
|
collateral: bigint;
|
|
207
211
|
borrowShares: bigint;
|
|
208
|
-
}): bigint;
|
|
212
|
+
}): bigint | undefined;
|
|
209
213
|
/**
|
|
210
214
|
* Returns the amount of collateral that would be seized in a liquidation given a certain amount of repaid shares.
|
|
215
|
+
* `undefined` iff the market's oracle is undefined or reverts.
|
|
211
216
|
* @param repaidShares The amount of shares hypothetically repaid.
|
|
212
217
|
*/
|
|
213
|
-
getLiquidationSeizedAssets(repaidShares: bigint): bigint;
|
|
218
|
+
getLiquidationSeizedAssets(repaidShares: bigint): bigint | undefined;
|
|
214
219
|
/**
|
|
215
220
|
* Returns the amount of borrow shares that would be repaid in a liquidation given a certain amount of seized collateral.
|
|
221
|
+
* `undefined` iff the market's oracle is undefined or reverts.
|
|
216
222
|
* @param seizedAssets The amount of collateral hypothetically seized.
|
|
217
223
|
*/
|
|
218
|
-
getLiquidationRepaidShares(seizedAssets: bigint): bigint;
|
|
224
|
+
getLiquidationRepaidShares(seizedAssets: bigint): bigint | undefined;
|
|
219
225
|
/**
|
|
220
226
|
* Returns the maximum amount of collateral that is worth being seized in a liquidation given a certain borrow position.
|
|
227
|
+
* `undefined` iff the market's oracle is undefined or reverts.
|
|
221
228
|
* @param position The borrow position to consider.
|
|
222
229
|
*/
|
|
223
230
|
getSeizableCollateral(position: {
|
|
224
231
|
collateral: bigint;
|
|
225
232
|
borrowShares: bigint;
|
|
226
|
-
}): bigint;
|
|
233
|
+
}): bigint | undefined;
|
|
227
234
|
/**
|
|
228
235
|
* Returns the amount of collateral that can be withdrawn given a certain borrow position.
|
|
236
|
+
* `undefined` iff the market's oracle is undefined or reverts.
|
|
229
237
|
* @param position The borrow position to consider.
|
|
230
238
|
*/
|
|
231
239
|
getWithdrawableCollateral(position: {
|
|
232
240
|
collateral: bigint;
|
|
233
241
|
borrowShares: bigint;
|
|
234
|
-
}, { maxLtv }?: MaxWithdrawCollateralOptions): bigint;
|
|
242
|
+
}, { maxLtv }?: MaxWithdrawCollateralOptions): bigint | undefined;
|
|
235
243
|
/**
|
|
236
244
|
* Returns whether a given borrow position is healthy.
|
|
245
|
+
* `undefined` iff the market's oracle is undefined or reverts.
|
|
237
246
|
* @param position The borrow position to check.
|
|
238
247
|
*/
|
|
239
248
|
isHealthy(position: {
|
|
240
249
|
collateral: bigint;
|
|
241
250
|
borrowShares: bigint;
|
|
242
|
-
}): boolean;
|
|
251
|
+
}): boolean | undefined;
|
|
243
252
|
/**
|
|
244
253
|
* Returns the liquidation price of a given borrow position.
|
|
245
254
|
* @param position The borrow position to consider.
|
|
@@ -249,13 +258,16 @@ export declare class Market implements InputMarket {
|
|
|
249
258
|
borrowShares: bigint;
|
|
250
259
|
}): bigint | null;
|
|
251
260
|
/**
|
|
252
|
-
* Returns the price
|
|
261
|
+
* Returns the price variation required for the given position to reach its liquidation threshold (scaled by WAD).
|
|
262
|
+
* Negative when healthy (the price needs to drop x%), positive when unhealthy (the price needs to soar x%).
|
|
263
|
+
* Returns `undefined` iff the market's price is undefined.
|
|
264
|
+
* Returns null if the position is not a borrow.
|
|
253
265
|
* @param position The borrow position to consider.
|
|
254
266
|
*/
|
|
255
|
-
|
|
267
|
+
getPriceVariationToLiquidationPrice(position: {
|
|
256
268
|
collateral: bigint;
|
|
257
269
|
borrowShares: bigint;
|
|
258
|
-
}): bigint | null;
|
|
270
|
+
}): bigint | null | undefined;
|
|
259
271
|
/**
|
|
260
272
|
* Returns the health factor of a given borrow position (scaled by WAD).
|
|
261
273
|
* @param position The borrow position to consider.
|
|
@@ -263,7 +275,7 @@ export declare class Market implements InputMarket {
|
|
|
263
275
|
getHealthFactor(position: {
|
|
264
276
|
collateral: bigint;
|
|
265
277
|
borrowShares: bigint;
|
|
266
|
-
}): bigint | null;
|
|
278
|
+
}): bigint | null | undefined;
|
|
267
279
|
/**
|
|
268
280
|
* Returns the loan-to-value ratio of a given borrow position (scaled by WAD).
|
|
269
281
|
* @param position The borrow position to consider.
|
|
@@ -271,7 +283,7 @@ export declare class Market implements InputMarket {
|
|
|
271
283
|
getLtv(position: {
|
|
272
284
|
collateral: bigint;
|
|
273
285
|
borrowShares: bigint;
|
|
274
|
-
}): bigint | null;
|
|
286
|
+
}): bigint | null | undefined;
|
|
275
287
|
/**
|
|
276
288
|
* Returns the usage ratio of the maximum borrow capacity given a certain borrow position (scaled by WAD).
|
|
277
289
|
* @param position The borrow position to consider.
|
|
@@ -279,16 +291,17 @@ export declare class Market implements InputMarket {
|
|
|
279
291
|
getBorrowCapacityUsage(position: {
|
|
280
292
|
collateral: bigint;
|
|
281
293
|
borrowShares: bigint;
|
|
282
|
-
}): bigint |
|
|
294
|
+
}): bigint | undefined;
|
|
283
295
|
/**
|
|
284
296
|
* Returns the maximum amount of loan assets that can be borrowed given a certain borrow position
|
|
285
297
|
* and the reason for the limit.
|
|
298
|
+
* Returns `undefined` iff the market's price is undefined.
|
|
286
299
|
* @param position The borrow position to consider.
|
|
287
300
|
*/
|
|
288
301
|
getBorrowCapacityLimit({ collateral, borrowShares, }: {
|
|
289
302
|
collateral: bigint;
|
|
290
303
|
borrowShares?: bigint;
|
|
291
|
-
}, options?: MaxBorrowOptions): CapacityLimit;
|
|
304
|
+
}, options?: MaxBorrowOptions): CapacityLimit | undefined;
|
|
292
305
|
/**
|
|
293
306
|
* Returns the maximum amount of loan assets that can be repaid given a certain borrow position
|
|
294
307
|
* and a balance of loan assets, and the reason for the limit.
|
|
@@ -306,12 +319,13 @@ export declare class Market implements InputMarket {
|
|
|
306
319
|
/**
|
|
307
320
|
* Returns the maximum amount of collateral assets that can be withdrawn given a certain borrow position
|
|
308
321
|
* and the reason for the limit.
|
|
322
|
+
* Returns `undefined` iff the market's price is undefined.
|
|
309
323
|
* @param position The borrow position to consider.
|
|
310
324
|
*/
|
|
311
325
|
getWithdrawCollateralCapacityLimit(position: {
|
|
312
326
|
collateral: bigint;
|
|
313
327
|
borrowShares: bigint;
|
|
314
|
-
}, options?: MaxWithdrawCollateralOptions): CapacityLimit;
|
|
328
|
+
}, options?: MaxWithdrawCollateralOptions): CapacityLimit | undefined;
|
|
315
329
|
/**
|
|
316
330
|
* Returns the maximum capacity for all interactions with Morpho Blue given a certain position
|
|
317
331
|
* and loan and collateral balances.
|