@morpho-org/bundler-sdk-viem 3.2.0-next.0 → 3.2.0-next.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.
- package/lib/actions.js +20 -10
- package/package.json +9 -9
package/lib/actions.js
CHANGED
|
@@ -437,7 +437,8 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
437
437
|
const market = dataBefore
|
|
438
438
|
.getMarket(id)
|
|
439
439
|
.accrueInterest(dataBefore.block.timestamp);
|
|
440
|
-
const
|
|
440
|
+
const { assets: suppliedAssets, shares: suppliedShares } = market.supply(assets, shares);
|
|
441
|
+
const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(suppliedAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), suppliedShares);
|
|
441
442
|
actions.push({
|
|
442
443
|
type: "morphoSupply",
|
|
443
444
|
args: [
|
|
@@ -458,7 +459,8 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
458
459
|
const market = dataBefore
|
|
459
460
|
.getMarket(id)
|
|
460
461
|
.accrueInterest(dataBefore.block.timestamp);
|
|
461
|
-
const
|
|
462
|
+
const { assets: withdrawnAssets, shares: withdrawnShares } = market.withdraw(assets, shares);
|
|
463
|
+
const minSharePrice = blue_sdk_1.MathLib.mulDivUp(withdrawnAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage), withdrawnShares);
|
|
462
464
|
actions.push({
|
|
463
465
|
type: "morphoWithdraw",
|
|
464
466
|
args: [
|
|
@@ -478,7 +480,8 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
478
480
|
const market = dataBefore
|
|
479
481
|
.getMarket(id)
|
|
480
482
|
.accrueInterest(dataBefore.block.timestamp);
|
|
481
|
-
const
|
|
483
|
+
const { assets: borrowedAssets, shares: borrowedShares } = market.borrow(assets, shares);
|
|
484
|
+
const minSharePrice = blue_sdk_1.MathLib.mulDivUp(borrowedAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage), borrowedShares);
|
|
482
485
|
actions.push({
|
|
483
486
|
type: "morphoBorrow",
|
|
484
487
|
args: [
|
|
@@ -498,7 +501,8 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
498
501
|
const market = dataBefore
|
|
499
502
|
.getMarket(id)
|
|
500
503
|
.accrueInterest(dataBefore.block.timestamp);
|
|
501
|
-
const
|
|
504
|
+
const { assets: repaidAssets, shares: repaidShares } = market.repay(assets, shares);
|
|
505
|
+
const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(repaidAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), repaidShares);
|
|
502
506
|
actions.push({
|
|
503
507
|
type: "morphoRepay",
|
|
504
508
|
args: [
|
|
@@ -558,8 +562,8 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
558
562
|
const vault = dataBefore
|
|
559
563
|
.getAccrualVault(operation.address)
|
|
560
564
|
.accrueInterest(dataBefore.block.timestamp);
|
|
561
|
-
|
|
562
|
-
|
|
565
|
+
if (shares === 0n) {
|
|
566
|
+
const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(assets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), vault.toShares(assets));
|
|
563
567
|
actions.push({
|
|
564
568
|
type: "erc4626Deposit",
|
|
565
569
|
args: [
|
|
@@ -570,7 +574,9 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
570
574
|
operation.skipRevert,
|
|
571
575
|
],
|
|
572
576
|
});
|
|
573
|
-
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(vault.toAssets(shares), blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), shares);
|
|
574
580
|
actions.push({
|
|
575
581
|
type: "erc4626Mint",
|
|
576
582
|
args: [
|
|
@@ -581,6 +587,7 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
581
587
|
operation.skipRevert,
|
|
582
588
|
],
|
|
583
589
|
});
|
|
590
|
+
}
|
|
584
591
|
break;
|
|
585
592
|
}
|
|
586
593
|
case "MetaMorpho_Withdraw": {
|
|
@@ -589,8 +596,8 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
589
596
|
const vault = dataBefore
|
|
590
597
|
.getAccrualVault(operation.address)
|
|
591
598
|
.accrueInterest(dataBefore.block.timestamp);
|
|
592
|
-
|
|
593
|
-
|
|
599
|
+
if (shares === 0n) {
|
|
600
|
+
const minSharePrice = blue_sdk_1.MathLib.mulDivUp(assets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage), vault.toShares(assets));
|
|
594
601
|
actions.push({
|
|
595
602
|
type: "erc4626Withdraw",
|
|
596
603
|
args: [
|
|
@@ -602,7 +609,9 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
602
609
|
operation.skipRevert,
|
|
603
610
|
],
|
|
604
611
|
});
|
|
605
|
-
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
const minSharePrice = blue_sdk_1.MathLib.mulDivUp(vault.toAssets(shares), blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage), shares);
|
|
606
615
|
actions.push({
|
|
607
616
|
type: "erc4626Redeem",
|
|
608
617
|
args: [
|
|
@@ -614,6 +623,7 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
614
623
|
operation.skipRevert,
|
|
615
624
|
],
|
|
616
625
|
});
|
|
626
|
+
}
|
|
617
627
|
break;
|
|
618
628
|
}
|
|
619
629
|
case "MetaMorpho_PublicReallocate": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/bundler-sdk-viem",
|
|
3
3
|
"description": "Viem-based extension of `@morpho-org/simulation-sdk` that exports utilities to transform simple interactions on Morpho (such as `Blue_Borrow`) and Morpho Vaults (such as `MetaMorpho_Deposit`) into the required bundles (with ERC20 approvals, transfers, etc) to submit to the bundler onchain.",
|
|
4
|
-
"version": "3.2.0-next.
|
|
4
|
+
"version": "3.2.0-next.1",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
],
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"viem": "^2.0.0",
|
|
22
|
-
"@morpho-org/blue-sdk": "^
|
|
22
|
+
"@morpho-org/blue-sdk": "^3.0.6",
|
|
23
23
|
"@morpho-org/blue-sdk-viem": "^3.0.0",
|
|
24
|
-
"@morpho-org/
|
|
25
|
-
"@morpho-org/
|
|
24
|
+
"@morpho-org/simulation-sdk": "^3.0.1",
|
|
25
|
+
"@morpho-org/morpho-ts": "^2.3.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@tanstack/query-core": "^5.62.16",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"typescript": "^5.7.2",
|
|
35
35
|
"viem": "^2.23.0",
|
|
36
36
|
"vitest": "^3.0.5",
|
|
37
|
-
"@morpho-org/blue-sdk": "^4.0.0-next.0",
|
|
38
37
|
"@morpho-org/blue-sdk-viem": "^3.0.0",
|
|
39
|
-
"@morpho-org/morpho-ts": "^2.4.0-next.0",
|
|
40
|
-
"@morpho-org/simulation-sdk": "^3.1.0-next.0",
|
|
41
38
|
"@morpho-org/morpho-test": "^2.3.0",
|
|
42
|
-
"@morpho-org/
|
|
43
|
-
"@morpho-org/
|
|
39
|
+
"@morpho-org/morpho-ts": "^2.3.0",
|
|
40
|
+
"@morpho-org/simulation-sdk": "^3.0.1",
|
|
41
|
+
"@morpho-org/blue-sdk": "^3.0.6",
|
|
42
|
+
"@morpho-org/simulation-sdk-wagmi": "^3.0.1",
|
|
43
|
+
"@morpho-org/test": "^2.1.3",
|
|
44
44
|
"@morpho-org/test-wagmi": "^2.0.4"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|