@morpho-org/blue-sdk 5.23.1 → 5.23.3
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 +184 -0
- package/lib/cjs/addresses.js +102 -0
- package/lib/cjs/chain.d.ts +37 -1
- package/lib/cjs/chain.js +24 -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.d.ts +26 -2
- package/lib/cjs/market/MarketUtils.js +49 -6
- 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/position/PreLiquidationPosition.d.ts +1 -0
- package/lib/cjs/position/PreLiquidationPosition.js +8 -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 +184 -0
- package/lib/esm/addresses.js +102 -0
- package/lib/esm/chain.d.ts +37 -1
- package/lib/esm/chain.js +24 -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.d.ts +26 -2
- package/lib/esm/market/MarketUtils.js +48 -5
- 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/position/PreLiquidationPosition.d.ts +1 -0
- package/lib/esm/position/PreLiquidationPosition.js +8 -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 +6 -6
- package/src/index.ts +6 -6
package/lib/esm/market/Market.js
CHANGED
|
@@ -165,6 +165,7 @@ export class Market {
|
|
|
165
165
|
* Defaults to `Time.timestamp()` (returns the current accrual borrow rate).
|
|
166
166
|
*/
|
|
167
167
|
getAccrualBorrowRates(timestamp = Time.timestamp()) {
|
|
168
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
168
169
|
timestamp = BigInt(timestamp);
|
|
169
170
|
const elapsed = timestamp - this.lastUpdate;
|
|
170
171
|
if (elapsed < 0n)
|
|
@@ -241,6 +242,7 @@ export class Market {
|
|
|
241
242
|
* Defaults to `lastUpdate` (returns a copy of the market).
|
|
242
243
|
*/
|
|
243
244
|
accrueInterest(timestamp = this.lastUpdate) {
|
|
245
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
244
246
|
timestamp = BigInt(timestamp);
|
|
245
247
|
const { elapsed, avgBorrowRate, endRateAtTarget } = this.getAccrualBorrowRates(timestamp);
|
|
246
248
|
const { interest, feeShares } = MarketUtils.getAccruedInterest(avgBorrowRate, this, elapsed);
|
|
@@ -253,24 +255,30 @@ export class Market {
|
|
|
253
255
|
rateAtTarget: endRateAtTarget,
|
|
254
256
|
});
|
|
255
257
|
}
|
|
258
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
256
259
|
supply(assets, shares, timestamp) {
|
|
257
260
|
if ((assets === 0n) === (shares === 0n))
|
|
258
261
|
throw new BlueErrors.InconsistentInput(assets, shares);
|
|
259
262
|
const market = this.accrueInterest(timestamp);
|
|
263
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
260
264
|
if (shares === 0n)
|
|
261
265
|
shares = market.toSupplyShares(assets, "Down");
|
|
266
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
262
267
|
else
|
|
263
268
|
assets = market.toSupplyAssets(shares, "Up");
|
|
264
269
|
market.totalSupplyAssets += assets;
|
|
265
270
|
market.totalSupplyShares += shares;
|
|
266
271
|
return { market, assets, shares };
|
|
267
272
|
}
|
|
273
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
268
274
|
withdraw(assets, shares, timestamp) {
|
|
269
275
|
if ((assets === 0n) === (shares === 0n))
|
|
270
276
|
throw new BlueErrors.InconsistentInput(assets, shares);
|
|
271
277
|
const market = this.accrueInterest(timestamp);
|
|
278
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
272
279
|
if (shares === 0n)
|
|
273
280
|
shares = market.toSupplyShares(assets, "Up");
|
|
281
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
274
282
|
else
|
|
275
283
|
assets = market.toSupplyAssets(shares, "Down");
|
|
276
284
|
market.totalSupplyAssets -= assets;
|
|
@@ -279,12 +287,15 @@ export class Market {
|
|
|
279
287
|
throw new BlueErrors.InsufficientLiquidity(market.id);
|
|
280
288
|
return { market, assets, shares };
|
|
281
289
|
}
|
|
290
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
282
291
|
borrow(assets, shares, timestamp) {
|
|
283
292
|
if ((assets === 0n) === (shares === 0n))
|
|
284
293
|
throw new BlueErrors.InconsistentInput(assets, shares);
|
|
285
294
|
const market = this.accrueInterest(timestamp);
|
|
295
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
286
296
|
if (shares === 0n)
|
|
287
297
|
shares = market.toBorrowShares(assets, "Up");
|
|
298
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
288
299
|
else
|
|
289
300
|
assets = market.toBorrowAssets(shares, "Down");
|
|
290
301
|
market.totalBorrowAssets += assets;
|
|
@@ -293,12 +304,15 @@ export class Market {
|
|
|
293
304
|
throw new BlueErrors.InsufficientLiquidity(market.id);
|
|
294
305
|
return { market, assets, shares };
|
|
295
306
|
}
|
|
307
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
296
308
|
repay(assets, shares, timestamp) {
|
|
297
309
|
if ((assets === 0n) === (shares === 0n))
|
|
298
310
|
throw new BlueErrors.InconsistentInput(assets, shares);
|
|
299
311
|
const market = this.accrueInterest(timestamp);
|
|
312
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
300
313
|
if (shares === 0n)
|
|
301
314
|
shares = market.toBorrowShares(assets, "Down");
|
|
315
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
302
316
|
else
|
|
303
317
|
assets = market.toBorrowAssets(shares, "Up");
|
|
304
318
|
market.totalBorrowAssets -= assets;
|
|
@@ -557,6 +571,7 @@ export class Market {
|
|
|
557
571
|
* @param loanTokenBalance The balance of loan assets.
|
|
558
572
|
* @param collateralTokenBalance The balance of collateral assets.
|
|
559
573
|
*/
|
|
574
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
560
575
|
getMaxCapacities(position, loanTokenBalance, collateralTokenBalance, options) {
|
|
561
576
|
return {
|
|
562
577
|
supply: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZERO_ADDRESS } from "@morpho-org/morpho-ts";
|
|
2
|
-
import { InvalidMarketParamsError, UnknownMarketParamsError, } from "../errors.js";
|
|
3
2
|
import { decodeAbiParameters } from "viem";
|
|
3
|
+
import { InvalidMarketParamsError, UnknownMarketParamsError, } from "../errors.js";
|
|
4
4
|
import { MarketUtils } from "./MarketUtils.js";
|
|
5
5
|
export const marketParamsAbi = {
|
|
6
6
|
type: "tuple",
|
|
@@ -34,11 +34,35 @@ export declare namespace MarketUtils {
|
|
|
34
34
|
/**
|
|
35
35
|
* Returns the interest accrued on both sides of the given market
|
|
36
36
|
* as well as the supply shares minted to the fee recipient.
|
|
37
|
+
*
|
|
38
|
+
* Fee shares are converted from the fee amount against post-interest supply assets minus the fee amount,
|
|
39
|
+
* matching Morpho Blue's onchain accrual.
|
|
40
|
+
*
|
|
37
41
|
* @param borrowRate The average borrow rate since the last market update (scaled by WAD).
|
|
38
|
-
* @param market The market
|
|
42
|
+
* @param market.totalSupplyAssets The market's total supplied assets before accrual.
|
|
43
|
+
* @param market.totalBorrowAssets The market's total borrowed assets before accrual.
|
|
44
|
+
* @param market.totalSupplyShares The market's total supply shares before fee shares are minted.
|
|
45
|
+
* @param market.fee The market fee percentage, scaled by WAD.
|
|
39
46
|
* @param elapsed The time elapsed since the last market update (in seconds).
|
|
47
|
+
* @returns The accrued interest and the supply shares minted to the fee recipient.
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { MarketUtils, MathLib } from "@morpho-org/blue-sdk";
|
|
51
|
+
*
|
|
52
|
+
* const { interest, feeShares } = MarketUtils.getAccruedInterest(
|
|
53
|
+
* 5_0000000000000000n,
|
|
54
|
+
* {
|
|
55
|
+
* totalSupplyAssets: 1_000_000n * MathLib.WAD,
|
|
56
|
+
* totalBorrowAssets: 800_000n * MathLib.WAD,
|
|
57
|
+
* totalSupplyShares: 1_100_000n * MathLib.WAD,
|
|
58
|
+
* fee: 10_0000000000000000n,
|
|
59
|
+
* },
|
|
60
|
+
* 1n,
|
|
61
|
+
* );
|
|
62
|
+
* // { interest, feeShares } satisfies { interest: bigint; feeShares: bigint }
|
|
63
|
+
* ```
|
|
40
64
|
*/
|
|
41
|
-
function getAccruedInterest(borrowRate: BigIntish,
|
|
65
|
+
function getAccruedInterest(borrowRate: BigIntish, market: {
|
|
42
66
|
totalSupplyAssets: BigIntish;
|
|
43
67
|
totalBorrowAssets: BigIntish;
|
|
44
68
|
totalSupplyShares: BigIntish;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { keccak_256 } from "@noble/hashes/sha3";
|
|
2
|
-
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
|
|
1
|
+
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
2
|
+
import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
|
|
3
3
|
import { formatEther } from "viem";
|
|
4
4
|
import { LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, } from "../constants.js";
|
|
5
5
|
import { MathLib, SharesMath } from "../math/index.js";
|
|
@@ -59,15 +59,41 @@ export var MarketUtils;
|
|
|
59
59
|
/**
|
|
60
60
|
* Returns the interest accrued on both sides of the given market
|
|
61
61
|
* as well as the supply shares minted to the fee recipient.
|
|
62
|
+
*
|
|
63
|
+
* Fee shares are converted from the fee amount against post-interest supply assets minus the fee amount,
|
|
64
|
+
* matching Morpho Blue's onchain accrual.
|
|
65
|
+
*
|
|
62
66
|
* @param borrowRate The average borrow rate since the last market update (scaled by WAD).
|
|
63
|
-
* @param market The market
|
|
67
|
+
* @param market.totalSupplyAssets The market's total supplied assets before accrual.
|
|
68
|
+
* @param market.totalBorrowAssets The market's total borrowed assets before accrual.
|
|
69
|
+
* @param market.totalSupplyShares The market's total supply shares before fee shares are minted.
|
|
70
|
+
* @param market.fee The market fee percentage, scaled by WAD.
|
|
64
71
|
* @param elapsed The time elapsed since the last market update (in seconds).
|
|
72
|
+
* @returns The accrued interest and the supply shares minted to the fee recipient.
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { MarketUtils, MathLib } from "@morpho-org/blue-sdk";
|
|
76
|
+
*
|
|
77
|
+
* const { interest, feeShares } = MarketUtils.getAccruedInterest(
|
|
78
|
+
* 5_0000000000000000n,
|
|
79
|
+
* {
|
|
80
|
+
* totalSupplyAssets: 1_000_000n * MathLib.WAD,
|
|
81
|
+
* totalBorrowAssets: 800_000n * MathLib.WAD,
|
|
82
|
+
* totalSupplyShares: 1_100_000n * MathLib.WAD,
|
|
83
|
+
* fee: 10_0000000000000000n,
|
|
84
|
+
* },
|
|
85
|
+
* 1n,
|
|
86
|
+
* );
|
|
87
|
+
* // { interest, feeShares } satisfies { interest: bigint; feeShares: bigint }
|
|
88
|
+
* ```
|
|
65
89
|
*/
|
|
66
|
-
|
|
90
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
91
|
+
function getAccruedInterest(borrowRate, market, elapsed = 0n) {
|
|
92
|
+
const { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee } = market;
|
|
67
93
|
const interest = MathLib.wMulDown(totalBorrowAssets, MathLib.wTaylorCompounded(borrowRate, elapsed));
|
|
68
94
|
const feeAmount = MathLib.wMulDown(interest, fee);
|
|
69
95
|
const feeShares = toSupplyShares(feeAmount, {
|
|
70
|
-
totalSupplyAssets: BigInt(totalSupplyAssets) - feeAmount,
|
|
96
|
+
totalSupplyAssets: BigInt(totalSupplyAssets) + interest - feeAmount,
|
|
71
97
|
totalSupplyShares,
|
|
72
98
|
}, "Down");
|
|
73
99
|
return { interest, feeShares };
|
|
@@ -79,6 +105,7 @@ export var MarketUtils;
|
|
|
79
105
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
80
106
|
*/
|
|
81
107
|
function getSupplyToUtilization(market, utilization) {
|
|
108
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
82
109
|
utilization = BigInt(utilization);
|
|
83
110
|
if (utilization === 0n) {
|
|
84
111
|
if (getUtilization(market) === 0n)
|
|
@@ -94,6 +121,7 @@ export var MarketUtils;
|
|
|
94
121
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
95
122
|
*/
|
|
96
123
|
function getWithdrawToUtilization({ totalSupplyAssets, totalBorrowAssets, }, utilization) {
|
|
124
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
97
125
|
utilization = BigInt(utilization);
|
|
98
126
|
totalSupplyAssets = BigInt(totalSupplyAssets);
|
|
99
127
|
totalBorrowAssets = BigInt(totalBorrowAssets);
|
|
@@ -142,6 +170,7 @@ export var MarketUtils;
|
|
|
142
170
|
* Return `undefined` iff the market's price is undefined.
|
|
143
171
|
* To calculate the amount of loan assets that can be borrowed, use `getMaxBorrowableAssets`.
|
|
144
172
|
*/
|
|
173
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
145
174
|
function getMaxBorrowAssets(collateral, market, { lltv }) {
|
|
146
175
|
const collateralValue = getCollateralValue(collateral, market);
|
|
147
176
|
if (collateralValue == null)
|
|
@@ -153,6 +182,7 @@ export var MarketUtils;
|
|
|
153
182
|
* Returns the maximum amount of loan assets that can be borrowed given a certain borrow position.
|
|
154
183
|
* Return `undefined` iff the market's price is undefined.
|
|
155
184
|
*/
|
|
185
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
156
186
|
function getMaxBorrowableAssets({ collateral, borrowShares, }, market, marketParams) {
|
|
157
187
|
const maxBorrowAssets = getMaxBorrowAssets(collateral, market, marketParams);
|
|
158
188
|
if (maxBorrowAssets == null)
|
|
@@ -164,6 +194,7 @@ export var MarketUtils;
|
|
|
164
194
|
* Returns the amount of collateral that would be seized in a liquidation given a certain amount of repaid shares.
|
|
165
195
|
* Return `undefined` iff the market's price is undefined.
|
|
166
196
|
*/
|
|
197
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
167
198
|
function getLiquidationSeizedAssets(repaidShares, market, config) {
|
|
168
199
|
if (market.price == null)
|
|
169
200
|
return;
|
|
@@ -177,6 +208,7 @@ export var MarketUtils;
|
|
|
177
208
|
* Returns the amount of borrow shares that would be repaid in a liquidation given a certain amount of seized collateral.
|
|
178
209
|
* Return `undefined` iff the market's price is undefined.
|
|
179
210
|
*/
|
|
211
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
180
212
|
function getLiquidationRepaidShares(seizedAssets, market, config) {
|
|
181
213
|
if (market.price == null)
|
|
182
214
|
return;
|
|
@@ -187,6 +219,7 @@ export var MarketUtils;
|
|
|
187
219
|
* Returns the maximum amount of collateral that is worth being seized in a liquidation given a certain borrow position.
|
|
188
220
|
* Return `undefined` iff the market's price is undefined.
|
|
189
221
|
*/
|
|
222
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
190
223
|
function getSeizableCollateral(position, market, config) {
|
|
191
224
|
if (market.price == null)
|
|
192
225
|
return; // Must be checked before calling `isHealthy`.
|
|
@@ -200,6 +233,7 @@ export var MarketUtils;
|
|
|
200
233
|
* Returns the amount of collateral that can be withdrawn given a certain borrow position.
|
|
201
234
|
* Return `undefined` iff the market's price is undefined.
|
|
202
235
|
*/
|
|
236
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
203
237
|
function getWithdrawableCollateral({ collateral, borrowShares, }, market, { lltv }) {
|
|
204
238
|
if (market.price == null)
|
|
205
239
|
return;
|
|
@@ -214,6 +248,7 @@ export var MarketUtils;
|
|
|
214
248
|
* Return `undefined` iff the market's price is undefined.
|
|
215
249
|
* @param position The borrow position to check.
|
|
216
250
|
*/
|
|
251
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
217
252
|
function isHealthy({ collateral, borrowShares, }, market, marketParams) {
|
|
218
253
|
const maxBorrowAssets = getMaxBorrowAssets(collateral, market, marketParams);
|
|
219
254
|
if (maxBorrowAssets == null)
|
|
@@ -226,6 +261,7 @@ export var MarketUtils;
|
|
|
226
261
|
* that set the user's position to be liquidatable.
|
|
227
262
|
* Returns null if the position is not a borrow.
|
|
228
263
|
*/
|
|
264
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
229
265
|
function getLiquidationPrice({ collateral, borrowShares, }, market, marketParams) {
|
|
230
266
|
borrowShares = BigInt(borrowShares);
|
|
231
267
|
market.totalBorrowShares = BigInt(market.totalBorrowShares);
|
|
@@ -244,6 +280,7 @@ export var MarketUtils;
|
|
|
244
280
|
* Returns `undefined` iff the market's price is undefined.
|
|
245
281
|
* Returns null if the position is not a borrow.
|
|
246
282
|
*/
|
|
283
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
247
284
|
function getPriceVariationToLiquidationPrice(position, market, marketParams) {
|
|
248
285
|
if (market.price == null)
|
|
249
286
|
return;
|
|
@@ -261,6 +298,7 @@ export var MarketUtils;
|
|
|
261
298
|
* If the debt is 0, health factor is `MaxUint256`.
|
|
262
299
|
* Returns `undefined` iff the market's price is undefined.
|
|
263
300
|
*/
|
|
301
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
264
302
|
function getHealthFactor({ collateral, borrowShares, }, market, marketParams) {
|
|
265
303
|
const borrowAssets = toBorrowAssets(borrowShares, market);
|
|
266
304
|
if (borrowAssets === 0n)
|
|
@@ -293,6 +331,7 @@ export var MarketUtils;
|
|
|
293
331
|
* Returns the usage ratio of the maximum borrow capacity given a certain borrow position (scaled by WAD).
|
|
294
332
|
* Returns `undefined` iff the market's price is undefined.
|
|
295
333
|
*/
|
|
334
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
296
335
|
function getBorrowCapacityUsage(position, market, marketParams) {
|
|
297
336
|
const hf = getHealthFactor(position, market, marketParams);
|
|
298
337
|
if (hf === undefined)
|
|
@@ -304,18 +343,22 @@ export var MarketUtils;
|
|
|
304
343
|
return MathLib.wDivUp(MathLib.WAD, hf);
|
|
305
344
|
}
|
|
306
345
|
MarketUtils.getBorrowCapacityUsage = getBorrowCapacityUsage;
|
|
346
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
307
347
|
function toSupplyAssets(shares, market, rounding = "Down") {
|
|
308
348
|
return SharesMath.toAssets(shares, market.totalSupplyAssets, market.totalSupplyShares, rounding);
|
|
309
349
|
}
|
|
310
350
|
MarketUtils.toSupplyAssets = toSupplyAssets;
|
|
351
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
311
352
|
function toSupplyShares(assets, market, rounding = "Up") {
|
|
312
353
|
return SharesMath.toShares(assets, market.totalSupplyAssets, market.totalSupplyShares, rounding);
|
|
313
354
|
}
|
|
314
355
|
MarketUtils.toSupplyShares = toSupplyShares;
|
|
356
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
315
357
|
function toBorrowAssets(shares, market, rounding = "Up") {
|
|
316
358
|
return SharesMath.toAssets(shares, market.totalBorrowAssets, market.totalBorrowShares, rounding);
|
|
317
359
|
}
|
|
318
360
|
MarketUtils.toBorrowAssets = toBorrowAssets;
|
|
361
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
319
362
|
function toBorrowShares(assets, market, rounding = "Down") {
|
|
320
363
|
return SharesMath.toShares(assets, market.totalBorrowAssets, market.totalBorrowShares, rounding);
|
|
321
364
|
}
|
package/lib/esm/market/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export var AdaptiveCurveIrmLib;
|
|
|
33
33
|
* @param x
|
|
34
34
|
*/
|
|
35
35
|
function wExp(x) {
|
|
36
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
36
37
|
x = BigInt(x);
|
|
37
38
|
// If x < ln(1e-18) then exp(x) < 1e-18 so it is rounded to zero.
|
|
38
39
|
if (x < AdaptiveCurveIrmLib.LN_WEI_INT)
|
|
@@ -53,9 +54,13 @@ export var AdaptiveCurveIrmLib;
|
|
|
53
54
|
return expR >> -q;
|
|
54
55
|
}
|
|
55
56
|
AdaptiveCurveIrmLib.wExp = wExp;
|
|
57
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
56
58
|
function getBorrowRate(startUtilization, startRateAtTarget, elapsed) {
|
|
59
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
57
60
|
startUtilization = BigInt(startUtilization);
|
|
61
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
58
62
|
startRateAtTarget = BigInt(startRateAtTarget);
|
|
63
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
59
64
|
elapsed = BigInt(elapsed);
|
|
60
65
|
const errNormFactor = startUtilization > AdaptiveCurveIrmLib.TARGET_UTILIZATION
|
|
61
66
|
? MathLib.WAD - AdaptiveCurveIrmLib.TARGET_UTILIZATION
|
|
@@ -80,6 +85,7 @@ export var AdaptiveCurveIrmLib;
|
|
|
80
85
|
}
|
|
81
86
|
else {
|
|
82
87
|
// Non negative because MIN_RATE_AT_TARGET > 0.
|
|
88
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
83
89
|
const _newRateAtTarget = (linearAdaptation) => MathLib.min(MathLib.max(MathLib.wMulDown(startRateAtTarget, wExp(linearAdaptation)), AdaptiveCurveIrmLib.MIN_RATE_AT_TARGET), AdaptiveCurveIrmLib.MAX_RATE_AT_TARGET);
|
|
84
90
|
// Formula of the average rate that should be returned to Morpho Blue:
|
|
85
91
|
// avg = 1/T * ∫_0^T curve(startRateAtTarget*exp(speed*x), err) dx
|
|
@@ -116,7 +122,9 @@ export var AdaptiveCurveIrmLib;
|
|
|
116
122
|
}
|
|
117
123
|
AdaptiveCurveIrmLib.getBorrowRate = getBorrowRate;
|
|
118
124
|
function getUtilizationAtBorrowRate(borrowRate, rateAtTarget) {
|
|
125
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
119
126
|
borrowRate = BigInt(borrowRate);
|
|
127
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
120
128
|
rateAtTarget = BigInt(rateAtTarget);
|
|
121
129
|
if (borrowRate >= rateAtTarget) {
|
|
122
130
|
const maxBorrowRate = MathLib.wMulDown(rateAtTarget, AdaptiveCurveIrmLib.CURVE_STEEPNESS);
|
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: {
|
|
@@ -44,6 +44,7 @@ export declare class PreLiquidationPosition extends AccrualPosition implements I
|
|
|
44
44
|
constructor({ preLiquidationParams, preLiquidation, preLiquidationOraclePrice, ...position }: IPreLiquidationPosition, market: IMarket);
|
|
45
45
|
get market(): Market;
|
|
46
46
|
protected get _lltv(): bigint;
|
|
47
|
+
accrueInterest(timestamp?: BigIntish): PreLiquidationPosition;
|
|
47
48
|
/**
|
|
48
49
|
* @inheritdoc `undefined` if the pre-liquidation's oracle reverts.
|
|
49
50
|
* `undefined` if it may be liquidatable on Morpho.
|
|
@@ -52,6 +52,14 @@ export class PreLiquidationPosition extends AccrualPosition {
|
|
|
52
52
|
get _lltv() {
|
|
53
53
|
return this._baseMarket.params.lltv;
|
|
54
54
|
}
|
|
55
|
+
accrueInterest(timestamp) {
|
|
56
|
+
return new PreLiquidationPosition({
|
|
57
|
+
...this,
|
|
58
|
+
preLiquidationParams: this.preLiquidationParams,
|
|
59
|
+
preLiquidation: this.preLiquidation,
|
|
60
|
+
preLiquidationOraclePrice: this.preLiquidationOraclePrice,
|
|
61
|
+
}, this._baseMarket.accrueInterest(timestamp));
|
|
62
|
+
}
|
|
55
63
|
/**
|
|
56
64
|
* @inheritdoc `undefined` if the pre-liquidation's oracle reverts.
|
|
57
65
|
* `undefined` if it may be liquidatable on Morpho.
|
|
@@ -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()
|