@morpho-org/bundler-sdk-viem 3.0.1 → 3.1.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.
@@ -1,4 +1,4 @@
1
- import { type ChainId, type InputMarketParams } from "@morpho-org/blue-sdk";
1
+ import { ChainId, type InputMarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address, type Hex } from "viem";
3
3
  import type { Action, Authorization, InputReallocation, Permit2PermitSingle } from "./types/index.js";
4
4
  export interface BundlerCall {
@@ -87,6 +87,14 @@ export declare namespace BundlerAction {
87
87
  * @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
88
88
  */
89
89
  function transferFrom2(chainId: ChainId, asset: Address, amount: bigint, recipient: Address, skipRevert?: boolean): BundlerCall[];
90
+ /**
91
+ * Encodes a call to the GeneralAdapter1 to wrap legacy MORPHO tokens.
92
+ * @param chainId The chain id for which to encode the call.
93
+ * @param recipient The recipient of MORPHO tokens.
94
+ * @param amount The amount of tokens to wrap.
95
+ * @param skipRevert Whether to allow the wrap to revert without making the whole bundler revert. Defaults to false.
96
+ */
97
+ function morphoWrapperDepositFor(chainId: ChainId, recipient: Address, amount: bigint, skipRevert?: boolean): BundlerCall[];
90
98
  /**
91
99
  * Encodes a call to the GeneralAdapter1 to wrap ERC20 tokens via the provided ERC20Wrapper.
92
100
  * @param chainId The chain id for which to encode the call.
@@ -195,6 +195,10 @@ var BundlerAction;
195
195
  throw new errors_js_1.BundlerErrors.MissingSignature();
196
196
  return BundlerAction.compoundV3AllowBySig(chainId, instance, owner, isAllowed, nonce, expiry, signature, skipRevert);
197
197
  }
198
+ /* MORPHO token */
199
+ case "morphoWrapperDepositFor": {
200
+ return BundlerAction.morphoWrapperDepositFor(chainId, ...args);
201
+ }
198
202
  }
199
203
  throw Error(`unhandled action encoding: ${type}`);
200
204
  }
@@ -449,6 +453,32 @@ var BundlerAction;
449
453
  ];
450
454
  }
451
455
  BundlerAction.transferFrom2 = transferFrom2;
456
+ /**
457
+ * Encodes a call to the GeneralAdapter1 to wrap legacy MORPHO tokens.
458
+ * @param chainId The chain id for which to encode the call.
459
+ * @param recipient The recipient of MORPHO tokens.
460
+ * @param amount The amount of tokens to wrap.
461
+ * @param skipRevert Whether to allow the wrap to revert without making the whole bundler revert. Defaults to false.
462
+ */
463
+ function morphoWrapperDepositFor(chainId, recipient, amount, skipRevert = false) {
464
+ if (chainId !== blue_sdk_1.ChainId.EthMainnet)
465
+ throw new Error("MORPHO wrapping is only available on ethereum mainnet");
466
+ const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
467
+ return [
468
+ {
469
+ to: generalAdapter1,
470
+ data: (0, viem_1.encodeFunctionData)({
471
+ abi: abis_js_1.ethereumGeneralAdapter1Abi,
472
+ functionName: "morphoWrapperDepositFor",
473
+ args: [recipient, amount],
474
+ }),
475
+ value: 0n,
476
+ skipRevert,
477
+ callbackHash: viem_1.zeroHash,
478
+ },
479
+ ];
480
+ }
481
+ BundlerAction.morphoWrapperDepositFor = morphoWrapperDepositFor;
452
482
  /* ERC20 Wrapper */
453
483
  /**
454
484
  * Encodes a call to the GeneralAdapter1 to wrap ERC20 tokens via the provided ERC20Wrapper.
@@ -876,15 +906,7 @@ var BundlerAction;
876
906
  data: (0, viem_1.encodeFunctionData)({
877
907
  abi: abis_js_1.generalAdapter1Abi,
878
908
  functionName: "morphoFlashLoan",
879
- args: [
880
- asset,
881
- amount,
882
- (0, viem_1.encodeFunctionData)({
883
- abi: abis_js_1.bundler3Abi,
884
- functionName: "reenter",
885
- args: [callbackCalls],
886
- }),
887
- ],
909
+ args: [asset, amount, reenterData],
888
910
  }),
889
911
  value: 0n,
890
912
  skipRevert,
@@ -279,6 +279,11 @@ export interface ActionArgs {
279
279
  signature: Hex | null,
280
280
  skipRevert?: boolean
281
281
  ];
282
+ morphoWrapperDepositFor: [
283
+ recipient: Address,
284
+ amount: bigint,
285
+ skipRevert?: boolean
286
+ ];
282
287
  }
283
288
  export type ActionType = keyof ActionArgs;
284
289
  export type Actions = {
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.0.1",
4
+ "version": "3.1.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-viem": "^3.0.0",
23
- "@morpho-org/blue-sdk": "^3.0.0",
22
+ "@morpho-org/blue-sdk": "^3.0.5",
24
23
  "@morpho-org/simulation-sdk": "^3.0.0",
25
- "@morpho-org/morpho-ts": "^2.3.0"
24
+ "@morpho-org/morpho-ts": "^2.3.0",
25
+ "@morpho-org/blue-sdk-viem": "^3.0.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@tanstack/query-core": "^5.62.16",
@@ -34,14 +34,14 @@
34
34
  "typescript": "^5.7.2",
35
35
  "viem": "^2.23.0",
36
36
  "vitest": "^3.0.5",
37
- "@morpho-org/blue-sdk": "^3.0.0",
38
- "@morpho-org/blue-sdk-viem": "^3.0.0",
37
+ "@morpho-org/blue-sdk": "^3.0.5",
39
38
  "@morpho-org/morpho-test": "^2.3.0",
40
- "@morpho-org/simulation-sdk": "^3.0.0",
39
+ "@morpho-org/blue-sdk-viem": "^3.0.0",
41
40
  "@morpho-org/morpho-ts": "^2.3.0",
41
+ "@morpho-org/simulation-sdk": "^3.0.0",
42
42
  "@morpho-org/test": "^2.1.3",
43
- "@morpho-org/simulation-sdk-wagmi": "^3.0.0",
44
- "@morpho-org/test-wagmi": "^2.0.4"
43
+ "@morpho-org/test-wagmi": "^2.0.4",
44
+ "@morpho-org/simulation-sdk-wagmi": "^3.0.0"
45
45
  },
46
46
  "scripts": {
47
47
  "prepublish": "$npm_execpath build",