@morpho-org/bundler-sdk-viem 3.4.0-next.0 → 4.0.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.
- package/lib/abis.d.ts +0 -6167
- package/lib/abis.js +1 -889
- package/lib/operations.js +10 -27
- package/package.json +12 -12
package/lib/operations.js
CHANGED
|
@@ -45,7 +45,6 @@ const populateInputTransfer = ({ address, args: { amount, from } }, data, { hasS
|
|
|
45
45
|
// Try using simple permit.
|
|
46
46
|
const useSimplePermit = erc2612Nonce != null &&
|
|
47
47
|
(data.tryGetVault(address) != null || // MetaMorpho vaults implement EIP-2612.
|
|
48
|
-
data.tryGetVaultV2(address) != null || // Vaults V2 implement EIP-2612.
|
|
49
48
|
hasSimplePermit);
|
|
50
49
|
const useSimpleTransfer = permit2 == null ||
|
|
51
50
|
// Token is permissioned and Permit2 may not be authorized so Permit2 cannot be used.
|
|
@@ -181,12 +180,10 @@ const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
181
180
|
if (isErc20Wrapper)
|
|
182
181
|
break;
|
|
183
182
|
case "MetaMorpho_Deposit":
|
|
184
|
-
case "MetaMorpho_Withdraw":
|
|
183
|
+
case "MetaMorpho_Withdraw":
|
|
185
184
|
// Only if sender is owner otherwise the owner would be lost.
|
|
186
185
|
if (draft.args.owner === sender)
|
|
187
186
|
draft.args.owner = generalAdapter1;
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
187
|
}
|
|
191
188
|
// Redirect operation targets.
|
|
192
189
|
switch (draft.type) {
|
|
@@ -492,15 +489,9 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
|
|
|
492
489
|
let steps = (0, exports.simulateBundlerOperations)(operations, startData);
|
|
493
490
|
// Redirect MetaMorpho deposits.
|
|
494
491
|
operations.forEach((operation, index) => {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
return;
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
default:
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
492
|
+
if (operation.type !== "MetaMorpho_Deposit" ||
|
|
493
|
+
operation.args.owner !== generalAdapter1)
|
|
494
|
+
return;
|
|
504
495
|
const token = operation.address;
|
|
505
496
|
// shares are not defined when depositing assets, so we rely on simulation steps.
|
|
506
497
|
const shares = steps[index + 1].getHolding(generalAdapter1, token).balance -
|
|
@@ -510,10 +501,9 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
|
|
|
510
501
|
.some((step) => step.getHolding(generalAdapter1, token).balance < shares))
|
|
511
502
|
// If the bundler's balance is at least once lower than assets, the bundler does need these assets.
|
|
512
503
|
return;
|
|
513
|
-
|
|
514
|
-
operation.args.owner = receiver;
|
|
504
|
+
operation.args.owner = receiver;
|
|
515
505
|
});
|
|
516
|
-
// Redirect borrows, withdrawals
|
|
506
|
+
// Redirect borrows, withdrawals & MetaMorpho withdrawals.
|
|
517
507
|
operations.forEach((operation, index) => {
|
|
518
508
|
let token;
|
|
519
509
|
switch (operation.type) {
|
|
@@ -544,15 +534,9 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
|
|
|
544
534
|
});
|
|
545
535
|
// Simplify Erc20_Transfer(sender = bundler, to = bundler) + MetaMorpho_Withdraw(owner = bundler) = MetaMorpho_Withdraw(owner = from).
|
|
546
536
|
operations.forEach((operation, index) => {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
return;
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
default:
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
537
|
+
if (operation.type !== "MetaMorpho_Withdraw" ||
|
|
538
|
+
operation.args.owner !== generalAdapter1)
|
|
539
|
+
return;
|
|
556
540
|
// shares are not defined when using assets, so we rely on simulation steps.
|
|
557
541
|
const shares = steps[index].getHolding(generalAdapter1, operation.address).balance -
|
|
558
542
|
steps[index + 1].getHolding(generalAdapter1, operation.address).balance;
|
|
@@ -565,8 +549,7 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
|
|
|
565
549
|
return;
|
|
566
550
|
const inputTransfer = operations[inputTransferIndex];
|
|
567
551
|
inputTransfer.args.amount -= shares;
|
|
568
|
-
|
|
569
|
-
operation.args.owner = inputTransfer.args.from;
|
|
552
|
+
operation.args.owner = inputTransfer.args.from;
|
|
570
553
|
});
|
|
571
554
|
// Filter out useless input transfers.
|
|
572
555
|
operations = operations.filter((operation, index) => {
|
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": "
|
|
4
|
+
"version": "4.0.0",
|
|
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-viem": "^
|
|
23
|
-
"@morpho-org/
|
|
24
|
-
"@morpho-org/
|
|
25
|
-
"@morpho-org/
|
|
22
|
+
"@morpho-org/blue-sdk-viem": "^4.0.0",
|
|
23
|
+
"@morpho-org/simulation-sdk": "^3.1.3",
|
|
24
|
+
"@morpho-org/blue-sdk": "^5.0.0",
|
|
25
|
+
"@morpho-org/morpho-ts": "^2.4.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@tanstack/query-core": "^5.62.16",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"@types/lodash": "^4.17.12",
|
|
33
33
|
"lodash": "^4.17.21",
|
|
34
34
|
"typescript": "^5.7.2",
|
|
35
|
-
"viem": "^2.
|
|
35
|
+
"viem": "^2.23.0",
|
|
36
36
|
"vitest": "^3.0.5",
|
|
37
|
-
"@morpho-org/blue-sdk": "^
|
|
38
|
-
"@morpho-org/blue-sdk-viem": "^
|
|
39
|
-
"@morpho-org/morpho-ts": "^2.4.2",
|
|
37
|
+
"@morpho-org/blue-sdk": "^5.0.0",
|
|
38
|
+
"@morpho-org/blue-sdk-viem": "^4.0.0",
|
|
40
39
|
"@morpho-org/morpho-test": "^2.4.0",
|
|
41
|
-
"@morpho-org/
|
|
42
|
-
"@morpho-org/
|
|
43
|
-
"@morpho-org/simulation-sdk-wagmi": "^3.
|
|
40
|
+
"@morpho-org/morpho-ts": "^2.4.3",
|
|
41
|
+
"@morpho-org/simulation-sdk": "^3.1.3",
|
|
42
|
+
"@morpho-org/simulation-sdk-wagmi": "^3.0.3",
|
|
43
|
+
"@morpho-org/test": "^2.6.0",
|
|
44
44
|
"@morpho-org/test-wagmi": "^2.0.4"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|