@morpho-org/blue-sdk 2.0.0-next.31 → 2.0.0-next.33
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/lib/holding/AssetBalances.d.ts +2 -2
- package/lib/holding/Holding.d.ts +5 -5
- package/lib/market/Market.d.ts +7 -7
- package/lib/market/Market.js +7 -7
- package/lib/market/MarketParams.d.ts +4 -3
- package/lib/market/MarketUtils.d.ts +8 -6
- package/lib/market/MarketUtils.js +8 -6
- package/lib/math/MathLib.d.ts +1 -16
- package/lib/math/MathLib.js +1 -27
- package/lib/position/Position.d.ts +6 -6
- package/lib/token/ConstantWrappedToken.d.ts +2 -2
- package/lib/token/ExchangeRateWrappedToken.d.ts +2 -2
- package/lib/token/Token.d.ts +3 -3
- package/lib/token/VaultToken.d.ts +4 -4
- package/lib/token/WrappedToken.d.ts +2 -2
- package/lib/vault/Vault.d.ts +9 -9
- package/lib/vault/VaultConfig.d.ts +3 -3
- package/lib/vault/VaultMarketAllocation.d.ts +3 -3
- package/lib/vault/VaultMarketConfig.d.ts +3 -3
- package/lib/vault/VaultMarketPublicAllocatorConfig.d.ts +3 -3
- package/lib/vault/VaultUser.d.ts +3 -3
- package/package.json +2 -2
|
@@ -27,7 +27,7 @@ export interface PeripheralBalance {
|
|
|
27
27
|
*/
|
|
28
28
|
dstAmount: bigint;
|
|
29
29
|
}
|
|
30
|
-
export interface
|
|
30
|
+
export interface IAssetBalances extends Omit<PeripheralBalance, "type"> {
|
|
31
31
|
}
|
|
32
32
|
export declare class AssetBalances {
|
|
33
33
|
/**
|
|
@@ -42,7 +42,7 @@ export declare class AssetBalances {
|
|
|
42
42
|
} & {
|
|
43
43
|
[T in Exclude<PeripheralBalanceType, "base">]?: PeripheralBalance;
|
|
44
44
|
};
|
|
45
|
-
constructor(balance:
|
|
45
|
+
constructor(balance: IAssetBalances);
|
|
46
46
|
add(balance: PeripheralBalance): this;
|
|
47
47
|
sub(balance: PeripheralBalance): this;
|
|
48
48
|
}
|
package/lib/holding/Holding.d.ts
CHANGED
|
@@ -8,25 +8,25 @@ export interface Permit2Allowance {
|
|
|
8
8
|
expiration: bigint;
|
|
9
9
|
nonce: bigint;
|
|
10
10
|
}
|
|
11
|
-
export interface
|
|
11
|
+
export interface IPermit2Allowance {
|
|
12
12
|
amount: BigIntish;
|
|
13
13
|
expiration: BigIntish;
|
|
14
14
|
nonce: BigIntish;
|
|
15
15
|
}
|
|
16
|
-
export interface
|
|
16
|
+
export interface IHolding {
|
|
17
17
|
user: Address;
|
|
18
18
|
token: Address;
|
|
19
19
|
erc20Allowances: {
|
|
20
20
|
[key in Erc20AllowanceRecipient]: bigint;
|
|
21
21
|
};
|
|
22
22
|
permit2Allowances: {
|
|
23
|
-
[key in Permit2AllowanceRecipient]:
|
|
23
|
+
[key in Permit2AllowanceRecipient]: IPermit2Allowance;
|
|
24
24
|
};
|
|
25
25
|
erc2612Nonce?: bigint;
|
|
26
26
|
canTransfer?: boolean;
|
|
27
27
|
balance: bigint;
|
|
28
28
|
}
|
|
29
|
-
export declare class Holding implements
|
|
29
|
+
export declare class Holding implements IHolding {
|
|
30
30
|
/**
|
|
31
31
|
* The user of this holding.
|
|
32
32
|
*/
|
|
@@ -60,5 +60,5 @@ export declare class Holding implements InputHolding {
|
|
|
60
60
|
* `undefined` if the token does not support ERC-2612.
|
|
61
61
|
*/
|
|
62
62
|
erc2612Nonce?: bigint;
|
|
63
|
-
constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer, }:
|
|
63
|
+
constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer, }: IHolding);
|
|
64
64
|
}
|
package/lib/market/Market.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface MaxPositionCapacities {
|
|
|
26
26
|
supplyCollateral: CapacityLimit;
|
|
27
27
|
withdrawCollateral: CapacityLimit | undefined;
|
|
28
28
|
}
|
|
29
|
-
export interface
|
|
29
|
+
export interface IMarket {
|
|
30
30
|
params: MarketParams;
|
|
31
31
|
totalSupplyAssets: bigint;
|
|
32
32
|
totalBorrowAssets: bigint;
|
|
@@ -40,7 +40,7 @@ export interface InputMarket {
|
|
|
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
45
|
* The market's params.
|
|
46
46
|
*/
|
|
@@ -79,7 +79,7 @@ export declare class Market implements InputMarket {
|
|
|
79
79
|
* Undefined otherwise.
|
|
80
80
|
*/
|
|
81
81
|
rateAtTarget?: bigint;
|
|
82
|
-
constructor({ params, totalSupplyAssets, totalBorrowAssets, totalSupplyShares, totalBorrowShares, lastUpdate, fee, price, rateAtTarget, }:
|
|
82
|
+
constructor({ params, totalSupplyAssets, totalBorrowAssets, totalSupplyShares, totalBorrowShares, lastUpdate, fee, price, rateAtTarget, }: IMarket);
|
|
83
83
|
/**
|
|
84
84
|
* The market's hex-encoded id, defined as the hash of the market params.
|
|
85
85
|
*/
|
|
@@ -102,21 +102,21 @@ export declare class Market implements InputMarket {
|
|
|
102
102
|
*/
|
|
103
103
|
get apyAtTarget(): bigint | undefined;
|
|
104
104
|
/**
|
|
105
|
-
* Returns the rate at which interest accrued
|
|
105
|
+
* Returns the rate at which interest accrued for suppliers of this market,
|
|
106
106
|
* since the last time the market was updated (scaled by WAD).
|
|
107
107
|
*/
|
|
108
108
|
get supplyRate(): bigint;
|
|
109
109
|
/**
|
|
110
|
-
* Returns the rate at which interest accrued
|
|
110
|
+
* Returns the rate at which interest accrued for borrowers of this market,
|
|
111
111
|
* since the last time the market was updated (scaled by WAD).
|
|
112
112
|
*/
|
|
113
113
|
get borrowRate(): bigint;
|
|
114
114
|
/**
|
|
115
|
-
* The market's supply Annual Percentage Yield (APY) (scaled by WAD).
|
|
115
|
+
* The market's supply-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
116
116
|
*/
|
|
117
117
|
get supplyApy(): bigint;
|
|
118
118
|
/**
|
|
119
|
-
* The market's borrow Annual Percentage Yield (APY) (scaled by WAD).
|
|
119
|
+
* The market's borrow-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
120
120
|
*/
|
|
121
121
|
get borrowApy(): bigint;
|
|
122
122
|
/**
|
package/lib/market/Market.js
CHANGED
|
@@ -98,17 +98,17 @@ class Market {
|
|
|
98
98
|
get apyAtTarget() {
|
|
99
99
|
if (this.rateAtTarget == null)
|
|
100
100
|
return;
|
|
101
|
-
return MarketUtils_js_1.MarketUtils.
|
|
101
|
+
return MarketUtils_js_1.MarketUtils.compoundRate(this.rateAtTarget);
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
* Returns the rate at which interest accrued
|
|
104
|
+
* Returns the rate at which interest accrued for suppliers of this market,
|
|
105
105
|
* since the last time the market was updated (scaled by WAD).
|
|
106
106
|
*/
|
|
107
107
|
get supplyRate() {
|
|
108
108
|
return MarketUtils_js_1.MarketUtils.getSupplyRate(this.borrowRate, this);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
* Returns the rate at which interest accrued
|
|
111
|
+
* Returns the rate at which interest accrued for borrowers of this market,
|
|
112
112
|
* since the last time the market was updated (scaled by WAD).
|
|
113
113
|
*/
|
|
114
114
|
get borrowRate() {
|
|
@@ -117,16 +117,16 @@ class Market {
|
|
|
117
117
|
return index_js_1.AdaptiveCurveIrmLib.getBorrowRate(this.utilization, this.rateAtTarget, 0n).avgBorrowRate;
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
|
-
* The market's supply Annual Percentage Yield (APY) (scaled by WAD).
|
|
120
|
+
* The market's supply-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
121
121
|
*/
|
|
122
122
|
get supplyApy() {
|
|
123
|
-
return MarketUtils_js_1.MarketUtils.
|
|
123
|
+
return MarketUtils_js_1.MarketUtils.compoundRate(this.supplyRate);
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* The market's borrow Annual Percentage Yield (APY) (scaled by WAD).
|
|
126
|
+
* The market's borrow-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
127
127
|
*/
|
|
128
128
|
get borrowApy() {
|
|
129
|
-
return MarketUtils_js_1.MarketUtils.
|
|
129
|
+
return MarketUtils_js_1.MarketUtils.compoundRate(this.borrowRate);
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { Address, BigIntish, MarketId } from "../types.js";
|
|
2
|
-
export interface
|
|
2
|
+
export interface IMarketParams {
|
|
3
3
|
loanToken: Address;
|
|
4
4
|
collateralToken: Address;
|
|
5
5
|
oracle: Address;
|
|
6
6
|
irm: Address;
|
|
7
7
|
lltv: BigIntish;
|
|
8
8
|
}
|
|
9
|
+
export type InputMarketParams = Pick<MarketParams, "loanToken" | "collateralToken" | "oracle" | "irm" | "lltv">;
|
|
9
10
|
/**
|
|
10
11
|
* Represents a market's configuration (also called market params).
|
|
11
12
|
*/
|
|
12
|
-
export declare class MarketParams implements
|
|
13
|
+
export declare class MarketParams implements IMarketParams {
|
|
13
14
|
private static readonly _CACHE;
|
|
14
15
|
/**
|
|
15
16
|
* Returns the previously cached market config for the given id, if any.
|
|
@@ -48,5 +49,5 @@ export declare class MarketParams implements InputMarketParams {
|
|
|
48
49
|
* The market's liquidation incentive factor.
|
|
49
50
|
*/
|
|
50
51
|
readonly liquidationIncentiveFactor: bigint;
|
|
51
|
-
constructor(params:
|
|
52
|
+
constructor(params: IMarketParams);
|
|
52
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RoundingDirection } from "../math/index.js";
|
|
2
2
|
import type { BigIntish, MarketId } from "../types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IMarketParams } from "./MarketParams.js";
|
|
4
4
|
/**
|
|
5
5
|
* Namespace of utility functions to ease market-related calculations.
|
|
6
6
|
*/
|
|
@@ -9,7 +9,7 @@ export declare namespace MarketUtils {
|
|
|
9
9
|
* Returns the id of a market based on its params.
|
|
10
10
|
* @param market The market params.
|
|
11
11
|
*/
|
|
12
|
-
function getMarketId(market:
|
|
12
|
+
function getMarketId(market: IMarketParams): MarketId;
|
|
13
13
|
/**
|
|
14
14
|
* Returns the liquidation incentive factor for a given market params.
|
|
15
15
|
* @param config The market params.
|
|
@@ -26,7 +26,7 @@ export declare namespace MarketUtils {
|
|
|
26
26
|
totalBorrowAssets: BigIntish;
|
|
27
27
|
}): bigint;
|
|
28
28
|
/**
|
|
29
|
-
* Returns the rate at which interest accrued
|
|
29
|
+
* Returns the rate at which interest accrued for suppliers on the corresponding market,
|
|
30
30
|
* since the last time the market was updated (scaled by WAD).
|
|
31
31
|
* @param borrowRate The average borrow rate since the last market update (scaled by WAD).
|
|
32
32
|
* @param market The market state.
|
|
@@ -36,10 +36,12 @@ export declare namespace MarketUtils {
|
|
|
36
36
|
fee: BigIntish;
|
|
37
37
|
}): bigint;
|
|
38
38
|
/**
|
|
39
|
-
* Returns the
|
|
40
|
-
*
|
|
39
|
+
* Returns the per-second rate continuously compounded over the given period, as calculated in Morpho Blue (scaled by WAD).
|
|
40
|
+
* If the period is 1 year, the compounded rate correspond to the Annual Percentage Yield (APY)
|
|
41
|
+
* @param rate The per-second rate to compound (scaled by WAD).
|
|
42
|
+
* @param period The period to compound the rate over (in seconds). Defaults to 1 year.
|
|
41
43
|
*/
|
|
42
|
-
function
|
|
44
|
+
function compoundRate(rate: BigIntish, period?: BigIntish): bigint;
|
|
43
45
|
/**
|
|
44
46
|
* Returns the interest accrued on both sides of the given market
|
|
45
47
|
* as well as the supply shares minted to the fee recipient.
|
|
@@ -50,7 +50,7 @@ var MarketUtils;
|
|
|
50
50
|
}
|
|
51
51
|
MarketUtils.getUtilization = getUtilization;
|
|
52
52
|
/**
|
|
53
|
-
* Returns the rate at which interest accrued
|
|
53
|
+
* Returns the rate at which interest accrued for suppliers on the corresponding market,
|
|
54
54
|
* since the last time the market was updated (scaled by WAD).
|
|
55
55
|
* @param borrowRate The average borrow rate since the last market update (scaled by WAD).
|
|
56
56
|
* @param market The market state.
|
|
@@ -61,13 +61,15 @@ var MarketUtils;
|
|
|
61
61
|
}
|
|
62
62
|
MarketUtils.getSupplyRate = getSupplyRate;
|
|
63
63
|
/**
|
|
64
|
-
* Returns the
|
|
65
|
-
*
|
|
64
|
+
* Returns the per-second rate continuously compounded over the given period, as calculated in Morpho Blue (scaled by WAD).
|
|
65
|
+
* If the period is 1 year, the compounded rate correspond to the Annual Percentage Yield (APY)
|
|
66
|
+
* @param rate The per-second rate to compound (scaled by WAD).
|
|
67
|
+
* @param period The period to compound the rate over (in seconds). Defaults to 1 year.
|
|
66
68
|
*/
|
|
67
|
-
function
|
|
68
|
-
return index_js_1.MathLib.wTaylorCompounded(rate,
|
|
69
|
+
function compoundRate(rate, period = constants_js_1.SECONDS_PER_YEAR) {
|
|
70
|
+
return index_js_1.MathLib.wTaylorCompounded(rate, period);
|
|
69
71
|
}
|
|
70
|
-
MarketUtils.
|
|
72
|
+
MarketUtils.compoundRate = compoundRate;
|
|
71
73
|
/**
|
|
72
74
|
* Returns the interest accrued on both sides of the given market
|
|
73
75
|
* as well as the supply shares minted to the fee recipient.
|
package/lib/math/MathLib.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Time } from "@morpho-org/morpho-ts";
|
|
2
1
|
import type { BigIntish } from "../types.js";
|
|
3
2
|
export type RoundingDirection = "Up" | "Down";
|
|
4
3
|
/**
|
|
@@ -88,24 +87,10 @@ export declare namespace MathLib {
|
|
|
88
87
|
function mulDiv(x: BigIntish, y: BigIntish, denominator: BigIntish, rounding: RoundingDirection): bigint;
|
|
89
88
|
/**
|
|
90
89
|
* The sum of the first three non-zero terms of a Taylor expansion of e^(nx) - 1,
|
|
91
|
-
* to approximate a
|
|
90
|
+
* to approximate a continuously compounded interest rate.
|
|
92
91
|
*
|
|
93
92
|
* @param x The base of the exponent
|
|
94
93
|
* @param n The exponent
|
|
95
94
|
*/
|
|
96
95
|
function wTaylorCompounded(x: BigIntish, n: BigIntish): bigint;
|
|
97
|
-
/**
|
|
98
|
-
* Converts an rate to compounded apy
|
|
99
|
-
*
|
|
100
|
-
* @param rate The rate to convert (in WAD)
|
|
101
|
-
* @param period The compounding basis
|
|
102
|
-
*/
|
|
103
|
-
function rateToApy(rate: BigIntish, period: Time.PeriodLike): number;
|
|
104
|
-
/**
|
|
105
|
-
* Converts an apr to compounded apy
|
|
106
|
-
*
|
|
107
|
-
* @param apr The apr to convert (in WAD)
|
|
108
|
-
* @param compounding The compounding basis
|
|
109
|
-
*/
|
|
110
|
-
function aprToApy(apr: BigIntish, compounding: Time.PeriodLike): number;
|
|
111
96
|
}
|
package/lib/math/MathLib.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MathLib = void 0;
|
|
4
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
4
|
/**
|
|
6
5
|
* Library to manage fixed-point arithmetic.
|
|
7
6
|
* https://github.com/morpho-org/morpho-blue/blob/main/src/libraries/MathLib.sol
|
|
@@ -148,7 +147,7 @@ var MathLib;
|
|
|
148
147
|
MathLib.mulDiv = mulDiv;
|
|
149
148
|
/**
|
|
150
149
|
* The sum of the first three non-zero terms of a Taylor expansion of e^(nx) - 1,
|
|
151
|
-
* to approximate a
|
|
150
|
+
* to approximate a continuously compounded interest rate.
|
|
152
151
|
*
|
|
153
152
|
* @param x The base of the exponent
|
|
154
153
|
* @param n The exponent
|
|
@@ -160,29 +159,4 @@ var MathLib;
|
|
|
160
159
|
return firstTerm + secondTerm + thirdTerm;
|
|
161
160
|
}
|
|
162
161
|
MathLib.wTaylorCompounded = wTaylorCompounded;
|
|
163
|
-
/**
|
|
164
|
-
* Converts an rate to compounded apy
|
|
165
|
-
*
|
|
166
|
-
* @param rate The rate to convert (in WAD)
|
|
167
|
-
* @param period The compounding basis
|
|
168
|
-
*/
|
|
169
|
-
function rateToApy(rate, period) {
|
|
170
|
-
const { unit, duration } = morpho_ts_1.Time.toPeriod(period);
|
|
171
|
-
const factor = morpho_ts_1.Time[unit].from.y(1) / duration;
|
|
172
|
-
return ((1 + Number(morpho_ts_1.format.number.locale("en").of(BigInt(rate), 18))) ** factor -
|
|
173
|
-
1);
|
|
174
|
-
}
|
|
175
|
-
MathLib.rateToApy = rateToApy;
|
|
176
|
-
/**
|
|
177
|
-
* Converts an apr to compounded apy
|
|
178
|
-
*
|
|
179
|
-
* @param apr The apr to convert (in WAD)
|
|
180
|
-
* @param compounding The compounding basis
|
|
181
|
-
*/
|
|
182
|
-
function aprToApy(apr, compounding) {
|
|
183
|
-
const { unit, duration } = morpho_ts_1.Time.toPeriod(compounding);
|
|
184
|
-
const rate = (BigInt(apr) * BigInt(duration)) / morpho_ts_1.Time[unit].from.y(1n);
|
|
185
|
-
return rateToApy(rate, compounding);
|
|
186
|
-
}
|
|
187
|
-
MathLib.aprToApy = aprToApy;
|
|
188
162
|
})(MathLib || (exports.MathLib = MathLib = {}));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Market, type MaxBorrowOptions, type MaxWithdrawCollateralOptions } from "../market/index.js";
|
|
2
2
|
import type { Address, BigIntish, MarketId } from "../types.js";
|
|
3
|
-
export interface
|
|
3
|
+
export interface IPosition {
|
|
4
4
|
user: Address;
|
|
5
5
|
marketId: MarketId;
|
|
6
6
|
supplyShares: bigint;
|
|
7
7
|
borrowShares: bigint;
|
|
8
8
|
collateral: bigint;
|
|
9
9
|
}
|
|
10
|
-
export declare class Position implements
|
|
10
|
+
export declare class Position implements IPosition {
|
|
11
11
|
/**
|
|
12
12
|
* The user holding this position.
|
|
13
13
|
*/
|
|
@@ -28,16 +28,16 @@ export declare class Position implements InputPosition {
|
|
|
28
28
|
* The amount of collateral assets held with this position.
|
|
29
29
|
*/
|
|
30
30
|
collateral: bigint;
|
|
31
|
-
constructor({ user, marketId, supplyShares, borrowShares, collateral, }:
|
|
31
|
+
constructor({ user, marketId, supplyShares, borrowShares, collateral, }: IPosition);
|
|
32
32
|
}
|
|
33
|
-
export interface
|
|
33
|
+
export interface IAccrualPosition extends Omit<IPosition, "marketId"> {
|
|
34
34
|
}
|
|
35
|
-
export declare class AccrualPosition extends Position implements
|
|
35
|
+
export declare class AccrualPosition extends Position implements IAccrualPosition {
|
|
36
36
|
/**
|
|
37
37
|
* The market on which this position is held.
|
|
38
38
|
*/
|
|
39
39
|
readonly market: Market;
|
|
40
|
-
constructor(position:
|
|
40
|
+
constructor(position: IAccrualPosition, market: Market);
|
|
41
41
|
get supplyAssets(): bigint;
|
|
42
42
|
get borrowAssets(): bigint;
|
|
43
43
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type RoundingDirection } from "../math/index.js";
|
|
2
2
|
import type { Address, BigIntish } from "../types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IToken } from "./Token.js";
|
|
4
4
|
import { WrappedToken } from "./WrappedToken.js";
|
|
5
5
|
export declare class ConstantWrappedToken extends WrappedToken {
|
|
6
6
|
readonly underlyingDecimals: bigint;
|
|
7
|
-
constructor(token:
|
|
7
|
+
constructor(token: IToken, underlying: Address, underlyingDecimals?: BigIntish);
|
|
8
8
|
toWrappedExactAmountIn(unwrappedAmount: bigint, _slippage?: bigint, rounding?: RoundingDirection): bigint;
|
|
9
9
|
/** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
|
|
10
10
|
toWrappedExactAmountOut(wrappedAmount: bigint, _slippage?: bigint, rounding?: RoundingDirection): bigint;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type RoundingDirection } from "../math/index.js";
|
|
2
2
|
import type { Address } from "../types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IToken } from "./Token.js";
|
|
4
4
|
import { WrappedToken } from "./WrappedToken.js";
|
|
5
5
|
export declare class ExchangeRateWrappedToken extends WrappedToken {
|
|
6
6
|
readonly underlying: Address;
|
|
7
7
|
wrappedTokenExchangeRate: bigint;
|
|
8
|
-
constructor(token:
|
|
8
|
+
constructor(token: IToken, underlying: Address, wrappedTokenExchangeRate: bigint);
|
|
9
9
|
protected _wrap(amount: bigint, rounding: RoundingDirection): bigint;
|
|
10
10
|
protected _unwrap(amount: bigint, rounding: RoundingDirection): bigint;
|
|
11
11
|
}
|
package/lib/token/Token.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type ChainId } from "../chain.js";
|
|
2
2
|
import { type RoundingDirection } from "../math/index.js";
|
|
3
3
|
import type { Address, BigIntish } from "../types.js";
|
|
4
|
-
export interface
|
|
4
|
+
export interface IToken {
|
|
5
5
|
address: Address;
|
|
6
6
|
name?: string;
|
|
7
7
|
symbol?: string;
|
|
8
8
|
decimals?: BigIntish;
|
|
9
9
|
price?: BigIntish;
|
|
10
10
|
}
|
|
11
|
-
export declare class Token implements
|
|
11
|
+
export declare class Token implements IToken {
|
|
12
12
|
static native(chainId: ChainId): Token;
|
|
13
13
|
/**
|
|
14
14
|
* The token's address.
|
|
@@ -30,7 +30,7 @@ export declare class Token implements InputToken {
|
|
|
30
30
|
* Price of the token in USD (scaled by WAD).
|
|
31
31
|
*/
|
|
32
32
|
price?: bigint;
|
|
33
|
-
constructor({ address, name, symbol, decimals, price }:
|
|
33
|
+
constructor({ address, name, symbol, decimals, price }: IToken);
|
|
34
34
|
/**
|
|
35
35
|
* Quotes an amount in USD (scaled by WAD) in this token.
|
|
36
36
|
* Returns `undefined` iff the token's price is undefined.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { RoundingDirection } from "../math/index.js";
|
|
2
2
|
import type { Address } from "../types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IVaultConfig } from "../vault/VaultConfig.js";
|
|
4
4
|
import { WrappedToken } from "./WrappedToken.js";
|
|
5
|
-
export interface
|
|
5
|
+
export interface IVaultToken {
|
|
6
6
|
totalAssets: bigint;
|
|
7
7
|
totalSupply: bigint;
|
|
8
8
|
}
|
|
9
|
-
export declare class VaultToken extends WrappedToken implements
|
|
9
|
+
export declare class VaultToken extends WrappedToken implements IVaultToken {
|
|
10
10
|
readonly asset: Address;
|
|
11
11
|
readonly decimalsOffset: bigint;
|
|
12
12
|
/**
|
|
@@ -17,7 +17,7 @@ export declare class VaultToken extends WrappedToken implements InputVaultToken
|
|
|
17
17
|
* The ERC4626 vault's total assets.
|
|
18
18
|
*/
|
|
19
19
|
totalAssets: bigint;
|
|
20
|
-
constructor(config:
|
|
20
|
+
constructor(config: IVaultConfig, { totalAssets, totalSupply }: IVaultToken);
|
|
21
21
|
protected _wrap(amount: bigint, rounding?: RoundingDirection): bigint;
|
|
22
22
|
protected _unwrap(amount: bigint, rounding?: RoundingDirection): bigint;
|
|
23
23
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type RoundingDirection } from "../math/index.js";
|
|
2
2
|
import type { Address } from "../types.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type IToken, Token } from "./Token.js";
|
|
4
4
|
export declare abstract class WrappedToken extends Token {
|
|
5
5
|
readonly underlying: Address;
|
|
6
|
-
constructor(token:
|
|
6
|
+
constructor(token: IToken, underlying: Address);
|
|
7
7
|
/** The expected amount when wrapping `unwrappedAmount` */
|
|
8
8
|
toWrappedExactAmountIn(unwrappedAmount: bigint, slippage?: bigint, rounding?: RoundingDirection): bigint;
|
|
9
9
|
/** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
|
package/lib/vault/Vault.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { type CapacityLimit } from "../market/index.js";
|
|
|
2
2
|
import { type RoundingDirection } from "../math/index.js";
|
|
3
3
|
import { VaultToken } from "../token/index.js";
|
|
4
4
|
import type { Address, BigIntish, MarketId } from "../types.js";
|
|
5
|
-
import type {
|
|
6
|
-
import { type
|
|
5
|
+
import type { IVaultConfig } from "./VaultConfig.js";
|
|
6
|
+
import { type IVaultMarketAllocation, VaultMarketAllocation } from "./VaultMarketAllocation.js";
|
|
7
7
|
export interface Pending<T> {
|
|
8
8
|
value: T;
|
|
9
9
|
validAt: bigint;
|
|
@@ -22,7 +22,7 @@ export interface VaultPublicAllocatorConfig {
|
|
|
22
22
|
*/
|
|
23
23
|
accruedFee: bigint;
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
25
|
+
export interface IVault extends IVaultConfig {
|
|
26
26
|
curator: Address;
|
|
27
27
|
owner: Address;
|
|
28
28
|
guardian: Address;
|
|
@@ -40,7 +40,7 @@ export interface InputVault extends InputVaultConfig {
|
|
|
40
40
|
lastTotalAssets: bigint;
|
|
41
41
|
publicAllocatorConfig?: VaultPublicAllocatorConfig;
|
|
42
42
|
}
|
|
43
|
-
export declare class Vault extends VaultToken implements
|
|
43
|
+
export declare class Vault extends VaultToken implements IVault {
|
|
44
44
|
/**
|
|
45
45
|
* The vault's share token's name.
|
|
46
46
|
*/
|
|
@@ -105,7 +105,7 @@ export declare class Vault extends VaultToken implements InputVault {
|
|
|
105
105
|
* The MetaMorpho vault's public allocator configuration.
|
|
106
106
|
*/
|
|
107
107
|
publicAllocatorConfig?: VaultPublicAllocatorConfig;
|
|
108
|
-
constructor({ curator, owner, guardian, publicAllocatorConfig, fee, feeRecipient, skimRecipient, pendingTimelock, pendingGuardian, pendingOwner, timelock, supplyQueue, withdrawQueue, totalSupply, totalAssets, lastTotalAssets, ...config }:
|
|
108
|
+
constructor({ curator, owner, guardian, publicAllocatorConfig, fee, feeRecipient, skimRecipient, pendingTimelock, pendingGuardian, pendingOwner, timelock, supplyQueue, withdrawQueue, totalSupply, totalAssets, lastTotalAssets, ...config }: IVault);
|
|
109
109
|
/**
|
|
110
110
|
* The amount of interest in assets accrued since the last interaction with the vault.
|
|
111
111
|
*/
|
|
@@ -120,9 +120,9 @@ export interface CollateralAllocation {
|
|
|
120
120
|
markets: Set<MarketId>;
|
|
121
121
|
proportion: bigint;
|
|
122
122
|
}
|
|
123
|
-
export interface
|
|
123
|
+
export interface IAccrualVault extends Omit<IVault, "withdrawQueue" | "totalAssets"> {
|
|
124
124
|
}
|
|
125
|
-
export declare class AccrualVault extends Vault implements
|
|
125
|
+
export declare class AccrualVault extends Vault implements IAccrualVault {
|
|
126
126
|
/**
|
|
127
127
|
* The allocation of the vault on each market enabled.
|
|
128
128
|
*/
|
|
@@ -131,12 +131,12 @@ export declare class AccrualVault extends Vault implements InputAccrualVault {
|
|
|
131
131
|
* The proportion of assets of the vault supplied to markets collateralized by each collateral asset.
|
|
132
132
|
*/
|
|
133
133
|
readonly collateralAllocations: Map<Address, CollateralAllocation>;
|
|
134
|
-
constructor(vault:
|
|
134
|
+
constructor(vault: IAccrualVault,
|
|
135
135
|
/**
|
|
136
136
|
* The allocation of the vault on each market of the withdraw queue,
|
|
137
137
|
* in the same order as the withdraw queue.
|
|
138
138
|
*/
|
|
139
|
-
allocations: Omit<
|
|
139
|
+
allocations: Omit<IVaultMarketAllocation, "proportion">[]);
|
|
140
140
|
/**
|
|
141
141
|
* The vault's liquidity directly available from allocated markets.
|
|
142
142
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ChainId } from "../chain.js";
|
|
2
2
|
import type { Address, BigIntish } from "../types.js";
|
|
3
|
-
export interface
|
|
3
|
+
export interface IVaultConfig {
|
|
4
4
|
address: Address;
|
|
5
5
|
decimalsOffset: BigIntish;
|
|
6
6
|
symbol: string;
|
|
7
7
|
name: string;
|
|
8
8
|
asset: Address;
|
|
9
9
|
}
|
|
10
|
-
export declare class VaultConfig implements
|
|
10
|
+
export declare class VaultConfig implements IVaultConfig {
|
|
11
11
|
readonly chainId?: number | undefined;
|
|
12
12
|
protected static readonly _CACHE: Record<number, Record<Address, VaultConfig>>;
|
|
13
13
|
static get(address: Address, chainId: ChainId): VaultConfig;
|
|
@@ -17,5 +17,5 @@ export declare class VaultConfig implements InputVaultConfig {
|
|
|
17
17
|
readonly symbol: string;
|
|
18
18
|
readonly name: string;
|
|
19
19
|
readonly asset: Address;
|
|
20
|
-
constructor({ address, decimalsOffset, symbol, name, asset }:
|
|
20
|
+
constructor({ address, decimalsOffset, symbol, name, asset }: IVaultConfig, chainId?: number | undefined);
|
|
21
21
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AccrualPosition } from "../position/index.js";
|
|
2
2
|
import type { VaultMarketConfig } from "./VaultMarketConfig.js";
|
|
3
|
-
export interface
|
|
3
|
+
export interface IVaultMarketAllocation {
|
|
4
4
|
config: VaultMarketConfig;
|
|
5
5
|
position: AccrualPosition;
|
|
6
6
|
}
|
|
7
|
-
export declare class VaultMarketAllocation implements
|
|
7
|
+
export declare class VaultMarketAllocation implements IVaultMarketAllocation {
|
|
8
8
|
/**
|
|
9
9
|
* The vault's configuration on the corresponding market.
|
|
10
10
|
*/
|
|
@@ -13,7 +13,7 @@ export declare class VaultMarketAllocation implements InputVaultMarketAllocation
|
|
|
13
13
|
* The vault's position on the corresponding market.
|
|
14
14
|
*/
|
|
15
15
|
readonly position: AccrualPosition;
|
|
16
|
-
constructor({ config, position }:
|
|
16
|
+
constructor({ config, position }: IVaultMarketAllocation);
|
|
17
17
|
get vault(): `0x${string}`;
|
|
18
18
|
get marketId(): import("../types.js").MarketId;
|
|
19
19
|
get utilization(): bigint;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, MarketId } from "../types.js";
|
|
2
2
|
import type { Pending } from "./Vault.js";
|
|
3
3
|
import type { VaultMarketPublicAllocatorConfig } from "./VaultMarketPublicAllocatorConfig.js";
|
|
4
|
-
export interface
|
|
4
|
+
export interface IVaultMarketConfig {
|
|
5
5
|
vault: Address;
|
|
6
6
|
marketId: MarketId;
|
|
7
7
|
cap: bigint;
|
|
@@ -10,7 +10,7 @@ export interface InputVaultMarketConfig {
|
|
|
10
10
|
enabled: boolean;
|
|
11
11
|
publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
|
|
12
12
|
}
|
|
13
|
-
export declare class VaultMarketConfig implements
|
|
13
|
+
export declare class VaultMarketConfig implements IVaultMarketConfig {
|
|
14
14
|
/**
|
|
15
15
|
* The vault's address.
|
|
16
16
|
*/
|
|
@@ -39,5 +39,5 @@ export declare class VaultMarketConfig implements InputVaultMarketConfig {
|
|
|
39
39
|
* The vault's PublicAllocator configuration on the corresponding market.
|
|
40
40
|
*/
|
|
41
41
|
readonly publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
|
|
42
|
-
constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }:
|
|
42
|
+
constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }: IVaultMarketConfig);
|
|
43
43
|
}
|
|
@@ -2,13 +2,13 @@ import type { Address, MarketId } from "../types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The vault's configuration of a market on the PublicAllocator.
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface IVaultMarketPublicAllocatorConfig {
|
|
6
6
|
vault: Address;
|
|
7
7
|
marketId: MarketId;
|
|
8
8
|
maxIn: bigint;
|
|
9
9
|
maxOut: bigint;
|
|
10
10
|
}
|
|
11
|
-
export declare class VaultMarketPublicAllocatorConfig implements
|
|
11
|
+
export declare class VaultMarketPublicAllocatorConfig implements IVaultMarketPublicAllocatorConfig {
|
|
12
12
|
/**
|
|
13
13
|
* The vault's address.
|
|
14
14
|
*/
|
|
@@ -25,5 +25,5 @@ export declare class VaultMarketPublicAllocatorConfig implements InputVaultMarke
|
|
|
25
25
|
* The maximum amount of tokens that can be allocated out of this market by the vault via the PublicAllocator.
|
|
26
26
|
*/
|
|
27
27
|
maxOut: bigint;
|
|
28
|
-
constructor({ vault, marketId, maxIn, maxOut, }:
|
|
28
|
+
constructor({ vault, marketId, maxIn, maxOut, }: IVaultMarketPublicAllocatorConfig);
|
|
29
29
|
}
|
package/lib/vault/VaultUser.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Address } from "../types.js";
|
|
2
|
-
export interface
|
|
2
|
+
export interface IVaultUser {
|
|
3
3
|
vault: Address;
|
|
4
4
|
user: Address;
|
|
5
5
|
isAllocator: boolean;
|
|
6
6
|
allowance: bigint;
|
|
7
7
|
}
|
|
8
|
-
export declare class VaultUser implements
|
|
8
|
+
export declare class VaultUser implements IVaultUser {
|
|
9
9
|
/**
|
|
10
10
|
* The vault's address.
|
|
11
11
|
*/
|
|
@@ -22,5 +22,5 @@ export declare class VaultUser implements InputVaultUser {
|
|
|
22
22
|
* The allowance of the vault over the user's underlying assets.
|
|
23
23
|
*/
|
|
24
24
|
allowance: bigint;
|
|
25
|
-
constructor({ vault, user, isAllocator, allowance }:
|
|
25
|
+
constructor({ vault, user, isAllocator, allowance }: IVaultUser);
|
|
26
26
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/blue-sdk",
|
|
3
3
|
"description": "Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).",
|
|
4
|
-
"version": "2.0.0-next.
|
|
4
|
+
"version": "2.0.0-next.33",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"viem": "^2.21.54",
|
|
29
29
|
"vitest": "^2.1.8",
|
|
30
30
|
"@morpho-org/morpho-ts": "^2.0.0-next.16",
|
|
31
|
-
"@morpho-org/test": "^2.0.0-next.
|
|
31
|
+
"@morpho-org/test": "^2.0.0-next.28"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"prepublish": "$npm_execpath build",
|