@morpho-org/bundler-sdk-viem 3.3.3 → 3.3.4

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.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type MaybeDraft, type SimulationState } from "@morpho-org/simulation-sdk";
2
2
  import { ActionBundle, ActionBundleRequirements } from "./ActionBundle.js";
3
3
  import type { Action, BundlerOperation, TransactionRequirement } from "./types/index.js";
4
+ export declare const MAX_ABSOLUTE_SHARE_PRICE: bigint;
4
5
  export declare const encodeOperation: (operation: BundlerOperation, dataBefore: MaybeDraft<SimulationState>, supportsSignature?: boolean, index?: number) => {
5
6
  dataAfter: MaybeDraft<SimulationState>;
6
7
  actions: Action[];
package/lib/actions.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodeOperation = void 0;
3
+ exports.encodeOperation = exports.MAX_ABSOLUTE_SHARE_PRICE = void 0;
4
4
  exports.encodeBundle = encodeBundle;
5
5
  const viem_1 = require("viem");
6
6
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
@@ -10,6 +10,7 @@ const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-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
+ exports.MAX_ABSOLUTE_SHARE_PRICE = 100n * blue_sdk_1.MathLib.RAY;
13
14
  const encodeErc20Approval = (token, spender, amount, data) => {
14
15
  const { chainId } = data;
15
16
  amount = blue_sdk_1.MathLib.min(amount, simulation_sdk_1.MAX_TOKEN_APPROVALS[chainId]?.[token] ?? viem_1.maxUint256);
@@ -409,7 +410,7 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
409
410
  .getMarket(id)
410
411
  .accrueInterest(dataBefore.block.timestamp);
411
412
  const { assets: suppliedAssets, shares: suppliedShares } = market.supply(assets, shares);
412
- const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(suppliedAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), suppliedShares);
413
+ const maxSharePrice = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(suppliedAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), suppliedShares), exports.MAX_ABSOLUTE_SHARE_PRICE);
413
414
  actions.push({
414
415
  type: "morphoSupply",
415
416
  args: [
@@ -473,7 +474,7 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
473
474
  .getMarket(id)
474
475
  .accrueInterest(dataBefore.block.timestamp);
475
476
  const { assets: repaidAssets, shares: repaidShares } = market.repay(assets, shares);
476
- const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(repaidAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), repaidShares);
477
+ const maxSharePrice = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(repaidAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), repaidShares), exports.MAX_ABSOLUTE_SHARE_PRICE);
477
478
  actions.push({
478
479
  type: "morphoRepay",
479
480
  args: [
@@ -534,7 +535,7 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
534
535
  .getAccrualVault(operation.address)
535
536
  .accrueInterest(dataBefore.block.timestamp);
536
537
  if (shares === 0n) {
537
- const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(assets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), vault.toShares(assets, "Down"));
538
+ const maxSharePrice = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(assets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), vault.toShares(assets, "Down")), exports.MAX_ABSOLUTE_SHARE_PRICE);
538
539
  actions.push({
539
540
  type: "erc4626Deposit",
540
541
  args: [
@@ -547,7 +548,7 @@ const encodeOperation = (operation, dataBefore, supportsSignature = true, index
547
548
  });
548
549
  }
549
550
  else {
550
- const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(vault.toAssets(shares, "Up"), blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), shares);
551
+ const maxSharePrice = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(vault.toAssets(shares, "Up"), blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage), shares), exports.MAX_ABSOLUTE_SHARE_PRICE);
551
552
  actions.push({
552
553
  type: "erc4626Mint",
553
554
  args: [
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.3",
4
+ "version": "3.3.4",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -19,8 +19,8 @@
19
19
  ],
20
20
  "peerDependencies": {
21
21
  "viem": "^2.0.0",
22
- "@morpho-org/blue-sdk": "^4.12.0",
23
- "@morpho-org/blue-sdk-viem": "^3.1.2",
22
+ "@morpho-org/blue-sdk": "^4.13.0",
23
+ "@morpho-org/blue-sdk-viem": "^3.2.0",
24
24
  "@morpho-org/morpho-ts": "^2.4.2",
25
25
  "@morpho-org/simulation-sdk": "^3.1.3"
26
26
  },
@@ -34,13 +34,13 @@
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.1.2",
38
- "@morpho-org/blue-sdk": "^4.12.0",
37
+ "@morpho-org/blue-sdk": "^4.13.0",
38
+ "@morpho-org/blue-sdk-viem": "^3.2.0",
39
39
  "@morpho-org/morpho-test": "^2.4.0",
40
- "@morpho-org/morpho-ts": "^2.4.2",
41
40
  "@morpho-org/simulation-sdk": "^3.1.3",
42
- "@morpho-org/simulation-sdk-wagmi": "^3.0.3",
41
+ "@morpho-org/morpho-ts": "^2.4.2",
43
42
  "@morpho-org/test": "^2.6.0",
43
+ "@morpho-org/simulation-sdk-wagmi": "^3.0.3",
44
44
  "@morpho-org/test-wagmi": "^2.0.4"
45
45
  },
46
46
  "scripts": {