@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/README.md
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
<br />
|
|
22
22
|
<br />
|
|
23
23
|
|
|
24
|
+
## Overview
|
|
25
|
+
|
|
24
26
|
Viem-based extension of `@morpho-org/simulation-sdk` that exports utilities to transform simple interactions on Morpho (such as `Blue_Borrow`) and Morpho Vaults (such as `MetaMorpho_Deposit`) into the required bundles (with ERC20 approvals, transfers, etc) to submit to the bundler onchain.
|
|
25
27
|
|
|
26
28
|
## Installation
|
|
@@ -32,3 +34,15 @@ npm install @morpho-org/bundler-sdk-viem
|
|
|
32
34
|
```bash
|
|
33
35
|
yarn add @morpho-org/bundler-sdk-viem
|
|
34
36
|
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
Use this package to turn high-level Morpho and Morpho Vault simulation operations into executable bundler transactions, including the required approvals, transfers, and bundler actions.
|
|
41
|
+
|
|
42
|
+
## Development
|
|
43
|
+
|
|
44
|
+
Contribute from the monorepo root. See [CONTRIBUTING.md](../../CONTRIBUTING.md) for setup, checks, and package workflow. Report vulnerabilities through [SECURITY.md](../../SECURITY.md).
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT. See [LICENSE](./LICENSE).
|
package/lib/cjs/ActionBundle.js
CHANGED
|
@@ -19,6 +19,7 @@ class ActionBundle {
|
|
|
19
19
|
requirements;
|
|
20
20
|
steps;
|
|
21
21
|
chainId;
|
|
22
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
22
23
|
constructor(stepsOrChainId, actions = [], requirements = new ActionBundleRequirements()) {
|
|
23
24
|
this.actions = actions;
|
|
24
25
|
this.requirements = requirements;
|
package/lib/cjs/BundlerAction.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BundlerAction = void 0;
|
|
4
|
-
const abis_js_1 = require("./abis.js");
|
|
5
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
5
|
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
7
6
|
const viem_1 = require("viem");
|
|
7
|
+
const abis_js_1 = require("./abis.js");
|
|
8
8
|
const errors_js_1 = require("./errors.js");
|
|
9
9
|
const reenterAbiInputs = abis_js_1.bundler3Abi.find((item) => item.name === "reenter").inputs;
|
|
10
10
|
/**
|
|
@@ -19,9 +19,10 @@ var BundlerAction;
|
|
|
19
19
|
if (type !== "nativeTransfer")
|
|
20
20
|
continue;
|
|
21
21
|
const [owner, recipient, amount] = args;
|
|
22
|
-
if (owner
|
|
23
|
-
owner
|
|
24
|
-
(recipient
|
|
22
|
+
if (!(0, viem_1.isAddressEqual)(owner, bundler3) &&
|
|
23
|
+
!(0, viem_1.isAddressEqual)(owner, generalAdapter1) &&
|
|
24
|
+
((0, viem_1.isAddressEqual)(recipient, bundler3) ||
|
|
25
|
+
(0, viem_1.isAddressEqual)(recipient, generalAdapter1)))
|
|
25
26
|
value += amount;
|
|
26
27
|
}
|
|
27
28
|
const encodedActions = actions.flatMap(BundlerAction.encode.bind(null, chainId));
|
|
@@ -226,11 +227,12 @@ var BundlerAction;
|
|
|
226
227
|
* @param amount The amount of native tokens to send (in wei).
|
|
227
228
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
228
229
|
*/
|
|
230
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
229
231
|
function nativeTransfer(chainId, owner, recipient, amount, skipRevert = false) {
|
|
230
232
|
const { bundler3: { bundler3, generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
231
|
-
if (recipient
|
|
233
|
+
if ((0, viem_1.isAddressEqual)(recipient, bundler3))
|
|
232
234
|
return [];
|
|
233
|
-
if (owner
|
|
235
|
+
if ((0, viem_1.isAddressEqual)(owner, generalAdapter1))
|
|
234
236
|
return [
|
|
235
237
|
{
|
|
236
238
|
to: generalAdapter1,
|
|
@@ -264,6 +266,7 @@ var BundlerAction;
|
|
|
264
266
|
* @param adapter The address of the adapter to use.
|
|
265
267
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
266
268
|
*/
|
|
269
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
267
270
|
function erc20Transfer(asset, recipient, amount, adapter, skipRevert = false) {
|
|
268
271
|
return [
|
|
269
272
|
{
|
|
@@ -288,6 +291,7 @@ var BundlerAction;
|
|
|
288
291
|
* @param recipient The recipient of ERC20 tokens.
|
|
289
292
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
290
293
|
*/
|
|
294
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
291
295
|
function erc20TransferFrom(chainId, asset, amount, recipient, skipRevert = false) {
|
|
292
296
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
293
297
|
return [
|
|
@@ -316,6 +320,7 @@ var BundlerAction;
|
|
|
316
320
|
* @param signature The Ethers signature to permit the tokens.
|
|
317
321
|
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert. Defaults to true.
|
|
318
322
|
*/
|
|
323
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
319
324
|
function permit(chainId, owner, asset, amount, deadline, signature, skipRevert = true) {
|
|
320
325
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
321
326
|
const { r, s, yParity } = (0, viem_1.parseSignature)(signature);
|
|
@@ -354,6 +359,7 @@ var BundlerAction;
|
|
|
354
359
|
* @param signature The Ethers signature to permit the tokens.
|
|
355
360
|
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert.
|
|
356
361
|
*/
|
|
362
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
357
363
|
function permitDai(chainId, owner, nonce, expiry, allowed, signature, skipRevert = true) {
|
|
358
364
|
const { dai, bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
359
365
|
if (dai == null)
|
|
@@ -413,6 +419,7 @@ var BundlerAction;
|
|
|
413
419
|
* @param signature The Ethers signature to permit the tokens.
|
|
414
420
|
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert. Defaults to true.
|
|
415
421
|
*/
|
|
422
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
416
423
|
function approve2(chainId, owner, permitSingle, signature, skipRevert = true) {
|
|
417
424
|
const { permit2, bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
418
425
|
if (permit2 == null)
|
|
@@ -450,6 +457,7 @@ var BundlerAction;
|
|
|
450
457
|
* @param recipient The recipient of ERC20 tokens.
|
|
451
458
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
452
459
|
*/
|
|
460
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
453
461
|
function transferFrom2(chainId, asset, amount, recipient, skipRevert = false) {
|
|
454
462
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
455
463
|
return [
|
|
@@ -474,6 +482,7 @@ var BundlerAction;
|
|
|
474
482
|
* @param amount The amount of tokens to wrap.
|
|
475
483
|
* @param skipRevert Whether to allow the wrap to revert without making the whole bundler revert. Defaults to false.
|
|
476
484
|
*/
|
|
485
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
477
486
|
function morphoWrapperDepositFor(chainId, recipient, amount, skipRevert = false) {
|
|
478
487
|
if (chainId !== blue_sdk_1.ChainId.EthMainnet)
|
|
479
488
|
throw new Error("MORPHO wrapping is only available on ethereum mainnet");
|
|
@@ -502,6 +511,7 @@ var BundlerAction;
|
|
|
502
511
|
* @param amount The amount of tokens to send.
|
|
503
512
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
504
513
|
*/
|
|
514
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
505
515
|
function erc20WrapperDepositFor(chainId, wrapper, underlying, amount, skipRevert = false) {
|
|
506
516
|
const { bundler3: { generalAdapter1, erc20WrapperAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
507
517
|
if (erc20WrapperAdapter == null)
|
|
@@ -551,6 +561,7 @@ var BundlerAction;
|
|
|
551
561
|
* @param amount The amount of tokens to send.
|
|
552
562
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
553
563
|
*/
|
|
564
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
554
565
|
function erc20WrapperWithdrawTo(chainId, wrapper, receiver, amount, skipRevert = false) {
|
|
555
566
|
const { bundler3: { generalAdapter1, erc20WrapperAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
556
567
|
if (erc20WrapperAdapter == null)
|
|
@@ -602,6 +613,7 @@ var BundlerAction;
|
|
|
602
613
|
* @param receiver The address to send the shares to.
|
|
603
614
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
604
615
|
*/
|
|
616
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
605
617
|
function erc4626Mint(chainId, erc4626, shares, maxSharePrice, receiver, skipRevert = false) {
|
|
606
618
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
607
619
|
return [
|
|
@@ -628,6 +640,7 @@ var BundlerAction;
|
|
|
628
640
|
* @param receiver The address to send the shares to.
|
|
629
641
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
630
642
|
*/
|
|
643
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
631
644
|
function erc4626Deposit(chainId, erc4626, assets, maxSharePrice, receiver, skipRevert = false) {
|
|
632
645
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
633
646
|
return [
|
|
@@ -655,6 +668,7 @@ var BundlerAction;
|
|
|
655
668
|
* @param owner The address on behalf of which the assets are withdrawn.
|
|
656
669
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
657
670
|
*/
|
|
671
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
658
672
|
function erc4626Withdraw(chainId, erc4626, assets, minSharePrice, receiver, owner, skipRevert = false) {
|
|
659
673
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
660
674
|
return [
|
|
@@ -682,6 +696,7 @@ var BundlerAction;
|
|
|
682
696
|
* @param owner The address on behalf of which the assets are withdrawn.
|
|
683
697
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
684
698
|
*/
|
|
699
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
685
700
|
function erc4626Redeem(chainId, erc4626, shares, minSharePrice, receiver, owner, skipRevert = false) {
|
|
686
701
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
687
702
|
return [
|
|
@@ -707,10 +722,11 @@ var BundlerAction;
|
|
|
707
722
|
* @param signature The Ethers signature to authorize the account.
|
|
708
723
|
* @param skipRevert Whether to allow the authorization call to revert without making the whole bundle revert. Defaults to true.
|
|
709
724
|
*/
|
|
725
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
710
726
|
function morphoSetAuthorizationWithSig(chainId, authorization, signature, skipRevert = true) {
|
|
711
727
|
const { morpho, bundler3: { bundler3 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
712
728
|
const { r, s, yParity } = (0, viem_1.parseSignature)(signature);
|
|
713
|
-
if (authorization.authorized
|
|
729
|
+
if ((0, viem_1.isAddressEqual)(authorization.authorized, bundler3))
|
|
714
730
|
throw new errors_js_1.BundlerErrors.UnexpectedSignature(authorization.authorized);
|
|
715
731
|
return [
|
|
716
732
|
{
|
|
@@ -738,6 +754,7 @@ var BundlerAction;
|
|
|
738
754
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupply` callback.
|
|
739
755
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
740
756
|
*/
|
|
757
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
741
758
|
function morphoSupply(chainId, market, assets, shares, slippageAmount, onBehalf, callbackCalls, skipRevert = false) {
|
|
742
759
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
743
760
|
const reenter = callbackCalls.length > 0;
|
|
@@ -768,6 +785,7 @@ var BundlerAction;
|
|
|
768
785
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupplyCollateral` callback.
|
|
769
786
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
770
787
|
*/
|
|
788
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
771
789
|
function morphoSupplyCollateral(chainId, market, assets, onBehalf, callbackCalls, skipRevert = false) {
|
|
772
790
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
773
791
|
const reenter = callbackCalls.length > 0;
|
|
@@ -799,6 +817,7 @@ var BundlerAction;
|
|
|
799
817
|
* @param receiver The address to send borrowed tokens to.
|
|
800
818
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
801
819
|
*/
|
|
820
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
802
821
|
function morphoBorrow(chainId, market, assets, shares, slippageAmount, receiver, skipRevert = false) {
|
|
803
822
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
804
823
|
return [
|
|
@@ -827,6 +846,7 @@ var BundlerAction;
|
|
|
827
846
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoSupply` callback.
|
|
828
847
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
829
848
|
*/
|
|
849
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
830
850
|
function morphoRepay(chainId, market, assets, shares, slippageAmount, onBehalf, callbackCalls, skipRevert = false) {
|
|
831
851
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
832
852
|
const reenter = callbackCalls.length > 0;
|
|
@@ -858,6 +878,7 @@ var BundlerAction;
|
|
|
858
878
|
* @param receiver The address to send withdrawn tokens to.
|
|
859
879
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
860
880
|
*/
|
|
881
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
861
882
|
function morphoWithdraw(chainId, market, assets, shares, slippageAmount, receiver, skipRevert = false) {
|
|
862
883
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
863
884
|
return [
|
|
@@ -883,6 +904,7 @@ var BundlerAction;
|
|
|
883
904
|
* @param receiver The address to send withdrawn tokens to.
|
|
884
905
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
885
906
|
*/
|
|
907
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
886
908
|
function morphoWithdrawCollateral(chainId, market, assets, receiver, skipRevert = false) {
|
|
887
909
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
888
910
|
return [
|
|
@@ -908,6 +930,7 @@ var BundlerAction;
|
|
|
908
930
|
* @param callbackCalls The array of calls to execute inside Morpho Blue's `onMorphoFlashLoan` callback.
|
|
909
931
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
910
932
|
*/
|
|
933
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
911
934
|
function morphoFlashLoan(chainId, token, assets, callbackCalls, skipRevert = false) {
|
|
912
935
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
913
936
|
const reenter = callbackCalls.length > 0;
|
|
@@ -938,6 +961,7 @@ var BundlerAction;
|
|
|
938
961
|
* @param supplyMarketParams The market params to reallocate to.
|
|
939
962
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
940
963
|
*/
|
|
964
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
941
965
|
function publicAllocatorReallocateTo(chainId, vault, fee, withdrawals, supplyMarketParams, skipRevert = false) {
|
|
942
966
|
const { publicAllocator } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
943
967
|
if (publicAllocator == null)
|
|
@@ -968,6 +992,7 @@ var BundlerAction;
|
|
|
968
992
|
* @param receiver The address to send the tokens to.
|
|
969
993
|
* @param skipRevert Whether to allow the swap to revert without making the whole bundle revert. Defaults to false.
|
|
970
994
|
*/
|
|
995
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
971
996
|
function paraswapBuy(chainId, augustus, callData, srcToken, dstToken, offsets, receiver, skipRevert = false) {
|
|
972
997
|
const { bundler3: { paraswapAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
973
998
|
if (paraswapAdapter == null)
|
|
@@ -999,6 +1024,7 @@ var BundlerAction;
|
|
|
999
1024
|
* @param receiver The address to send the tokens to.
|
|
1000
1025
|
* @param skipRevert Whether to allow the swap to revert without making the whole bundle revert. Defaults to false.
|
|
1001
1026
|
*/
|
|
1027
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1002
1028
|
function paraswapSell(chainId, augustus, callData, srcToken, dstToken, sellEntireBalance, offsets, receiver, skipRevert = false) {
|
|
1003
1029
|
const { bundler3: { paraswapAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1004
1030
|
if (paraswapAdapter == null)
|
|
@@ -1038,6 +1064,7 @@ var BundlerAction;
|
|
|
1038
1064
|
* @param receiver The address to send the tokens to.
|
|
1039
1065
|
* @param skipRevert Whether to allow the swap to revert without making the whole bundle revert. Defaults to false.
|
|
1040
1066
|
*/
|
|
1067
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1041
1068
|
function paraswapBuyMorphoDebt(chainId, augustus, callData, srcToken, marketParams, offsets, onBehalf, receiver, skipRevert = false) {
|
|
1042
1069
|
const { bundler3: { paraswapAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1043
1070
|
if (paraswapAdapter == null)
|
|
@@ -1076,6 +1103,7 @@ var BundlerAction;
|
|
|
1076
1103
|
* @param proof The Merkle proof to claim the rewards.
|
|
1077
1104
|
* @param skipRevert Whether to allow the claim to revert without making the whole bundle revert. Defaults to true.
|
|
1078
1105
|
*/
|
|
1106
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1079
1107
|
function urdClaim(distributor, account, reward, amount, proof, skipRevert = true) {
|
|
1080
1108
|
return [
|
|
1081
1109
|
{
|
|
@@ -1100,6 +1128,7 @@ var BundlerAction;
|
|
|
1100
1128
|
* @param recipient The address to send tokens to.
|
|
1101
1129
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1102
1130
|
*/
|
|
1131
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1103
1132
|
function wrapNative(chainId, amount, recipient, skipRevert = false) {
|
|
1104
1133
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1105
1134
|
return [
|
|
@@ -1124,6 +1153,7 @@ var BundlerAction;
|
|
|
1124
1153
|
* @param recipient The address to send tokens to.
|
|
1125
1154
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1126
1155
|
*/
|
|
1156
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1127
1157
|
function unwrapNative(chainId, amount, recipient, skipRevert = false) {
|
|
1128
1158
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1129
1159
|
return [
|
|
@@ -1151,6 +1181,7 @@ var BundlerAction;
|
|
|
1151
1181
|
* @param recipient The address to send stETH to.
|
|
1152
1182
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1153
1183
|
*/
|
|
1184
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1154
1185
|
function stakeEth(chainId, amount, maxSharePrice, referral, recipient, skipRevert = false) {
|
|
1155
1186
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1156
1187
|
return [
|
|
@@ -1176,6 +1207,7 @@ var BundlerAction;
|
|
|
1176
1207
|
* @param recipient The address to send wstETH to.
|
|
1177
1208
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1178
1209
|
*/
|
|
1210
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1179
1211
|
function wrapStEth(chainId, amount, recipient, skipRevert = false) {
|
|
1180
1212
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1181
1213
|
return [
|
|
@@ -1200,6 +1232,7 @@ var BundlerAction;
|
|
|
1200
1232
|
* @param recipient The address to send stETH to.
|
|
1201
1233
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1202
1234
|
*/
|
|
1235
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1203
1236
|
function unwrapStEth(chainId, amount, recipient, skipRevert = false) {
|
|
1204
1237
|
const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1205
1238
|
return [
|
|
@@ -1227,6 +1260,7 @@ var BundlerAction;
|
|
|
1227
1260
|
* @param rateMode The interest rate mode used by the debt to repay.
|
|
1228
1261
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1229
1262
|
*/
|
|
1263
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1230
1264
|
function aaveV2Repay(chainId, asset, amount, onBehalf, rateMode = 1n, skipRevert = false) {
|
|
1231
1265
|
const { bundler3: { aaveV2MigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1232
1266
|
if (aaveV2MigrationAdapter == null)
|
|
@@ -1254,6 +1288,7 @@ var BundlerAction;
|
|
|
1254
1288
|
* @param recipient The recipient of ERC20 tokens.
|
|
1255
1289
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1256
1290
|
*/
|
|
1291
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1257
1292
|
function aaveV2Withdraw(chainId, asset, amount, recipient, skipRevert = false) {
|
|
1258
1293
|
const { bundler3: { aaveV2MigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1259
1294
|
if (aaveV2MigrationAdapter == null)
|
|
@@ -1283,6 +1318,7 @@ var BundlerAction;
|
|
|
1283
1318
|
* @param rateMode The interest rate mode used by the debt to repay.
|
|
1284
1319
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1285
1320
|
*/
|
|
1321
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1286
1322
|
function aaveV3Repay(chainId, asset, amount, onBehalf, rateMode = 1n, skipRevert = false) {
|
|
1287
1323
|
const { bundler3: { aaveV3CoreMigrationAdapter }, // TODO: choose between core & prime
|
|
1288
1324
|
} = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
@@ -1311,6 +1347,7 @@ var BundlerAction;
|
|
|
1311
1347
|
* @param recipient The recipient of ERC20 tokens.
|
|
1312
1348
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1313
1349
|
*/
|
|
1350
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1314
1351
|
function aaveV3Withdraw(chainId, asset, amount, recipient, skipRevert = false) {
|
|
1315
1352
|
const { bundler3: { aaveV3CoreMigrationAdapter }, // TODO: choose between core & prime
|
|
1316
1353
|
} = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
@@ -1340,6 +1377,7 @@ var BundlerAction;
|
|
|
1340
1377
|
* @param onBehalf The address on behalf of which to repay.
|
|
1341
1378
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1342
1379
|
*/
|
|
1380
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1343
1381
|
function aaveV3OptimizerRepay(chainId, underlying, amount, onBehalf, skipRevert = false) {
|
|
1344
1382
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1345
1383
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
@@ -1368,6 +1406,7 @@ var BundlerAction;
|
|
|
1368
1406
|
* @param recipient The recipient of ERC20 tokens.
|
|
1369
1407
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1370
1408
|
*/
|
|
1409
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1371
1410
|
function aaveV3OptimizerWithdraw(chainId, underlying, amount, maxIterations, recipient, skipRevert = false) {
|
|
1372
1411
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1373
1412
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
@@ -1395,6 +1434,7 @@ var BundlerAction;
|
|
|
1395
1434
|
* @param recipient The recipient of ERC20 tokens.
|
|
1396
1435
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1397
1436
|
*/
|
|
1437
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1398
1438
|
function aaveV3OptimizerWithdrawCollateral(chainId, underlying, amount, recipient, skipRevert = false) {
|
|
1399
1439
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1400
1440
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
@@ -1425,6 +1465,7 @@ var BundlerAction;
|
|
|
1425
1465
|
* @param signature The Ethers signature to submit.
|
|
1426
1466
|
* @param skipRevert Whether to allow the signature to revert without making the whole bundle revert. Defaults to true.
|
|
1427
1467
|
*/
|
|
1468
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1428
1469
|
function aaveV3OptimizerApproveManagerWithSig(chainId, aaveV3Optimizer, owner, isApproved, nonce, deadline, signature, skipRevert = true) {
|
|
1429
1470
|
const { bundler3: { aaveV3OptimizerMigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1430
1471
|
if (aaveV3OptimizerMigrationAdapter == null)
|
|
@@ -1485,6 +1526,7 @@ var BundlerAction;
|
|
|
1485
1526
|
* @param onBehalf The account on behalf of which to repay.
|
|
1486
1527
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1487
1528
|
*/
|
|
1529
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1488
1530
|
function compoundV2Repay(chainId, cToken, amount, isEth, onBehalf, skipRevert = false) {
|
|
1489
1531
|
const { bundler3: { compoundV2MigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1490
1532
|
if (compoundV2MigrationAdapter == null)
|
|
@@ -1518,6 +1560,7 @@ var BundlerAction;
|
|
|
1518
1560
|
* @param recipient The recipient of ERC20 tokens.
|
|
1519
1561
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1520
1562
|
*/
|
|
1563
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1521
1564
|
function compoundV2Redeem(chainId, cToken, amount, isEth, recipient, skipRevert = false) {
|
|
1522
1565
|
const { bundler3: { compoundV2MigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1523
1566
|
if (compoundV2MigrationAdapter == null)
|
|
@@ -1552,6 +1595,7 @@ var BundlerAction;
|
|
|
1552
1595
|
* @param onBehalf The address on behalf of which to repay.
|
|
1553
1596
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1554
1597
|
*/
|
|
1598
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1555
1599
|
function compoundV3Repay(chainId, instance, amount, onBehalf, skipRevert = false) {
|
|
1556
1600
|
const { bundler3: { compoundV3MigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1557
1601
|
if (compoundV3MigrationAdapter == null)
|
|
@@ -1580,6 +1624,7 @@ var BundlerAction;
|
|
|
1580
1624
|
* @param recipient The recipient of ERC20 tokens.
|
|
1581
1625
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
1582
1626
|
*/
|
|
1627
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1583
1628
|
function compoundV3WithdrawFrom(chainId, instance, asset, amount, recipient, skipRevert = false) {
|
|
1584
1629
|
const { bundler3: { compoundV3MigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1585
1630
|
if (compoundV3MigrationAdapter == null)
|
|
@@ -1611,6 +1656,7 @@ var BundlerAction;
|
|
|
1611
1656
|
* @param signature The Ethers signature to submit.
|
|
1612
1657
|
* @param skipRevert Whether to allow the signature to revert without making the whole bundle revert. Defaults to true.
|
|
1613
1658
|
*/
|
|
1659
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1614
1660
|
function compoundV3AllowBySig(chainId, instance, owner, isAllowed, nonce, expiry, signature, skipRevert = true) {
|
|
1615
1661
|
const { bundler3: { compoundV3MigrationAdapter }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
1616
1662
|
if (compoundV3MigrationAdapter == null)
|
package/lib/cjs/actions.js
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.encodeOperation = exports.MAX_ABSOLUTE_SHARE_PRICE = void 0;
|
|
4
4
|
exports.encodeBundle = encodeBundle;
|
|
5
|
-
const viem_1 = require("viem");
|
|
6
5
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
|
+
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
7
7
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
8
8
|
const simulation_sdk_1 = require("@morpho-org/simulation-sdk");
|
|
9
|
-
const
|
|
9
|
+
const viem_1 = require("viem");
|
|
10
10
|
const actions_1 = require("viem/actions");
|
|
11
11
|
const ActionBundle_js_1 = require("./ActionBundle.js");
|
|
12
12
|
const errors_js_1 = require("./errors.js");
|
|
13
13
|
exports.MAX_ABSOLUTE_SHARE_PRICE = 100n * blue_sdk_1.MathLib.RAY;
|
|
14
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
14
15
|
const encodeErc20Approval = (token, spender, amount, data) => {
|
|
15
16
|
const { chainId } = data;
|
|
17
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
16
18
|
amount = blue_sdk_1.MathLib.min(amount, simulation_sdk_1.MAX_TOKEN_APPROVALS[chainId]?.[token] ?? viem_1.maxUint256);
|
|
17
19
|
const txRequirements = [];
|
|
18
20
|
txRequirements.push({
|
|
@@ -29,6 +31,7 @@ const encodeErc20Approval = (token, spender, amount, data) => {
|
|
|
29
31
|
});
|
|
30
32
|
return txRequirements;
|
|
31
33
|
};
|
|
34
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
32
35
|
const encodeOperation = (operation, dataBefore, supportsSignature = true, index = 0) => {
|
|
33
36
|
const { chainId } = dataBefore;
|
|
34
37
|
const { morpho, bundler3: { bundler3, generalAdapter1, paraswapAdapter }, permit2, wNative, dai, wstEth, stEth, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
@@ -41,6 +44,7 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
41
44
|
args: {
|
|
42
45
|
...operation.args,
|
|
43
46
|
...(callback && {
|
|
47
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
44
48
|
callback: (dataBefore) => {
|
|
45
49
|
callbackBundle = encodeBundle(callback.map((callbackOperation) => ({
|
|
46
50
|
...callbackOperation,
|
|
@@ -772,6 +776,7 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
|
|
|
772
776
|
};
|
|
773
777
|
};
|
|
774
778
|
exports.encodeOperation = encodeOperation;
|
|
779
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
775
780
|
function encodeBundle(operations, startData, supportsSignature = true) {
|
|
776
781
|
const bundle = new ActionBundle_js_1.ActionBundle([startData]);
|
|
777
782
|
for (let index = 0; index < operations.length; ++index) {
|
package/lib/cjs/bundle.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setupBundle = void 0;
|
|
4
4
|
const actions_js_1 = require("./actions.js");
|
|
5
5
|
const operations_js_1 = require("./operations.js");
|
|
6
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
6
7
|
const setupBundle = (inputOperations, startData, receiver, { supportsSignature, unwrapTokens, unwrapSlippage, ...options } = {}) => {
|
|
7
8
|
let { operations } = (0, operations_js_1.populateBundle)(inputOperations, startData, options);
|
|
8
9
|
operations = (0, operations_js_1.finalizeBundle)(operations, startData, receiver, unwrapTokens, unwrapSlippage);
|
package/lib/cjs/errors.js
CHANGED
package/lib/cjs/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/cjs/index.js
CHANGED
|
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ActionBundle.js"), exports);
|
|
18
|
+
__exportStar(require("./abis.js"), exports);
|
|
17
19
|
__exportStar(require("./actions.js"), exports);
|
|
18
|
-
__exportStar(require("./operations.js"), exports);
|
|
19
|
-
__exportStar(require("./errors.js"), exports);
|
|
20
|
-
__exportStar(require("./types/index.js"), exports);
|
|
21
20
|
__exportStar(require("./BundlerAction.js"), exports);
|
|
22
21
|
__exportStar(require("./bundle.js"), exports);
|
|
23
|
-
__exportStar(require("./
|
|
24
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./errors.js"), exports);
|
|
23
|
+
__exportStar(require("./operations.js"), exports);
|
|
24
|
+
__exportStar(require("./types/index.js"), exports);
|
package/lib/cjs/operations.js
CHANGED
|
@@ -10,6 +10,7 @@ const errors_js_1 = require("./errors.js");
|
|
|
10
10
|
* The default target utilization above which the shared liquidity algorithm is triggered (scaled by WAD).
|
|
11
11
|
*/
|
|
12
12
|
exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = 905000000000000000n;
|
|
13
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
13
14
|
const populateInputTransfer = ({ address, args: { amount, from } }, data, { hasSimplePermit = false } = {}) => {
|
|
14
15
|
const { bundler3: { generalAdapter1 }, permit2, } = (0, blue_sdk_1.getChainAddresses)(data.chainId);
|
|
15
16
|
// If native token, it is expected to be sent along as call value.
|
|
@@ -158,6 +159,7 @@ exports.populateInputTransfer = populateInputTransfer;
|
|
|
158
159
|
* @param wrapSlippage The slippage simulated during wraps. Should never be 0.
|
|
159
160
|
* @return The bundle of operations to optimize and skim before being encoded.
|
|
160
161
|
*/
|
|
162
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
161
163
|
const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
162
164
|
const { sender } = inputOperation;
|
|
163
165
|
const { bundler3: { bundler3, generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(data.chainId);
|
|
@@ -221,7 +223,7 @@ const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
221
223
|
});
|
|
222
224
|
}
|
|
223
225
|
// Reallocate liquidity if necessary.
|
|
224
|
-
if (
|
|
226
|
+
if (publicAllocatorOptions?.enabled &&
|
|
225
227
|
(mainOperation.type === "Blue_Borrow" ||
|
|
226
228
|
mainOperation.type === "Blue_Withdraw")) {
|
|
227
229
|
const market = data
|
|
@@ -315,7 +317,9 @@ const populateSubBundle = (inputOperation, data, options = {}) => {
|
|
|
315
317
|
args: {
|
|
316
318
|
...mainOperation.args,
|
|
317
319
|
...(callback && {
|
|
320
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
318
321
|
callback: (data) => {
|
|
322
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
319
323
|
const operations = callback.flatMap((inputOperation) => {
|
|
320
324
|
const subBundleOperations = (0, exports.populateSubBundle)({
|
|
321
325
|
...inputOperation,
|
|
@@ -384,6 +388,7 @@ exports.populateSubBundle = populateSubBundle;
|
|
|
384
388
|
* @param unwrapSlippage The slippage simulated during unwraps. Should never be 0.
|
|
385
389
|
* @return The optimized bundle.
|
|
386
390
|
*/
|
|
391
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
387
392
|
const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(), unwrapSlippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE) => {
|
|
388
393
|
const nbOperations = operations.length;
|
|
389
394
|
if (nbOperations === 0)
|
|
@@ -481,6 +486,7 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
|
|
|
481
486
|
others.push(operation);
|
|
482
487
|
}
|
|
483
488
|
});
|
|
489
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
484
490
|
operations = [
|
|
485
491
|
approvals,
|
|
486
492
|
permits,
|
|
@@ -569,6 +575,7 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
|
|
|
569
575
|
operation.args.owner = inputTransfer.args.from;
|
|
570
576
|
});
|
|
571
577
|
// Filter out useless input transfers.
|
|
578
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
572
579
|
operations = operations.filter((operation, index) => {
|
|
573
580
|
if (operation.type !== "Erc20_Transfer")
|
|
574
581
|
return true;
|
|
@@ -684,7 +691,7 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
|
|
|
684
691
|
uniqueSkimTokens.add(blue_sdk_1.NATIVE_ADDRESS);
|
|
685
692
|
break;
|
|
686
693
|
default:
|
|
687
|
-
//@ts-
|
|
694
|
+
//@ts-expect-error This is dead code but acts as a guard in case a new operation is added
|
|
688
695
|
throw new errors_js_1.BundlerErrors.MissingSkimHandler(operation.type);
|
|
689
696
|
}
|
|
690
697
|
if ("callback" in operation.args)
|
|
@@ -719,6 +726,7 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
|
|
|
719
726
|
return finalizedOperations;
|
|
720
727
|
};
|
|
721
728
|
exports.finalizeBundle = finalizeBundle;
|
|
729
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
722
730
|
const populateBundle = (inputOperations, data, options) => {
|
|
723
731
|
const steps = [data];
|
|
724
732
|
let end = data;
|
|
@@ -779,7 +787,9 @@ const getSimulatedBundlerOperation = (operation, { slippage } = {}) => {
|
|
|
779
787
|
args: {
|
|
780
788
|
...operation.args,
|
|
781
789
|
...(callback && {
|
|
782
|
-
callback: () =>
|
|
790
|
+
callback: () =>
|
|
791
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
792
|
+
callback.map((operation) => (0, exports.getSimulatedBundlerOperation)(operation, { slippage })),
|
|
783
793
|
}),
|
|
784
794
|
},
|
|
785
795
|
};
|
|
@@ -803,11 +813,17 @@ const getSimulatedBundlerOperation = (operation, { slippage } = {}) => {
|
|
|
803
813
|
return simulatedOperation;
|
|
804
814
|
};
|
|
805
815
|
exports.getSimulatedBundlerOperation = getSimulatedBundlerOperation;
|
|
806
|
-
const handleBundlerOperation = (options) =>
|
|
816
|
+
const handleBundlerOperation = (options) =>
|
|
817
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
818
|
+
(operation, startData, index) => (0, simulation_sdk_1.handleOperation)((0, exports.getSimulatedBundlerOperation)(operation, options), startData, index);
|
|
807
819
|
exports.handleBundlerOperation = handleBundlerOperation;
|
|
820
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
808
821
|
const handleBundlerOperations = (operations, startData, options) => (0, simulation_sdk_1.handleOperations)(operations, startData, (0, exports.handleBundlerOperation)(options));
|
|
809
822
|
exports.handleBundlerOperations = handleBundlerOperations;
|
|
810
|
-
const simulateBundlerOperation = (options) =>
|
|
823
|
+
const simulateBundlerOperation = (options) =>
|
|
824
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
825
|
+
(operation, startData, index) => (0, simulation_sdk_1.simulateOperation)((0, exports.getSimulatedBundlerOperation)(operation, options), startData, index);
|
|
811
826
|
exports.simulateBundlerOperation = simulateBundlerOperation;
|
|
827
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
812
828
|
const simulateBundlerOperations = (operations, startData, options) => (0, simulation_sdk_1.handleOperations)(operations, startData, (0, exports.simulateBundlerOperation)(options));
|
|
813
829
|
exports.simulateBundlerOperations = simulateBundlerOperations;
|
|
@@ -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;
|
package/lib/esm/ActionBundle.js
CHANGED
|
@@ -15,6 +15,7 @@ export class ActionBundle {
|
|
|
15
15
|
requirements;
|
|
16
16
|
steps;
|
|
17
17
|
chainId;
|
|
18
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
18
19
|
constructor(stepsOrChainId, actions = [], requirements = new ActionBundleRequirements()) {
|
|
19
20
|
this.actions = actions;
|
|
20
21
|
this.requirements = requirements;
|