@morpho-org/bundler-sdk-viem 4.3.3 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/lib/cjs/ActionBundle.js +1 -0
- package/lib/cjs/BundlerAction.js +53 -7
- package/lib/cjs/actions.js +7 -2
- package/lib/cjs/bundle.js +1 -0
- package/lib/cjs/errors.js +1 -0
- package/lib/cjs/index.d.ts +5 -5
- package/lib/cjs/index.js +5 -5
- package/lib/cjs/operations.js +21 -5
- package/lib/cjs/types/actions.d.ts +1 -1
- package/lib/esm/ActionBundle.js +1 -0
- package/lib/esm/BundlerAction.js +54 -8
- package/lib/esm/actions.js +9 -4
- package/lib/esm/bundle.js +1 -0
- package/lib/esm/errors.js +1 -0
- package/lib/esm/index.d.ts +5 -5
- package/lib/esm/index.js +5 -5
- package/lib/esm/operations.js +22 -6
- package/lib/esm/types/actions.d.ts +1 -1
- package/package.json +21 -21
- package/src/index.ts +5 -5
package/lib/esm/BundlerAction.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { aaveV2MigrationAdapterAbi, aaveV3MigrationAdapterAbi, aaveV3OptimizerMigrationAdapterAbi, bundler3Abi, compoundV2MigrationAdapterAbi, compoundV3MigrationAdapterAbi, coreAdapterAbi, erc20WrapperAdapterAbi, ethereumGeneralAdapter1Abi, generalAdapter1Abi, paraswapAdapterAbi, universalRewardsDistributorAbi, } from "./abis.js";
|
|
2
1
|
import { ChainId, getChainAddresses, } from "@morpho-org/blue-sdk";
|
|
3
2
|
import { blueAbi, erc2612Abi, permit2Abi, publicAllocatorAbi, } from "@morpho-org/blue-sdk-viem";
|
|
4
|
-
import { encodeAbiParameters, encodeFunctionData, keccak256, maxUint256, parseSignature, zeroHash, } from "viem";
|
|
3
|
+
import { encodeAbiParameters, encodeFunctionData, isAddressEqual, keccak256, maxUint256, parseSignature, zeroHash, } from "viem";
|
|
4
|
+
import { aaveV2MigrationAdapterAbi, aaveV3MigrationAdapterAbi, aaveV3OptimizerMigrationAdapterAbi, bundler3Abi, compoundV2MigrationAdapterAbi, compoundV3MigrationAdapterAbi, coreAdapterAbi, erc20WrapperAdapterAbi, ethereumGeneralAdapter1Abi, generalAdapter1Abi, paraswapAdapterAbi, universalRewardsDistributorAbi, } from "./abis.js";
|
|
5
5
|
import { BundlerErrors } from "./errors.js";
|
|
6
6
|
const reenterAbiInputs = bundler3Abi.find((item) => item.name === "reenter").inputs;
|
|
7
7
|
/**
|
|
@@ -16,9 +16,10 @@ export var BundlerAction;
|
|
|
16
16
|
if (type !== "nativeTransfer")
|
|
17
17
|
continue;
|
|
18
18
|
const [owner, recipient, amount] = args;
|
|
19
|
-
if (owner
|
|
20
|
-
owner
|
|
21
|
-
(recipient
|
|
19
|
+
if (!isAddressEqual(owner, bundler3) &&
|
|
20
|
+
!isAddressEqual(owner, generalAdapter1) &&
|
|
21
|
+
(isAddressEqual(recipient, bundler3) ||
|
|
22
|
+
isAddressEqual(recipient, generalAdapter1)))
|
|
22
23
|
value += amount;
|
|
23
24
|
}
|
|
24
25
|
const encodedActions = actions.flatMap(BundlerAction.encode.bind(null, chainId));
|
|
@@ -223,11 +224,12 @@ export var BundlerAction;
|
|
|
223
224
|
* @param amount The amount of native tokens to send (in wei).
|
|
224
225
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
225
226
|
*/
|
|
227
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
226
228
|
function nativeTransfer(chainId, owner, recipient, amount, skipRevert = false) {
|
|
227
229
|
const { bundler3: { bundler3, generalAdapter1 }, } = getChainAddresses(chainId);
|
|
228
|
-
if (recipient
|
|
230
|
+
if (isAddressEqual(recipient, bundler3))
|
|
229
231
|
return [];
|
|
230
|
-
if (owner
|
|
232
|
+
if (isAddressEqual(owner, generalAdapter1))
|
|
231
233
|
return [
|
|
232
234
|
{
|
|
233
235
|
to: generalAdapter1,
|
|
@@ -261,6 +263,7 @@ export var BundlerAction;
|
|
|
261
263
|
* @param adapter The address of the adapter to use.
|
|
262
264
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
263
265
|
*/
|
|
266
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
264
267
|
function erc20Transfer(asset, recipient, amount, adapter, skipRevert = false) {
|
|
265
268
|
return [
|
|
266
269
|
{
|
|
@@ -285,6 +288,7 @@ export var BundlerAction;
|
|
|
285
288
|
* @param recipient The recipient of ERC20 tokens.
|
|
286
289
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
287
290
|
*/
|
|
291
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
288
292
|
function erc20TransferFrom(chainId, asset, amount, recipient, skipRevert = false) {
|
|
289
293
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
290
294
|
return [
|
|
@@ -313,6 +317,7 @@ export var BundlerAction;
|
|
|
313
317
|
* @param signature The Ethers signature to permit the tokens.
|
|
314
318
|
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert. Defaults to true.
|
|
315
319
|
*/
|
|
320
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
316
321
|
function permit(chainId, owner, asset, amount, deadline, signature, skipRevert = true) {
|
|
317
322
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
318
323
|
const { r, s, yParity } = parseSignature(signature);
|
|
@@ -351,6 +356,7 @@ export var BundlerAction;
|
|
|
351
356
|
* @param signature The Ethers signature to permit the tokens.
|
|
352
357
|
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert.
|
|
353
358
|
*/
|
|
359
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
354
360
|
function permitDai(chainId, owner, nonce, expiry, allowed, signature, skipRevert = true) {
|
|
355
361
|
const { dai, bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
356
362
|
if (dai == null)
|
|
@@ -410,6 +416,7 @@ export var BundlerAction;
|
|
|
410
416
|
* @param signature The Ethers signature to permit the tokens.
|
|
411
417
|
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert. Defaults to true.
|
|
412
418
|
*/
|
|
419
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
413
420
|
function approve2(chainId, owner, permitSingle, signature, skipRevert = true) {
|
|
414
421
|
const { permit2, bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
415
422
|
if (permit2 == null)
|
|
@@ -447,6 +454,7 @@ export var BundlerAction;
|
|
|
447
454
|
* @param recipient The recipient of ERC20 tokens.
|
|
448
455
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
449
456
|
*/
|
|
457
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
450
458
|
function transferFrom2(chainId, asset, amount, recipient, skipRevert = false) {
|
|
451
459
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
452
460
|
return [
|
|
@@ -471,6 +479,7 @@ export var BundlerAction;
|
|
|
471
479
|
* @param amount The amount of tokens to wrap.
|
|
472
480
|
* @param skipRevert Whether to allow the wrap to revert without making the whole bundler revert. Defaults to false.
|
|
473
481
|
*/
|
|
482
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
474
483
|
function morphoWrapperDepositFor(chainId, recipient, amount, skipRevert = false) {
|
|
475
484
|
if (chainId !== ChainId.EthMainnet)
|
|
476
485
|
throw new Error("MORPHO wrapping is only available on ethereum mainnet");
|
|
@@ -499,6 +508,7 @@ export var BundlerAction;
|
|
|
499
508
|
* @param amount The amount of tokens to send.
|
|
500
509
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
501
510
|
*/
|
|
511
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
502
512
|
function erc20WrapperDepositFor(chainId, wrapper, underlying, amount, skipRevert = false) {
|
|
503
513
|
const { bundler3: { generalAdapter1, erc20WrapperAdapter }, } = getChainAddresses(chainId);
|
|
504
514
|
if (erc20WrapperAdapter == null)
|
|
@@ -548,6 +558,7 @@ export var BundlerAction;
|
|
|
548
558
|
* @param amount The amount of tokens to send.
|
|
549
559
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
550
560
|
*/
|
|
561
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
551
562
|
function erc20WrapperWithdrawTo(chainId, wrapper, receiver, amount, skipRevert = false) {
|
|
552
563
|
const { bundler3: { generalAdapter1, erc20WrapperAdapter }, } = getChainAddresses(chainId);
|
|
553
564
|
if (erc20WrapperAdapter == null)
|
|
@@ -599,6 +610,7 @@ export var BundlerAction;
|
|
|
599
610
|
* @param receiver The address to send the shares to.
|
|
600
611
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
601
612
|
*/
|
|
613
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
602
614
|
function erc4626Mint(chainId, erc4626, shares, maxSharePrice, receiver, skipRevert = false) {
|
|
603
615
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
604
616
|
return [
|
|
@@ -625,6 +637,7 @@ export var BundlerAction;
|
|
|
625
637
|
* @param receiver The address to send the shares to.
|
|
626
638
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
627
639
|
*/
|
|
640
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
628
641
|
function erc4626Deposit(chainId, erc4626, assets, maxSharePrice, receiver, skipRevert = false) {
|
|
629
642
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
630
643
|
return [
|
|
@@ -652,6 +665,7 @@ export var BundlerAction;
|
|
|
652
665
|
* @param owner The address on behalf of which the assets are withdrawn.
|
|
653
666
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
654
667
|
*/
|
|
668
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
655
669
|
function erc4626Withdraw(chainId, erc4626, assets, minSharePrice, receiver, owner, skipRevert = false) {
|
|
656
670
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
657
671
|
return [
|
|
@@ -679,6 +693,7 @@ export var BundlerAction;
|
|
|
679
693
|
* @param owner The address on behalf of which the assets are withdrawn.
|
|
680
694
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
681
695
|
*/
|
|
696
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
682
697
|
function erc4626Redeem(chainId, erc4626, shares, minSharePrice, receiver, owner, skipRevert = false) {
|
|
683
698
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
684
699
|
return [
|
|
@@ -704,10 +719,11 @@ export var BundlerAction;
|
|
|
704
719
|
* @param signature The Ethers signature to authorize the account.
|
|
705
720
|
* @param skipRevert Whether to allow the authorization call to revert without making the whole bundle revert. Defaults to true.
|
|
706
721
|
*/
|
|
722
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
707
723
|
function morphoSetAuthorizationWithSig(chainId, authorization, signature, skipRevert = true) {
|
|
708
724
|
const { morpho, bundler3: { bundler3 }, } = getChainAddresses(chainId);
|
|
709
725
|
const { r, s, yParity } = parseSignature(signature);
|
|
710
|
-
if (authorization.authorized
|
|
726
|
+
if (isAddressEqual(authorization.authorized, bundler3))
|
|
711
727
|
throw new BundlerErrors.UnexpectedSignature(authorization.authorized);
|
|
712
728
|
return [
|
|
713
729
|
{
|
|
@@ -735,6 +751,7 @@ export var BundlerAction;
|
|
|
735
751
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupply` callback.
|
|
736
752
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
737
753
|
*/
|
|
754
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
738
755
|
function morphoSupply(chainId, market, assets, shares, slippageAmount, onBehalf, callbackCalls, skipRevert = false) {
|
|
739
756
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
740
757
|
const reenter = callbackCalls.length > 0;
|
|
@@ -765,6 +782,7 @@ export var BundlerAction;
|
|
|
765
782
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupplyCollateral` callback.
|
|
766
783
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
767
784
|
*/
|
|
785
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
768
786
|
function morphoSupplyCollateral(chainId, market, assets, onBehalf, callbackCalls, skipRevert = false) {
|
|
769
787
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
770
788
|
const reenter = callbackCalls.length > 0;
|
|
@@ -796,6 +814,7 @@ export var BundlerAction;
|
|
|
796
814
|
* @param receiver The address to send borrowed tokens to.
|
|
797
815
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
798
816
|
*/
|
|
817
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
799
818
|
function morphoBorrow(chainId, market, assets, shares, slippageAmount, receiver, skipRevert = false) {
|
|
800
819
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
801
820
|
return [
|
|
@@ -824,6 +843,7 @@ export var BundlerAction;
|
|
|
824
843
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupply` callback.
|
|
825
844
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
826
845
|
*/
|
|
846
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
827
847
|
function morphoRepay(chainId, market, assets, shares, slippageAmount, onBehalf, callbackCalls, skipRevert = false) {
|
|
828
848
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
829
849
|
const reenter = callbackCalls.length > 0;
|
|
@@ -855,6 +875,7 @@ export var BundlerAction;
|
|
|
855
875
|
* @param receiver The address to send withdrawn tokens to.
|
|
856
876
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
857
877
|
*/
|
|
878
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
858
879
|
function morphoWithdraw(chainId, market, assets, shares, slippageAmount, receiver, skipRevert = false) {
|
|
859
880
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
860
881
|
return [
|
|
@@ -880,6 +901,7 @@ export var BundlerAction;
|
|
|
880
901
|
* @param receiver The address to send withdrawn tokens to.
|
|
881
902
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
882
903
|
*/
|
|
904
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
883
905
|
function morphoWithdrawCollateral(chainId, market, assets, receiver, skipRevert = false) {
|
|
884
906
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
885
907
|
return [
|
|
@@ -905,6 +927,7 @@ export var BundlerAction;
|
|
|
905
927
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoFlashLoan` callback.
|
|
906
928
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
907
929
|
*/
|
|
930
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
908
931
|
function morphoFlashLoan(chainId, token, assets, callbackCalls, skipRevert = false) {
|
|
909
932
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
910
933
|
const reenter = callbackCalls.length > 0;
|
|
@@ -935,6 +958,7 @@ export var BundlerAction;
|
|
|
935
958
|
* @param supplyMarketParams The market params to reallocate to.
|
|
936
959
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
937
960
|
*/
|
|
961
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
938
962
|
function publicAllocatorReallocateTo(chainId, vault, fee, withdrawals, supplyMarketParams, skipRevert = false) {
|
|
939
963
|
const { publicAllocator } = getChainAddresses(chainId);
|
|
940
964
|
if (publicAllocator == null)
|
|
@@ -965,6 +989,7 @@ export var BundlerAction;
|
|
|
965
989
|
* @param receiver The address to send the tokens to.
|
|
966
990
|
* @param skipRevert Whether to allow the swap to revert without making the whole bundle revert. Defaults to false.
|
|
967
991
|
*/
|
|
992
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
968
993
|
function paraswapBuy(chainId, augustus, callData, srcToken, dstToken, offsets, receiver, skipRevert = false) {
|
|
969
994
|
const { bundler3: { paraswapAdapter }, } = getChainAddresses(chainId);
|
|
970
995
|
if (paraswapAdapter == null)
|
|
@@ -996,6 +1021,7 @@ export var BundlerAction;
|
|
|
996
1021
|
* @param receiver The address to send the tokens to.
|
|
997
1022
|
* @param skipRevert Whether to allow the swap to revert without making the whole bundle revert. Defaults to false.
|
|
998
1023
|
*/
|
|
1024
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
999
1025
|
function paraswapSell(chainId, augustus, callData, srcToken, dstToken, sellEntireBalance, offsets, receiver, skipRevert = false) {
|
|
1000
1026
|
const { bundler3: { paraswapAdapter }, } = getChainAddresses(chainId);
|
|
1001
1027
|
if (paraswapAdapter == null)
|
|
@@ -1035,6 +1061,7 @@ export var BundlerAction;
|
|
|
1035
1061
|
* @param receiver The address to send the tokens to.
|
|
1036
1062
|
* @param skipRevert Whether to allow the swap to revert without making the whole bundle revert. Defaults to false.
|
|
1037
1063
|
*/
|
|
1064
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1038
1065
|
function paraswapBuyMorphoDebt(chainId, augustus, callData, srcToken, marketParams, offsets, onBehalf, receiver, skipRevert = false) {
|
|
1039
1066
|
const { bundler3: { paraswapAdapter }, } = getChainAddresses(chainId);
|
|
1040
1067
|
if (paraswapAdapter == null)
|
|
@@ -1073,6 +1100,7 @@ export var BundlerAction;
|
|
|
1073
1100
|
* @param proof The Merkle proof to claim the rewards.
|
|
1074
1101
|
* @param skipRevert Whether to allow the claim to revert without making the whole bundle revert. Defaults to true.
|
|
1075
1102
|
*/
|
|
1103
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1076
1104
|
function urdClaim(distributor, account, reward, amount, proof, skipRevert = true) {
|
|
1077
1105
|
return [
|
|
1078
1106
|
{
|
|
@@ -1097,6 +1125,7 @@ export var BundlerAction;
|
|
|
1097
1125
|
* @param recipient The address to send tokens to.
|
|
1098
1126
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1099
1127
|
*/
|
|
1128
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1100
1129
|
function wrapNative(chainId, amount, recipient, skipRevert = false) {
|
|
1101
1130
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
1102
1131
|
return [
|
|
@@ -1121,6 +1150,7 @@ export var BundlerAction;
|
|
|
1121
1150
|
* @param recipient The address to send tokens to.
|
|
1122
1151
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1123
1152
|
*/
|
|
1153
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1124
1154
|
function unwrapNative(chainId, amount, recipient, skipRevert = false) {
|
|
1125
1155
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
1126
1156
|
return [
|
|
@@ -1148,6 +1178,7 @@ export var BundlerAction;
|
|
|
1148
1178
|
* @param recipient The address to send stETH to.
|
|
1149
1179
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1150
1180
|
*/
|
|
1181
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1151
1182
|
function stakeEth(chainId, amount, maxSharePrice, referral, recipient, skipRevert = false) {
|
|
1152
1183
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
1153
1184
|
return [
|
|
@@ -1173,6 +1204,7 @@ export var BundlerAction;
|
|
|
1173
1204
|
* @param recipient The address to send wstETH to.
|
|
1174
1205
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1175
1206
|
*/
|
|
1207
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1176
1208
|
function wrapStEth(chainId, amount, recipient, skipRevert = false) {
|
|
1177
1209
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
1178
1210
|
return [
|
|
@@ -1197,6 +1229,7 @@ export var BundlerAction;
|
|
|
1197
1229
|
* @param recipient The address to send stETH to.
|
|
1198
1230
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1199
1231
|
*/
|
|
1232
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1200
1233
|
function unwrapStEth(chainId, amount, recipient, skipRevert = false) {
|
|
1201
1234
|
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
1202
1235
|
return [
|
|
@@ -1224,6 +1257,7 @@ export var BundlerAction;
|
|
|
1224
1257
|
* @param rateMode The interest rate mode used by the debt to repay.
|
|
1225
1258
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1226
1259
|
*/
|
|
1260
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1227
1261
|
function aaveV2Repay(chainId, asset, amount, onBehalf, rateMode = 1n, skipRevert = false) {
|
|
1228
1262
|
const { bundler3: { aaveV2MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1229
1263
|
if (aaveV2MigrationAdapter == null)
|
|
@@ -1251,6 +1285,7 @@ export var BundlerAction;
|
|
|
1251
1285
|
* @param recipient The recipient of ERC20 tokens.
|
|
1252
1286
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1253
1287
|
*/
|
|
1288
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1254
1289
|
function aaveV2Withdraw(chainId, asset, amount, recipient, skipRevert = false) {
|
|
1255
1290
|
const { bundler3: { aaveV2MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1256
1291
|
if (aaveV2MigrationAdapter == null)
|
|
@@ -1280,6 +1315,7 @@ export var BundlerAction;
|
|
|
1280
1315
|
* @param rateMode The interest rate mode used by the debt to repay.
|
|
1281
1316
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1282
1317
|
*/
|
|
1318
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1283
1319
|
function aaveV3Repay(chainId, asset, amount, onBehalf, rateMode = 1n, skipRevert = false) {
|
|
1284
1320
|
const { bundler3: { aaveV3CoreMigrationAdapter }, // TODO: choose between core & prime
|
|
1285
1321
|
} = getChainAddresses(chainId);
|
|
@@ -1308,6 +1344,7 @@ export var BundlerAction;
|
|
|
1308
1344
|
* @param recipient The recipient of ERC20 tokens.
|
|
1309
1345
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1310
1346
|
*/
|
|
1347
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1311
1348
|
function aaveV3Withdraw(chainId, asset, amount, recipient, skipRevert = false) {
|
|
1312
1349
|
const { bundler3: { aaveV3CoreMigrationAdapter }, // TODO: choose between core & prime
|
|
1313
1350
|
} = getChainAddresses(chainId);
|
|
@@ -1337,6 +1374,7 @@ export var BundlerAction;
|
|
|
1337
1374
|
* @param onBehalf The address on behalf of which to repay.
|
|
1338
1375
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1339
1376
|
*/
|
|
1377
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1340
1378
|
function aaveV3OptimizerRepay(chainId, underlying, amount, onBehalf, skipRevert = false) {
|
|
1341
1379
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = getChainAddresses(chainId);
|
|
1342
1380
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
@@ -1365,6 +1403,7 @@ export var BundlerAction;
|
|
|
1365
1403
|
* @param recipient The recipient of ERC20 tokens.
|
|
1366
1404
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1367
1405
|
*/
|
|
1406
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1368
1407
|
function aaveV3OptimizerWithdraw(chainId, underlying, amount, maxIterations, recipient, skipRevert = false) {
|
|
1369
1408
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = getChainAddresses(chainId);
|
|
1370
1409
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
@@ -1392,6 +1431,7 @@ export var BundlerAction;
|
|
|
1392
1431
|
* @param recipient The recipient of ERC20 tokens.
|
|
1393
1432
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1394
1433
|
*/
|
|
1434
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1395
1435
|
function aaveV3OptimizerWithdrawCollateral(chainId, underlying, amount, recipient, skipRevert = false) {
|
|
1396
1436
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = getChainAddresses(chainId);
|
|
1397
1437
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
@@ -1422,6 +1462,7 @@ export var BundlerAction;
|
|
|
1422
1462
|
* @param signature The Ethers signature to submit.
|
|
1423
1463
|
* @param skipRevert Whether to allow the signature to revert without making the whole bundle revert. Defaults to true.
|
|
1424
1464
|
*/
|
|
1465
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1425
1466
|
function aaveV3OptimizerApproveManagerWithSig(chainId, aaveV3Optimizer, owner, isApproved, nonce, deadline, signature, skipRevert = true) {
|
|
1426
1467
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = getChainAddresses(chainId);
|
|
1427
1468
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
@@ -1482,6 +1523,7 @@ export var BundlerAction;
|
|
|
1482
1523
|
* @param onBehalf The account on behalf of which to repay.
|
|
1483
1524
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1484
1525
|
*/
|
|
1526
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1485
1527
|
function compoundV2Repay(chainId, cToken, amount, isEth, onBehalf, skipRevert = false) {
|
|
1486
1528
|
const { bundler3: { compoundV2MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1487
1529
|
if (compoundV2MigrationAdapter == null)
|
|
@@ -1515,6 +1557,7 @@ export var BundlerAction;
|
|
|
1515
1557
|
* @param recipient The recipient of ERC20 tokens.
|
|
1516
1558
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1517
1559
|
*/
|
|
1560
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1518
1561
|
function compoundV2Redeem(chainId, cToken, amount, isEth, recipient, skipRevert = false) {
|
|
1519
1562
|
const { bundler3: { compoundV2MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1520
1563
|
if (compoundV2MigrationAdapter == null)
|
|
@@ -1549,6 +1592,7 @@ export var BundlerAction;
|
|
|
1549
1592
|
* @param onBehalf The address on behalf of which to repay.
|
|
1550
1593
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1551
1594
|
*/
|
|
1595
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1552
1596
|
function compoundV3Repay(chainId, instance, amount, onBehalf, skipRevert = false) {
|
|
1553
1597
|
const { bundler3: { compoundV3MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1554
1598
|
if (compoundV3MigrationAdapter == null)
|
|
@@ -1577,6 +1621,7 @@ export var BundlerAction;
|
|
|
1577
1621
|
* @param recipient The recipient of ERC20 tokens.
|
|
1578
1622
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1579
1623
|
*/
|
|
1624
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1580
1625
|
function compoundV3WithdrawFrom(chainId, instance, asset, amount, recipient, skipRevert = false) {
|
|
1581
1626
|
const { bundler3: { compoundV3MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1582
1627
|
if (compoundV3MigrationAdapter == null)
|
|
@@ -1608,6 +1653,7 @@ export var BundlerAction;
|
|
|
1608
1653
|
* @param signature The Ethers signature to submit.
|
|
1609
1654
|
* @param skipRevert Whether to allow the signature to revert without making the whole bundle revert. Defaults to true.
|
|
1610
1655
|
*/
|
|
1656
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1611
1657
|
function compoundV3AllowBySig(chainId, instance, owner, isAllowed, nonce, expiry, signature, skipRevert = true) {
|
|
1612
1658
|
const { bundler3: { compoundV3MigrationAdapter }, } = getChainAddresses(chainId);
|
|
1613
1659
|
if (compoundV3MigrationAdapter == null)
|
package/lib/esm/actions.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DEFAULT_SLIPPAGE_TOLERANCE, MathLib, NATIVE_ADDRESS, convexWrapperTokens, erc20WrapperTokens, getChainAddresses, getUnwrappedToken, } from "@morpho-org/blue-sdk";
|
|
3
|
-
import { Time, getValue } from "@morpho-org/morpho-ts";
|
|
4
|
-
import { APPROVE_ONLY_ONCE_TOKENS, MAX_TOKEN_APPROVALS, getCurrent, simulateOperation, } from "@morpho-org/simulation-sdk";
|
|
1
|
+
import { convexWrapperTokens, DEFAULT_SLIPPAGE_TOLERANCE, erc20WrapperTokens, getChainAddresses, getUnwrappedToken, MathLib, NATIVE_ADDRESS, } from "@morpho-org/blue-sdk";
|
|
5
2
|
import { blueAbi, getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermitTypedData, } from "@morpho-org/blue-sdk-viem";
|
|
3
|
+
import { getValue, Time } from "@morpho-org/morpho-ts";
|
|
4
|
+
import { APPROVE_ONLY_ONCE_TOKENS, getCurrent, MAX_TOKEN_APPROVALS, simulateOperation, } from "@morpho-org/simulation-sdk";
|
|
5
|
+
import { encodeFunctionData, erc20Abi, hexToBigInt, maxUint256, slice, verifyTypedData, zeroAddress, } from "viem";
|
|
6
6
|
import { signTypedData } from "viem/actions";
|
|
7
7
|
import { ActionBundle, ActionBundleRequirements } from "./ActionBundle.js";
|
|
8
8
|
import { BundlerErrors } from "./errors.js";
|
|
9
9
|
export const MAX_ABSOLUTE_SHARE_PRICE = 100n * MathLib.RAY;
|
|
10
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
10
11
|
const encodeErc20Approval = (token, spender, amount, data) => {
|
|
11
12
|
const { chainId } = data;
|
|
13
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
12
14
|
amount = MathLib.min(amount, MAX_TOKEN_APPROVALS[chainId]?.[token] ?? maxUint256);
|
|
13
15
|
const txRequirements = [];
|
|
14
16
|
txRequirements.push({
|
|
@@ -25,6 +27,7 @@ const encodeErc20Approval = (token, spender, amount, data) => {
|
|
|
25
27
|
});
|
|
26
28
|
return txRequirements;
|
|
27
29
|
};
|
|
30
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
28
31
|
export const encodeOperation = (operation, dataBefore, supportsSignature = true, index = 0) => {
|
|
29
32
|
const { chainId } = dataBefore;
|
|
30
33
|
const { morpho, bundler3: { bundler3, generalAdapter1, paraswapAdapter }, permit2, wNative, dai, wstEth, stEth, } = getChainAddresses(chainId);
|
|
@@ -37,6 +40,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
37
40
|
args: {
|
|
38
41
|
...operation.args,
|
|
39
42
|
...(callback && {
|
|
43
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
40
44
|
callback: (dataBefore) => {
|
|
41
45
|
callbackBundle = encodeBundle(callback.map((callbackOperation) => ({
|
|
42
46
|
...callbackOperation,
|
|
@@ -767,6 +771,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
767
771
|
requirements,
|
|
768
772
|
};
|
|
769
773
|
};
|
|
774
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
770
775
|
export function encodeBundle(operations, startData, supportsSignature = true) {
|
|
771
776
|
const bundle = new ActionBundle([startData]);
|
|
772
777
|
for (let index = 0; index < operations.length; ++index) {
|
package/lib/esm/bundle.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { encodeBundle } from "./actions.js";
|
|
2
2
|
import { finalizeBundle, populateBundle, } from "./operations.js";
|
|
3
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
3
4
|
export const setupBundle = (inputOperations, startData, receiver, { supportsSignature, unwrapTokens, unwrapSlippage, ...options } = {}) => {
|
|
4
5
|
let { operations } = populateBundle(inputOperations, startData, options);
|
|
5
6
|
operations = finalizeBundle(operations, startData, receiver, unwrapTokens, unwrapSlippage);
|
package/lib/esm/errors.js
CHANGED
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
export * from "./ActionBundle.js";
|
|
2
|
+
export * from "./abis.js";
|
|
1
3
|
export * from "./actions.js";
|
|
2
|
-
export * from "./operations.js";
|
|
3
|
-
export * from "./errors.js";
|
|
4
|
-
export * from "./types/index.js";
|
|
5
4
|
export * from "./BundlerAction.js";
|
|
6
5
|
export * from "./bundle.js";
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
6
|
+
export * from "./errors.js";
|
|
7
|
+
export * from "./operations.js";
|
|
8
|
+
export * from "./types/index.js";
|
package/lib/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
export * from "./ActionBundle.js";
|
|
2
|
+
export * from "./abis.js";
|
|
1
3
|
export * from "./actions.js";
|
|
2
|
-
export * from "./operations.js";
|
|
3
|
-
export * from "./errors.js";
|
|
4
|
-
export * from "./types/index.js";
|
|
5
4
|
export * from "./BundlerAction.js";
|
|
6
5
|
export * from "./bundle.js";
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
6
|
+
export * from "./errors.js";
|
|
7
|
+
export * from "./operations.js";
|
|
8
|
+
export * from "./types/index.js";
|
package/lib/esm/operations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_SLIPPAGE_TOLERANCE,
|
|
1
|
+
import { DEFAULT_SLIPPAGE_TOLERANCE, erc20WrapperTokens, getChainAddresses, getUnwrappedToken, Holding, MarketUtils, MathLib, NATIVE_ADDRESS, permissionedBackedTokens, permissionedWrapperTokens, } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { entries, getLast, getValue, keys } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { APPROVE_ONLY_ONCE_TOKENS, handleOperation, handleOperations, produceImmutable, simulateOperation, simulateOperations, } from "@morpho-org/simulation-sdk";
|
|
4
4
|
import { isAddressEqual, maxUint256 } from "viem";
|
|
@@ -7,6 +7,7 @@ import { BundlerErrors } from "./errors.js";
|
|
|
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
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
10
11
|
export const populateInputTransfer = ({ address, args: { amount, from } }, data, { hasSimplePermit = false } = {}) => {
|
|
11
12
|
const { bundler3: { generalAdapter1 }, permit2, } = getChainAddresses(data.chainId);
|
|
12
13
|
// If native token, it is expected to be sent along as call value.
|
|
@@ -154,6 +155,7 @@ export const populateInputTransfer = ({ address, args: { amount, from } }, data,
|
|
|
154
155
|
* @param wrapSlippage The slippage simulated during wraps. Should never be 0.
|
|
155
156
|
* @return The bundle of operations to optimize and skim before being encoded.
|
|
156
157
|
*/
|
|
158
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
157
159
|
export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
158
160
|
const { sender } = inputOperation;
|
|
159
161
|
const { bundler3: { bundler3, generalAdapter1 }, } = getChainAddresses(data.chainId);
|
|
@@ -217,7 +219,7 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
217
219
|
});
|
|
218
220
|
}
|
|
219
221
|
// Reallocate liquidity if necessary.
|
|
220
|
-
if (
|
|
222
|
+
if (publicAllocatorOptions?.enabled &&
|
|
221
223
|
(mainOperation.type === "Blue_Borrow" ||
|
|
222
224
|
mainOperation.type === "Blue_Withdraw")) {
|
|
223
225
|
const market = data
|
|
@@ -311,7 +313,9 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
311
313
|
args: {
|
|
312
314
|
...mainOperation.args,
|
|
313
315
|
...(callback && {
|
|
316
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
314
317
|
callback: (data) => {
|
|
318
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
315
319
|
const operations = callback.flatMap((inputOperation) => {
|
|
316
320
|
const subBundleOperations = populateSubBundle({
|
|
317
321
|
...inputOperation,
|
|
@@ -379,6 +383,7 @@ export const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
379
383
|
* @param unwrapSlippage The slippage simulated during unwraps. Should never be 0.
|
|
380
384
|
* @return The optimized bundle.
|
|
381
385
|
*/
|
|
386
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
382
387
|
export const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(), unwrapSlippage = DEFAULT_SLIPPAGE_TOLERANCE) => {
|
|
383
388
|
const nbOperations = operations.length;
|
|
384
389
|
if (nbOperations === 0)
|
|
@@ -476,6 +481,7 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
476
481
|
others.push(operation);
|
|
477
482
|
}
|
|
478
483
|
});
|
|
484
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
479
485
|
operations = [
|
|
480
486
|
approvals,
|
|
481
487
|
permits,
|
|
@@ -564,6 +570,7 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
564
570
|
operation.args.owner = inputTransfer.args.from;
|
|
565
571
|
});
|
|
566
572
|
// Filter out useless input transfers.
|
|
573
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
567
574
|
operations = operations.filter((operation, index) => {
|
|
568
575
|
if (operation.type !== "Erc20_Transfer")
|
|
569
576
|
return true;
|
|
@@ -679,7 +686,7 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
679
686
|
uniqueSkimTokens.add(NATIVE_ADDRESS);
|
|
680
687
|
break;
|
|
681
688
|
default:
|
|
682
|
-
//@ts-
|
|
689
|
+
//@ts-expect-error This is dead code but acts as a guard in case a new operation is added
|
|
683
690
|
throw new BundlerErrors.MissingSkimHandler(operation.type);
|
|
684
691
|
}
|
|
685
692
|
if ("callback" in operation.args)
|
|
@@ -713,6 +720,7 @@ export const finalizeBundle = (operations, startData, receiver, unwrapTokens = n
|
|
|
713
720
|
}
|
|
714
721
|
return finalizedOperations;
|
|
715
722
|
};
|
|
723
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
716
724
|
export const populateBundle = (inputOperations, data, options) => {
|
|
717
725
|
const steps = [data];
|
|
718
726
|
let end = data;
|
|
@@ -771,7 +779,9 @@ export const getSimulatedBundlerOperation = (operation, { slippage } = {}) => {
|
|
|
771
779
|
args: {
|
|
772
780
|
...operation.args,
|
|
773
781
|
...(callback && {
|
|
774
|
-
callback: () =>
|
|
782
|
+
callback: () =>
|
|
783
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
784
|
+
callback.map((operation) => getSimulatedBundlerOperation(operation, { slippage })),
|
|
775
785
|
}),
|
|
776
786
|
},
|
|
777
787
|
};
|
|
@@ -794,7 +804,13 @@ export const getSimulatedBundlerOperation = (operation, { slippage } = {}) => {
|
|
|
794
804
|
}
|
|
795
805
|
return simulatedOperation;
|
|
796
806
|
};
|
|
797
|
-
export const handleBundlerOperation = (options) =>
|
|
807
|
+
export const handleBundlerOperation = (options) =>
|
|
808
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
809
|
+
(operation, startData, index) => handleOperation(getSimulatedBundlerOperation(operation, options), startData, index);
|
|
810
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
798
811
|
export const handleBundlerOperations = (operations, startData, options) => handleOperations(operations, startData, handleBundlerOperation(options));
|
|
799
|
-
export const simulateBundlerOperation = (options) =>
|
|
812
|
+
export const simulateBundlerOperation = (options) =>
|
|
813
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
814
|
+
(operation, startData, index) => simulateOperation(getSimulatedBundlerOperation(operation, options), startData, index);
|
|
815
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
800
816
|
export const simulateBundlerOperations = (operations, startData, options) => handleOperations(operations, startData, simulateBundlerOperation(options));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Account, Chain, Client, Hex, TransactionRequest, Transport } from "viem";
|
|
2
1
|
import type { Address, InputMarketParams } from "@morpho-org/blue-sdk";
|
|
3
2
|
import type { ParaswapOffsets } from "@morpho-org/simulation-sdk";
|
|
3
|
+
import type { Account, Chain, Client, Hex, TransactionRequest, Transport } from "viem";
|
|
4
4
|
export interface Authorization {
|
|
5
5
|
authorizer: Address;
|
|
6
6
|
authorized: Address;
|