@morpho-org/bundler-sdk-viem 3.2.0-next.1 → 3.2.0-next.2

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
@@ -179,7 +179,14 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
179
179
  const action = isDai
180
180
  ? {
181
181
  type: "permitDai",
182
- args: [sender, nonce, deadline, true, null, operation.skipRevert],
182
+ args: [
183
+ sender,
184
+ nonce,
185
+ deadline,
186
+ amount > 0n,
187
+ null,
188
+ operation.skipRevert,
189
+ ],
183
190
  }
184
191
  : {
185
192
  type: "permit",
package/lib/operations.js CHANGED
@@ -358,7 +358,7 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
358
358
  const nbOperations = operations.length;
359
359
  if (nbOperations === 0)
360
360
  return operations;
361
- const { bundler3: { bundler3, generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(startData.chainId);
361
+ const { bundler3: { bundler3, generalAdapter1 }, dai, } = (0, blue_sdk_1.getChainAddresses)(startData.chainId);
362
362
  if ((0, viem_1.isAddressEqual)(receiver, bundler3) ||
363
363
  (0, viem_1.isAddressEqual)(receiver, generalAdapter1))
364
364
  throw Error(`receiver is bundler`);
@@ -541,9 +541,25 @@ const finalizeBundle = (operations, startData, receiver, unwrapTokens = new Set(
541
541
  });
542
542
  // Simulate without slippage to skim the bundler of all possible surplus of shares & assets.
543
543
  steps = (0, exports.simulateBundlerOperations)(operations, startData, { slippage: 0n });
544
+ const lastStep = (0, morpho_ts_1.getLast)(steps);
545
+ const daiPermit = dai != null
546
+ ? operations.find(
547
+ // There should exist only one dai permit operation in the bundle thanks to the first optimization step.
548
+ (operation) => operation.type === "Erc20_Permit" && operation.address === dai)
549
+ : undefined;
550
+ // If the bundle approves dai, reset the dai allowance at the end of the bundle.
551
+ if (daiPermit != null)
552
+ operations.push({
553
+ ...daiPermit,
554
+ args: {
555
+ amount: 0n,
556
+ spender: daiPermit.args.spender,
557
+ nonce: daiPermit.args.nonce + 1n,
558
+ },
559
+ });
544
560
  // Unwrap requested remaining wrapped tokens.
545
561
  const unwraps = [];
546
- const endBundlerTokenData = (0, morpho_ts_1.getLast)(steps).holdings[generalAdapter1] ?? {};
562
+ const endBundlerTokenData = lastStep.holdings[generalAdapter1] ?? {};
547
563
  unwrapTokens.forEach((wrappedToken) => {
548
564
  const remaining = endBundlerTokenData[wrappedToken]?.balance ?? 0n;
549
565
  if (remaining <= 5n)
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.2.0-next.1",
4
+ "version": "3.2.0-next.2",
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": "^3.0.6",
23
- "@morpho-org/blue-sdk-viem": "^3.0.0",
24
- "@morpho-org/simulation-sdk": "^3.0.1",
25
- "@morpho-org/morpho-ts": "^2.3.0"
22
+ "@morpho-org/blue-sdk-viem": "^3.1.1",
23
+ "@morpho-org/morpho-ts": "^2.3.0",
24
+ "@morpho-org/blue-sdk": "^4.0.0-next.2",
25
+ "@morpho-org/simulation-sdk": "^3.1.0-next.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@tanstack/query-core": "^5.62.16",
@@ -34,11 +34,11 @@
34
34
  "typescript": "^5.7.2",
35
35
  "viem": "^2.23.0",
36
36
  "vitest": "^3.0.5",
37
- "@morpho-org/blue-sdk-viem": "^3.0.0",
37
+ "@morpho-org/blue-sdk": "^4.0.0-next.2",
38
38
  "@morpho-org/morpho-test": "^2.3.0",
39
39
  "@morpho-org/morpho-ts": "^2.3.0",
40
- "@morpho-org/simulation-sdk": "^3.0.1",
41
- "@morpho-org/blue-sdk": "^3.0.6",
40
+ "@morpho-org/simulation-sdk": "^3.1.0-next.1",
41
+ "@morpho-org/blue-sdk-viem": "^3.1.1",
42
42
  "@morpho-org/simulation-sdk-wagmi": "^3.0.1",
43
43
  "@morpho-org/test": "^2.1.3",
44
44
  "@morpho-org/test-wagmi": "^2.0.4"