@morpho-org/bundler-sdk-viem 3.3.0-next.0 → 3.3.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/lib/actions.js CHANGED
@@ -210,7 +210,11 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
210
210
  break;
211
211
  }
212
212
  // Simple permit is not supported, fallback to standard approval.
213
- requirements.txs.push(...encodeErc20Approval(operation.address, spender, amount, dataBefore));
213
+ // Ignore zero permits used to reset allowances at the end of a bundle
214
+ // when the signer does not support signatures, as they cannot be bundled.
215
+ // Currently only used by DAI-specific permit which does not support specific amounts.
216
+ if (amount > 0n)
217
+ requirements.txs.push(...encodeErc20Approval(operation.address, spender, amount, dataBefore));
214
218
  break;
215
219
  }
216
220
  case "Erc20_Permit2": {
@@ -749,76 +753,6 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
749
753
  });
750
754
  break;
751
755
  }
752
- case "VaultV2_Deposit": {
753
- const { assets = 0n, shares = 0n, onBehalf, slippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
754
- // Accrue interest to calculate the expected share price.
755
- const { vault } = dataBefore
756
- .getAccrualVaultV2(operation.address)
757
- .accrueInterest(dataBefore.block.timestamp);
758
- if (shares === 0n) {
759
- const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(assets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), vault.toShares(assets));
760
- actions.push({
761
- type: "erc4626Deposit",
762
- args: [
763
- operation.address,
764
- assets,
765
- maxSharePrice,
766
- onBehalf,
767
- operation.skipRevert,
768
- ],
769
- });
770
- }
771
- else {
772
- const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(vault.toAssets(shares), blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), shares);
773
- actions.push({
774
- type: "erc4626Mint",
775
- args: [
776
- operation.address,
777
- shares,
778
- maxSharePrice,
779
- onBehalf,
780
- operation.skipRevert,
781
- ],
782
- });
783
- }
784
- break;
785
- }
786
- case "VaultV2_Withdraw": {
787
- const { assets = 0n, shares = 0n, onBehalf, receiver, slippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
788
- // Accrue interest to calculate the expected share price.
789
- const { vault } = dataBefore
790
- .getAccrualVaultV2(operation.address)
791
- .accrueInterest(dataBefore.block.timestamp);
792
- if (shares === 0n) {
793
- const minSharePrice = blue_sdk_1.MathLib.mulDivDown(assets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage), vault.toShares(assets));
794
- actions.push({
795
- type: "erc4626Withdraw",
796
- args: [
797
- operation.address,
798
- assets,
799
- minSharePrice,
800
- receiver,
801
- onBehalf,
802
- operation.skipRevert,
803
- ],
804
- });
805
- }
806
- else {
807
- const minSharePrice = blue_sdk_1.MathLib.mulDivDown(vault.toAssets(shares), blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage), shares);
808
- actions.push({
809
- type: "erc4626Redeem",
810
- args: [
811
- operation.address,
812
- shares,
813
- minSharePrice,
814
- receiver,
815
- onBehalf,
816
- operation.skipRevert,
817
- ],
818
- });
819
- }
820
- break;
821
- }
822
756
  }
823
757
  return {
824
758
  dataAfter,
package/lib/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SimulationResult } from "@morpho-org/simulation-sdk";
1
+ import type { OperationType, SimulationResult } from "@morpho-org/simulation-sdk";
2
2
  import type { Address } from "viem";
3
3
  import type { ActionType, InputBundlerOperation } from "./types/index.js";
4
4
  export declare namespace BundlerErrors {
@@ -21,4 +21,10 @@ export declare namespace BundlerErrors {
21
21
  class UnexpectedSignature extends Error {
22
22
  constructor(spender: Address);
23
23
  }
24
+ class MissingSkimHandler extends Error {
25
+ constructor(type: OperationType);
26
+ }
27
+ class UnskimedToken extends Error {
28
+ constructor(token: Address);
29
+ }
24
30
  }
package/lib/errors.js CHANGED
@@ -42,4 +42,16 @@ var BundlerErrors;
42
42
  }
43
43
  }
44
44
  BundlerErrors.UnexpectedSignature = UnexpectedSignature;
45
+ class MissingSkimHandler extends Error {
46
+ constructor(type) {
47
+ super(`missing skim handler for operation "${type}"`);
48
+ }
49
+ }
50
+ BundlerErrors.MissingSkimHandler = MissingSkimHandler;
51
+ class UnskimedToken extends Error {
52
+ constructor(token) {
53
+ super(`missing final skim for token "${token}"`);
54
+ }
55
+ }
56
+ BundlerErrors.UnskimedToken = UnskimedToken;
45
57
  })(BundlerErrors || (exports.BundlerErrors = BundlerErrors = {}));
@@ -42,7 +42,7 @@ export declare const populateInputTransfer: ({ address, args: { amount, from } }
42
42
  export declare const populateSubBundle: (inputOperation: InputBundlerOperation, data: MaybeDraft<SimulationState>, options?: BundlingOptions) => BundlerOperation[];
43
43
  /**
44
44
  * Merges unnecessary duplicate `Erc20_Approve`, `Erc20_Transfer` and `Erc20_Wrap`.
45
- * Also redirects `Blue_Borrow|Withdraw|WithdrawCollateral` & `MetaMorpho_Withdraw` & `VaultV2_Withdraw` operations from the bundler to the receiver,
45
+ * Also redirects `Blue_Borrow|Withdraw|WithdrawCollateral` & `MetaMorpho_Withdraw` operations from the bundler to the receiver,
46
46
  * as long as the tokens received (possibly ERC4626 shares) are not used afterwards in the bundle.
47
47
  * For all the other remaining tokens, appends `Erc20_Transfer` operations to the bundle, from the bundler to the receiver.
48
48
  * @param operations The bundle to optimize.
package/lib/operations.js CHANGED
@@ -45,7 +45,6 @@ const populateInputTransfer = ({ address, args: { amount, from } }, data, { hasS
45
45
  // Try using simple permit.
46
46
  const useSimplePermit = erc2612Nonce != null &&
47
47
  (data.tryGetVault(address) != null || // MetaMorpho vaults implement EIP-2612.
48
- data.tryGetVaultV2(address) != null || // Vaults V2 implement EIP-2612.
49
48
  hasSimplePermit);
50
49
  const useSimpleTransfer = permit2 == null ||
51
50
  // Token is permissioned and Permit2 may not be authorized so Permit2 cannot be used.
@@ -181,18 +180,10 @@ const populateSubBundle = (inputOperation, data, options = {}) => {
181
180
  if (isErc20Wrapper)
182
181
  break;
183
182
  case "MetaMorpho_Deposit":
184
- case "MetaMorpho_Withdraw": {
183
+ case "MetaMorpho_Withdraw":
185
184
  // Only if sender is owner otherwise the owner would be lost.
186
185
  if (draft.args.owner === sender)
187
186
  draft.args.owner = generalAdapter1;
188
- break;
189
- }
190
- case "VaultV2_Deposit":
191
- case "VaultV2_Withdraw": {
192
- // Only if sender is owner otherwise the owner would be lost.
193
- if (draft.args.onBehalf === sender)
194
- draft.args.onBehalf = generalAdapter1;
195
- }
196
187
  }
197
188
  // Redirect operation targets.
198
189
  switch (draft.type) {
@@ -201,7 +192,6 @@ const populateSubBundle = (inputOperation, data, options = {}) => {
201
192
  case "Blue_WithdrawCollateral":
202
193
  draft.args.onBehalf = sender;
203
194
  case "MetaMorpho_Withdraw":
204
- case "VaultV2_Withdraw":
205
195
  case "Paraswap_Buy":
206
196
  case "Paraswap_Sell":
207
197
  case "Blue_Paraswap_BuyDebt":
@@ -357,8 +347,6 @@ const populateSubBundle = (inputOperation, data, options = {}) => {
357
347
  ("shares" in mainOperation.args && mainOperation.args.shares === viem_1.maxUint256)) {
358
348
  if (mainOperation.type === "MetaMorpho_Withdraw")
359
349
  mainOperation.args.owner = generalAdapter1;
360
- if (mainOperation.type === "VaultV2_Withdraw")
361
- mainOperation.args.onBehalf = generalAdapter1;
362
350
  return allOperations;
363
351
  }
364
352
  const requirementOperations = getRequirementOperations?.(requiredTokenAmounts) ?? [];
@@ -383,7 +371,7 @@ const populateSubBundle = (inputOperation, data, options = {}) => {
383
371
  exports.populateSubBundle = populateSubBundle;
384
372
  /**
385
373
  * Merges unnecessary duplicate `Erc20_Approve`, `Erc20_Transfer` and `Erc20_Wrap`.
386
- * Also redirects `Blue_Borrow|Withdraw|WithdrawCollateral` & `MetaMorpho_Withdraw` & `VaultV2_Withdraw` operations from the bundler to the receiver,
374
+ * Also redirects `Blue_Borrow|Withdraw|WithdrawCollateral` & `MetaMorpho_Withdraw` operations from the bundler to the receiver,
387
375
  * as long as the tokens received (possibly ERC4626 shares) are not used afterwards in the bundle.
388
376
  * For all the other remaining tokens, appends `Erc20_Transfer` operations to the bundle, from the bundler to the receiver.
389
377
  * @param operations The bundle to optimize.
@@ -501,20 +489,9 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
501
489
  let steps = (0, exports.simulateBundlerOperations)(operations, startData);
502
490
  // Redirect MetaMorpho deposits.
503
491
  operations.forEach((operation, index) => {
504
- switch (operation.type) {
505
- case "MetaMorpho_Deposit": {
506
- if (operation.args.owner !== generalAdapter1)
507
- return;
508
- break;
509
- }
510
- case "VaultV2_Deposit": {
511
- if (operation.args.onBehalf !== generalAdapter1)
512
- return;
513
- break;
514
- }
515
- default:
516
- return;
517
- }
492
+ if (operation.type !== "MetaMorpho_Deposit" ||
493
+ operation.args.owner !== generalAdapter1)
494
+ return;
518
495
  const token = operation.address;
519
496
  // shares are not defined when depositing assets, so we rely on simulation steps.
520
497
  const shares = steps[index + 1].getHolding(generalAdapter1, token).balance -
@@ -524,12 +501,9 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
524
501
  .some((step) => step.getHolding(generalAdapter1, token).balance < shares))
525
502
  // If the bundler's balance is at least once lower than assets, the bundler does need these assets.
526
503
  return;
527
- if (operation.type === "MetaMorpho_Deposit")
528
- operation.args.owner = receiver;
529
- if (operation.type === "VaultV2_Deposit")
530
- operation.args.onBehalf = receiver;
504
+ operation.args.owner = receiver;
531
505
  });
532
- // Redirect borrows, withdrawals, MetaMorpho withdrawals & Vault V2 withdrawals.
506
+ // Redirect borrows, withdrawals & MetaMorpho withdrawals.
533
507
  operations.forEach((operation, index) => {
534
508
  let token;
535
509
  switch (operation.type) {
@@ -543,9 +517,6 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
543
517
  case "MetaMorpho_Withdraw":
544
518
  token = startData.getVault(operation.address).asset;
545
519
  break;
546
- case "VaultV2_Withdraw":
547
- token = startData.getVaultV2(operation.address).asset;
548
- break;
549
520
  default:
550
521
  return;
551
522
  }
@@ -563,20 +534,9 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
563
534
  });
564
535
  // Simplify Erc20_Transfer(sender = bundler, to = bundler) + MetaMorpho_Withdraw(owner = bundler) = MetaMorpho_Withdraw(owner = from).
565
536
  operations.forEach((operation, index) => {
566
- switch (operation.type) {
567
- case "MetaMorpho_Withdraw": {
568
- if (operation.args.owner !== generalAdapter1)
569
- return;
570
- break;
571
- }
572
- case "VaultV2_Withdraw": {
573
- if (operation.args.onBehalf !== generalAdapter1)
574
- return;
575
- break;
576
- }
577
- default:
578
- return;
579
- }
537
+ if (operation.type !== "MetaMorpho_Withdraw" ||
538
+ operation.args.owner !== generalAdapter1)
539
+ return;
580
540
  // shares are not defined when using assets, so we rely on simulation steps.
581
541
  const shares = steps[index].getHolding(generalAdapter1, operation.address).balance -
582
542
  steps[index + 1].getHolding(generalAdapter1, operation.address).balance;
@@ -589,10 +549,7 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
589
549
  return;
590
550
  const inputTransfer = operations[inputTransferIndex];
591
551
  inputTransfer.args.amount -= shares;
592
- if (operation.type === "MetaMorpho_Withdraw")
593
- operation.args.owner = inputTransfer.args.from;
594
- if (operation.type === "VaultV2_Withdraw")
595
- operation.args.onBehalf = inputTransfer.args.from;
552
+ operation.args.owner = inputTransfer.args.from;
596
553
  });
597
554
  // Filter out useless input transfers.
598
555
  operations = operations.filter((operation, index) => {
@@ -657,29 +614,66 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
657
614
  }
658
615
  // Skim any token expected to be left on the bundler.
659
616
  const skims = [];
660
- const startBundlerTokenData = steps[0].holdings[generalAdapter1] ?? {};
661
- const uniqueSkimTokens = new Set((0, morpho_ts_1.entries)(endBundlerTokenData)
662
- .filter(([token, holding]) => holding != null &&
663
- holding.balance - (startBundlerTokenData[token]?.balance ?? 0n) > 5n)
664
- .map(([address]) => address));
665
- const pushCustomSkim = (operation) => {
617
+ const uniqueSkimTokens = new Set();
618
+ const pushSkim = (operation) => {
666
619
  // Paraswap does not guarantee that the amount effectively bought (resp. sold) corresponds to
667
620
  // the requested amount to buy (resp. sell), so we force skim the possible surplus of bought (resp. sold) token.
668
621
  switch (operation.type) {
622
+ case "Blue_Borrow":
623
+ case "Blue_Repay":
624
+ case "Blue_Supply":
625
+ case "Blue_Withdraw":
626
+ uniqueSkimTokens.add(startData.getMarket(operation.args.id).params.loanToken);
627
+ break;
628
+ case "Blue_WithdrawCollateral":
629
+ case "Blue_SupplyCollateral":
630
+ uniqueSkimTokens.add(startData.getMarket(operation.args.id).params.collateralToken);
631
+ break;
632
+ case "Blue_FlashLoan":
633
+ uniqueSkimTokens.add(operation.args.token);
634
+ break;
669
635
  case "Paraswap_Buy":
670
- case "Paraswap_Sell":
671
636
  uniqueSkimTokens.add(operation.address);
637
+ uniqueSkimTokens.add(operation.args.srcToken);
672
638
  break;
673
639
  case "Blue_Paraswap_BuyDebt":
674
640
  uniqueSkimTokens.add(startData.getMarket(operation.args.id).params.loanToken);
641
+ uniqueSkimTokens.add(operation.args.srcToken);
675
642
  break;
676
- default:
643
+ case "Paraswap_Sell":
644
+ uniqueSkimTokens.add(operation.address);
645
+ uniqueSkimTokens.add(operation.args.dstToken);
677
646
  break;
647
+ case "Erc20_Transfer":
648
+ case "Erc20_Transfer2":
649
+ uniqueSkimTokens.add(operation.address);
650
+ break;
651
+ case "Blue_SetAuthorization":
652
+ case "Erc20_Approve":
653
+ case "Erc20_Permit":
654
+ case "Erc20_Permit2":
655
+ break;
656
+ case "Erc20_Wrap":
657
+ case "Erc20_Unwrap":
658
+ uniqueSkimTokens.add(operation.address);
659
+ uniqueSkimTokens.add(startData.getWrappedToken(operation.address).underlying);
660
+ break;
661
+ case "MetaMorpho_Deposit":
662
+ case "MetaMorpho_Withdraw":
663
+ uniqueSkimTokens.add(operation.address);
664
+ uniqueSkimTokens.add(startData.getVault(operation.address).asset);
665
+ break;
666
+ case "MetaMorpho_PublicReallocate":
667
+ uniqueSkimTokens.add(blue_sdk_1.NATIVE_ADDRESS);
668
+ break;
669
+ default:
670
+ //@ts-ignore This is dead code but acts as a guard in case a new operation is added
671
+ throw new errors_js_1.BundlerErrors.MissingSkimHandler(operation.type);
678
672
  }
679
673
  if ("callback" in operation.args)
680
- operation.args.callback?.forEach(pushCustomSkim);
674
+ operation.args.callback?.forEach(pushSkim);
681
675
  };
682
- operations.forEach(pushCustomSkim);
676
+ operations.concat(unwraps).forEach(pushSkim);
683
677
  skims.push(...Array.from(uniqueSkimTokens, (address) => ({
684
678
  type: "Erc20_Transfer",
685
679
  address,
@@ -690,7 +684,15 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
690
684
  to: receiver,
691
685
  },
692
686
  })));
693
- return operations.concat(unwraps, skims);
687
+ const finalizedOperations = operations.concat(unwraps, skims);
688
+ const finalizedSteps = (0, exports.simulateBundlerOperations)(finalizedOperations, startData);
689
+ for (const holding of (0, morpho_ts_1.values)((0, morpho_ts_1.getLast)(finalizedSteps).holdings[generalAdapter1])) {
690
+ if (!holding)
691
+ continue;
692
+ if (holding.balance > 0n)
693
+ throw new errors_js_1.BundlerErrors.UnskimedToken(holding.token);
694
+ }
695
+ return finalizedOperations;
694
696
  };
695
697
  exports.finalizeBundle = finalizeBundle;
696
698
  const populateBundle = (inputOperations, data, options) => {
@@ -767,8 +769,6 @@ const getSimulatedBundlerOperation = (operation, { slippage } = {}) => {
767
769
  case "Blue_Repay":
768
770
  case "MetaMorpho_Deposit":
769
771
  case "MetaMorpho_Withdraw":
770
- case "VaultV2_Deposit":
771
- case "VaultV2_Withdraw":
772
772
  case "Paraswap_Buy":
773
773
  case "Paraswap_Sell":
774
774
  case "Blue_Paraswap_BuyDebt":
@@ -1,4 +1,4 @@
1
- import { type BlueOperationArgs, CALLBACK_OPERATIONS, type CallbackOperationType, type Erc20OperationArgs, type MetaMorphoOperationArgs, type OperationArgs, type OperationType, type ParaswapOperationArgs, type VaultV2OperationArgs, type WithOperationArgs } from "@morpho-org/simulation-sdk";
1
+ import { type BlueOperationArgs, CALLBACK_OPERATIONS, type CallbackOperationType, type Erc20OperationArgs, type MetaMorphoOperationArgs, type OperationArgs, type OperationType, type ParaswapOperationArgs, type WithOperationArgs } from "@morpho-org/simulation-sdk";
2
2
  import type { UnionOmit } from "viem";
3
3
  export declare const BLUE_BUNDLER_OPERATIONS: readonly ["Blue_SetAuthorization", "Blue_Borrow", "Blue_Repay", "Blue_Supply", "Blue_SupplyCollateral", "Blue_Withdraw", "Blue_WithdrawCollateral", "Blue_FlashLoan", "Blue_Paraswap_BuyDebt"];
4
4
  export type BlueBundlerOperationType = (typeof BLUE_BUNDLER_OPERATIONS)[number];
@@ -32,18 +32,12 @@ export type Erc20BundlerOperations = {
32
32
  [OperationType in Erc20BundlerOperationType]: WithOperationArgs<OperationType, Erc20OperationArgs>;
33
33
  };
34
34
  export type Erc20BundlerOperation = Erc20BundlerOperations[Erc20BundlerOperationType];
35
- export declare const VAULT_V2_BUNDLER_OPERATIONS: readonly ["VaultV2_Deposit", "VaultV2_Withdraw"];
36
- export type VaultV2BundlerOperationType = (typeof VAULT_V2_BUNDLER_OPERATIONS)[number];
37
- export type VaultV2BundlerOperations = {
38
- [OperationType in VaultV2BundlerOperationType]: WithOperationArgs<OperationType, VaultV2OperationArgs>;
39
- };
40
- export type VaultV2BundlerOperation = VaultV2BundlerOperations[VaultV2BundlerOperationType];
41
- export interface BundlerOperationArgs extends BlueOperationArgs, MetaMorphoOperationArgs, ParaswapOperationArgs, Erc20OperationArgs, VaultV2OperationArgs {
35
+ export interface BundlerOperationArgs extends BlueOperationArgs, MetaMorphoOperationArgs, ParaswapOperationArgs, Erc20OperationArgs {
42
36
  }
43
- export type BundlerOperations = BlueBundlerOperations & MetaMorphoBundlerOperations & ParaswapBundlerOperations & Erc20BundlerOperations & VaultV2BundlerOperations;
44
- export type BundlerOperationType = BlueBundlerOperationType | MetaMorphoBundlerOperationType | ParaswapBundlerOperationType | Erc20BundlerOperationType | VaultV2BundlerOperationType;
45
- export type BundlerOperation = BlueBundlerOperation | MetaMorphoBundlerOperation | ParaswapBundlerOperation | Erc20BundlerOperation | VaultV2BundlerOperation;
46
- export declare const BUNDLER_OPERATIONS: readonly ["Blue_SetAuthorization", "Blue_Borrow", "Blue_Repay", "Blue_Supply", "Blue_SupplyCollateral", "Blue_Withdraw", "Blue_WithdrawCollateral", "Blue_FlashLoan", "Blue_Paraswap_BuyDebt", "MetaMorpho_Deposit", "MetaMorpho_Withdraw", "MetaMorpho_PublicReallocate", "Erc20_Approve", "Erc20_Permit", "Erc20_Permit2", "Erc20_Transfer", "Erc20_Transfer2", "Erc20_Wrap", "Erc20_Unwrap", "VaultV2_Deposit", "VaultV2_Withdraw"];
37
+ export type BundlerOperations = BlueBundlerOperations & MetaMorphoBundlerOperations & ParaswapBundlerOperations & Erc20BundlerOperations;
38
+ export type BundlerOperationType = BlueBundlerOperationType | MetaMorphoBundlerOperationType | ParaswapBundlerOperationType | Erc20BundlerOperationType;
39
+ export type BundlerOperation = BlueBundlerOperation | MetaMorphoBundlerOperation | ParaswapBundlerOperation | Erc20BundlerOperation;
40
+ export declare const BUNDLER_OPERATIONS: readonly ["Blue_SetAuthorization", "Blue_Borrow", "Blue_Repay", "Blue_Supply", "Blue_SupplyCollateral", "Blue_Withdraw", "Blue_WithdrawCollateral", "Blue_FlashLoan", "Blue_Paraswap_BuyDebt", "MetaMorpho_Deposit", "MetaMorpho_Withdraw", "MetaMorpho_PublicReallocate", "Erc20_Approve", "Erc20_Permit", "Erc20_Permit2", "Erc20_Transfer", "Erc20_Transfer2", "Erc20_Wrap", "Erc20_Unwrap"];
47
41
  export type CallbackBundlerOperationType = (typeof CALLBACK_OPERATIONS)[number];
48
42
  export type CallbackBundlerOperations = Pick<BundlerOperations, CallbackBundlerOperationType>;
49
43
  export type CallbackBundlerOperation = CallbackBundlerOperations[CallbackBundlerOperationType];
@@ -51,7 +45,6 @@ export declare const isBlueBundlerOperation: (operation: BundlerOperation) => op
51
45
  export declare const isMetaMorphoBundlerOperation: (operation: BundlerOperation) => operation is MetaMorphoBundlerOperation;
52
46
  export declare const isErc20BundlerOperation: (operation: BundlerOperation) => operation is Erc20BundlerOperation;
53
47
  export declare const isCallbackBundlerOperation: (operation: BundlerOperation) => operation is CallbackBundlerOperation;
54
- export declare const isVaultV2BundlerOperation: (operation: BundlerOperation) => operation is VaultV2BundlerOperation;
55
48
  export declare const BLUE_INPUT_OPERATIONS: readonly ["Blue_SetAuthorization", "Blue_Borrow", "Blue_Repay", "Blue_Supply", "Blue_SupplyCollateral", "Blue_Withdraw", "Blue_WithdrawCollateral", "Blue_FlashLoan", "Blue_Paraswap_BuyDebt"];
56
49
  export type BlueInputBundlerOperationType = (typeof BLUE_INPUT_OPERATIONS)[number];
57
50
  export type BlueInputBundlerOperationArgs = Omit<OperationArgs, (typeof CALLBACK_OPERATIONS)[number]> & {
@@ -75,13 +68,10 @@ export type ParaswapInputBundlerOperation = BundlerOperations[ParaswapInputBundl
75
68
  export declare const ERC20_INPUT_OPERATIONS: readonly ["Erc20_Approve", "Erc20_Permit", "Erc20_Permit2", "Erc20_Transfer", "Erc20_Transfer2", "Erc20_Wrap", "Erc20_Unwrap"];
76
69
  export type Erc20InputBundlerOperationType = (typeof ERC20_INPUT_OPERATIONS)[number];
77
70
  export type Erc20InputBundlerOperation = Erc20BundlerOperations[Erc20InputBundlerOperationType];
78
- export declare const VAULT_V2_INPUT_OPERATIONS: readonly ["VaultV2_Deposit", "VaultV2_Withdraw"];
79
- export type VaultV2InputBundlerOperationType = (typeof VAULT_V2_INPUT_OPERATIONS)[number];
80
- export type VaultV2InputBundlerOperation = VaultV2BundlerOperations[VaultV2InputBundlerOperationType];
81
- export interface InputBundlerOperationArgs extends BlueOperationArgs, MetaMorphoOperationArgs, ParaswapOperationArgs, Erc20OperationArgs, VaultV2OperationArgs {
71
+ export interface InputBundlerOperationArgs extends BlueOperationArgs, MetaMorphoOperationArgs, ParaswapOperationArgs, Erc20OperationArgs {
82
72
  }
83
- export type InputBundlerOperationType = BlueInputBundlerOperationType | MetaMorphoInputBundlerOperationType | ParaswapInputBundlerOperationType | Erc20InputBundlerOperationType | VaultV2InputBundlerOperationType;
84
- export type InputBundlerOperation = BlueInputBundlerOperation | MetaMorphoInputBundlerOperation | ParaswapInputBundlerOperation | Erc20InputBundlerOperation | VaultV2InputBundlerOperation;
73
+ export type InputBundlerOperationType = BlueInputBundlerOperationType | MetaMorphoInputBundlerOperationType | ParaswapInputBundlerOperationType | Erc20InputBundlerOperationType;
74
+ export type InputBundlerOperation = BlueInputBundlerOperation | MetaMorphoInputBundlerOperation | ParaswapInputBundlerOperation | Erc20InputBundlerOperation;
85
75
  export declare const isBlueInputBundlerOperation: (operation: {
86
76
  type: OperationType;
87
77
  }) => operation is BlueInputBundlerOperation;
@@ -94,6 +84,3 @@ export declare const isErc20InputBundlerOperation: (operation: {
94
84
  export declare const isParaswapInputBundlerOperation: (operation: {
95
85
  type: OperationType;
96
86
  }) => operation is ParaswapInputBundlerOperation;
97
- export declare const isVaultV2InputBundlerOperation: (operation: {
98
- type: OperationType;
99
- }) => operation is VaultV2InputBundlerOperation;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isVaultV2InputBundlerOperation = exports.isParaswapInputBundlerOperation = exports.isErc20InputBundlerOperation = exports.isMetaMorphoInputBundlerOperation = exports.isBlueInputBundlerOperation = exports.VAULT_V2_INPUT_OPERATIONS = exports.ERC20_INPUT_OPERATIONS = exports.PARASWAP_INPUT_OPERATIONS = exports.METAMORPHO_INPUT_OPERATIONS = exports.BLUE_INPUT_OPERATIONS = exports.isVaultV2BundlerOperation = exports.isCallbackBundlerOperation = exports.isErc20BundlerOperation = exports.isMetaMorphoBundlerOperation = exports.isBlueBundlerOperation = exports.BUNDLER_OPERATIONS = exports.VAULT_V2_BUNDLER_OPERATIONS = exports.ERC20_BUNDLER_OPERATIONS = exports.PARASWAP_BUNDLER_OPERATIONS = exports.METAMORPHO_BUNDLER_OPERATIONS = exports.BLUE_BUNDLER_OPERATIONS = void 0;
3
+ exports.isParaswapInputBundlerOperation = exports.isErc20InputBundlerOperation = exports.isMetaMorphoInputBundlerOperation = exports.isBlueInputBundlerOperation = exports.ERC20_INPUT_OPERATIONS = exports.PARASWAP_INPUT_OPERATIONS = exports.METAMORPHO_INPUT_OPERATIONS = exports.BLUE_INPUT_OPERATIONS = exports.isCallbackBundlerOperation = exports.isErc20BundlerOperation = exports.isMetaMorphoBundlerOperation = exports.isBlueBundlerOperation = exports.BUNDLER_OPERATIONS = exports.ERC20_BUNDLER_OPERATIONS = exports.PARASWAP_BUNDLER_OPERATIONS = exports.METAMORPHO_BUNDLER_OPERATIONS = exports.BLUE_BUNDLER_OPERATIONS = void 0;
4
4
  const simulation_sdk_1 = require("@morpho-org/simulation-sdk");
5
5
  exports.BLUE_BUNDLER_OPERATIONS = [
6
6
  "Blue_SetAuthorization",
@@ -20,15 +20,10 @@ exports.METAMORPHO_BUNDLER_OPERATIONS = [
20
20
  ];
21
21
  exports.PARASWAP_BUNDLER_OPERATIONS = simulation_sdk_1.PARASWAP_OPERATIONS;
22
22
  exports.ERC20_BUNDLER_OPERATIONS = simulation_sdk_1.ERC20_OPERATIONS;
23
- exports.VAULT_V2_BUNDLER_OPERATIONS = [
24
- "VaultV2_Deposit",
25
- "VaultV2_Withdraw",
26
- ];
27
23
  exports.BUNDLER_OPERATIONS = [
28
24
  ...exports.BLUE_BUNDLER_OPERATIONS,
29
25
  ...exports.METAMORPHO_BUNDLER_OPERATIONS,
30
26
  ...exports.ERC20_BUNDLER_OPERATIONS,
31
- ...exports.VAULT_V2_BUNDLER_OPERATIONS,
32
27
  ];
33
28
  const isBlueBundlerOperation = (operation) => {
34
29
  return exports.BLUE_BUNDLER_OPERATIONS.includes(operation.type);
@@ -46,10 +41,6 @@ const isCallbackBundlerOperation = (operation) => {
46
41
  return simulation_sdk_1.CALLBACK_OPERATIONS.includes(operation.type);
47
42
  };
48
43
  exports.isCallbackBundlerOperation = isCallbackBundlerOperation;
49
- const isVaultV2BundlerOperation = (operation) => {
50
- return exports.VAULT_V2_BUNDLER_OPERATIONS.includes(operation.type);
51
- };
52
- exports.isVaultV2BundlerOperation = isVaultV2BundlerOperation;
53
44
  exports.BLUE_INPUT_OPERATIONS = exports.BLUE_BUNDLER_OPERATIONS;
54
45
  exports.METAMORPHO_INPUT_OPERATIONS = [
55
46
  "MetaMorpho_Deposit",
@@ -57,10 +48,6 @@ exports.METAMORPHO_INPUT_OPERATIONS = [
57
48
  ];
58
49
  exports.PARASWAP_INPUT_OPERATIONS = exports.PARASWAP_BUNDLER_OPERATIONS;
59
50
  exports.ERC20_INPUT_OPERATIONS = exports.ERC20_BUNDLER_OPERATIONS;
60
- exports.VAULT_V2_INPUT_OPERATIONS = [
61
- "VaultV2_Deposit",
62
- "VaultV2_Withdraw",
63
- ];
64
51
  const isBlueInputBundlerOperation = (operation) => {
65
52
  return exports.BLUE_INPUT_OPERATIONS.includes(operation.type);
66
53
  };
@@ -77,7 +64,3 @@ const isParaswapInputBundlerOperation = (operation) => {
77
64
  return exports.PARASWAP_INPUT_OPERATIONS.includes(operation.type);
78
65
  };
79
66
  exports.isParaswapInputBundlerOperation = isParaswapInputBundlerOperation;
80
- const isVaultV2InputBundlerOperation = (operation) => {
81
- return exports.VAULT_V2_INPUT_OPERATIONS.includes(operation.type);
82
- };
83
- exports.isVaultV2InputBundlerOperation = isVaultV2InputBundlerOperation;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/bundler-sdk-viem",
3
3
  "description": "Viem-based extension of `@morpho-org/simulation-sdk` that exports utilities to transform simple interactions on Morpho (such as `Blue_Borrow`) and Morpho Vaults (such as `MetaMorpho_Deposit`) into the required bundles (with ERC20 approvals, transfers, etc) to submit to the bundler onchain.",
4
- "version": "3.3.0-next.0",
4
+ "version": "3.3.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -19,10 +19,10 @@
19
19
  ],
20
20
  "peerDependencies": {
21
21
  "viem": "^2.0.0",
22
+ "@morpho-org/blue-sdk": "^4.10.0",
23
+ "@morpho-org/blue-sdk-viem": "^3.1.2",
22
24
  "@morpho-org/morpho-ts": "^2.4.1",
23
- "@morpho-org/blue-sdk-viem": "^3.2.0-next.0",
24
- "@morpho-org/blue-sdk": "^4.10.0-next.0",
25
- "@morpho-org/simulation-sdk": "^3.2.0-next.0"
25
+ "@morpho-org/simulation-sdk": "^3.1.3"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@tanstack/query-core": "^5.62.16",
@@ -32,16 +32,16 @@
32
32
  "@types/lodash": "^4.17.12",
33
33
  "lodash": "^4.17.21",
34
34
  "typescript": "^5.7.2",
35
- "viem": "^2.33.3",
35
+ "viem": "^2.23.0",
36
36
  "vitest": "^3.0.5",
37
- "@morpho-org/blue-sdk": "^4.10.0-next.0",
38
- "@morpho-org/blue-sdk-viem": "^3.2.0-next.0",
37
+ "@morpho-org/blue-sdk": "^4.10.0",
38
+ "@morpho-org/blue-sdk-viem": "^3.1.2",
39
+ "@morpho-org/morpho-test": "^2.4.0",
39
40
  "@morpho-org/morpho-ts": "^2.4.1",
40
- "@morpho-org/morpho-test": "^2.4.1-next.0",
41
- "@morpho-org/simulation-sdk": "^3.2.0-next.0",
42
- "@morpho-org/simulation-sdk-wagmi": "^3.1.0-next.0",
43
- "@morpho-org/test-wagmi": "^2.0.5-next.0",
44
- "@morpho-org/test": "^2.1.6-next.0"
41
+ "@morpho-org/simulation-sdk": "^3.1.3",
42
+ "@morpho-org/simulation-sdk-wagmi": "^3.0.3",
43
+ "@morpho-org/test-wagmi": "^2.0.4",
44
+ "@morpho-org/test": "^2.4.0"
45
45
  },
46
46
  "scripts": {
47
47
  "prepublish": "$npm_execpath build",