@morpho-org/bundler-sdk-viem 2.2.1-next.0 → 3.0.0-next.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/BundlerAction.d.ts +177 -107
- package/lib/BundlerAction.js +1032 -403
- package/lib/abis.d.ts +3062 -0
- package/lib/abis.js +2095 -0
- package/lib/actions.d.ts +0 -1
- package/lib/actions.js +92 -163
- package/lib/errors.d.ts +4 -1
- package/lib/errors.js +6 -0
- package/lib/operations.js +61 -53
- package/lib/types/actions.d.ts +73 -27
- package/package.json +11 -11
package/lib/operations.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { DEFAULT_SLIPPAGE_TOLERANCE, MarketUtils, MathLib, NATIVE_ADDRESS, erc20WrapperTokens, getChainAddresses, getUnwrappedToken, permissionedBackedTokens, permissionedWrapperTokens, } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { bigIntComparator, entries, getLast, getValue, keys, } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { handleOperation, handleOperations, produceImmutable, simulateOperation, simulateOperations, } from "@morpho-org/simulation-sdk";
|
|
4
|
-
import { maxUint256 } from "viem";
|
|
4
|
+
import { isAddressEqual, maxUint256 } from "viem";
|
|
5
5
|
import { BundlerErrors } from "./errors.js";
|
|
6
6
|
/**
|
|
7
7
|
* The default target utilization above which the shared liquidity algorithm is triggered (scaled by WAD).
|
|
8
8
|
*/
|
|
9
9
|
export const DEFAULT_SUPPLY_TARGET_UTILIZATION = 905000000000000000n;
|
|
10
10
|
export const populateInputTransfer = ({ address, args: { amount, from } }, data, { hasSimplePermit = false } = {}) => {
|
|
11
|
-
const {
|
|
11
|
+
const { bundler3: { bundler3, generalAdapter1 }, permit2, } = getChainAddresses(data.chainId);
|
|
12
12
|
// If native token, it is expected to be sent along as call value.
|
|
13
13
|
if (address === NATIVE_ADDRESS)
|
|
14
14
|
return [
|
|
@@ -19,22 +19,22 @@ export const populateInputTransfer = ({ address, args: { amount, from } }, data,
|
|
|
19
19
|
args: {
|
|
20
20
|
amount,
|
|
21
21
|
from,
|
|
22
|
-
to:
|
|
22
|
+
to: generalAdapter1,
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
];
|
|
26
26
|
const { erc20Allowances, permit2BundlerAllowance, erc2612Nonce } = data.getHolding(from, address);
|
|
27
27
|
// ERC20 allowance to the bundler is enough, consume it.
|
|
28
|
-
if (erc20Allowances.
|
|
28
|
+
if (erc20Allowances["bundler3.generalAdapter1"] >= amount)
|
|
29
29
|
return [
|
|
30
30
|
{
|
|
31
31
|
type: "Erc20_Transfer",
|
|
32
|
-
sender:
|
|
32
|
+
sender: generalAdapter1,
|
|
33
33
|
address,
|
|
34
34
|
args: {
|
|
35
35
|
amount,
|
|
36
36
|
from,
|
|
37
|
-
to:
|
|
37
|
+
to: generalAdapter1,
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
];
|
|
@@ -52,7 +52,7 @@ export const populateInputTransfer = ({ address, args: { amount, from } }, data,
|
|
|
52
52
|
address,
|
|
53
53
|
args: {
|
|
54
54
|
amount,
|
|
55
|
-
spender:
|
|
55
|
+
spender: generalAdapter1,
|
|
56
56
|
nonce: erc2612Nonce,
|
|
57
57
|
},
|
|
58
58
|
});
|
|
@@ -64,18 +64,18 @@ export const populateInputTransfer = ({ address, args: { amount, from } }, data,
|
|
|
64
64
|
address,
|
|
65
65
|
args: {
|
|
66
66
|
amount,
|
|
67
|
-
spender:
|
|
67
|
+
spender: generalAdapter1,
|
|
68
68
|
},
|
|
69
69
|
});
|
|
70
70
|
if (useSimplePermit || isPermissioned)
|
|
71
71
|
operations.push({
|
|
72
72
|
type: "Erc20_Transfer",
|
|
73
|
-
sender:
|
|
73
|
+
sender: generalAdapter1,
|
|
74
74
|
address,
|
|
75
75
|
args: {
|
|
76
76
|
amount,
|
|
77
77
|
from,
|
|
78
|
-
to:
|
|
78
|
+
to: generalAdapter1,
|
|
79
79
|
},
|
|
80
80
|
});
|
|
81
81
|
// Simple permit is not supported and token is not permissioned: fallback to Permit2.
|
|
@@ -104,12 +104,12 @@ export const populateInputTransfer = ({ address, args: { amount, from } }, data,
|
|
|
104
104
|
});
|
|
105
105
|
operations.push({
|
|
106
106
|
type: "Erc20_Transfer2",
|
|
107
|
-
sender:
|
|
107
|
+
sender: bundler3,
|
|
108
108
|
address,
|
|
109
109
|
args: {
|
|
110
110
|
amount,
|
|
111
111
|
from,
|
|
112
|
-
to:
|
|
112
|
+
to: generalAdapter1,
|
|
113
113
|
},
|
|
114
114
|
});
|
|
115
115
|
}
|
|
@@ -130,7 +130,7 @@ export const populateInputTransfer = ({ address, args: { amount, from } }, data,
|
|
|
130
130
|
*/
|
|
131
131
|
export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
132
132
|
const { sender } = inputOperation;
|
|
133
|
-
const { morpho,
|
|
133
|
+
const { morpho, bundler3: { bundler3, generalAdapter1 }, } = getChainAddresses(data.chainId);
|
|
134
134
|
const { withSimplePermit = new Set(), publicAllocatorOptions, getRequirementOperations, } = options;
|
|
135
135
|
const operations = [];
|
|
136
136
|
const wrappedToken = inputOperation.type === "Erc20_Wrap"
|
|
@@ -140,7 +140,7 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
140
140
|
erc20WrapperTokens[data.chainId].has(wrappedToken.address);
|
|
141
141
|
// Transform input operation to act on behalf of the sender, via the bundler.
|
|
142
142
|
const mainOperation = produceImmutable(inputOperation, (draft) => {
|
|
143
|
-
draft.sender =
|
|
143
|
+
draft.sender = generalAdapter1;
|
|
144
144
|
// Redirect MetaMorpho operation owner.
|
|
145
145
|
switch (draft.type) {
|
|
146
146
|
case "Erc20_Wrap": {
|
|
@@ -154,7 +154,7 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
154
154
|
case "MetaMorpho_Withdraw":
|
|
155
155
|
// Only if sender is owner otherwise the owner would be lost.
|
|
156
156
|
if (draft.args.owner === sender)
|
|
157
|
-
draft.args.owner =
|
|
157
|
+
draft.args.owner = generalAdapter1;
|
|
158
158
|
}
|
|
159
159
|
// Redirect operation targets.
|
|
160
160
|
switch (draft.type) {
|
|
@@ -165,7 +165,7 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
165
165
|
case "MetaMorpho_Withdraw":
|
|
166
166
|
// Only if sender is receiver otherwise the receiver would be lost.
|
|
167
167
|
if (draft.args.receiver === sender)
|
|
168
|
-
draft.args.receiver =
|
|
168
|
+
draft.args.receiver = generalAdapter1;
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
const needsBundlerAuthorization = mainOperation.type === "Blue_Borrow" ||
|
|
@@ -174,7 +174,7 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
174
174
|
if (needsBundlerAuthorization && !data.getUser(sender).isBundlerAuthorized)
|
|
175
175
|
operations.push({
|
|
176
176
|
type: "Blue_SetAuthorization",
|
|
177
|
-
sender:
|
|
177
|
+
sender: bundler3,
|
|
178
178
|
address: morpho,
|
|
179
179
|
args: {
|
|
180
180
|
owner: sender,
|
|
@@ -238,6 +238,9 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
238
238
|
requiredAssets -= withdrawal.assets;
|
|
239
239
|
vaultReallocations.push(withdrawal);
|
|
240
240
|
}
|
|
241
|
+
// TODO: we know there are no unwrap native in the middle
|
|
242
|
+
// of the bundle so we are certain we need to add an input transfer.
|
|
243
|
+
// This could be handled by `simulateRequiredTokenAmounts` below.
|
|
241
244
|
const fees = keys(reallocations).reduce((total, vault) => total + data.getVault(vault).publicAllocatorConfig.fee, 0n);
|
|
242
245
|
// Native input transfer of all fees.
|
|
243
246
|
if (fees > 0n)
|
|
@@ -248,14 +251,14 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
248
251
|
args: {
|
|
249
252
|
amount: fees,
|
|
250
253
|
from: sender,
|
|
251
|
-
to:
|
|
254
|
+
to: bundler3,
|
|
252
255
|
},
|
|
253
256
|
});
|
|
254
257
|
}
|
|
255
258
|
// Reallocate each vault.
|
|
256
259
|
operations.push(...Object.entries(reallocations).map(([vault, vaultWithdrawals]) => ({
|
|
257
260
|
type: "MetaMorpho_PublicReallocate",
|
|
258
|
-
sender:
|
|
261
|
+
sender: bundler3,
|
|
259
262
|
address: vault,
|
|
260
263
|
args: {
|
|
261
264
|
// Reallocation withdrawals must be sorted by market id in ascending alphabetical order.
|
|
@@ -296,7 +299,7 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
296
299
|
mainOperation.args.assets === maxUint256) ||
|
|
297
300
|
("shares" in mainOperation.args && mainOperation.args.shares === maxUint256)) {
|
|
298
301
|
if (mainOperation.type === "MetaMorpho_Withdraw")
|
|
299
|
-
mainOperation.args.owner =
|
|
302
|
+
mainOperation.args.owner = generalAdapter1;
|
|
300
303
|
return allOperations;
|
|
301
304
|
}
|
|
302
305
|
const requirementOperations = getRequirementOperations?.(requiredTokenAmounts) ?? [];
|
|
@@ -307,12 +310,12 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
307
310
|
requiredTokenAmounts.forEach(({ token, required }) => {
|
|
308
311
|
requirementOperations.push(...populateInputTransfer({
|
|
309
312
|
type: "Erc20_Transfer",
|
|
310
|
-
sender:
|
|
313
|
+
sender: generalAdapter1,
|
|
311
314
|
address: token,
|
|
312
315
|
args: {
|
|
313
316
|
amount: required,
|
|
314
317
|
from: sender,
|
|
315
|
-
to:
|
|
318
|
+
to: generalAdapter1,
|
|
316
319
|
},
|
|
317
320
|
}, data, { hasSimplePermit: withSimplePermit.has(token) }));
|
|
318
321
|
});
|
|
@@ -334,8 +337,9 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
334
337
|
const nbOperations = operations.length;
|
|
335
338
|
if (nbOperations === 0)
|
|
336
339
|
return operations;
|
|
337
|
-
const {
|
|
338
|
-
if (receiver
|
|
340
|
+
const { bundler3: { bundler3, generalAdapter1 }, } = getChainAddresses(startData.chainId);
|
|
341
|
+
if (isAddressEqual(receiver, bundler3) ||
|
|
342
|
+
isAddressEqual(receiver, generalAdapter1))
|
|
339
343
|
throw Error(`receiver is bundler`);
|
|
340
344
|
const approvals = [];
|
|
341
345
|
const permits = [];
|
|
@@ -387,8 +391,8 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
387
391
|
}
|
|
388
392
|
case "Erc20_Transfer": {
|
|
389
393
|
const { address, sender, args: { amount, from, to }, } = operation;
|
|
390
|
-
if (from !==
|
|
391
|
-
to ===
|
|
394
|
+
if (from !== generalAdapter1 &&
|
|
395
|
+
to === generalAdapter1 &&
|
|
392
396
|
!erc20WrapperTokens[startData.chainId].has(address)) {
|
|
393
397
|
const duplicateTransfer = inputTransfers.find((transfer) => transfer.address === address &&
|
|
394
398
|
transfer.sender === sender &&
|
|
@@ -405,7 +409,7 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
405
409
|
}
|
|
406
410
|
case "Erc20_Transfer2": {
|
|
407
411
|
const { address, sender, args: { amount, from, to }, } = operation;
|
|
408
|
-
if (from !==
|
|
412
|
+
if (from !== generalAdapter1 && to === generalAdapter1) {
|
|
409
413
|
const duplicateTransfer2 = inputTransfer2s.find((transfer) => transfer.address === address &&
|
|
410
414
|
transfer.sender === sender &&
|
|
411
415
|
transfer.args.from === from);
|
|
@@ -436,15 +440,15 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
436
440
|
// Redirect MetaMorpho deposits.
|
|
437
441
|
operations.forEach((operation, index) => {
|
|
438
442
|
if (operation.type !== "MetaMorpho_Deposit" ||
|
|
439
|
-
operation.args.owner !==
|
|
443
|
+
operation.args.owner !== generalAdapter1)
|
|
440
444
|
return;
|
|
441
445
|
const token = operation.address;
|
|
442
446
|
// shares are not defined when depositing assets, so we rely on simulation steps.
|
|
443
|
-
const shares = steps[index + 1].getHolding(
|
|
444
|
-
steps[index].getHolding(
|
|
447
|
+
const shares = steps[index + 1].getHolding(generalAdapter1, token).balance -
|
|
448
|
+
steps[index].getHolding(generalAdapter1, token).balance;
|
|
445
449
|
if (steps
|
|
446
450
|
.slice(index + 2)
|
|
447
|
-
.some((step) => step.getHolding(
|
|
451
|
+
.some((step) => step.getHolding(generalAdapter1, token).balance < shares))
|
|
448
452
|
// If the bundler's balance is at least once lower than assets, the bundler does need these assets.
|
|
449
453
|
return;
|
|
450
454
|
operation.args.owner = receiver;
|
|
@@ -466,14 +470,14 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
466
470
|
default:
|
|
467
471
|
return;
|
|
468
472
|
}
|
|
469
|
-
if (operation.args.receiver !==
|
|
473
|
+
if (operation.args.receiver !== generalAdapter1 || unwrapTokens.has(token))
|
|
470
474
|
return;
|
|
471
475
|
// assets are not defined when using shares, so we rely on simulation steps.
|
|
472
|
-
const assets = steps[index + 1].getHolding(
|
|
473
|
-
steps[index].getHolding(
|
|
476
|
+
const assets = steps[index + 1].getHolding(generalAdapter1, token).balance -
|
|
477
|
+
steps[index].getHolding(generalAdapter1, token).balance;
|
|
474
478
|
if (steps
|
|
475
479
|
.slice(index + 2)
|
|
476
|
-
.some((step) => step.getHolding(
|
|
480
|
+
.some((step) => step.getHolding(generalAdapter1, token).balance < assets))
|
|
477
481
|
// If the bundler's balance is at least once lower than assets, the bundler does need these assets.
|
|
478
482
|
return;
|
|
479
483
|
operation.args.receiver = receiver;
|
|
@@ -481,15 +485,15 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
481
485
|
// Simplify Erc20_Transfer(sender = bundler, to = bundler) + MetaMorpho_Withdraw(owner = bundler) = MetaMorpho_Withdraw(owner = from).
|
|
482
486
|
operations.forEach((operation, index) => {
|
|
483
487
|
if (operation.type !== "MetaMorpho_Withdraw" ||
|
|
484
|
-
operation.args.owner !==
|
|
488
|
+
operation.args.owner !== generalAdapter1)
|
|
485
489
|
return;
|
|
486
490
|
// shares are not defined when using assets, so we rely on simulation steps.
|
|
487
|
-
const shares = steps[index].getHolding(
|
|
488
|
-
steps[index + 1].getHolding(
|
|
491
|
+
const shares = steps[index].getHolding(generalAdapter1, operation.address).balance -
|
|
492
|
+
steps[index + 1].getHolding(generalAdapter1, operation.address).balance;
|
|
489
493
|
const inputTransferIndex = operations.findIndex((candidate) => candidate.type === "Erc20_Transfer" &&
|
|
490
494
|
candidate.address === operation.address &&
|
|
491
|
-
candidate.sender ===
|
|
492
|
-
candidate.args.to ===
|
|
495
|
+
candidate.sender === generalAdapter1 &&
|
|
496
|
+
candidate.args.to === generalAdapter1 &&
|
|
493
497
|
candidate.args.amount >= shares);
|
|
494
498
|
if (inputTransferIndex <= 0)
|
|
495
499
|
return;
|
|
@@ -502,12 +506,12 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
502
506
|
if (operation.type !== "Erc20_Transfer")
|
|
503
507
|
return true;
|
|
504
508
|
const { amount, from, to } = operation.args;
|
|
505
|
-
if (from ===
|
|
509
|
+
if (from === generalAdapter1 || to !== generalAdapter1)
|
|
506
510
|
return true;
|
|
507
511
|
const token = operation.address;
|
|
508
512
|
if (steps
|
|
509
513
|
.slice(index + 2)
|
|
510
|
-
.some((step) => step.getHolding(
|
|
514
|
+
.some((step) => step.getHolding(generalAdapter1, token).balance < amount))
|
|
511
515
|
// If the bundler's balance is at least once less than amount, the bundler does need these assets.
|
|
512
516
|
// Do not only keep the amount actually used in this case because some input transfers
|
|
513
517
|
// are expected to be larger to account for slippage.
|
|
@@ -518,7 +522,7 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
518
522
|
steps = simulateBundlerOperations(operations, startData, { slippage: 0n });
|
|
519
523
|
// Unwrap requested remaining wrapped tokens.
|
|
520
524
|
const unwraps = [];
|
|
521
|
-
const endBundlerTokenData = getLast(steps).holdings[
|
|
525
|
+
const endBundlerTokenData = getLast(steps).holdings[generalAdapter1] ?? {};
|
|
522
526
|
unwrapTokens.forEach((wrappedToken) => {
|
|
523
527
|
const remaining = endBundlerTokenData[wrappedToken]?.balance ?? 0n;
|
|
524
528
|
if (remaining <= 5n)
|
|
@@ -529,7 +533,7 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
529
533
|
unwraps.push({
|
|
530
534
|
type: "Erc20_Unwrap",
|
|
531
535
|
address: wrappedToken,
|
|
532
|
-
sender:
|
|
536
|
+
sender: generalAdapter1,
|
|
533
537
|
args: {
|
|
534
538
|
amount: maxUint256,
|
|
535
539
|
receiver,
|
|
@@ -544,17 +548,19 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
544
548
|
// Skim any token expected to be left on the bundler.
|
|
545
549
|
const skims = [];
|
|
546
550
|
{
|
|
547
|
-
const startBundlerTokenData = steps[0].holdings[
|
|
548
|
-
const endBundlerTokenData = getLast(steps).holdings[
|
|
551
|
+
const startBundlerTokenData = steps[0].holdings[generalAdapter1] ?? {};
|
|
552
|
+
const endBundlerTokenData = getLast(steps).holdings[generalAdapter1] ?? {};
|
|
549
553
|
skims.push(...entries(endBundlerTokenData)
|
|
550
|
-
.filter(([token,
|
|
554
|
+
.filter(([token, holding]) => holding != null &&
|
|
555
|
+
holding.balance - (startBundlerTokenData[token]?.balance ?? 0n) >
|
|
556
|
+
5n)
|
|
551
557
|
.map(([address]) => ({
|
|
552
558
|
type: "Erc20_Transfer",
|
|
553
559
|
address,
|
|
554
|
-
sender:
|
|
560
|
+
sender: generalAdapter1,
|
|
555
561
|
args: {
|
|
556
562
|
amount: maxUint256,
|
|
557
|
-
from:
|
|
563
|
+
from: generalAdapter1,
|
|
558
564
|
to: receiver,
|
|
559
565
|
},
|
|
560
566
|
})));
|
|
@@ -579,15 +585,17 @@ export const populateBundle = (inputOperations, data, options) => {
|
|
|
579
585
|
return { operations, steps };
|
|
580
586
|
};
|
|
581
587
|
export const simulateRequiredTokenAmounts = (operations, data) => {
|
|
582
|
-
const {
|
|
588
|
+
const { bundler3: { generalAdapter1 }, } = getChainAddresses(data.chainId);
|
|
583
589
|
const virtualBundlerData = produceImmutable(data, (draft) => {
|
|
584
|
-
Object.values(draft.holdings[
|
|
590
|
+
Object.values(draft.holdings[generalAdapter1] ?? {}).forEach((bundlerTokenData) => {
|
|
591
|
+
if (bundlerTokenData == null)
|
|
592
|
+
return;
|
|
585
593
|
// Virtual balance to calculate the amount required.
|
|
586
594
|
bundlerTokenData.balance += MathLib.MAX_UINT_160;
|
|
587
595
|
});
|
|
588
596
|
});
|
|
589
597
|
const steps = simulateOperations(operations, virtualBundlerData);
|
|
590
|
-
const bundlerTokenDiffs = keys(virtualBundlerData.holdings[
|
|
598
|
+
const bundlerTokenDiffs = keys(virtualBundlerData.holdings[generalAdapter1]).map((token) => ({
|
|
591
599
|
token,
|
|
592
600
|
required: steps
|
|
593
601
|
.map((step) =>
|
|
@@ -597,7 +605,7 @@ export const simulateRequiredTokenAmounts = (operations, data) => {
|
|
|
597
605
|
// | |=> MAX_UINT_160 - (2 * MAX_UINT_160 - y) < 0
|
|
598
606
|
// |=> MAX_UINT_160 - (MAX_UINT_160 - y - x) > 0
|
|
599
607
|
MathLib.MAX_UINT_160 -
|
|
600
|
-
(step.holdings[
|
|
608
|
+
(step.holdings[generalAdapter1]?.[token]?.balance ?? 0n))
|
|
601
609
|
.sort(bigIntComparator((required) => required,
|
|
602
610
|
// Take the highest required amount among all operations.
|
|
603
611
|
"desc"))[0],
|
package/lib/types/actions.d.ts
CHANGED
|
@@ -24,54 +24,68 @@ export interface Permit2PermitSingle {
|
|
|
24
24
|
sigDeadline: bigint;
|
|
25
25
|
}
|
|
26
26
|
export interface ActionArgs {
|
|
27
|
-
nativeTransfer: [recipient: Address, amount: bigint];
|
|
27
|
+
nativeTransfer: [owner: Address, recipient: Address, amount: bigint];
|
|
28
28
|
erc20Transfer: [asset: Address, recipient: Address, amount: bigint];
|
|
29
|
-
erc20TransferFrom: [asset: Address, amount: bigint];
|
|
30
|
-
erc20WrapperDepositFor: [
|
|
31
|
-
|
|
29
|
+
erc20TransferFrom: [asset: Address, amount: bigint, recipient?: Address];
|
|
30
|
+
erc20WrapperDepositFor: [
|
|
31
|
+
wrapper: Address,
|
|
32
|
+
underlying: Address,
|
|
33
|
+
amount: bigint
|
|
34
|
+
];
|
|
35
|
+
erc20WrapperWithdrawTo: [wrapper: Address, receiver: Address, amount: bigint];
|
|
32
36
|
permit: [
|
|
37
|
+
owner: Address,
|
|
33
38
|
asset: Address,
|
|
34
39
|
amount: bigint,
|
|
35
40
|
deadline: bigint,
|
|
36
41
|
signature: Hex | null,
|
|
42
|
+
spender?: Address,
|
|
37
43
|
skipRevert?: boolean
|
|
38
44
|
];
|
|
39
45
|
permitDai: [
|
|
46
|
+
owner: Address,
|
|
40
47
|
nonce: bigint,
|
|
41
48
|
expiry: bigint,
|
|
42
49
|
allowed: boolean,
|
|
43
50
|
signature: Hex | null,
|
|
51
|
+
spender?: Address,
|
|
44
52
|
skipRevert?: boolean
|
|
45
53
|
];
|
|
46
54
|
approve2: [
|
|
55
|
+
owner: Address,
|
|
47
56
|
permitSingle: Permit2PermitSingle,
|
|
48
57
|
signature: Hex | null,
|
|
49
58
|
skipRevert?: boolean
|
|
50
59
|
];
|
|
51
|
-
transferFrom2: [
|
|
60
|
+
transferFrom2: [
|
|
61
|
+
asset: Address,
|
|
62
|
+
owner: Address,
|
|
63
|
+
amount: bigint,
|
|
64
|
+
recipient?: Address
|
|
65
|
+
];
|
|
52
66
|
erc4626Mint: [
|
|
53
67
|
erc4626: Address,
|
|
54
68
|
shares: bigint,
|
|
55
|
-
|
|
69
|
+
maxSharePrice: bigint,
|
|
56
70
|
receiver: Address
|
|
57
71
|
];
|
|
58
72
|
erc4626Deposit: [
|
|
59
73
|
erc4626: Address,
|
|
60
74
|
assets: bigint,
|
|
61
|
-
|
|
75
|
+
maxSharePrice: bigint,
|
|
62
76
|
receiver: Address
|
|
63
77
|
];
|
|
64
78
|
erc4626Withdraw: [
|
|
65
79
|
erc4626: Address,
|
|
66
80
|
assets: bigint,
|
|
67
|
-
|
|
81
|
+
minSharePrice: bigint,
|
|
68
82
|
receiver: Address,
|
|
69
83
|
owner: Address
|
|
70
84
|
];
|
|
71
85
|
erc4626Redeem: [
|
|
72
86
|
erc4626: Address,
|
|
73
87
|
shares: bigint,
|
|
74
|
-
|
|
88
|
+
minSharePrice: bigint,
|
|
75
89
|
receiver: Address,
|
|
76
90
|
owner: Address
|
|
77
91
|
];
|
|
@@ -128,9 +142,8 @@ export interface ActionArgs {
|
|
|
128
142
|
receiver: Address
|
|
129
143
|
];
|
|
130
144
|
reallocateTo: [
|
|
131
|
-
publicAllocator: Address,
|
|
132
145
|
vault: Address,
|
|
133
|
-
|
|
146
|
+
fee: bigint,
|
|
134
147
|
withdrawals: InputReallocation[],
|
|
135
148
|
supplyMarket: InputMarketParams
|
|
136
149
|
];
|
|
@@ -142,39 +155,72 @@ export interface ActionArgs {
|
|
|
142
155
|
proof: Hex[],
|
|
143
156
|
skipRevert?: boolean
|
|
144
157
|
];
|
|
145
|
-
wrapNative: [amount: bigint];
|
|
146
|
-
unwrapNative: [amount: bigint];
|
|
147
|
-
stakeEth: [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
wrapNative: [amount: bigint, recipient?: Address];
|
|
159
|
+
unwrapNative: [amount: bigint, recipient?: Address];
|
|
160
|
+
stakeEth: [
|
|
161
|
+
amount: bigint,
|
|
162
|
+
minShares: bigint,
|
|
163
|
+
referral: Address,
|
|
164
|
+
recipient?: Address
|
|
165
|
+
];
|
|
166
|
+
wrapStEth: [amount: bigint, recipient?: Address];
|
|
167
|
+
unwrapStEth: [amount: bigint, recipient?: Address];
|
|
168
|
+
aaveV2Repay: [
|
|
169
|
+
asset: Address,
|
|
170
|
+
amount: bigint,
|
|
171
|
+
onBehalf: Address,
|
|
172
|
+
rateMode?: bigint
|
|
173
|
+
];
|
|
174
|
+
aaveV2Withdraw: [asset: Address, amount: bigint, recipient?: Address];
|
|
175
|
+
aaveV3Repay: [
|
|
176
|
+
asset: Address,
|
|
177
|
+
amount: bigint,
|
|
178
|
+
onBehalf: Address,
|
|
179
|
+
rateMode?: bigint
|
|
180
|
+
];
|
|
181
|
+
aaveV3Withdraw: [asset: Address, amount: bigint, recipient?: Address];
|
|
182
|
+
aaveV3OptimizerRepay: [
|
|
183
|
+
underlying: Address,
|
|
184
|
+
amount: bigint,
|
|
185
|
+
onBehalf: Address
|
|
186
|
+
];
|
|
155
187
|
aaveV3OptimizerWithdraw: [
|
|
156
188
|
underlying: Address,
|
|
157
189
|
amount: bigint,
|
|
158
|
-
maxIterations: bigint
|
|
190
|
+
maxIterations: bigint,
|
|
191
|
+
recipient?: Address
|
|
192
|
+
];
|
|
193
|
+
aaveV3OptimizerWithdrawCollateral: [
|
|
194
|
+
underlying: Address,
|
|
195
|
+
amount: bigint,
|
|
196
|
+
recipient?: Address
|
|
159
197
|
];
|
|
160
|
-
aaveV3OptimizerWithdrawCollateral: [underlying: Address, amount: bigint];
|
|
161
198
|
aaveV3OptimizerApproveManagerWithSig: [
|
|
199
|
+
owner: Address,
|
|
162
200
|
isApproved: boolean,
|
|
163
201
|
nonce: bigint,
|
|
164
202
|
deadline: bigint,
|
|
165
203
|
signature: Hex | null,
|
|
204
|
+
manager?: Address,
|
|
166
205
|
skipRevert?: boolean
|
|
167
206
|
];
|
|
168
|
-
compoundV2Repay: [cToken: Address, amount: bigint];
|
|
169
|
-
compoundV2Redeem: [cToken: Address, amount: bigint];
|
|
170
|
-
compoundV3Repay: [instance: Address, amount: bigint];
|
|
171
|
-
compoundV3WithdrawFrom: [
|
|
207
|
+
compoundV2Repay: [cToken: Address, amount: bigint, onBehalf: Address];
|
|
208
|
+
compoundV2Redeem: [cToken: Address, amount: bigint, recipient?: Address];
|
|
209
|
+
compoundV3Repay: [instance: Address, amount: bigint, onBehalf: Address];
|
|
210
|
+
compoundV3WithdrawFrom: [
|
|
211
|
+
instance: Address,
|
|
212
|
+
asset: Address,
|
|
213
|
+
amount: bigint,
|
|
214
|
+
recipient?: Address
|
|
215
|
+
];
|
|
172
216
|
compoundV3AllowBySig: [
|
|
173
217
|
instance: Address,
|
|
218
|
+
owner: Address,
|
|
174
219
|
isAllowed: boolean,
|
|
175
220
|
nonce: bigint,
|
|
176
221
|
expiry: bigint,
|
|
177
222
|
signature: Hex | null,
|
|
223
|
+
manager?: Address,
|
|
178
224
|
skipRevert?: boolean
|
|
179
225
|
];
|
|
180
226
|
}
|
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": "3.0.0-next.0",
|
|
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": "^
|
|
24
|
-
"@morpho-org/
|
|
25
|
-
"@morpho-org/simulation-sdk": "^
|
|
26
|
-
"@morpho-org/
|
|
23
|
+
"@morpho-org/blue-sdk": "^3.0.0-next.1",
|
|
24
|
+
"@morpho-org/blue-sdk-viem": "^3.0.0-next.0",
|
|
25
|
+
"@morpho-org/simulation-sdk": "^3.0.0-next.0",
|
|
26
|
+
"@morpho-org/morpho-ts": "^2.1.0"
|
|
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": "^
|
|
39
|
-
"@morpho-org/blue-sdk-viem": "^
|
|
40
|
-
"@morpho-org/morpho-test": "^2.2.1",
|
|
41
|
-
"@morpho-org/simulation-sdk": "^2.1.4-next.0",
|
|
38
|
+
"@morpho-org/blue-sdk": "^3.0.0-next.1",
|
|
39
|
+
"@morpho-org/blue-sdk-viem": "^3.0.0-next.0",
|
|
42
40
|
"@morpho-org/morpho-ts": "^2.1.0",
|
|
43
|
-
"@morpho-org/
|
|
44
|
-
"@morpho-org/
|
|
41
|
+
"@morpho-org/simulation-sdk": "^3.0.0-next.0",
|
|
42
|
+
"@morpho-org/morpho-test": "^2.2.1",
|
|
43
|
+
"@morpho-org/test": "^2.0.7-next.0",
|
|
44
|
+
"@morpho-org/simulation-sdk-wagmi": "^3.0.0-next.0",
|
|
45
45
|
"@morpho-org/test-wagmi": "^2.0.4"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|