@morpho-org/bundler-sdk-viem 3.0.0-next.8 → 3.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/ActionBundle.d.ts +3 -1
- package/lib/ActionBundle.js +11 -4
- package/lib/BundlerAction.d.ts +137 -104
- package/lib/BundlerAction.js +243 -202
- package/lib/actions.js +129 -39
- package/lib/errors.d.ts +4 -0
- package/lib/errors.js +6 -0
- package/lib/operations.js +18 -14
- package/lib/types/actions.d.ts +87 -46
- package/lib/types/operations.d.ts +1 -1
- package/lib/types/operations.js +1 -0
- package/package.json +12 -12
package/lib/BundlerAction.js
CHANGED
|
@@ -12,7 +12,6 @@ export var BundlerAction;
|
|
|
12
12
|
function encodeBundle(chainId, actions) {
|
|
13
13
|
const { bundler3: { bundler3, generalAdapter1 }, } = getChainAddresses(chainId);
|
|
14
14
|
let value = 0n;
|
|
15
|
-
let generalAdapter1Value = 0n;
|
|
16
15
|
for (const { type, args } of actions) {
|
|
17
16
|
if (type !== "nativeTransfer")
|
|
18
17
|
continue;
|
|
@@ -21,18 +20,8 @@ export var BundlerAction;
|
|
|
21
20
|
owner !== generalAdapter1 &&
|
|
22
21
|
(recipient === bundler3 || recipient === generalAdapter1))
|
|
23
22
|
value += amount;
|
|
24
|
-
if (owner !== generalAdapter1 && recipient === generalAdapter1)
|
|
25
|
-
generalAdapter1Value += amount;
|
|
26
23
|
}
|
|
27
24
|
const encodedActions = actions.flatMap(BundlerAction.encode.bind(null, chainId));
|
|
28
|
-
if (generalAdapter1Value > 0n)
|
|
29
|
-
encodedActions.unshift({
|
|
30
|
-
to: generalAdapter1,
|
|
31
|
-
value: generalAdapter1Value,
|
|
32
|
-
data: "0x",
|
|
33
|
-
skipRevert: false,
|
|
34
|
-
callbackHash: zeroHash,
|
|
35
|
-
});
|
|
36
25
|
return {
|
|
37
26
|
to: bundler3,
|
|
38
27
|
value,
|
|
@@ -51,7 +40,7 @@ export var BundlerAction;
|
|
|
51
40
|
return BundlerAction.nativeTransfer(chainId, ...args);
|
|
52
41
|
}
|
|
53
42
|
case "erc20Transfer": {
|
|
54
|
-
return BundlerAction.erc20Transfer(
|
|
43
|
+
return BundlerAction.erc20Transfer(...args);
|
|
55
44
|
}
|
|
56
45
|
case "erc20TransferFrom": {
|
|
57
46
|
return BundlerAction.erc20TransferFrom(chainId, ...args);
|
|
@@ -65,16 +54,16 @@ export var BundlerAction;
|
|
|
65
54
|
}
|
|
66
55
|
/* Permit */
|
|
67
56
|
case "permit": {
|
|
68
|
-
const [sender, asset, amount, deadline, signature,
|
|
57
|
+
const [sender, asset, amount, deadline, signature, skipRevert] = args;
|
|
69
58
|
if (signature == null)
|
|
70
59
|
throw new BundlerErrors.MissingSignature();
|
|
71
|
-
return BundlerAction.permit(chainId, sender, asset, amount, deadline, signature,
|
|
60
|
+
return BundlerAction.permit(chainId, sender, asset, amount, deadline, signature, skipRevert);
|
|
72
61
|
}
|
|
73
62
|
case "permitDai": {
|
|
74
|
-
const [sender, nonce, expiry, allowed, signature,
|
|
63
|
+
const [sender, nonce, expiry, allowed, signature, skipRevert] = args;
|
|
75
64
|
if (signature == null)
|
|
76
65
|
throw new BundlerErrors.MissingSignature();
|
|
77
|
-
return BundlerAction.permitDai(chainId, sender, nonce, expiry, allowed, signature,
|
|
66
|
+
return BundlerAction.permitDai(chainId, sender, nonce, expiry, allowed, signature, skipRevert);
|
|
78
67
|
}
|
|
79
68
|
/* Permit2 */
|
|
80
69
|
case "approve2": {
|
|
@@ -107,19 +96,19 @@ export var BundlerAction;
|
|
|
107
96
|
return BundlerAction.morphoSetAuthorizationWithSig(chainId, authorization, signature, skipRevert);
|
|
108
97
|
}
|
|
109
98
|
case "morphoSupply": {
|
|
110
|
-
const [market, assets, shares, slippageAmount, onBehalf, onMorphoSupply,] = args;
|
|
111
|
-
return BundlerAction.morphoSupply(chainId, market, assets, shares, slippageAmount, onBehalf, onMorphoSupply.flatMap(BundlerAction.encode.bind(null, chainId)));
|
|
99
|
+
const [market, assets, shares, slippageAmount, onBehalf, onMorphoSupply, skipRevert,] = args;
|
|
100
|
+
return BundlerAction.morphoSupply(chainId, market, assets, shares, slippageAmount, onBehalf, onMorphoSupply.flatMap(BundlerAction.encode.bind(null, chainId)), skipRevert);
|
|
112
101
|
}
|
|
113
102
|
case "morphoSupplyCollateral": {
|
|
114
|
-
const [market, amount, onBehalf, onMorphoSupplyCollateral] = args;
|
|
115
|
-
return BundlerAction.morphoSupplyCollateral(chainId, market, amount, onBehalf, onMorphoSupplyCollateral.flatMap(BundlerAction.encode.bind(null, chainId)));
|
|
103
|
+
const [market, amount, onBehalf, onMorphoSupplyCollateral, skipRevert] = args;
|
|
104
|
+
return BundlerAction.morphoSupplyCollateral(chainId, market, amount, onBehalf, onMorphoSupplyCollateral.flatMap(BundlerAction.encode.bind(null, chainId)), skipRevert);
|
|
116
105
|
}
|
|
117
106
|
case "morphoBorrow": {
|
|
118
107
|
return BundlerAction.morphoBorrow(chainId, ...args);
|
|
119
108
|
}
|
|
120
109
|
case "morphoRepay": {
|
|
121
|
-
const [market, assets, shares, slippageAmount, onBehalf, onMorphoRepay,] = args;
|
|
122
|
-
return BundlerAction.morphoRepay(chainId, market, assets, shares, slippageAmount, onBehalf, onMorphoRepay.flatMap(BundlerAction.encode.bind(null, chainId)));
|
|
110
|
+
const [market, assets, shares, slippageAmount, onBehalf, onMorphoRepay, skipRevert,] = args;
|
|
111
|
+
return BundlerAction.morphoRepay(chainId, market, assets, shares, slippageAmount, onBehalf, onMorphoRepay.flatMap(BundlerAction.encode.bind(null, chainId)), skipRevert);
|
|
123
112
|
}
|
|
124
113
|
case "morphoWithdraw": {
|
|
125
114
|
return BundlerAction.morphoWithdraw(chainId, ...args);
|
|
@@ -178,10 +167,10 @@ export var BundlerAction;
|
|
|
178
167
|
return BundlerAction.aaveV3OptimizerWithdrawCollateral(chainId, ...args);
|
|
179
168
|
}
|
|
180
169
|
case "aaveV3OptimizerApproveManagerWithSig": {
|
|
181
|
-
const [aaveV3Optimizer, owner, isApproved, nonce, deadline, signature,
|
|
170
|
+
const [aaveV3Optimizer, owner, isApproved, nonce, deadline, signature, skipRevert,] = args;
|
|
182
171
|
if (signature == null)
|
|
183
172
|
throw new BundlerErrors.MissingSignature();
|
|
184
|
-
return BundlerAction.aaveV3OptimizerApproveManagerWithSig(chainId, aaveV3Optimizer, owner, isApproved, nonce, deadline, signature,
|
|
173
|
+
return BundlerAction.aaveV3OptimizerApproveManagerWithSig(chainId, aaveV3Optimizer, owner, isApproved, nonce, deadline, signature, skipRevert);
|
|
185
174
|
}
|
|
186
175
|
/* CompoundV2 */
|
|
187
176
|
case "compoundV2Repay": {
|
|
@@ -198,10 +187,10 @@ export var BundlerAction;
|
|
|
198
187
|
return BundlerAction.compoundV3WithdrawFrom(chainId, ...args);
|
|
199
188
|
}
|
|
200
189
|
case "compoundV3AllowBySig": {
|
|
201
|
-
const [instance, owner, isAllowed, nonce, expiry, signature,
|
|
190
|
+
const [instance, owner, isAllowed, nonce, expiry, signature, skipRevert,] = args;
|
|
202
191
|
if (signature == null)
|
|
203
192
|
throw new BundlerErrors.MissingSignature();
|
|
204
|
-
return BundlerAction.compoundV3AllowBySig(chainId, instance, owner, isAllowed, nonce, expiry, signature,
|
|
193
|
+
return BundlerAction.compoundV3AllowBySig(chainId, instance, owner, isAllowed, nonce, expiry, signature, skipRevert);
|
|
205
194
|
}
|
|
206
195
|
}
|
|
207
196
|
throw Error(`unhandled action encoding: ${type}`);
|
|
@@ -209,13 +198,14 @@ export var BundlerAction;
|
|
|
209
198
|
BundlerAction.encode = encode;
|
|
210
199
|
/* ERC20 */
|
|
211
200
|
/**
|
|
212
|
-
* Encodes a call to the
|
|
201
|
+
* Encodes a call to the GeneralAdapter1 to transfer native tokens (ETH on ethereum, MATIC on polygon, etc).
|
|
213
202
|
* @param chainId The chain id for which to encode the call.
|
|
214
203
|
* @param owner The owner of native tokens.
|
|
215
204
|
* @param recipient The address to send native tokens to.
|
|
216
205
|
* @param amount The amount of native tokens to send (in wei).
|
|
206
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
217
207
|
*/
|
|
218
|
-
function nativeTransfer(chainId, owner, recipient, amount) {
|
|
208
|
+
function nativeTransfer(chainId, owner, recipient, amount, skipRevert = false) {
|
|
219
209
|
const { bundler3: { bundler3, generalAdapter1 }, } = getChainAddresses(chainId);
|
|
220
210
|
if (recipient === bundler3)
|
|
221
211
|
return [];
|
|
@@ -238,22 +228,22 @@ export var BundlerAction;
|
|
|
238
228
|
to: recipient,
|
|
239
229
|
data: "0x",
|
|
240
230
|
value: amount,
|
|
241
|
-
skipRevert
|
|
231
|
+
skipRevert,
|
|
242
232
|
callbackHash: zeroHash,
|
|
243
233
|
},
|
|
244
234
|
];
|
|
245
235
|
}
|
|
246
236
|
BundlerAction.nativeTransfer = nativeTransfer;
|
|
247
237
|
/**
|
|
248
|
-
* Encodes a call to the
|
|
238
|
+
* Encodes a call to the requested adapter to transfer ERC20 tokens.
|
|
249
239
|
* @param chainId The chain id for which to encode the call.
|
|
250
240
|
* @param asset The address of the ERC20 token to transfer.
|
|
251
241
|
* @param recipient The address to send tokens to.
|
|
252
242
|
* @param amount The amount of tokens to send.
|
|
243
|
+
* @param adapter The address of the adapter to use.
|
|
244
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
253
245
|
*/
|
|
254
|
-
function erc20Transfer(
|
|
255
|
-
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
256
|
-
adapter ??= generalAdapter1;
|
|
246
|
+
function erc20Transfer(asset, recipient, amount, adapter, skipRevert = false) {
|
|
257
247
|
return [
|
|
258
248
|
{
|
|
259
249
|
to: adapter,
|
|
@@ -263,22 +253,22 @@ export var BundlerAction;
|
|
|
263
253
|
args: [asset, recipient, amount],
|
|
264
254
|
}),
|
|
265
255
|
value: 0n,
|
|
266
|
-
skipRevert
|
|
256
|
+
skipRevert,
|
|
267
257
|
callbackHash: zeroHash,
|
|
268
258
|
},
|
|
269
259
|
];
|
|
270
260
|
}
|
|
271
261
|
BundlerAction.erc20Transfer = erc20Transfer;
|
|
272
262
|
/**
|
|
273
|
-
* Encodes a call to the
|
|
263
|
+
* Encodes a call to the GeneralAdapter1 to transfer ERC20 tokens with `transferFrom`.
|
|
274
264
|
* @param chainId The chain id for which to encode the call.
|
|
275
265
|
* @param asset The address of the ERC20 token to transfer.
|
|
276
266
|
* @param amount The amount of tokens to send.
|
|
277
|
-
* @param recipient The recipient of ERC20 tokens.
|
|
267
|
+
* @param recipient The recipient of ERC20 tokens.
|
|
268
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
278
269
|
*/
|
|
279
|
-
function erc20TransferFrom(chainId, asset, amount, recipient) {
|
|
270
|
+
function erc20TransferFrom(chainId, asset, amount, recipient, skipRevert = false) {
|
|
280
271
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
281
|
-
recipient ??= generalAdapter1;
|
|
282
272
|
return [
|
|
283
273
|
{
|
|
284
274
|
to: generalAdapter1,
|
|
@@ -288,7 +278,7 @@ export var BundlerAction;
|
|
|
288
278
|
args: [asset, recipient, amount],
|
|
289
279
|
}),
|
|
290
280
|
value: 0n,
|
|
291
|
-
skipRevert
|
|
281
|
+
skipRevert,
|
|
292
282
|
callbackHash: zeroHash,
|
|
293
283
|
},
|
|
294
284
|
];
|
|
@@ -296,27 +286,35 @@ export var BundlerAction;
|
|
|
296
286
|
BundlerAction.erc20TransferFrom = erc20TransferFrom;
|
|
297
287
|
/* Permit */
|
|
298
288
|
/**
|
|
299
|
-
* Encodes a call to the
|
|
289
|
+
* Encodes a call to the GeneralAdapter1 to permit an ERC20 token.
|
|
300
290
|
* @param chainId The chain id for which to encode the call.
|
|
301
291
|
* @param owner The address which owns the tokens.
|
|
302
292
|
* @param asset The address of the ERC20 token to permit.
|
|
303
293
|
* @param amount The amount of tokens to permit.
|
|
304
294
|
* @param deadline The timestamp until which the signature is valid.
|
|
305
295
|
* @param signature The Ethers signature to permit the tokens.
|
|
306
|
-
* @param
|
|
307
|
-
* @param skipRevert Whether to allow the permit to revert without making the whole multicall revert.
|
|
296
|
+
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert. Defaults to true.
|
|
308
297
|
*/
|
|
309
|
-
function permit(chainId, owner, asset, amount, deadline, signature,
|
|
298
|
+
function permit(chainId, owner, asset, amount, deadline, signature, skipRevert = true) {
|
|
310
299
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
311
300
|
const { r, s, yParity } = parseSignature(signature);
|
|
312
|
-
spender ??= generalAdapter1;
|
|
313
301
|
return [
|
|
314
302
|
{
|
|
315
303
|
to: asset,
|
|
316
304
|
data: encodeFunctionData({
|
|
317
305
|
abi: erc2612Abi,
|
|
318
306
|
functionName: "permit",
|
|
319
|
-
args: [
|
|
307
|
+
args: [
|
|
308
|
+
owner,
|
|
309
|
+
// Never permit any other address than the GeneralAdapter1 otherwise
|
|
310
|
+
// there are no guarantees that the signature can't be used independently.
|
|
311
|
+
generalAdapter1,
|
|
312
|
+
amount,
|
|
313
|
+
deadline,
|
|
314
|
+
yParity + 27,
|
|
315
|
+
r,
|
|
316
|
+
s,
|
|
317
|
+
],
|
|
320
318
|
}),
|
|
321
319
|
value: 0n,
|
|
322
320
|
skipRevert,
|
|
@@ -326,21 +324,19 @@ export var BundlerAction;
|
|
|
326
324
|
}
|
|
327
325
|
BundlerAction.permit = permit;
|
|
328
326
|
/**
|
|
329
|
-
* Encodes a call to the
|
|
327
|
+
* Encodes a call to the GeneralAdapter1 to permit DAI.
|
|
330
328
|
* @param chainId The chain id for which to encode the call.
|
|
331
329
|
* @param owner The address which owns the tokens.
|
|
332
330
|
* @param nonce The permit nonce used.
|
|
333
331
|
* @param expiry The timestamp until which the signature is valid.
|
|
334
332
|
* @param allowed The amount of DAI to permit.
|
|
335
333
|
* @param signature The Ethers signature to permit the tokens.
|
|
336
|
-
* @param
|
|
337
|
-
* @param skipRevert Whether to allow the permit to revert without making the whole multicall revert.
|
|
334
|
+
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert.
|
|
338
335
|
*/
|
|
339
|
-
function permitDai(chainId, owner, nonce, expiry, allowed, signature,
|
|
336
|
+
function permitDai(chainId, owner, nonce, expiry, allowed, signature, skipRevert = true) {
|
|
340
337
|
const { dai, bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
341
338
|
if (dai == null)
|
|
342
339
|
throw new BundlerErrors.UnexpectedAction("permitDai", chainId);
|
|
343
|
-
spender ??= generalAdapter1;
|
|
344
340
|
const { r, s, yParity } = parseSignature(signature);
|
|
345
341
|
return [
|
|
346
342
|
{
|
|
@@ -367,7 +363,18 @@ export var BundlerAction;
|
|
|
367
363
|
},
|
|
368
364
|
],
|
|
369
365
|
functionName: "permit",
|
|
370
|
-
args: [
|
|
366
|
+
args: [
|
|
367
|
+
owner,
|
|
368
|
+
// Never permit any other address than the GeneralAdapter1 otherwise
|
|
369
|
+
// there are no guarantees that the signature can't be used independently.
|
|
370
|
+
generalAdapter1,
|
|
371
|
+
nonce,
|
|
372
|
+
expiry,
|
|
373
|
+
allowed,
|
|
374
|
+
yParity + 27,
|
|
375
|
+
r,
|
|
376
|
+
s,
|
|
377
|
+
],
|
|
371
378
|
}),
|
|
372
379
|
value: 0n,
|
|
373
380
|
skipRevert,
|
|
@@ -378,15 +385,15 @@ export var BundlerAction;
|
|
|
378
385
|
BundlerAction.permitDai = permitDai;
|
|
379
386
|
/* Permit2 */
|
|
380
387
|
/**
|
|
381
|
-
* Encodes a call to the
|
|
388
|
+
* Encodes a call to permit the chain's GeneralAdapter1 ERC20 tokens via Permit2.
|
|
382
389
|
* @param chainId The chain id for which to encode the call.
|
|
383
390
|
* @param owner The owner of ERC20 tokens.
|
|
384
391
|
* @param permitSingle The permit details to submit to Permit2.
|
|
385
392
|
* @param signature The Ethers signature to permit the tokens.
|
|
386
|
-
* @param skipRevert Whether to allow the permit to revert without making the whole
|
|
393
|
+
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert. Defaults to true.
|
|
387
394
|
*/
|
|
388
395
|
function approve2(chainId, owner, permitSingle, signature, skipRevert = true) {
|
|
389
|
-
const { permit2 } = getChainAddresses(chainId);
|
|
396
|
+
const { permit2, bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
390
397
|
if (permit2 == null)
|
|
391
398
|
throw new BundlerErrors.UnexpectedAction("approve2", chainId);
|
|
392
399
|
return [
|
|
@@ -395,7 +402,16 @@ export var BundlerAction;
|
|
|
395
402
|
data: encodeFunctionData({
|
|
396
403
|
abi: permit2Abi,
|
|
397
404
|
functionName: "permit",
|
|
398
|
-
args: [
|
|
405
|
+
args: [
|
|
406
|
+
owner,
|
|
407
|
+
{
|
|
408
|
+
...permitSingle,
|
|
409
|
+
// Never permit any other address than the GeneralAdapter1 otherwise
|
|
410
|
+
// there are no guarantees that the signature can't be used independently.
|
|
411
|
+
spender: generalAdapter1,
|
|
412
|
+
},
|
|
413
|
+
signature,
|
|
414
|
+
],
|
|
399
415
|
}),
|
|
400
416
|
value: 0n,
|
|
401
417
|
skipRevert,
|
|
@@ -405,29 +421,26 @@ export var BundlerAction;
|
|
|
405
421
|
}
|
|
406
422
|
BundlerAction.approve2 = approve2;
|
|
407
423
|
/**
|
|
408
|
-
* Encodes a call to the
|
|
424
|
+
* Encodes a call to the GeneralAdapter1 to transfer ERC20 tokens via Permit2.
|
|
409
425
|
* @param chainId The chain id for which to encode the call.
|
|
410
426
|
* @param asset The address of the ERC20 token to transfer.
|
|
411
427
|
* @param owner The owner of ERC20 tokens.
|
|
412
428
|
* @param amount The amount of tokens to send.
|
|
413
|
-
* @param recipient The recipient of ERC20 tokens.
|
|
429
|
+
* @param recipient The recipient of ERC20 tokens.
|
|
430
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
414
431
|
*/
|
|
415
|
-
function transferFrom2(chainId, asset,
|
|
416
|
-
const {
|
|
417
|
-
if (permit2 == null)
|
|
418
|
-
throw new BundlerErrors.UnexpectedAction("transferFrom2", chainId);
|
|
419
|
-
recipient ??= generalAdapter1;
|
|
432
|
+
function transferFrom2(chainId, asset, amount, recipient, skipRevert = false) {
|
|
433
|
+
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
420
434
|
return [
|
|
421
435
|
{
|
|
422
|
-
to:
|
|
436
|
+
to: generalAdapter1,
|
|
423
437
|
data: encodeFunctionData({
|
|
424
|
-
abi:
|
|
425
|
-
functionName: "
|
|
426
|
-
|
|
427
|
-
args: [owner, recipient, amount, asset],
|
|
438
|
+
abi: generalAdapter1Abi,
|
|
439
|
+
functionName: "permit2TransferFrom",
|
|
440
|
+
args: [asset, recipient, amount],
|
|
428
441
|
}),
|
|
429
442
|
value: 0n,
|
|
430
|
-
skipRevert
|
|
443
|
+
skipRevert,
|
|
431
444
|
callbackHash: zeroHash,
|
|
432
445
|
},
|
|
433
446
|
];
|
|
@@ -435,13 +448,14 @@ export var BundlerAction;
|
|
|
435
448
|
BundlerAction.transferFrom2 = transferFrom2;
|
|
436
449
|
/* ERC20 Wrapper */
|
|
437
450
|
/**
|
|
438
|
-
* Encodes a call to the
|
|
451
|
+
* Encodes a call to the GeneralAdapter1 to wrap ERC20 tokens via the provided ERC20Wrapper.
|
|
439
452
|
* @param chainId The chain id for which to encode the call.
|
|
440
453
|
* @param wrapper The address of the ERC20 wrapper token.
|
|
441
454
|
* @param underlying The address of the underlying ERC20 token.
|
|
442
455
|
* @param amount The amount of tokens to send.
|
|
456
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
443
457
|
*/
|
|
444
|
-
function erc20WrapperDepositFor(chainId, wrapper, underlying, amount) {
|
|
458
|
+
function erc20WrapperDepositFor(chainId, wrapper, underlying, amount, skipRevert = false) {
|
|
445
459
|
const { bundler3: { generalAdapter1, erc20WrapperAdapter }, } = getChainAddresses(chainId);
|
|
446
460
|
if (erc20WrapperAdapter == null)
|
|
447
461
|
throw new BundlerErrors.UnexpectedAction("erc20WrapperDepositFor", chainId);
|
|
@@ -454,7 +468,7 @@ export var BundlerAction;
|
|
|
454
468
|
args: [underlying, erc20WrapperAdapter, maxUint256],
|
|
455
469
|
}),
|
|
456
470
|
value: 0n,
|
|
457
|
-
skipRevert
|
|
471
|
+
skipRevert,
|
|
458
472
|
callbackHash: zeroHash,
|
|
459
473
|
},
|
|
460
474
|
{
|
|
@@ -465,7 +479,7 @@ export var BundlerAction;
|
|
|
465
479
|
args: [wrapper, amount],
|
|
466
480
|
}),
|
|
467
481
|
value: 0n,
|
|
468
|
-
skipRevert
|
|
482
|
+
skipRevert,
|
|
469
483
|
callbackHash: zeroHash,
|
|
470
484
|
},
|
|
471
485
|
{
|
|
@@ -476,20 +490,21 @@ export var BundlerAction;
|
|
|
476
490
|
args: [underlying, generalAdapter1, maxUint256],
|
|
477
491
|
}),
|
|
478
492
|
value: 0n,
|
|
479
|
-
skipRevert
|
|
493
|
+
skipRevert,
|
|
480
494
|
callbackHash: zeroHash,
|
|
481
495
|
},
|
|
482
496
|
];
|
|
483
497
|
}
|
|
484
498
|
BundlerAction.erc20WrapperDepositFor = erc20WrapperDepositFor;
|
|
485
499
|
/**
|
|
486
|
-
* Encodes a call to the
|
|
500
|
+
* Encodes a call to the GeneralAdapter1 to unwrap ERC20 tokens from the provided ERC20Wrapper.
|
|
487
501
|
* @param chainId The chain id for which to encode the call.
|
|
488
502
|
* @param wrapper The address of the ERC20 wrapper token.
|
|
489
503
|
* @param account The address to send the underlying ERC20 tokens.
|
|
490
504
|
* @param amount The amount of tokens to send.
|
|
505
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
491
506
|
*/
|
|
492
|
-
function erc20WrapperWithdrawTo(chainId, wrapper, receiver, amount) {
|
|
507
|
+
function erc20WrapperWithdrawTo(chainId, wrapper, receiver, amount, skipRevert = false) {
|
|
493
508
|
const { bundler3: { generalAdapter1, erc20WrapperAdapter }, } = getChainAddresses(chainId);
|
|
494
509
|
if (erc20WrapperAdapter == null)
|
|
495
510
|
throw new BundlerErrors.UnexpectedAction("erc20WrapperWithdrawTo", chainId);
|
|
@@ -502,7 +517,7 @@ export var BundlerAction;
|
|
|
502
517
|
args: [wrapper, erc20WrapperAdapter, maxUint256],
|
|
503
518
|
}),
|
|
504
519
|
value: 0n,
|
|
505
|
-
skipRevert
|
|
520
|
+
skipRevert,
|
|
506
521
|
callbackHash: zeroHash,
|
|
507
522
|
},
|
|
508
523
|
{
|
|
@@ -513,7 +528,7 @@ export var BundlerAction;
|
|
|
513
528
|
args: [wrapper, receiver, amount],
|
|
514
529
|
}),
|
|
515
530
|
value: 0n,
|
|
516
|
-
skipRevert
|
|
531
|
+
skipRevert,
|
|
517
532
|
callbackHash: zeroHash,
|
|
518
533
|
},
|
|
519
534
|
{
|
|
@@ -524,7 +539,7 @@ export var BundlerAction;
|
|
|
524
539
|
args: [wrapper, generalAdapter1, maxUint256],
|
|
525
540
|
}),
|
|
526
541
|
value: 0n,
|
|
527
|
-
skipRevert
|
|
542
|
+
skipRevert,
|
|
528
543
|
callbackHash: zeroHash,
|
|
529
544
|
},
|
|
530
545
|
];
|
|
@@ -532,14 +547,15 @@ export var BundlerAction;
|
|
|
532
547
|
BundlerAction.erc20WrapperWithdrawTo = erc20WrapperWithdrawTo;
|
|
533
548
|
/* ERC4626 */
|
|
534
549
|
/**
|
|
535
|
-
* Encodes a call to the
|
|
550
|
+
* Encodes a call to the GeneralAdapter1 to mint shares of the provided ERC4626 vault.
|
|
536
551
|
* @param chainId The chain id for which to encode the call.
|
|
537
552
|
* @param erc4626 The address of the ERC4626 vault.
|
|
538
553
|
* @param shares The amount of shares to mint.
|
|
539
554
|
* @param maxSharePrice The maximum amount of assets to pay to get 1 share (scaled by RAY).
|
|
540
555
|
* @param receiver The address to send the shares to.
|
|
556
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
541
557
|
*/
|
|
542
|
-
function erc4626Mint(chainId, erc4626, shares, maxSharePrice, receiver) {
|
|
558
|
+
function erc4626Mint(chainId, erc4626, shares, maxSharePrice, receiver, skipRevert = false) {
|
|
543
559
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
544
560
|
return [
|
|
545
561
|
{
|
|
@@ -550,21 +566,22 @@ export var BundlerAction;
|
|
|
550
566
|
args: [erc4626, shares, maxSharePrice, receiver],
|
|
551
567
|
}),
|
|
552
568
|
value: 0n,
|
|
553
|
-
skipRevert
|
|
569
|
+
skipRevert,
|
|
554
570
|
callbackHash: zeroHash,
|
|
555
571
|
},
|
|
556
572
|
];
|
|
557
573
|
}
|
|
558
574
|
BundlerAction.erc4626Mint = erc4626Mint;
|
|
559
575
|
/**
|
|
560
|
-
* Encodes a call to the
|
|
576
|
+
* Encodes a call to the GeneralAdapter1 to deposit assets into the provided ERC4626 vault.
|
|
561
577
|
* @param chainId The chain id for which to encode the call.
|
|
562
578
|
* @param erc4626 The address of the ERC4626 vault.
|
|
563
579
|
* @param assets The amount of assets to deposit.
|
|
564
580
|
* @param maxSharePrice The maximum amount of assets to pay to get 1 share (scaled by RAY).
|
|
565
581
|
* @param receiver The address to send the shares to.
|
|
582
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
566
583
|
*/
|
|
567
|
-
function erc4626Deposit(chainId, erc4626, assets, maxSharePrice, receiver) {
|
|
584
|
+
function erc4626Deposit(chainId, erc4626, assets, maxSharePrice, receiver, skipRevert = false) {
|
|
568
585
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
569
586
|
return [
|
|
570
587
|
{
|
|
@@ -575,22 +592,23 @@ export var BundlerAction;
|
|
|
575
592
|
args: [erc4626, assets, maxSharePrice, receiver],
|
|
576
593
|
}),
|
|
577
594
|
value: 0n,
|
|
578
|
-
skipRevert
|
|
595
|
+
skipRevert,
|
|
579
596
|
callbackHash: zeroHash,
|
|
580
597
|
},
|
|
581
598
|
];
|
|
582
599
|
}
|
|
583
600
|
BundlerAction.erc4626Deposit = erc4626Deposit;
|
|
584
601
|
/**
|
|
585
|
-
* Encodes a call to the
|
|
602
|
+
* Encodes a call to the GeneralAdapter1 to withdraw assets from the provided ERC4626 vault.
|
|
586
603
|
* @param chainId The chain id for which to encode the call.
|
|
587
604
|
* @param erc4626 The address of the ERC4626 vault.
|
|
588
605
|
* @param assets The amount of assets to withdraw.
|
|
589
606
|
* @param minSharePrice The minimum number of assets to receive per share (scaled by RAY).
|
|
590
607
|
* @param receiver The address to send the assets to.
|
|
591
608
|
* @param owner The address on behalf of which the assets are withdrawn.
|
|
609
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
592
610
|
*/
|
|
593
|
-
function erc4626Withdraw(chainId, erc4626, assets, minSharePrice, receiver, owner) {
|
|
611
|
+
function erc4626Withdraw(chainId, erc4626, assets, minSharePrice, receiver, owner, skipRevert = false) {
|
|
594
612
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
595
613
|
return [
|
|
596
614
|
{
|
|
@@ -601,22 +619,23 @@ export var BundlerAction;
|
|
|
601
619
|
args: [erc4626, assets, minSharePrice, receiver, owner],
|
|
602
620
|
}),
|
|
603
621
|
value: 0n,
|
|
604
|
-
skipRevert
|
|
622
|
+
skipRevert,
|
|
605
623
|
callbackHash: zeroHash,
|
|
606
624
|
},
|
|
607
625
|
];
|
|
608
626
|
}
|
|
609
627
|
BundlerAction.erc4626Withdraw = erc4626Withdraw;
|
|
610
628
|
/**
|
|
611
|
-
* Encodes a call to the
|
|
629
|
+
* Encodes a call to the GeneralAdapter1 to redeem shares from the provided ERC4626 vault.
|
|
612
630
|
* @param chainId The chain id for which to encode the call.
|
|
613
631
|
* @param erc4626 The address of the ERC4626 vault.
|
|
614
632
|
* @param shares The amount of shares to redeem.
|
|
615
633
|
* @param minSharePrice The minimum number of assets to receive per share (scaled by RAY).
|
|
616
634
|
* @param receiver The address to send the assets to.
|
|
617
635
|
* @param owner The address on behalf of which the assets are withdrawn.
|
|
636
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
618
637
|
*/
|
|
619
|
-
function erc4626Redeem(chainId, erc4626, shares, minSharePrice, receiver, owner) {
|
|
638
|
+
function erc4626Redeem(chainId, erc4626, shares, minSharePrice, receiver, owner, skipRevert = false) {
|
|
620
639
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
621
640
|
return [
|
|
622
641
|
{
|
|
@@ -627,7 +646,7 @@ export var BundlerAction;
|
|
|
627
646
|
args: [erc4626, shares, minSharePrice, receiver, owner],
|
|
628
647
|
}),
|
|
629
648
|
value: 0n,
|
|
630
|
-
skipRevert
|
|
649
|
+
skipRevert,
|
|
631
650
|
callbackHash: zeroHash,
|
|
632
651
|
},
|
|
633
652
|
];
|
|
@@ -635,15 +654,17 @@ export var BundlerAction;
|
|
|
635
654
|
BundlerAction.erc4626Redeem = erc4626Redeem;
|
|
636
655
|
/* Morpho */
|
|
637
656
|
/**
|
|
638
|
-
* Encodes a call to
|
|
657
|
+
* Encodes a call to authorize an account on Morpho Blue.
|
|
639
658
|
* @param chainId The chain id for which to encode the call.
|
|
640
659
|
* @param authorization The authorization details to submit to Morpho Blue.
|
|
641
660
|
* @param signature The Ethers signature to authorize the account.
|
|
642
|
-
* @param skipRevert Whether to allow the authorization call to revert without making the whole
|
|
661
|
+
* @param skipRevert Whether to allow the authorization call to revert without making the whole bundle revert. Defaults to true.
|
|
643
662
|
*/
|
|
644
663
|
function morphoSetAuthorizationWithSig(chainId, authorization, signature, skipRevert = true) {
|
|
645
|
-
const { morpho } = getChainAddresses(chainId);
|
|
664
|
+
const { morpho, bundler3: { bundler3 }, } = getChainAddresses(chainId);
|
|
646
665
|
const { r, s, yParity } = parseSignature(signature);
|
|
666
|
+
if (authorization.authorized === bundler3)
|
|
667
|
+
throw new BundlerErrors.UnexpectedSignature(authorization.authorized);
|
|
647
668
|
return [
|
|
648
669
|
{
|
|
649
670
|
to: morpho,
|
|
@@ -660,7 +681,7 @@ export var BundlerAction;
|
|
|
660
681
|
}
|
|
661
682
|
BundlerAction.morphoSetAuthorizationWithSig = morphoSetAuthorizationWithSig;
|
|
662
683
|
/**
|
|
663
|
-
* Encodes a call to the
|
|
684
|
+
* Encodes a call to the GeneralAdapter1 to supply to a Morpho Blue market.
|
|
664
685
|
* @param chainId The chain id for which to encode the call.
|
|
665
686
|
* @param market The market params to supply to.
|
|
666
687
|
* @param assets The amount of assets to supply.
|
|
@@ -668,8 +689,9 @@ export var BundlerAction;
|
|
|
668
689
|
* @param slippageAmount The maximum (resp. minimum) amount of assets (resp. supply shares) to supply (resp. mint) (protects the sender from unexpected slippage).
|
|
669
690
|
* @param onBehalf The address to supply on behalf of.
|
|
670
691
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupply` callback.
|
|
692
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
671
693
|
*/
|
|
672
|
-
function morphoSupply(chainId, market, assets, shares, slippageAmount, onBehalf, callbackCalls) {
|
|
694
|
+
function morphoSupply(chainId, market, assets, shares, slippageAmount, onBehalf, callbackCalls, skipRevert = false) {
|
|
673
695
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
674
696
|
const reenter = callbackCalls.length > 0;
|
|
675
697
|
const reenterData = reenter
|
|
@@ -684,21 +706,22 @@ export var BundlerAction;
|
|
|
684
706
|
args: [market, assets, shares, slippageAmount, onBehalf, reenterData],
|
|
685
707
|
}),
|
|
686
708
|
value: 0n,
|
|
687
|
-
skipRevert
|
|
709
|
+
skipRevert,
|
|
688
710
|
callbackHash: reenter ? keccak256(reenterData) : zeroHash,
|
|
689
711
|
},
|
|
690
712
|
];
|
|
691
713
|
}
|
|
692
714
|
BundlerAction.morphoSupply = morphoSupply;
|
|
693
715
|
/**
|
|
694
|
-
* Encodes a call to the
|
|
716
|
+
* Encodes a call to the GeneralAdapter1 to supply collateral to a Morpho Blue market.
|
|
695
717
|
* @param chainId The chain id for which to encode the call.
|
|
696
718
|
* @param market The market params to supply to.
|
|
697
719
|
* @param assets The amount of assets to supply.
|
|
698
720
|
* @param onBehalf The address to supply on behalf of.
|
|
699
721
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupplyCollateral` callback.
|
|
722
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
700
723
|
*/
|
|
701
|
-
function morphoSupplyCollateral(chainId, market, assets, onBehalf, callbackCalls) {
|
|
724
|
+
function morphoSupplyCollateral(chainId, market, assets, onBehalf, callbackCalls, skipRevert = false) {
|
|
702
725
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
703
726
|
const reenter = callbackCalls.length > 0;
|
|
704
727
|
const reenterData = reenter
|
|
@@ -713,22 +736,23 @@ export var BundlerAction;
|
|
|
713
736
|
args: [market, assets, onBehalf, reenterData],
|
|
714
737
|
}),
|
|
715
738
|
value: 0n,
|
|
716
|
-
skipRevert
|
|
739
|
+
skipRevert,
|
|
717
740
|
callbackHash: reenter ? keccak256(reenterData) : zeroHash,
|
|
718
741
|
},
|
|
719
742
|
];
|
|
720
743
|
}
|
|
721
744
|
BundlerAction.morphoSupplyCollateral = morphoSupplyCollateral;
|
|
722
745
|
/**
|
|
723
|
-
* Encodes a call to the
|
|
746
|
+
* Encodes a call to the GeneralAdapter1 to borrow from a Morpho Blue market.
|
|
724
747
|
* @param chainId The chain id for which to encode the call.
|
|
725
748
|
* @param market The market params to borrow from.
|
|
726
749
|
* @param assets The amount of assets to borrow.
|
|
727
750
|
* @param shares The amount of borrow shares to mint.
|
|
728
751
|
* @param slippageAmount The minimum (resp. maximum) amount of assets (resp. borrow shares) to borrow (resp. mint) (protects the sender from unexpected slippage).
|
|
729
752
|
* @param receiver The address to send borrowed tokens to.
|
|
753
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
730
754
|
*/
|
|
731
|
-
function morphoBorrow(chainId, market, assets, shares, slippageAmount, receiver) {
|
|
755
|
+
function morphoBorrow(chainId, market, assets, shares, slippageAmount, receiver, skipRevert = false) {
|
|
732
756
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
733
757
|
return [
|
|
734
758
|
{
|
|
@@ -739,14 +763,14 @@ export var BundlerAction;
|
|
|
739
763
|
args: [market, assets, shares, slippageAmount, receiver],
|
|
740
764
|
}),
|
|
741
765
|
value: 0n,
|
|
742
|
-
skipRevert
|
|
766
|
+
skipRevert,
|
|
743
767
|
callbackHash: zeroHash,
|
|
744
768
|
},
|
|
745
769
|
];
|
|
746
770
|
}
|
|
747
771
|
BundlerAction.morphoBorrow = morphoBorrow;
|
|
748
772
|
/**
|
|
749
|
-
* Encodes a call to the
|
|
773
|
+
* Encodes a call to the GeneralAdapter1 to repay to a Morpho Blue market.
|
|
750
774
|
* @param chainId The chain id for which to encode the call.
|
|
751
775
|
* @param market The market params to repay to.
|
|
752
776
|
* @param assets The amount of assets to repay.
|
|
@@ -754,8 +778,9 @@ export var BundlerAction;
|
|
|
754
778
|
* @param slippageAmount The maximum (resp. minimum) amount of assets (resp. borrow shares) to repay (resp. redeem) (protects the sender from unexpected slippage).
|
|
755
779
|
* @param onBehalf The address to repay on behalf of.
|
|
756
780
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupply` callback.
|
|
781
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
757
782
|
*/
|
|
758
|
-
function morphoRepay(chainId, market, assets, shares, slippageAmount, onBehalf, callbackCalls) {
|
|
783
|
+
function morphoRepay(chainId, market, assets, shares, slippageAmount, onBehalf, callbackCalls, skipRevert = false) {
|
|
759
784
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
760
785
|
const reenter = callbackCalls.length > 0;
|
|
761
786
|
const reenterData = reenter
|
|
@@ -770,22 +795,23 @@ export var BundlerAction;
|
|
|
770
795
|
args: [market, assets, shares, slippageAmount, onBehalf, reenterData],
|
|
771
796
|
}),
|
|
772
797
|
value: 0n,
|
|
773
|
-
skipRevert
|
|
798
|
+
skipRevert,
|
|
774
799
|
callbackHash: reenter ? keccak256(reenterData) : zeroHash,
|
|
775
800
|
},
|
|
776
801
|
];
|
|
777
802
|
}
|
|
778
803
|
BundlerAction.morphoRepay = morphoRepay;
|
|
779
804
|
/**
|
|
780
|
-
* Encodes a call to the
|
|
805
|
+
* Encodes a call to the GeneralAdapter1 to withdraw from a Morpho Blue market.
|
|
781
806
|
* @param chainId The chain id for which to encode the call.
|
|
782
807
|
* @param market The market params to withdraw from.
|
|
783
808
|
* @param assets The amount of assets to withdraw.
|
|
784
809
|
* @param shares The amount of supply shares to redeem.
|
|
785
810
|
* @param slippageAmount The minimum (resp. maximum) amount of assets (resp. supply shares) to withdraw (resp. redeem) (protects the sender from unexpected slippage).
|
|
786
811
|
* @param receiver The address to send withdrawn tokens to.
|
|
812
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
787
813
|
*/
|
|
788
|
-
function morphoWithdraw(chainId, market, assets, shares, slippageAmount, receiver) {
|
|
814
|
+
function morphoWithdraw(chainId, market, assets, shares, slippageAmount, receiver, skipRevert = false) {
|
|
789
815
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
790
816
|
return [
|
|
791
817
|
{
|
|
@@ -796,20 +822,21 @@ export var BundlerAction;
|
|
|
796
822
|
args: [market, assets, shares, slippageAmount, receiver],
|
|
797
823
|
}),
|
|
798
824
|
value: 0n,
|
|
799
|
-
skipRevert
|
|
825
|
+
skipRevert,
|
|
800
826
|
callbackHash: zeroHash,
|
|
801
827
|
},
|
|
802
828
|
];
|
|
803
829
|
}
|
|
804
830
|
BundlerAction.morphoWithdraw = morphoWithdraw;
|
|
805
831
|
/**
|
|
806
|
-
* Encodes a call to the
|
|
832
|
+
* Encodes a call to the GeneralAdapter1 to withdraw collateral from a Morpho Blue market.
|
|
807
833
|
* @param chainId The chain id for which to encode the call.
|
|
808
834
|
* @param market The market params to withdraw from.
|
|
809
835
|
* @param assets The amount of assets to withdraw.
|
|
810
836
|
* @param receiver The address to send withdrawn tokens to.
|
|
837
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
811
838
|
*/
|
|
812
|
-
function morphoWithdrawCollateral(chainId, market, assets, receiver) {
|
|
839
|
+
function morphoWithdrawCollateral(chainId, market, assets, receiver, skipRevert = false) {
|
|
813
840
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
814
841
|
return [
|
|
815
842
|
{
|
|
@@ -820,20 +847,21 @@ export var BundlerAction;
|
|
|
820
847
|
args: [market, assets, receiver],
|
|
821
848
|
}),
|
|
822
849
|
value: 0n,
|
|
823
|
-
skipRevert
|
|
850
|
+
skipRevert,
|
|
824
851
|
callbackHash: zeroHash,
|
|
825
852
|
},
|
|
826
853
|
];
|
|
827
854
|
}
|
|
828
855
|
BundlerAction.morphoWithdrawCollateral = morphoWithdrawCollateral;
|
|
829
856
|
/**
|
|
830
|
-
* Encodes a call to the
|
|
857
|
+
* Encodes a call to the GeneralAdapter1 to flash loan from Morpho Blue.
|
|
831
858
|
* @param chainId The chain id for which to encode the call.
|
|
832
859
|
* @param asset The address of the ERC20 token to flash loan.
|
|
833
860
|
* @param amount The amount of tokens to flash loan.
|
|
834
861
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoFlashLoan` callback.
|
|
862
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
835
863
|
*/
|
|
836
|
-
function morphoFlashLoan(chainId, asset, amount, callbackCalls) {
|
|
864
|
+
function morphoFlashLoan(chainId, asset, amount, callbackCalls, skipRevert = false) {
|
|
837
865
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
838
866
|
const reenter = callbackCalls.length > 0;
|
|
839
867
|
const reenterData = reenter
|
|
@@ -856,21 +884,22 @@ export var BundlerAction;
|
|
|
856
884
|
],
|
|
857
885
|
}),
|
|
858
886
|
value: 0n,
|
|
859
|
-
skipRevert
|
|
887
|
+
skipRevert,
|
|
860
888
|
callbackHash: reenter ? keccak256(reenterData) : zeroHash,
|
|
861
889
|
},
|
|
862
890
|
];
|
|
863
891
|
}
|
|
864
892
|
BundlerAction.morphoFlashLoan = morphoFlashLoan;
|
|
865
893
|
/**
|
|
866
|
-
* Encodes a call to
|
|
894
|
+
* Encodes a call to trigger a public reallocation on the PublicAllocator.
|
|
867
895
|
* @param chainId The chain id for which to encode the call.
|
|
868
896
|
* @param vault The vault to reallocate.
|
|
869
897
|
* @param fee The vault public reallocation fee.
|
|
870
898
|
* @param withdrawals The array of withdrawals to perform, before supplying everything to the supply market.
|
|
871
899
|
* @param supplyMarketParams The market params to reallocate to.
|
|
900
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
872
901
|
*/
|
|
873
|
-
function publicAllocatorReallocateTo(chainId, vault, fee, withdrawals, supplyMarketParams) {
|
|
902
|
+
function publicAllocatorReallocateTo(chainId, vault, fee, withdrawals, supplyMarketParams, skipRevert = false) {
|
|
874
903
|
const { publicAllocator } = getChainAddresses(chainId);
|
|
875
904
|
if (publicAllocator == null)
|
|
876
905
|
throw new BundlerErrors.UnexpectedAction("reallocateTo", chainId);
|
|
@@ -883,7 +912,7 @@ export var BundlerAction;
|
|
|
883
912
|
args: [vault, withdrawals, supplyMarketParams],
|
|
884
913
|
}),
|
|
885
914
|
value: fee,
|
|
886
|
-
skipRevert
|
|
915
|
+
skipRevert,
|
|
887
916
|
callbackHash: zeroHash,
|
|
888
917
|
},
|
|
889
918
|
];
|
|
@@ -891,14 +920,14 @@ export var BundlerAction;
|
|
|
891
920
|
BundlerAction.publicAllocatorReallocateTo = publicAllocatorReallocateTo;
|
|
892
921
|
/* Universal Rewards Distributor */
|
|
893
922
|
/**
|
|
894
|
-
* Encodes a call to the
|
|
923
|
+
* Encodes a call to the Universal Rewards Distributor to claim rewards.
|
|
895
924
|
* @param chainId The chain id for which to encode the call.
|
|
896
925
|
* @param distributor The address of the distributor to claim rewards from.
|
|
897
926
|
* @param account The address to claim rewards for.
|
|
898
927
|
* @param reward The address of the reward token to claim.
|
|
899
928
|
* @param amount The amount of rewards to claim.
|
|
900
929
|
* @param proof The Merkle proof to claim the rewards.
|
|
901
|
-
* @param skipRevert Whether to allow the claim to revert without making the whole
|
|
930
|
+
* @param skipRevert Whether to allow the claim to revert without making the whole bundle revert. Defaults to true.
|
|
902
931
|
*/
|
|
903
932
|
function urdClaim(distributor, account, reward, amount, proof, skipRevert = true) {
|
|
904
933
|
return [
|
|
@@ -918,14 +947,14 @@ export var BundlerAction;
|
|
|
918
947
|
BundlerAction.urdClaim = urdClaim;
|
|
919
948
|
/* Wrapped Native */
|
|
920
949
|
/**
|
|
921
|
-
* Encodes a call to the
|
|
950
|
+
* Encodes a call to the GeneralAdapter1 to wrap native tokens (ETH to WETH on ethereum, MATIC to WMATIC on polygon, etc).
|
|
922
951
|
* @param chainId The chain id for which to encode the call.
|
|
923
952
|
* @param amount The amount of native tokens to wrap (in wei).
|
|
924
|
-
* @param recipient The address to send tokens to.
|
|
953
|
+
* @param recipient The address to send tokens to.
|
|
954
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
925
955
|
*/
|
|
926
|
-
function wrapNative(chainId, amount, recipient) {
|
|
956
|
+
function wrapNative(chainId, amount, recipient, skipRevert = false) {
|
|
927
957
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
928
|
-
recipient ??= generalAdapter1;
|
|
929
958
|
return [
|
|
930
959
|
{
|
|
931
960
|
to: generalAdapter1,
|
|
@@ -935,21 +964,21 @@ export var BundlerAction;
|
|
|
935
964
|
args: [amount, recipient],
|
|
936
965
|
}),
|
|
937
966
|
value: 0n,
|
|
938
|
-
skipRevert
|
|
967
|
+
skipRevert,
|
|
939
968
|
callbackHash: zeroHash,
|
|
940
969
|
},
|
|
941
970
|
];
|
|
942
971
|
}
|
|
943
972
|
BundlerAction.wrapNative = wrapNative;
|
|
944
973
|
/**
|
|
945
|
-
* Encodes a call to the
|
|
974
|
+
* Encodes a call to the GeneralAdapter1 to unwrap native tokens (WETH to ETH on ethereum, WMATIC to MATIC on polygon, etc).
|
|
946
975
|
* @param chainId The chain id for which to encode the call.
|
|
947
976
|
* @param amount The amount of native tokens to unwrap (in wei).
|
|
948
|
-
* @param recipient The address to send tokens to.
|
|
977
|
+
* @param recipient The address to send tokens to.
|
|
978
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
949
979
|
*/
|
|
950
|
-
function unwrapNative(chainId, amount, recipient) {
|
|
980
|
+
function unwrapNative(chainId, amount, recipient, skipRevert = false) {
|
|
951
981
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
952
|
-
recipient ??= generalAdapter1;
|
|
953
982
|
return [
|
|
954
983
|
{
|
|
955
984
|
to: generalAdapter1,
|
|
@@ -959,7 +988,7 @@ export var BundlerAction;
|
|
|
959
988
|
args: [amount, recipient],
|
|
960
989
|
}),
|
|
961
990
|
value: 0n,
|
|
962
|
-
skipRevert
|
|
991
|
+
skipRevert,
|
|
963
992
|
callbackHash: zeroHash,
|
|
964
993
|
},
|
|
965
994
|
];
|
|
@@ -967,16 +996,16 @@ export var BundlerAction;
|
|
|
967
996
|
BundlerAction.unwrapNative = unwrapNative;
|
|
968
997
|
/* stETH */
|
|
969
998
|
/**
|
|
970
|
-
* Encodes a call to the
|
|
999
|
+
* Encodes a call to the GeneralAdapter1 to stake native tokens using Lido (ETH to stETH on ethereum).
|
|
971
1000
|
* @param chainId The chain id for which to encode the call.
|
|
972
1001
|
* @param amount The amount of native tokens to stake (in wei).
|
|
973
1002
|
* @param maxSharePrice The maximum amount of wei to pay for minting 1 share (scaled by RAY).
|
|
974
1003
|
* @param referral The referral address to use.
|
|
975
|
-
* @param recipient The address to send stETH to.
|
|
1004
|
+
* @param recipient The address to send stETH to.
|
|
1005
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
976
1006
|
*/
|
|
977
|
-
function stakeEth(chainId, amount, maxSharePrice, referral, recipient) {
|
|
1007
|
+
function stakeEth(chainId, amount, maxSharePrice, referral, recipient, skipRevert = false) {
|
|
978
1008
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
979
|
-
recipient ??= generalAdapter1;
|
|
980
1009
|
return [
|
|
981
1010
|
{
|
|
982
1011
|
to: generalAdapter1,
|
|
@@ -986,7 +1015,7 @@ export var BundlerAction;
|
|
|
986
1015
|
args: [amount, maxSharePrice, referral, recipient],
|
|
987
1016
|
}),
|
|
988
1017
|
value: 0n,
|
|
989
|
-
skipRevert
|
|
1018
|
+
skipRevert,
|
|
990
1019
|
callbackHash: zeroHash,
|
|
991
1020
|
},
|
|
992
1021
|
];
|
|
@@ -994,14 +1023,14 @@ export var BundlerAction;
|
|
|
994
1023
|
BundlerAction.stakeEth = stakeEth;
|
|
995
1024
|
/* Wrapped stETH */
|
|
996
1025
|
/**
|
|
997
|
-
* Encodes a call to the
|
|
1026
|
+
* Encodes a call to the GeneralAdapter1 to wrap stETH (stETH to wstETH on ethereum).
|
|
998
1027
|
* @param chainId The chain id for which to encode the call.
|
|
999
1028
|
* @param amount The amount of stETH to wrap (in wei).
|
|
1000
|
-
* @param recipient The address to send wstETH to.
|
|
1029
|
+
* @param recipient The address to send wstETH to.
|
|
1030
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1001
1031
|
*/
|
|
1002
|
-
function wrapStEth(chainId, amount, recipient) {
|
|
1032
|
+
function wrapStEth(chainId, amount, recipient, skipRevert = false) {
|
|
1003
1033
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
1004
|
-
recipient ??= generalAdapter1;
|
|
1005
1034
|
return [
|
|
1006
1035
|
{
|
|
1007
1036
|
to: generalAdapter1,
|
|
@@ -1011,21 +1040,21 @@ export var BundlerAction;
|
|
|
1011
1040
|
args: [amount, recipient],
|
|
1012
1041
|
}),
|
|
1013
1042
|
value: 0n,
|
|
1014
|
-
skipRevert
|
|
1043
|
+
skipRevert,
|
|
1015
1044
|
callbackHash: zeroHash,
|
|
1016
1045
|
},
|
|
1017
1046
|
];
|
|
1018
1047
|
}
|
|
1019
1048
|
BundlerAction.wrapStEth = wrapStEth;
|
|
1020
1049
|
/**
|
|
1021
|
-
* Encodes a call to the
|
|
1050
|
+
* Encodes a call to the GeneralAdapter1 to unwrap wstETH (wstETH to stETH on ethereum).
|
|
1022
1051
|
* @param chainId The chain id for which to encode the call.
|
|
1023
1052
|
* @param amount The amount of wstETH to unwrap (in wei).
|
|
1024
|
-
* @param recipient The address to send stETH to.
|
|
1053
|
+
* @param recipient The address to send stETH to.
|
|
1054
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1025
1055
|
*/
|
|
1026
|
-
function unwrapStEth(chainId, amount, recipient) {
|
|
1056
|
+
function unwrapStEth(chainId, amount, recipient, skipRevert = false) {
|
|
1027
1057
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
1028
|
-
recipient ??= generalAdapter1;
|
|
1029
1058
|
return [
|
|
1030
1059
|
{
|
|
1031
1060
|
to: generalAdapter1,
|
|
@@ -1035,7 +1064,7 @@ export var BundlerAction;
|
|
|
1035
1064
|
args: [amount, recipient],
|
|
1036
1065
|
}),
|
|
1037
1066
|
value: 0n,
|
|
1038
|
-
skipRevert
|
|
1067
|
+
skipRevert,
|
|
1039
1068
|
callbackHash: zeroHash,
|
|
1040
1069
|
},
|
|
1041
1070
|
];
|
|
@@ -1043,14 +1072,15 @@ export var BundlerAction;
|
|
|
1043
1072
|
BundlerAction.unwrapStEth = unwrapStEth;
|
|
1044
1073
|
/* AaveV2 */
|
|
1045
1074
|
/**
|
|
1046
|
-
* Encodes a call to the
|
|
1075
|
+
* Encodes a call to the AaveV2MigrationAdapter to repay a debt on AaveV2.
|
|
1047
1076
|
* @param chainId The chain id for which to encode the call.
|
|
1048
1077
|
* @param asset The debt asset to repay.
|
|
1049
1078
|
* @param amount The amount of debt to repay.
|
|
1050
1079
|
* @param onBehalf The address on behalf of which to repay.
|
|
1051
1080
|
* @param rateMode The interest rate mode used by the debt to repay.
|
|
1081
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1052
1082
|
*/
|
|
1053
|
-
function aaveV2Repay(chainId, asset, amount, onBehalf, rateMode = 1n) {
|
|
1083
|
+
function aaveV2Repay(chainId, asset, amount, onBehalf, rateMode = 1n, skipRevert = false) {
|
|
1054
1084
|
const { bundler3: { aaveV2MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1055
1085
|
if (aaveV2MigrationAdapter == null)
|
|
1056
1086
|
throw new BundlerErrors.UnexpectedAction("aaveV2Repay", chainId);
|
|
@@ -1063,24 +1093,24 @@ export var BundlerAction;
|
|
|
1063
1093
|
args: [asset, amount, rateMode, onBehalf],
|
|
1064
1094
|
}),
|
|
1065
1095
|
value: 0n,
|
|
1066
|
-
skipRevert
|
|
1096
|
+
skipRevert,
|
|
1067
1097
|
callbackHash: zeroHash,
|
|
1068
1098
|
},
|
|
1069
1099
|
];
|
|
1070
1100
|
}
|
|
1071
1101
|
BundlerAction.aaveV2Repay = aaveV2Repay;
|
|
1072
1102
|
/**
|
|
1073
|
-
* Encodes a call to the
|
|
1103
|
+
* Encodes a call to the AaveV2MigrationAdapter to withdraw from AaveV2.
|
|
1074
1104
|
* @param chainId The chain id for which to encode the call.
|
|
1075
1105
|
* @param asset The asset to withdraw.
|
|
1076
1106
|
* @param amount The amount of asset to withdraw.
|
|
1077
|
-
* @param recipient The recipient of ERC20 tokens.
|
|
1107
|
+
* @param recipient The recipient of ERC20 tokens.
|
|
1108
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1078
1109
|
*/
|
|
1079
|
-
function aaveV2Withdraw(chainId, asset, amount, recipient) {
|
|
1110
|
+
function aaveV2Withdraw(chainId, asset, amount, recipient, skipRevert = false) {
|
|
1080
1111
|
const { bundler3: { aaveV2MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1081
1112
|
if (aaveV2MigrationAdapter == null)
|
|
1082
1113
|
throw new BundlerErrors.UnexpectedAction("aaveV2Withdraw", chainId);
|
|
1083
|
-
recipient ??= aaveV2MigrationAdapter;
|
|
1084
1114
|
return [
|
|
1085
1115
|
{
|
|
1086
1116
|
to: aaveV2MigrationAdapter,
|
|
@@ -1090,7 +1120,7 @@ export var BundlerAction;
|
|
|
1090
1120
|
args: [asset, amount, recipient],
|
|
1091
1121
|
}),
|
|
1092
1122
|
value: 0n,
|
|
1093
|
-
skipRevert
|
|
1123
|
+
skipRevert,
|
|
1094
1124
|
callbackHash: zeroHash,
|
|
1095
1125
|
},
|
|
1096
1126
|
];
|
|
@@ -1098,14 +1128,15 @@ export var BundlerAction;
|
|
|
1098
1128
|
BundlerAction.aaveV2Withdraw = aaveV2Withdraw;
|
|
1099
1129
|
/* AaveV3 */
|
|
1100
1130
|
/**
|
|
1101
|
-
* Encodes a call to the
|
|
1131
|
+
* Encodes a call to the AaveV3CoreMigrationAdapter to repay a debt on AaveV3.
|
|
1102
1132
|
* @param chainId The chain id for which to encode the call.
|
|
1103
1133
|
* @param asset The debt asset to repay.
|
|
1104
1134
|
* @param amount The amount of debt to repay.
|
|
1105
1135
|
* @param onBehalf The address on behalf of which to repay.
|
|
1106
1136
|
* @param rateMode The interest rate mode used by the debt to repay.
|
|
1137
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1107
1138
|
*/
|
|
1108
|
-
function aaveV3Repay(chainId, asset, amount, onBehalf, rateMode = 1n) {
|
|
1139
|
+
function aaveV3Repay(chainId, asset, amount, onBehalf, rateMode = 1n, skipRevert = false) {
|
|
1109
1140
|
const { bundler3: { aaveV3CoreMigrationAdapter }, // TODO: choose between core & prime
|
|
1110
1141
|
} = getChainAddresses(chainId);
|
|
1111
1142
|
if (aaveV3CoreMigrationAdapter == null)
|
|
@@ -1119,25 +1150,25 @@ export var BundlerAction;
|
|
|
1119
1150
|
args: [asset, amount, rateMode, onBehalf],
|
|
1120
1151
|
}),
|
|
1121
1152
|
value: 0n,
|
|
1122
|
-
skipRevert
|
|
1153
|
+
skipRevert,
|
|
1123
1154
|
callbackHash: zeroHash,
|
|
1124
1155
|
},
|
|
1125
1156
|
];
|
|
1126
1157
|
}
|
|
1127
1158
|
BundlerAction.aaveV3Repay = aaveV3Repay;
|
|
1128
1159
|
/**
|
|
1129
|
-
* Encodes a call to the
|
|
1160
|
+
* Encodes a call to the AaveV3CoreMigrationAdapter to withdrawn from AaveV3.
|
|
1130
1161
|
* @param chainId The chain id for which to encode the call.
|
|
1131
1162
|
* @param asset The asset to withdraw.
|
|
1132
1163
|
* @param amount The amount of asset to withdraw.
|
|
1133
|
-
* @param recipient The recipient of ERC20 tokens.
|
|
1164
|
+
* @param recipient The recipient of ERC20 tokens.
|
|
1165
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1134
1166
|
*/
|
|
1135
|
-
function aaveV3Withdraw(chainId, asset, amount, recipient) {
|
|
1167
|
+
function aaveV3Withdraw(chainId, asset, amount, recipient, skipRevert = false) {
|
|
1136
1168
|
const { bundler3: { aaveV3CoreMigrationAdapter }, // TODO: choose between core & prime
|
|
1137
1169
|
} = getChainAddresses(chainId);
|
|
1138
1170
|
if (aaveV3CoreMigrationAdapter == null)
|
|
1139
1171
|
throw new BundlerErrors.UnexpectedAction("aaveV3Withdraw", chainId);
|
|
1140
|
-
recipient ??= aaveV3CoreMigrationAdapter;
|
|
1141
1172
|
return [
|
|
1142
1173
|
{
|
|
1143
1174
|
to: aaveV3CoreMigrationAdapter,
|
|
@@ -1147,7 +1178,7 @@ export var BundlerAction;
|
|
|
1147
1178
|
args: [asset, amount, recipient],
|
|
1148
1179
|
}),
|
|
1149
1180
|
value: 0n,
|
|
1150
|
-
skipRevert
|
|
1181
|
+
skipRevert,
|
|
1151
1182
|
callbackHash: zeroHash,
|
|
1152
1183
|
},
|
|
1153
1184
|
];
|
|
@@ -1155,13 +1186,14 @@ export var BundlerAction;
|
|
|
1155
1186
|
BundlerAction.aaveV3Withdraw = aaveV3Withdraw;
|
|
1156
1187
|
/* AaveV3 Optimizer */
|
|
1157
1188
|
/**
|
|
1158
|
-
* Encodes a call to the
|
|
1189
|
+
* Encodes a call to the AaveV3OptimizerMigrationAdapter to repay a debt on Morpho's AaveV3Optimizer.
|
|
1159
1190
|
* @param chainId The chain id for which to encode the call.
|
|
1160
1191
|
* @param underlying The underlying debt asset to repay.
|
|
1161
1192
|
* @param amount The amount of debt to repay.
|
|
1162
1193
|
* @param onBehalf The address on behalf of which to repay.
|
|
1194
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1163
1195
|
*/
|
|
1164
|
-
function aaveV3OptimizerRepay(chainId, underlying, amount, onBehalf) {
|
|
1196
|
+
function aaveV3OptimizerRepay(chainId, underlying, amount, onBehalf, skipRevert = false) {
|
|
1165
1197
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = getChainAddresses(chainId);
|
|
1166
1198
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
1167
1199
|
throw new BundlerErrors.UnexpectedAction("aaveV3OptimizerRepay", chainId);
|
|
@@ -1174,25 +1206,25 @@ export var BundlerAction;
|
|
|
1174
1206
|
args: [underlying, amount, onBehalf],
|
|
1175
1207
|
}),
|
|
1176
1208
|
value: 0n,
|
|
1177
|
-
skipRevert
|
|
1209
|
+
skipRevert,
|
|
1178
1210
|
callbackHash: zeroHash,
|
|
1179
1211
|
},
|
|
1180
1212
|
];
|
|
1181
1213
|
}
|
|
1182
1214
|
BundlerAction.aaveV3OptimizerRepay = aaveV3OptimizerRepay;
|
|
1183
1215
|
/**
|
|
1184
|
-
* Encodes a call to the
|
|
1216
|
+
* Encodes a call to the AaveV3OptimizerMigrationAdapter to withdraw from Morpho's AaveV3Optimizer.
|
|
1185
1217
|
* @param chainId The chain id for which to encode the call.
|
|
1186
1218
|
* @param underlying The underlying asset to withdraw.
|
|
1187
1219
|
* @param amount The amount to withdraw.
|
|
1188
1220
|
* @param maxIterations The maximum amount of iterations to use for the withdrawal.
|
|
1189
|
-
* @param recipient The recipient of ERC20 tokens.
|
|
1221
|
+
* @param recipient The recipient of ERC20 tokens.
|
|
1222
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1190
1223
|
*/
|
|
1191
|
-
function aaveV3OptimizerWithdraw(chainId, underlying, amount, maxIterations, recipient) {
|
|
1224
|
+
function aaveV3OptimizerWithdraw(chainId, underlying, amount, maxIterations, recipient, skipRevert = false) {
|
|
1192
1225
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = getChainAddresses(chainId);
|
|
1193
1226
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
1194
1227
|
throw new BundlerErrors.UnexpectedAction("aaveV3OptimizerWithdraw", chainId);
|
|
1195
|
-
recipient ??= aaveV3OptimizerMigrationAdapter;
|
|
1196
1228
|
return [
|
|
1197
1229
|
{
|
|
1198
1230
|
to: aaveV3OptimizerMigrationAdapter,
|
|
@@ -1202,24 +1234,24 @@ export var BundlerAction;
|
|
|
1202
1234
|
args: [underlying, amount, maxIterations, recipient],
|
|
1203
1235
|
}),
|
|
1204
1236
|
value: 0n,
|
|
1205
|
-
skipRevert
|
|
1237
|
+
skipRevert,
|
|
1206
1238
|
callbackHash: zeroHash,
|
|
1207
1239
|
},
|
|
1208
1240
|
];
|
|
1209
1241
|
}
|
|
1210
1242
|
BundlerAction.aaveV3OptimizerWithdraw = aaveV3OptimizerWithdraw;
|
|
1211
1243
|
/**
|
|
1212
|
-
* Encodes a call to the
|
|
1244
|
+
* Encodes a call to the AaveV3OptimizerMigrationAdapter to withdraw collateral from Morpho's AaveV3Optimizer.
|
|
1213
1245
|
* @param chainId The chain id for which to encode the call.
|
|
1214
1246
|
* @param underlying The underlying asset to withdraw.
|
|
1215
1247
|
* @param amount The amount to withdraw.
|
|
1216
|
-
* @param recipient The recipient of ERC20 tokens.
|
|
1248
|
+
* @param recipient The recipient of ERC20 tokens.
|
|
1249
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1217
1250
|
*/
|
|
1218
|
-
function aaveV3OptimizerWithdrawCollateral(chainId, underlying, amount, recipient) {
|
|
1251
|
+
function aaveV3OptimizerWithdrawCollateral(chainId, underlying, amount, recipient, skipRevert = false) {
|
|
1219
1252
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = getChainAddresses(chainId);
|
|
1220
1253
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
1221
1254
|
throw new BundlerErrors.UnexpectedAction("aaveV3OptimizerWithdrawCollateral", chainId);
|
|
1222
|
-
recipient ??= aaveV3OptimizerMigrationAdapter;
|
|
1223
1255
|
return [
|
|
1224
1256
|
{
|
|
1225
1257
|
to: aaveV3OptimizerMigrationAdapter,
|
|
@@ -1229,28 +1261,27 @@ export var BundlerAction;
|
|
|
1229
1261
|
args: [underlying, amount, recipient],
|
|
1230
1262
|
}),
|
|
1231
1263
|
value: 0n,
|
|
1232
|
-
skipRevert
|
|
1264
|
+
skipRevert,
|
|
1233
1265
|
callbackHash: zeroHash,
|
|
1234
1266
|
},
|
|
1235
1267
|
];
|
|
1236
1268
|
}
|
|
1237
1269
|
BundlerAction.aaveV3OptimizerWithdrawCollateral = aaveV3OptimizerWithdrawCollateral;
|
|
1238
1270
|
/**
|
|
1239
|
-
* Encodes a call to the
|
|
1271
|
+
* Encodes a call to the AaveV3 optimizer to approve the chain's AaveV3OptimizerMigrationAdapter.
|
|
1272
|
+
* as the sender's manager on Morpho's AaveV3Optimizer.
|
|
1240
1273
|
* @param chainId The chain id for which to encode the call.
|
|
1241
1274
|
* @param owner The owner of the AaveV3Optimizer position.
|
|
1242
1275
|
* @param isApproved Whether the manager is approved.
|
|
1243
1276
|
* @param nonce The nonce used to sign.
|
|
1244
1277
|
* @param deadline The timestamp until which the signature is valid.
|
|
1245
1278
|
* @param signature The Ethers signature to submit.
|
|
1246
|
-
* @param
|
|
1247
|
-
* @param skipRevert Whether to allow the signature to revert without making the whole multicall revert.
|
|
1279
|
+
* @param skipRevert Whether to allow the signature to revert without making the whole bundle revert. Defaults to true.
|
|
1248
1280
|
*/
|
|
1249
|
-
function aaveV3OptimizerApproveManagerWithSig(chainId, aaveV3Optimizer, owner, isApproved, nonce, deadline, signature,
|
|
1281
|
+
function aaveV3OptimizerApproveManagerWithSig(chainId, aaveV3Optimizer, owner, isApproved, nonce, deadline, signature, skipRevert = true) {
|
|
1250
1282
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = getChainAddresses(chainId);
|
|
1251
1283
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
1252
1284
|
throw new BundlerErrors.UnexpectedAction("aaveV3OptimizerApproveManagerWithSig", chainId);
|
|
1253
|
-
manager ??= aaveV3OptimizerMigrationAdapter;
|
|
1254
1285
|
const { r, s, yParity } = parseSignature(signature);
|
|
1255
1286
|
return [
|
|
1256
1287
|
{
|
|
@@ -1284,7 +1315,7 @@ export var BundlerAction;
|
|
|
1284
1315
|
functionName: "approveManagerWithSig",
|
|
1285
1316
|
args: [
|
|
1286
1317
|
owner,
|
|
1287
|
-
|
|
1318
|
+
aaveV3OptimizerMigrationAdapter,
|
|
1288
1319
|
isApproved,
|
|
1289
1320
|
nonce,
|
|
1290
1321
|
deadline,
|
|
@@ -1300,13 +1331,14 @@ export var BundlerAction;
|
|
|
1300
1331
|
BundlerAction.aaveV3OptimizerApproveManagerWithSig = aaveV3OptimizerApproveManagerWithSig;
|
|
1301
1332
|
/* CompoundV2 */
|
|
1302
1333
|
/**
|
|
1303
|
-
* Encodes a call to the
|
|
1334
|
+
* Encodes a call to the CompoundV2MigrationAdapter to repay a debt on CompoundV2.
|
|
1304
1335
|
* @param chainId The chain id for which to encode the call.
|
|
1305
1336
|
* @param cToken The cToken on which to repay the debt.
|
|
1306
1337
|
* @param amount The amount of debt to repay.
|
|
1307
|
-
* @param
|
|
1338
|
+
* @param onBehalf The account on behalf of which to repay.
|
|
1339
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1308
1340
|
*/
|
|
1309
|
-
function compoundV2Repay(chainId, cToken, amount, isEth, onBehalf) {
|
|
1341
|
+
function compoundV2Repay(chainId, cToken, amount, isEth, onBehalf, skipRevert = false) {
|
|
1310
1342
|
const { bundler3: { compoundV2MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1311
1343
|
if (compoundV2MigrationAdapter == null)
|
|
1312
1344
|
throw new BundlerErrors.UnexpectedAction("compoundV2Repay", chainId);
|
|
@@ -1325,24 +1357,24 @@ export var BundlerAction;
|
|
|
1325
1357
|
args: [cToken, amount, onBehalf],
|
|
1326
1358
|
}),
|
|
1327
1359
|
value: isEth ? amount : 0n,
|
|
1328
|
-
skipRevert
|
|
1360
|
+
skipRevert,
|
|
1329
1361
|
callbackHash: zeroHash,
|
|
1330
1362
|
},
|
|
1331
1363
|
];
|
|
1332
1364
|
}
|
|
1333
1365
|
BundlerAction.compoundV2Repay = compoundV2Repay;
|
|
1334
1366
|
/**
|
|
1335
|
-
* Encodes a call to the
|
|
1367
|
+
* Encodes a call to the CompoundV2MigrationAdapter to withdraw collateral from CompoundV2.
|
|
1336
1368
|
* @param chainId The chain id for which to encode the call.
|
|
1337
1369
|
* @param cToken The cToken on which to withdraw.
|
|
1338
1370
|
* @param amount The amount to withdraw.
|
|
1339
|
-
* @param recipient The recipient of ERC20 tokens.
|
|
1371
|
+
* @param recipient The recipient of ERC20 tokens.
|
|
1372
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1340
1373
|
*/
|
|
1341
|
-
function compoundV2Redeem(chainId, cToken, amount, isEth, recipient) {
|
|
1374
|
+
function compoundV2Redeem(chainId, cToken, amount, isEth, recipient, skipRevert = false) {
|
|
1342
1375
|
const { bundler3: { compoundV2MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1343
1376
|
if (compoundV2MigrationAdapter == null)
|
|
1344
1377
|
throw new BundlerErrors.UnexpectedAction("compoundV2Repay", chainId);
|
|
1345
|
-
recipient ??= compoundV2MigrationAdapter;
|
|
1346
1378
|
return [
|
|
1347
1379
|
{
|
|
1348
1380
|
to: compoundV2MigrationAdapter,
|
|
@@ -1358,7 +1390,7 @@ export var BundlerAction;
|
|
|
1358
1390
|
args: [cToken, amount, recipient],
|
|
1359
1391
|
}),
|
|
1360
1392
|
value: 0n,
|
|
1361
|
-
skipRevert
|
|
1393
|
+
skipRevert,
|
|
1362
1394
|
callbackHash: zeroHash,
|
|
1363
1395
|
},
|
|
1364
1396
|
];
|
|
@@ -1366,13 +1398,14 @@ export var BundlerAction;
|
|
|
1366
1398
|
BundlerAction.compoundV2Redeem = compoundV2Redeem;
|
|
1367
1399
|
/* CompoundV3 */
|
|
1368
1400
|
/**
|
|
1369
|
-
* Encodes a call to the
|
|
1401
|
+
* Encodes a call to the CompoundV3MigrationAdapter to repay a debt on CompoundV3.
|
|
1370
1402
|
* @param chainId The chain id for which to encode the call.
|
|
1371
1403
|
* @param instance The CompoundV3 instance on which to repay the debt.
|
|
1372
1404
|
* @param amount The amount of debt to repay.
|
|
1373
1405
|
* @param onBehalf The address on behalf of which to repay.
|
|
1406
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1374
1407
|
*/
|
|
1375
|
-
function compoundV3Repay(chainId, instance, amount, onBehalf) {
|
|
1408
|
+
function compoundV3Repay(chainId, instance, amount, onBehalf, skipRevert = false) {
|
|
1376
1409
|
const { bundler3: { compoundV3MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1377
1410
|
if (compoundV3MigrationAdapter == null)
|
|
1378
1411
|
throw new BundlerErrors.UnexpectedAction("compoundV3Repay", chainId);
|
|
@@ -1385,25 +1418,25 @@ export var BundlerAction;
|
|
|
1385
1418
|
args: [instance, amount, onBehalf],
|
|
1386
1419
|
}),
|
|
1387
1420
|
value: 0n,
|
|
1388
|
-
skipRevert
|
|
1421
|
+
skipRevert,
|
|
1389
1422
|
callbackHash: zeroHash,
|
|
1390
1423
|
},
|
|
1391
1424
|
];
|
|
1392
1425
|
}
|
|
1393
1426
|
BundlerAction.compoundV3Repay = compoundV3Repay;
|
|
1394
1427
|
/**
|
|
1395
|
-
* Encodes a call to the
|
|
1428
|
+
* Encodes a call to the CompoundV3MigrationAdapter to withdraw collateral from CompoundV3.
|
|
1396
1429
|
* @param chainId The chain id for which to encode the call.
|
|
1397
1430
|
* @param instance The CompoundV3 instance on which to withdraw.
|
|
1398
1431
|
* @param asset The asset to withdraw.
|
|
1399
1432
|
* @param amount The amount to withdraw.
|
|
1400
|
-
* @param recipient The recipient of ERC20 tokens.
|
|
1433
|
+
* @param recipient The recipient of ERC20 tokens.
|
|
1434
|
+
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1401
1435
|
*/
|
|
1402
|
-
function compoundV3WithdrawFrom(chainId, instance, asset, amount, recipient) {
|
|
1436
|
+
function compoundV3WithdrawFrom(chainId, instance, asset, amount, recipient, skipRevert = false) {
|
|
1403
1437
|
const { bundler3: { compoundV3MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1404
1438
|
if (compoundV3MigrationAdapter == null)
|
|
1405
1439
|
throw new BundlerErrors.UnexpectedAction("compoundV3WithdrawFrom", chainId);
|
|
1406
|
-
recipient ??= compoundV3MigrationAdapter;
|
|
1407
1440
|
return [
|
|
1408
1441
|
{
|
|
1409
1442
|
to: compoundV3MigrationAdapter,
|
|
@@ -1413,14 +1446,15 @@ export var BundlerAction;
|
|
|
1413
1446
|
args: [instance, asset, amount, recipient],
|
|
1414
1447
|
}),
|
|
1415
1448
|
value: 0n,
|
|
1416
|
-
skipRevert
|
|
1449
|
+
skipRevert,
|
|
1417
1450
|
callbackHash: zeroHash,
|
|
1418
1451
|
},
|
|
1419
1452
|
];
|
|
1420
1453
|
}
|
|
1421
1454
|
BundlerAction.compoundV3WithdrawFrom = compoundV3WithdrawFrom;
|
|
1422
1455
|
/**
|
|
1423
|
-
* Encodes a call to the
|
|
1456
|
+
* Encodes a call to the CompoundV3 instance to allow the chain's CompoundV3MigrationAdapter.
|
|
1457
|
+
* to act on the sender's position on CompoundV3.
|
|
1424
1458
|
* @param chainId The chain id for which to encode the call.
|
|
1425
1459
|
* @param instance The CompoundV3 instance on which to submit the signature.
|
|
1426
1460
|
* @param owner The owner of the CompoundV3 position.
|
|
@@ -1428,15 +1462,13 @@ export var BundlerAction;
|
|
|
1428
1462
|
* @param nonce The nonce used to sign.
|
|
1429
1463
|
* @param expiry The timestamp until which the signature is valid.
|
|
1430
1464
|
* @param signature The Ethers signature to submit.
|
|
1431
|
-
* @param
|
|
1432
|
-
* @param skipRevert Whether to allow the signature to revert without making the whole multicall revert.
|
|
1465
|
+
* @param skipRevert Whether to allow the signature to revert without making the whole bundle revert. Defaults to true.
|
|
1433
1466
|
*/
|
|
1434
|
-
function compoundV3AllowBySig(chainId, instance, owner, isAllowed, nonce, expiry, signature,
|
|
1467
|
+
function compoundV3AllowBySig(chainId, instance, owner, isAllowed, nonce, expiry, signature, skipRevert = true) {
|
|
1435
1468
|
const { bundler3: { compoundV3MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1436
1469
|
if (compoundV3MigrationAdapter == null)
|
|
1437
1470
|
throw new BundlerErrors.UnexpectedAction("compoundV3AllowBySig", chainId);
|
|
1438
1471
|
const { r, s, yParity } = parseSignature(signature);
|
|
1439
|
-
manager ??= compoundV3MigrationAdapter;
|
|
1440
1472
|
return [
|
|
1441
1473
|
{
|
|
1442
1474
|
to: instance,
|
|
@@ -1460,7 +1492,16 @@ export var BundlerAction;
|
|
|
1460
1492
|
},
|
|
1461
1493
|
],
|
|
1462
1494
|
functionName: "allowBySig",
|
|
1463
|
-
args: [
|
|
1495
|
+
args: [
|
|
1496
|
+
owner,
|
|
1497
|
+
compoundV3MigrationAdapter,
|
|
1498
|
+
isAllowed,
|
|
1499
|
+
nonce,
|
|
1500
|
+
expiry,
|
|
1501
|
+
yParity + 27,
|
|
1502
|
+
r,
|
|
1503
|
+
s,
|
|
1504
|
+
],
|
|
1464
1505
|
}),
|
|
1465
1506
|
value: 0n,
|
|
1466
1507
|
skipRevert,
|