@morpho-org/blue-sdk 5.23.1 → 5.23.2
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/README.md +11 -2
- package/lib/cjs/addresses.d.ts +4 -0
- package/lib/cjs/addresses.js +3 -0
- package/lib/cjs/errors.js +2 -0
- package/lib/cjs/holding/index.d.ts +1 -1
- package/lib/cjs/holding/index.js +1 -1
- package/lib/cjs/index.d.ts +6 -6
- package/lib/cjs/index.js +6 -6
- package/lib/cjs/market/Market.js +15 -0
- package/lib/cjs/market/MarketParams.d.ts +1 -1
- package/lib/cjs/market/MarketParams.js +1 -1
- package/lib/cjs/market/MarketUtils.js +18 -0
- package/lib/cjs/market/index.d.ts +2 -2
- package/lib/cjs/market/index.js +2 -2
- package/lib/cjs/math/AdaptiveCurveIrmLib.js +8 -0
- package/lib/cjs/math/MathLib.js +14 -0
- package/lib/cjs/math/SharesMath.js +2 -0
- package/lib/cjs/math/index.d.ts +1 -1
- package/lib/cjs/math/index.js +1 -1
- package/lib/cjs/position/Position.js +9 -0
- package/lib/cjs/preLiquidation.js +1 -0
- package/lib/cjs/token/ConstantWrappedToken.js +5 -0
- package/lib/cjs/token/ExchangeRateWrappedToken.js +1 -0
- package/lib/cjs/token/WrappedToken.js +4 -0
- package/lib/cjs/token/index.d.ts +3 -3
- package/lib/cjs/token/index.js +3 -3
- package/lib/cjs/vault/Vault.js +1 -0
- package/lib/cjs/vault/VaultUtils.js +8 -2
- package/lib/cjs/vault/index.d.ts +2 -2
- package/lib/cjs/vault/index.js +2 -2
- package/lib/cjs/vault/v2/VaultV2.js +2 -0
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +1 -1
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1Adapter.js +3 -1
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +1 -1
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +1 -0
- package/lib/cjs/vault/v2/VaultV2MorphoVaultV1Adapter.js +1 -0
- package/lib/esm/addresses.d.ts +4 -0
- package/lib/esm/addresses.js +3 -0
- package/lib/esm/errors.js +2 -0
- package/lib/esm/holding/index.d.ts +1 -1
- package/lib/esm/holding/index.js +1 -1
- package/lib/esm/index.d.ts +6 -6
- package/lib/esm/index.js +6 -6
- package/lib/esm/market/Market.js +15 -0
- package/lib/esm/market/MarketParams.d.ts +1 -1
- package/lib/esm/market/MarketParams.js +1 -1
- package/lib/esm/market/MarketUtils.js +18 -0
- package/lib/esm/market/index.d.ts +2 -2
- package/lib/esm/market/index.js +2 -2
- package/lib/esm/math/AdaptiveCurveIrmLib.js +8 -0
- package/lib/esm/math/MathLib.js +14 -0
- package/lib/esm/math/SharesMath.js +2 -0
- package/lib/esm/math/index.d.ts +1 -1
- package/lib/esm/math/index.js +1 -1
- package/lib/esm/position/Position.js +9 -0
- package/lib/esm/preLiquidation.js +1 -0
- package/lib/esm/token/ConstantWrappedToken.js +5 -0
- package/lib/esm/token/ExchangeRateWrappedToken.js +1 -0
- package/lib/esm/token/WrappedToken.js +4 -0
- package/lib/esm/token/index.d.ts +3 -3
- package/lib/esm/token/index.js +3 -3
- package/lib/esm/vault/Vault.js +1 -0
- package/lib/esm/vault/VaultUtils.js +8 -2
- package/lib/esm/vault/index.d.ts +2 -2
- package/lib/esm/vault/index.js +2 -2
- package/lib/esm/vault/v2/VaultV2.js +2 -0
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +1 -1
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.js +3 -1
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +1 -1
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +1 -0
- package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.js +1 -0
- package/package.json +2 -2
- package/src/index.ts +6 -6
package/lib/esm/math/MathLib.js
CHANGED
|
@@ -21,6 +21,7 @@ export var MathLib;
|
|
|
21
21
|
* @param a The number
|
|
22
22
|
*/
|
|
23
23
|
function abs(a) {
|
|
24
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
24
25
|
a = BigInt(a);
|
|
25
26
|
return a >= 0 ? a : -a;
|
|
26
27
|
}
|
|
@@ -49,7 +50,9 @@ export var MathLib;
|
|
|
49
50
|
* @param y The second number
|
|
50
51
|
*/
|
|
51
52
|
function zeroFloorSub(x, y) {
|
|
53
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
52
54
|
x = BigInt(x);
|
|
55
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
53
56
|
y = BigInt(y);
|
|
54
57
|
return x <= y ? 0n : x - y;
|
|
55
58
|
}
|
|
@@ -77,6 +80,7 @@ export var MathLib;
|
|
|
77
80
|
* @param x The first number
|
|
78
81
|
* @param y The second number
|
|
79
82
|
*/
|
|
83
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
80
84
|
function wMul(x, y, rounding) {
|
|
81
85
|
return MathLib.mulDiv(x, y, MathLib.WAD, rounding);
|
|
82
86
|
}
|
|
@@ -104,6 +108,7 @@ export var MathLib;
|
|
|
104
108
|
* @param x The first number
|
|
105
109
|
* @param y The second number
|
|
106
110
|
*/
|
|
111
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
107
112
|
function wDiv(x, y, rounding) {
|
|
108
113
|
return MathLib.mulDiv(x, MathLib.WAD, y, rounding);
|
|
109
114
|
}
|
|
@@ -114,9 +119,13 @@ export var MathLib;
|
|
|
114
119
|
* @param y The second number
|
|
115
120
|
* @param denominator The denominator
|
|
116
121
|
*/
|
|
122
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
117
123
|
function mulDivDown(x, y, denominator) {
|
|
124
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
118
125
|
x = BigInt(x);
|
|
126
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
119
127
|
y = BigInt(y);
|
|
128
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
120
129
|
denominator = BigInt(denominator);
|
|
121
130
|
if (denominator === 0n)
|
|
122
131
|
throw Error("MathLib: DIVISION_BY_ZERO");
|
|
@@ -129,9 +138,13 @@ export var MathLib;
|
|
|
129
138
|
* @param y The second number
|
|
130
139
|
* @param denominator The denominator
|
|
131
140
|
*/
|
|
141
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
132
142
|
function mulDivUp(x, y, denominator) {
|
|
143
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
133
144
|
x = BigInt(x);
|
|
145
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
134
146
|
y = BigInt(y);
|
|
147
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
135
148
|
denominator = BigInt(denominator);
|
|
136
149
|
if (denominator === 0n)
|
|
137
150
|
throw Error("MathLib: DIVISION_BY_ZERO");
|
|
@@ -139,6 +152,7 @@ export var MathLib;
|
|
|
139
152
|
return (x * y) / denominator + roundup;
|
|
140
153
|
}
|
|
141
154
|
MathLib.mulDivUp = mulDivUp;
|
|
155
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
142
156
|
function mulDiv(x, y, denominator, rounding) {
|
|
143
157
|
return MathLib[`mulDiv${rounding}`](x, y, denominator);
|
|
144
158
|
}
|
|
@@ -7,10 +7,12 @@ export var SharesMath;
|
|
|
7
7
|
(function (SharesMath) {
|
|
8
8
|
SharesMath.VIRTUAL_SHARES = 1000000n;
|
|
9
9
|
SharesMath.VIRTUAL_ASSETS = 1n;
|
|
10
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
10
11
|
function toAssets(shares, totalAssets, totalShares, rounding) {
|
|
11
12
|
return MathLib.mulDiv(shares, BigInt(totalAssets) + SharesMath.VIRTUAL_ASSETS, BigInt(totalShares) + SharesMath.VIRTUAL_SHARES, rounding);
|
|
12
13
|
}
|
|
13
14
|
SharesMath.toAssets = toAssets;
|
|
15
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
14
16
|
function toShares(assets, totalAssets, totalShares, rounding) {
|
|
15
17
|
return MathLib.mulDiv(assets, BigInt(totalShares) + SharesMath.VIRTUAL_SHARES, BigInt(totalAssets) + SharesMath.VIRTUAL_ASSETS, rounding);
|
|
16
18
|
}
|
package/lib/esm/math/index.d.ts
CHANGED
package/lib/esm/math/index.js
CHANGED
|
@@ -158,15 +158,19 @@ export class AccrualPosition extends Position {
|
|
|
158
158
|
accrueInterest(timestamp) {
|
|
159
159
|
return new AccrualPosition(this, this._market.accrueInterest(timestamp));
|
|
160
160
|
}
|
|
161
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
161
162
|
supply(assets, shares, timestamp) {
|
|
162
163
|
let { _market: market } = this;
|
|
164
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
163
165
|
({ market, assets, shares } = market.supply(assets, shares, timestamp));
|
|
164
166
|
const position = new AccrualPosition(this, market);
|
|
165
167
|
position.supplyShares += shares;
|
|
166
168
|
return { position, assets, shares };
|
|
167
169
|
}
|
|
170
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
168
171
|
withdraw(assets, shares, timestamp) {
|
|
169
172
|
let { _market: market } = this;
|
|
173
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
170
174
|
({ market, assets, shares } = market.withdraw(assets, shares, timestamp));
|
|
171
175
|
const position = new AccrualPosition(this, market);
|
|
172
176
|
position.supplyShares -= shares;
|
|
@@ -189,10 +193,12 @@ export class AccrualPosition extends Position {
|
|
|
189
193
|
throw new BlueErrors.InsufficientCollateral(position.user, position.marketId);
|
|
190
194
|
return position;
|
|
191
195
|
}
|
|
196
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
192
197
|
borrow(assets, shares, timestamp) {
|
|
193
198
|
let { _market: market } = this;
|
|
194
199
|
if (market.price == null)
|
|
195
200
|
throw new BlueErrors.UnknownOraclePrice(market.id);
|
|
201
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
196
202
|
({ market, assets, shares } = market.borrow(assets, shares, timestamp));
|
|
197
203
|
const position = new AccrualPosition(this, market);
|
|
198
204
|
position.borrowShares += shares;
|
|
@@ -200,8 +206,10 @@ export class AccrualPosition extends Position {
|
|
|
200
206
|
throw new BlueErrors.InsufficientCollateral(this.user, this.marketId);
|
|
201
207
|
return { position, assets, shares };
|
|
202
208
|
}
|
|
209
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
203
210
|
repay(assets, shares, timestamp) {
|
|
204
211
|
let { _market: market } = this;
|
|
212
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
205
213
|
({ market, assets, shares } = market.repay(assets, shares, timestamp));
|
|
206
214
|
const position = new AccrualPosition(this, market);
|
|
207
215
|
position.borrowShares -= shares;
|
|
@@ -218,6 +226,7 @@ export class AccrualPosition extends Position {
|
|
|
218
226
|
getRepayCapacityLimit(loanTokenBalance) {
|
|
219
227
|
return this._market.getRepayCapacityLimit(this.borrowShares, loanTokenBalance);
|
|
220
228
|
}
|
|
229
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
221
230
|
getMaxCapacities(loanTokenBalance, collateralTokenBalance, options) {
|
|
222
231
|
return {
|
|
223
232
|
supply: {
|
|
@@ -83,6 +83,7 @@ export const defaultPreLiquidationParamsRegistry = new Map([
|
|
|
83
83
|
],
|
|
84
84
|
]);
|
|
85
85
|
export const getDefaultPreLiquidationParams = (lltv) => {
|
|
86
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
86
87
|
lltv = BigInt(lltv);
|
|
87
88
|
const defaultParams = defaultPreLiquidationParamsRegistry.get(lltv);
|
|
88
89
|
if (defaultParams == null)
|
|
@@ -2,22 +2,27 @@ import { MathLib } from "../math/index.js";
|
|
|
2
2
|
import { WrappedToken } from "./WrappedToken.js";
|
|
3
3
|
export class ConstantWrappedToken extends WrappedToken {
|
|
4
4
|
underlyingDecimals;
|
|
5
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
5
6
|
constructor(token, underlying, underlyingDecimals = 0) {
|
|
6
7
|
super(token, underlying);
|
|
7
8
|
this.underlyingDecimals = BigInt(underlyingDecimals);
|
|
8
9
|
}
|
|
10
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
9
11
|
toWrappedExactAmountIn(unwrappedAmount, _slippage, rounding = "Down") {
|
|
10
12
|
return super.toWrappedExactAmountIn(unwrappedAmount, 0n, rounding);
|
|
11
13
|
}
|
|
12
14
|
/** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
|
|
15
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
13
16
|
toWrappedExactAmountOut(wrappedAmount, _slippage, rounding = "Up") {
|
|
14
17
|
return super.toWrappedExactAmountOut(wrappedAmount, 0n, rounding);
|
|
15
18
|
}
|
|
16
19
|
/** The expected amount when unwrapping `wrappedAmount` */
|
|
20
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
17
21
|
toUnwrappedExactAmountIn(wrappedAmount, _slippage, rounding = "Down") {
|
|
18
22
|
return super.toUnwrappedExactAmountIn(wrappedAmount, 0n, rounding);
|
|
19
23
|
}
|
|
20
24
|
/** The amount of wrappedTokens that should be unwrapped to receive `unwrappedAmount` */
|
|
25
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
21
26
|
toUnwrappedExactAmountOut(unwrappedAmount, _slippage, rounding = "Up") {
|
|
22
27
|
return super.toUnwrappedExactAmountOut(unwrappedAmount, 0n, rounding);
|
|
23
28
|
}
|
|
@@ -3,6 +3,7 @@ import { WrappedToken } from "./WrappedToken.js";
|
|
|
3
3
|
export class ExchangeRateWrappedToken extends WrappedToken {
|
|
4
4
|
underlying;
|
|
5
5
|
wrappedTokenExchangeRate;
|
|
6
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
6
7
|
constructor(token, underlying, wrappedTokenExchangeRate) {
|
|
7
8
|
super(token, underlying);
|
|
8
9
|
this.underlying = underlying;
|
|
@@ -7,21 +7,25 @@ export class WrappedToken extends Token {
|
|
|
7
7
|
this.underlying = underlying;
|
|
8
8
|
}
|
|
9
9
|
/** The expected amount when wrapping `unwrappedAmount` */
|
|
10
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
10
11
|
toWrappedExactAmountIn(unwrappedAmount, slippage = 0n, rounding = "Down") {
|
|
11
12
|
const wrappedAmount = this._wrap(unwrappedAmount, rounding);
|
|
12
13
|
return MathLib.wMulDown(wrappedAmount, MathLib.WAD - slippage);
|
|
13
14
|
}
|
|
14
15
|
/** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
|
|
16
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
15
17
|
toWrappedExactAmountOut(wrappedAmount, slippage = 0n, rounding = "Up") {
|
|
16
18
|
const wAmountTarget = MathLib.wDiv(wrappedAmount, MathLib.WAD - slippage, rounding);
|
|
17
19
|
return this._unwrap(wAmountTarget, rounding);
|
|
18
20
|
}
|
|
19
21
|
/** The expected amount when unwrapping `wrappedAmount` */
|
|
22
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
20
23
|
toUnwrappedExactAmountIn(wrappedAmount, slippage = 0n, rounding = "Down") {
|
|
21
24
|
const unwrappedAmount = this._unwrap(wrappedAmount, rounding);
|
|
22
25
|
return MathLib.wMulUp(unwrappedAmount, MathLib.WAD - slippage);
|
|
23
26
|
}
|
|
24
27
|
/** The amount of wrappedTokens that should be unwrapped to receive `unwrappedAmount` */
|
|
28
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
25
29
|
toUnwrappedExactAmountOut(unwrappedAmount, slippage = 0n, rounding = "Up") {
|
|
26
30
|
const unwrappedAmountToTarget = MathLib.wDiv(unwrappedAmount, MathLib.WAD - slippage, rounding);
|
|
27
31
|
return this._wrap(unwrappedAmountToTarget, rounding);
|
package/lib/esm/token/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./Token.js";
|
|
2
|
-
export * from "./WrappedToken.js";
|
|
3
1
|
export * from "./ConstantWrappedToken.js";
|
|
2
|
+
export * from "./Eip5267Domain.js";
|
|
4
3
|
export * from "./ExchangeRateWrappedToken.js";
|
|
4
|
+
export * from "./Token.js";
|
|
5
5
|
export * from "./VaultToken.js";
|
|
6
|
-
export * from "./
|
|
6
|
+
export * from "./WrappedToken.js";
|
package/lib/esm/token/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./Token.js";
|
|
2
|
-
export * from "./WrappedToken.js";
|
|
3
1
|
export * from "./ConstantWrappedToken.js";
|
|
2
|
+
export * from "./Eip5267Domain.js";
|
|
4
3
|
export * from "./ExchangeRateWrappedToken.js";
|
|
4
|
+
export * from "./Token.js";
|
|
5
5
|
export * from "./VaultToken.js";
|
|
6
|
-
export * from "./
|
|
6
|
+
export * from "./WrappedToken.js";
|
package/lib/esm/vault/Vault.js
CHANGED
|
@@ -226,6 +226,7 @@ export class AccrualVault extends Vault {
|
|
|
226
226
|
* @param assets The maximum amount of assets to deposit.
|
|
227
227
|
*/
|
|
228
228
|
maxDeposit(assets) {
|
|
229
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
229
230
|
assets = BigInt(assets);
|
|
230
231
|
const suppliable = this.allocations
|
|
231
232
|
.values()
|
|
@@ -6,11 +6,17 @@ export var VaultUtils;
|
|
|
6
6
|
return MathLib.zeroFloorSub(18n, decimals);
|
|
7
7
|
}
|
|
8
8
|
VaultUtils.decimalsOffset = decimalsOffset;
|
|
9
|
-
|
|
9
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
10
|
+
function toAssets(shares, { totalAssets, totalSupply,
|
|
11
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
12
|
+
decimalsOffset, }, rounding = "Down") {
|
|
10
13
|
return MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
|
|
11
14
|
}
|
|
12
15
|
VaultUtils.toAssets = toAssets;
|
|
13
|
-
|
|
16
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
17
|
+
function toShares(assets, { totalAssets, totalSupply,
|
|
18
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
19
|
+
decimalsOffset, }, rounding = "Up") {
|
|
14
20
|
return MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
|
|
15
21
|
}
|
|
16
22
|
VaultUtils.toShares = toShares;
|
package/lib/esm/vault/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./Vault.js";
|
|
2
2
|
export * from "./VaultConfig.js";
|
|
3
3
|
export * from "./VaultMarketAllocation.js";
|
|
4
4
|
export * from "./VaultMarketConfig.js";
|
|
5
5
|
export * from "./VaultMarketPublicAllocatorConfig.js";
|
|
6
6
|
export * from "./VaultUser.js";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./VaultUtils.js";
|
|
8
8
|
export * from "./v2/index.js";
|
package/lib/esm/vault/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./Vault.js";
|
|
2
2
|
export * from "./VaultConfig.js";
|
|
3
3
|
export * from "./VaultMarketAllocation.js";
|
|
4
4
|
export * from "./VaultMarketConfig.js";
|
|
5
5
|
export * from "./VaultMarketPublicAllocatorConfig.js";
|
|
6
6
|
export * from "./VaultUser.js";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./VaultUtils.js";
|
|
8
8
|
export * from "./v2/index.js";
|
|
@@ -55,6 +55,7 @@ export class AccrualVaultV2 extends VaultV2 {
|
|
|
55
55
|
accrualAdapters;
|
|
56
56
|
assetBalance;
|
|
57
57
|
forceDeallocatePenalties;
|
|
58
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
58
59
|
constructor(vault, accrualLiquidityAdapter, accrualAdapters, assetBalance,
|
|
59
60
|
/**
|
|
60
61
|
* The force deallocate penalty for each adapter, keyed by adapter address.
|
|
@@ -126,6 +127,7 @@ export class AccrualVaultV2 extends VaultV2 {
|
|
|
126
127
|
*/
|
|
127
128
|
accrueInterest(timestamp) {
|
|
128
129
|
const vault = new AccrualVaultV2(this, this.accrualLiquidityAdapter, this.accrualAdapters, this.assetBalance, this.forceDeallocatePenalties);
|
|
130
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
129
131
|
timestamp = BigInt(timestamp);
|
|
130
132
|
const elapsed = timestamp - this.lastUpdate;
|
|
131
133
|
if (elapsed < 0n)
|
|
@@ -3,8 +3,8 @@ import { type IMarketParams, MarketParams } from "../../market/index.js";
|
|
|
3
3
|
import type { AccrualPosition } from "../../position/index.js";
|
|
4
4
|
import type { BigIntish } from "../../types.js";
|
|
5
5
|
import { CapacityLimitReason } from "../../utils.js";
|
|
6
|
-
import { VaultV2Adapter } from "./VaultV2Adapter.js";
|
|
7
6
|
import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
|
|
7
|
+
import { VaultV2Adapter } from "./VaultV2Adapter.js";
|
|
8
8
|
export interface IVaultV2MorphoMarketV1Adapter extends Omit<IVaultV2Adapter, "adapterId" | "type"> {
|
|
9
9
|
type?: "VaultV2MorphoMarketV1Adapter";
|
|
10
10
|
marketParamsList: IMarketParams[];
|
|
@@ -46,7 +46,9 @@ export class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Ad
|
|
|
46
46
|
}
|
|
47
47
|
maxWithdraw(data) {
|
|
48
48
|
const marketId = MarketParams.fromHex(data).id;
|
|
49
|
-
const position = this.positions.find(
|
|
49
|
+
const position = this.positions.find(
|
|
50
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
51
|
+
(position) => position.marketId === marketId);
|
|
50
52
|
return (position?.market?.getWithdrawCapacityLimit(position) ?? {
|
|
51
53
|
value: 0n,
|
|
52
54
|
limiter: CapacityLimitReason.position,
|
|
@@ -2,8 +2,8 @@ import { type Address, type Hex } from "viem";
|
|
|
2
2
|
import { type Market, MarketParams } from "../../market/index.js";
|
|
3
3
|
import type { BigIntish, MarketId } from "../../types.js";
|
|
4
4
|
import { CapacityLimitReason } from "../../utils.js";
|
|
5
|
-
import { VaultV2Adapter } from "./VaultV2Adapter.js";
|
|
6
5
|
import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
|
|
6
|
+
import { VaultV2Adapter } from "./VaultV2Adapter.js";
|
|
7
7
|
export interface IVaultV2MorphoMarketV1AdapterV2 extends Omit<IVaultV2Adapter, "adapterId" | "type"> {
|
|
8
8
|
type?: "VaultV2MorphoMarketV1AdapterV2";
|
|
9
9
|
marketIds: MarketId[];
|
|
@@ -53,6 +53,7 @@ export class AccrualVaultV2MorphoMarketV1AdapterV2 extends VaultV2MorphoMarketV1
|
|
|
53
53
|
}
|
|
54
54
|
maxWithdraw(data) {
|
|
55
55
|
const marketId = MarketParams.fromHex(data).id;
|
|
56
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
56
57
|
const market = this.markets.find((market) => market.id === marketId);
|
|
57
58
|
return (market?.getWithdrawCapacityLimit({
|
|
58
59
|
supplyShares: this.supplyShares[marketId] ?? 0n,
|
|
@@ -20,6 +20,7 @@ export class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter {
|
|
|
20
20
|
export class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter {
|
|
21
21
|
accrualVaultV1;
|
|
22
22
|
shares;
|
|
23
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
23
24
|
constructor(adapter, accrualVaultV1, shares) {
|
|
24
25
|
super(adapter);
|
|
25
26
|
this.accrualVaultV1 = accrualVaultV1;
|
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": "5.23.
|
|
4
|
+
"version": "5.23.2",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"viem": "^2.41.2",
|
|
34
34
|
"vitest": "^4.1.4",
|
|
35
35
|
"@morpho-org/morpho-ts": "^2.5.1",
|
|
36
|
-
"@morpho-org/test": "^2.7.
|
|
36
|
+
"@morpho-org/test": "^2.7.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"prepublish": "$npm_execpath build",
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export * from "./addresses.js";
|
|
2
|
+
export * from "./chain.js";
|
|
2
3
|
export * from "./constants.js";
|
|
3
4
|
export * from "./errors.js";
|
|
5
|
+
export * from "./holding/index.js";
|
|
4
6
|
export * from "./market/index.js";
|
|
5
|
-
export * from "./chain.js";
|
|
6
|
-
export * from "./token/index.js";
|
|
7
|
-
export * from "./types.js";
|
|
8
7
|
export * from "./math/index.js";
|
|
9
|
-
export * from "./user/index.js";
|
|
10
|
-
export * from "./holding/index.js";
|
|
11
8
|
export * from "./position/index.js";
|
|
12
|
-
export * from "./vault/index.js";
|
|
13
9
|
export * from "./preLiquidation.js";
|
|
10
|
+
export * from "./token/index.js";
|
|
11
|
+
export * from "./types.js";
|
|
12
|
+
export * from "./user/index.js";
|
|
14
13
|
export * from "./utils.js";
|
|
14
|
+
export * from "./vault/index.js";
|