@morpho-org/morpho-sdk 5.3.0 → 5.3.1
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.
|
@@ -317,7 +317,10 @@ class MorphoBlue {
|
|
|
317
317
|
let repayAssets;
|
|
318
318
|
let repayShares;
|
|
319
319
|
let erc20Amount;
|
|
320
|
-
|
|
320
|
+
// Forward-accrue (2h) before deriving `maxSharePrice` (both modes): on-chain `morphoRepay` accrues `lastUpdate → execution`, so an un-accrued bound reverts on quiet markets.
|
|
321
|
+
const accrualTimestamp = blue_sdk_1.MathLib.max(morpho_ts_1.Time.timestamp(), positionData.market.lastUpdate) +
|
|
322
|
+
morpho_ts_1.Time.s.from.h(2n);
|
|
323
|
+
const marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
321
324
|
if ("shares" in params) {
|
|
322
325
|
(0, index_js_2.validateRepayShares)({
|
|
323
326
|
positionData,
|
|
@@ -326,11 +329,6 @@ class MorphoBlue {
|
|
|
326
329
|
});
|
|
327
330
|
repayAssets = 0n;
|
|
328
331
|
repayShares = shares;
|
|
329
|
-
// 2h forward accrual upper-bounds the on-chain repay price; bundle
|
|
330
|
-
// skims residual back to the receiver.
|
|
331
|
-
const accrualTimestamp = blue_sdk_1.MathLib.max(morpho_ts_1.Time.timestamp(), positionData.market.lastUpdate) +
|
|
332
|
-
morpho_ts_1.Time.s.from.h(2n);
|
|
333
|
-
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
334
332
|
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
335
333
|
// Native funds the transfer first; the ERC-20 pulled is the remainder.
|
|
336
334
|
// When native covers the full (2h-forward-accrued, rounded-up) borrow
|
|
@@ -349,7 +347,6 @@ class MorphoBlue {
|
|
|
349
347
|
});
|
|
350
348
|
repayShares = 0n;
|
|
351
349
|
erc20Amount = amount;
|
|
352
|
-
marketForRepay = positionData.market;
|
|
353
350
|
}
|
|
354
351
|
const maxSharePrice = (0, index_js_2.computeMaxRepaySharePrice)({
|
|
355
352
|
repayAssets,
|
|
@@ -493,11 +490,10 @@ class MorphoBlue {
|
|
|
493
490
|
let repayAssets;
|
|
494
491
|
let repayShares;
|
|
495
492
|
let erc20Amount;
|
|
496
|
-
|
|
497
|
-
// 2h forward accrual upper-bounds the on-chain repay price (shares
|
|
498
|
-
// mode) and the post-repay health check; bundle skims residual back.
|
|
493
|
+
// Forward-accrue (2h) for `maxSharePrice` (both modes) and the post-repay health check: on-chain `morphoRepay` accrues `lastUpdate → execution`, so an un-accrued bound reverts on quiet markets.
|
|
499
494
|
const accrualTimestamp = blue_sdk_1.MathLib.max(morpho_ts_1.Time.timestamp(), positionData.market.lastUpdate) +
|
|
500
495
|
morpho_ts_1.Time.s.from.h(2n);
|
|
496
|
+
const marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
501
497
|
if ("shares" in params) {
|
|
502
498
|
(0, index_js_2.validateRepayShares)({
|
|
503
499
|
positionData,
|
|
@@ -506,7 +502,6 @@ class MorphoBlue {
|
|
|
506
502
|
});
|
|
507
503
|
repayAssets = 0n;
|
|
508
504
|
repayShares = shares;
|
|
509
|
-
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
510
505
|
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
511
506
|
// Native funds the transfer first; the ERC-20 pulled is the remainder.
|
|
512
507
|
// When native covers the full (2h-forward-accrued, rounded-up) borrow
|
|
@@ -525,7 +520,6 @@ class MorphoBlue {
|
|
|
525
520
|
});
|
|
526
521
|
repayShares = 0n;
|
|
527
522
|
erc20Amount = amount;
|
|
528
|
-
marketForRepay = positionData.market;
|
|
529
523
|
}
|
|
530
524
|
if (withdrawAmount > positionData.collateral) {
|
|
531
525
|
throw new index_js_3.WithdrawExceedsCollateralError({
|
|
@@ -314,7 +314,10 @@ export class MorphoBlue {
|
|
|
314
314
|
let repayAssets;
|
|
315
315
|
let repayShares;
|
|
316
316
|
let erc20Amount;
|
|
317
|
-
|
|
317
|
+
// Forward-accrue (2h) before deriving `maxSharePrice` (both modes): on-chain `morphoRepay` accrues `lastUpdate → execution`, so an un-accrued bound reverts on quiet markets.
|
|
318
|
+
const accrualTimestamp = MathLib.max(Time.timestamp(), positionData.market.lastUpdate) +
|
|
319
|
+
Time.s.from.h(2n);
|
|
320
|
+
const marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
318
321
|
if ("shares" in params) {
|
|
319
322
|
validateRepayShares({
|
|
320
323
|
positionData,
|
|
@@ -323,11 +326,6 @@ export class MorphoBlue {
|
|
|
323
326
|
});
|
|
324
327
|
repayAssets = 0n;
|
|
325
328
|
repayShares = shares;
|
|
326
|
-
// 2h forward accrual upper-bounds the on-chain repay price; bundle
|
|
327
|
-
// skims residual back to the receiver.
|
|
328
|
-
const accrualTimestamp = MathLib.max(Time.timestamp(), positionData.market.lastUpdate) +
|
|
329
|
-
Time.s.from.h(2n);
|
|
330
|
-
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
331
329
|
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
332
330
|
// Native funds the transfer first; the ERC-20 pulled is the remainder.
|
|
333
331
|
// When native covers the full (2h-forward-accrued, rounded-up) borrow
|
|
@@ -346,7 +344,6 @@ export class MorphoBlue {
|
|
|
346
344
|
});
|
|
347
345
|
repayShares = 0n;
|
|
348
346
|
erc20Amount = amount;
|
|
349
|
-
marketForRepay = positionData.market;
|
|
350
347
|
}
|
|
351
348
|
const maxSharePrice = computeMaxRepaySharePrice({
|
|
352
349
|
repayAssets,
|
|
@@ -490,11 +487,10 @@ export class MorphoBlue {
|
|
|
490
487
|
let repayAssets;
|
|
491
488
|
let repayShares;
|
|
492
489
|
let erc20Amount;
|
|
493
|
-
|
|
494
|
-
// 2h forward accrual upper-bounds the on-chain repay price (shares
|
|
495
|
-
// mode) and the post-repay health check; bundle skims residual back.
|
|
490
|
+
// Forward-accrue (2h) for `maxSharePrice` (both modes) and the post-repay health check: on-chain `morphoRepay` accrues `lastUpdate → execution`, so an un-accrued bound reverts on quiet markets.
|
|
496
491
|
const accrualTimestamp = MathLib.max(Time.timestamp(), positionData.market.lastUpdate) +
|
|
497
492
|
Time.s.from.h(2n);
|
|
493
|
+
const marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
498
494
|
if ("shares" in params) {
|
|
499
495
|
validateRepayShares({
|
|
500
496
|
positionData,
|
|
@@ -503,7 +499,6 @@ export class MorphoBlue {
|
|
|
503
499
|
});
|
|
504
500
|
repayAssets = 0n;
|
|
505
501
|
repayShares = shares;
|
|
506
|
-
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
507
502
|
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
508
503
|
// Native funds the transfer first; the ERC-20 pulled is the remainder.
|
|
509
504
|
// When native covers the full (2h-forward-accrued, rounded-up) borrow
|
|
@@ -522,7 +517,6 @@ export class MorphoBlue {
|
|
|
522
517
|
});
|
|
523
518
|
repayShares = 0n;
|
|
524
519
|
erc20Amount = amount;
|
|
525
|
-
marketForRepay = positionData.market;
|
|
526
520
|
}
|
|
527
521
|
if (withdrawAmount > positionData.collateral) {
|
|
528
522
|
throw new WithdrawExceedsCollateralError({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/morpho-sdk",
|
|
3
3
|
"description": "Abstraction layer for Morpho's complexity.",
|
|
4
|
-
"version": "5.3.
|
|
4
|
+
"version": "5.3.1",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Foulks-Plb <https://x.com/FoulkPlb>"
|
|
@@ -147,8 +147,8 @@
|
|
|
147
147
|
"zod": "^4.4.3",
|
|
148
148
|
"@morpho-org/blue-sdk": "^6.3.1",
|
|
149
149
|
"@morpho-org/blue-sdk-viem": "^5.2.0",
|
|
150
|
-
"@morpho-org/
|
|
151
|
-
"@morpho-org/
|
|
150
|
+
"@morpho-org/midnight-sdk": "^1.2.0",
|
|
151
|
+
"@morpho-org/morpho-ts": "^2.8.0"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
154
154
|
"viem": "^2.0.0"
|