@morpho-org/morpho-sdk 5.1.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -306,15 +306,12 @@ class MorphoBlue {
|
|
|
306
306
|
morpho_ts_1.Time.s.from.h(2n);
|
|
307
307
|
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
308
308
|
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
309
|
-
// Native funds
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
erc20Amount = borrowAssets - nativeAmount;
|
|
309
|
+
// Native funds the transfer first; the ERC-20 pulled is the remainder.
|
|
310
|
+
// When native covers the full (2h-forward-accrued, rounded-up) borrow
|
|
311
|
+
// assets, nothing is pulled as ERC-20 — the bundle wraps the native and
|
|
312
|
+
// skims any residual wNative back to the receiver. So a fully-native
|
|
313
|
+
// shares repay pulls no ERC-20 and emits no loan-token approval requirement.
|
|
314
|
+
erc20Amount = blue_sdk_1.MathLib.zeroFloorSub(borrowAssets, nativeAmount);
|
|
318
315
|
}
|
|
319
316
|
else {
|
|
320
317
|
// Assets mode is additive, like supply: repaid = amount + nativeAmount.
|
|
@@ -481,15 +478,12 @@ class MorphoBlue {
|
|
|
481
478
|
repayShares = shares;
|
|
482
479
|
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
483
480
|
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
484
|
-
// Native funds
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
erc20Amount = borrowAssets - nativeAmount;
|
|
481
|
+
// Native funds the transfer first; the ERC-20 pulled is the remainder.
|
|
482
|
+
// When native covers the full (2h-forward-accrued, rounded-up) borrow
|
|
483
|
+
// assets, nothing is pulled as ERC-20 — the bundle wraps the native and
|
|
484
|
+
// skims any residual wNative back to the receiver. So a fully-native
|
|
485
|
+
// shares repay pulls no ERC-20 and emits no loan-token approval requirement.
|
|
486
|
+
erc20Amount = blue_sdk_1.MathLib.zeroFloorSub(borrowAssets, nativeAmount);
|
|
493
487
|
}
|
|
494
488
|
else {
|
|
495
489
|
// Assets mode is additive, like supply: repaid = amount + nativeAmount.
|
package/lib/cjs/types/error.d.ts
CHANGED
|
@@ -270,6 +270,11 @@ export declare class TransferAmountNotEqualToAssetsError extends Error {
|
|
|
270
270
|
/**
|
|
271
271
|
* Thrown when a shares-mode repay's `nativeAmount` exceeds `transferAmount`, which
|
|
272
272
|
* would make the ERC-20 amount to pull (`transferAmount − nativeAmount`) negative.
|
|
273
|
+
*
|
|
274
|
+
* @deprecated No longer thrown. A shares-mode repay now accepts a `nativeAmount` that
|
|
275
|
+
* covers (or exceeds) the full repaid assets: it wraps the native, pulls no ERC-20, and
|
|
276
|
+
* the bundle skims the residual wNative back to the receiver. This class is retained for
|
|
277
|
+
* one minor for API stability and will be removed in the next major.
|
|
273
278
|
*/
|
|
274
279
|
export declare class NativeAmountExceedsTransferAmountError extends Error {
|
|
275
280
|
constructor(params: {
|
package/lib/cjs/types/error.js
CHANGED
|
@@ -386,6 +386,11 @@ exports.TransferAmountNotEqualToAssetsError = TransferAmountNotEqualToAssetsErro
|
|
|
386
386
|
/**
|
|
387
387
|
* Thrown when a shares-mode repay's `nativeAmount` exceeds `transferAmount`, which
|
|
388
388
|
* would make the ERC-20 amount to pull (`transferAmount − nativeAmount`) negative.
|
|
389
|
+
*
|
|
390
|
+
* @deprecated No longer thrown. A shares-mode repay now accepts a `nativeAmount` that
|
|
391
|
+
* covers (or exceeds) the full repaid assets: it wraps the native, pulls no ERC-20, and
|
|
392
|
+
* the bundle skims the residual wNative back to the receiver. This class is retained for
|
|
393
|
+
* one minor for API stability and will be removed in the next major.
|
|
389
394
|
*/
|
|
390
395
|
class NativeAmountExceedsTransferAmountError extends Error {
|
|
391
396
|
constructor(params) {
|
|
@@ -4,7 +4,7 @@ import { Time } from "@morpho-org/morpho-ts";
|
|
|
4
4
|
import { isAddressEqual } from "viem";
|
|
5
5
|
import { blueBorrow, blueRefinance, blueRepay, blueRepayWithdrawCollateral, blueSupply, blueSupplyCollateral, blueSupplyCollateralBorrow, blueWithdraw, blueWithdrawCollateral, getBlueAuthorizationRequirement, getGeneralAdapterRequirements, } from "../../actions/index.js";
|
|
6
6
|
import { computeMaxRepaySharePrice, computeMaxSupplySharePrice, computeMinBorrowSharePrice, computeMinWithdrawSharePrice, computeReallocations, validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateWithdrawAmount, validateWithdrawShares, } from "../../helpers/index.js";
|
|
7
|
-
import { BorrowAmountAndSharesExclusiveError, MarketIdMismatchError, MissingAccrualPositionError, MutuallyExclusiveRepayAmountsError, MutuallyExclusiveWithdrawAmountsError,
|
|
7
|
+
import { BorrowAmountAndSharesExclusiveError, MarketIdMismatchError, MissingAccrualPositionError, MutuallyExclusiveRepayAmountsError, MutuallyExclusiveWithdrawAmountsError, NegativeBorrowSharesError, NegativeNativeAmountError, NegativeSupplyAmountError, NonPositiveAssetAmountError, NonPositiveBorrowAmountError, NonPositiveRepayAmountError, NonPositiveWithdrawAmountError, NonPositiveWithdrawCollateralAmountError, RefinanceExceedsBorrowAssetsError, RefinanceExceedsBorrowSharesError, RefinanceExceedsCollateralError, RefinanceSameMarketError, RefinanceTokenMismatchError, selectRequirementSignatures, WithdrawExceedsCollateralError, ZeroCollateralAmountError, ZeroSupplyAmountError, } from "../../types/index.js";
|
|
8
8
|
import { ReallocationData } from "../reallocationData.js";
|
|
9
9
|
export class MorphoBlue {
|
|
10
10
|
client;
|
|
@@ -303,15 +303,12 @@ export class MorphoBlue {
|
|
|
303
303
|
Time.s.from.h(2n);
|
|
304
304
|
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
305
305
|
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
306
|
-
// Native funds
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
erc20Amount = borrowAssets - nativeAmount;
|
|
306
|
+
// Native funds the transfer first; the ERC-20 pulled is the remainder.
|
|
307
|
+
// When native covers the full (2h-forward-accrued, rounded-up) borrow
|
|
308
|
+
// assets, nothing is pulled as ERC-20 — the bundle wraps the native and
|
|
309
|
+
// skims any residual wNative back to the receiver. So a fully-native
|
|
310
|
+
// shares repay pulls no ERC-20 and emits no loan-token approval requirement.
|
|
311
|
+
erc20Amount = MathLib.zeroFloorSub(borrowAssets, nativeAmount);
|
|
315
312
|
}
|
|
316
313
|
else {
|
|
317
314
|
// Assets mode is additive, like supply: repaid = amount + nativeAmount.
|
|
@@ -478,15 +475,12 @@ export class MorphoBlue {
|
|
|
478
475
|
repayShares = shares;
|
|
479
476
|
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
480
477
|
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
481
|
-
// Native funds
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
erc20Amount = borrowAssets - nativeAmount;
|
|
478
|
+
// Native funds the transfer first; the ERC-20 pulled is the remainder.
|
|
479
|
+
// When native covers the full (2h-forward-accrued, rounded-up) borrow
|
|
480
|
+
// assets, nothing is pulled as ERC-20 — the bundle wraps the native and
|
|
481
|
+
// skims any residual wNative back to the receiver. So a fully-native
|
|
482
|
+
// shares repay pulls no ERC-20 and emits no loan-token approval requirement.
|
|
483
|
+
erc20Amount = MathLib.zeroFloorSub(borrowAssets, nativeAmount);
|
|
490
484
|
}
|
|
491
485
|
else {
|
|
492
486
|
// Assets mode is additive, like supply: repaid = amount + nativeAmount.
|
package/lib/esm/types/error.d.ts
CHANGED
|
@@ -270,6 +270,11 @@ export declare class TransferAmountNotEqualToAssetsError extends Error {
|
|
|
270
270
|
/**
|
|
271
271
|
* Thrown when a shares-mode repay's `nativeAmount` exceeds `transferAmount`, which
|
|
272
272
|
* would make the ERC-20 amount to pull (`transferAmount − nativeAmount`) negative.
|
|
273
|
+
*
|
|
274
|
+
* @deprecated No longer thrown. A shares-mode repay now accepts a `nativeAmount` that
|
|
275
|
+
* covers (or exceeds) the full repaid assets: it wraps the native, pulls no ERC-20, and
|
|
276
|
+
* the bundle skims the residual wNative back to the receiver. This class is retained for
|
|
277
|
+
* one minor for API stability and will be removed in the next major.
|
|
273
278
|
*/
|
|
274
279
|
export declare class NativeAmountExceedsTransferAmountError extends Error {
|
|
275
280
|
constructor(params: {
|
package/lib/esm/types/error.js
CHANGED
|
@@ -346,6 +346,11 @@ export class TransferAmountNotEqualToAssetsError extends Error {
|
|
|
346
346
|
/**
|
|
347
347
|
* Thrown when a shares-mode repay's `nativeAmount` exceeds `transferAmount`, which
|
|
348
348
|
* would make the ERC-20 amount to pull (`transferAmount − nativeAmount`) negative.
|
|
349
|
+
*
|
|
350
|
+
* @deprecated No longer thrown. A shares-mode repay now accepts a `nativeAmount` that
|
|
351
|
+
* covers (or exceeds) the full repaid assets: it wraps the native, pulls no ERC-20, and
|
|
352
|
+
* the bundle skims the residual wNative back to the receiver. This class is retained for
|
|
353
|
+
* one minor for API stability and will be removed in the next major.
|
|
349
354
|
*/
|
|
350
355
|
export class NativeAmountExceedsTransferAmountError extends Error {
|
|
351
356
|
constructor(params) {
|
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.
|
|
4
|
+
"version": "5.2.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Foulks-Plb <https://x.com/FoulkPlb>"
|
|
@@ -137,9 +137,9 @@
|
|
|
137
137
|
],
|
|
138
138
|
"dependencies": {
|
|
139
139
|
"zod": "^4.4.3",
|
|
140
|
-
"@morpho-org/blue-sdk": "^6.3.
|
|
141
|
-
"@morpho-org/
|
|
142
|
-
"@morpho-org/
|
|
140
|
+
"@morpho-org/blue-sdk": "^6.3.1",
|
|
141
|
+
"@morpho-org/blue-sdk-viem": "^5.2.0",
|
|
142
|
+
"@morpho-org/morpho-ts": "^2.8.0"
|
|
143
143
|
},
|
|
144
144
|
"peerDependencies": {
|
|
145
145
|
"viem": "^2.0.0"
|