@morpho-org/bundler-sdk-viem 3.0.0-next.14 → 3.0.0-next.16
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 +24 -6
- package/package.json +6 -6
package/lib/actions.js
CHANGED
|
@@ -414,7 +414,10 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
414
414
|
}
|
|
415
415
|
case "Blue_Supply": {
|
|
416
416
|
const { id, assets = 0n, shares = 0n, onBehalf, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
|
|
417
|
-
|
|
417
|
+
// Accrue interest to calculate the expected share price.
|
|
418
|
+
const market = dataBefore
|
|
419
|
+
.getMarket(id)
|
|
420
|
+
.accrueInterest(dataBefore.block.timestamp);
|
|
418
421
|
const maxSharePrice = market.toSupplyAssets(MathLib.wToRay(MathLib.WAD + slippage));
|
|
419
422
|
actions.push({
|
|
420
423
|
type: "morphoSupply",
|
|
@@ -432,7 +435,10 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
432
435
|
}
|
|
433
436
|
case "Blue_Withdraw": {
|
|
434
437
|
const { id, assets = 0n, shares = 0n, receiver, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
|
|
435
|
-
|
|
438
|
+
// Accrue interest to calculate the expected share price.
|
|
439
|
+
const market = dataBefore
|
|
440
|
+
.getMarket(id)
|
|
441
|
+
.accrueInterest(dataBefore.block.timestamp);
|
|
436
442
|
const minSharePrice = market.toSupplyAssets(MathLib.wToRay(MathLib.WAD - slippage));
|
|
437
443
|
actions.push({
|
|
438
444
|
type: "morphoWithdraw",
|
|
@@ -449,7 +455,10 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
449
455
|
}
|
|
450
456
|
case "Blue_Borrow": {
|
|
451
457
|
const { id, assets = 0n, shares = 0n, receiver, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
|
|
452
|
-
|
|
458
|
+
// Accrue interest to calculate the expected share price.
|
|
459
|
+
const market = dataBefore
|
|
460
|
+
.getMarket(id)
|
|
461
|
+
.accrueInterest(dataBefore.block.timestamp);
|
|
453
462
|
const minSharePrice = market.toBorrowAssets(MathLib.wToRay(MathLib.WAD - slippage));
|
|
454
463
|
actions.push({
|
|
455
464
|
type: "morphoBorrow",
|
|
@@ -466,7 +475,10 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
466
475
|
}
|
|
467
476
|
case "Blue_Repay": {
|
|
468
477
|
const { id, assets = 0n, shares = 0n, onBehalf, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
|
|
469
|
-
|
|
478
|
+
// Accrue interest to calculate the expected share price.
|
|
479
|
+
const market = dataBefore
|
|
480
|
+
.getMarket(id)
|
|
481
|
+
.accrueInterest(dataBefore.block.timestamp);
|
|
470
482
|
const maxSharePrice = market.toBorrowAssets(MathLib.wToRay(MathLib.WAD + slippage));
|
|
471
483
|
actions.push({
|
|
472
484
|
type: "morphoRepay",
|
|
@@ -523,7 +535,10 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
523
535
|
}
|
|
524
536
|
case "MetaMorpho_Deposit": {
|
|
525
537
|
const { assets = 0n, shares = 0n, owner, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
|
|
526
|
-
|
|
538
|
+
// Accrue interest to calculate the expected share price.
|
|
539
|
+
const vault = dataBefore
|
|
540
|
+
.getAccrualVault(address)
|
|
541
|
+
.accrueInterest(dataBefore.block.timestamp);
|
|
527
542
|
const maxSharePrice = vault.toAssets(MathLib.wToRay(MathLib.WAD + slippage));
|
|
528
543
|
if (shares === 0n)
|
|
529
544
|
actions.push({
|
|
@@ -539,7 +554,10 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
539
554
|
}
|
|
540
555
|
case "MetaMorpho_Withdraw": {
|
|
541
556
|
const { assets = 0n, shares = 0n, owner, receiver, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
|
|
542
|
-
|
|
557
|
+
// Accrue interest to calculate the expected share price.
|
|
558
|
+
const vault = dataBefore
|
|
559
|
+
.getAccrualVault(address)
|
|
560
|
+
.accrueInterest(dataBefore.block.timestamp);
|
|
543
561
|
const minSharePrice = vault.toAssets(MathLib.wToRay(MathLib.WAD - slippage));
|
|
544
562
|
if (assets > 0n)
|
|
545
563
|
actions.push({
|
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.0.0-next.
|
|
4
|
+
"version": "3.0.0-next.16",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
],
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"viem": "^2.0.0",
|
|
23
|
+
"@morpho-org/blue-sdk-viem": "^2.2.2",
|
|
23
24
|
"@morpho-org/blue-sdk": "^2.3.2",
|
|
24
|
-
"@morpho-org/
|
|
25
|
-
"@morpho-org/simulation-sdk": "^2.1.4"
|
|
26
|
-
"@morpho-org/morpho-ts": "^2.2.0"
|
|
25
|
+
"@morpho-org/morpho-ts": "^2.2.0",
|
|
26
|
+
"@morpho-org/simulation-sdk": "^2.1.4"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@tanstack/query-core": "^5.62.16",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"typescript": "^5.7.2",
|
|
36
36
|
"viem": "^2.23.0",
|
|
37
37
|
"vitest": "^3.0.5",
|
|
38
|
-
"@morpho-org/blue-sdk-viem": "^3.0.0-next.6",
|
|
39
38
|
"@morpho-org/blue-sdk": "^2.3.2",
|
|
40
39
|
"@morpho-org/morpho-test": "^2.2.1",
|
|
41
40
|
"@morpho-org/morpho-ts": "^2.2.0",
|
|
42
41
|
"@morpho-org/simulation-sdk": "^2.1.4",
|
|
43
|
-
"@morpho-org/
|
|
42
|
+
"@morpho-org/blue-sdk-viem": "^2.2.2",
|
|
44
43
|
"@morpho-org/test": "^2.1.1",
|
|
44
|
+
"@morpho-org/simulation-sdk-wagmi": "^2.0.5",
|
|
45
45
|
"@morpho-org/test-wagmi": "^2.0.4"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|