@morpho-org/evm-simulation 4.1.2 → 4.1.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/README.md CHANGED
@@ -2,19 +2,13 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- EVM transaction simulation engine for Morpho — bundle execution preview
6
- and transfer parsing.
5
+ EVM transaction simulation engine for Morpho — bundle execution preview,
6
+ transfer parsing, and net per-account balance changes.
7
7
 
8
8
  ## Installation
9
9
 
10
- Add to the consuming app's `package.json`:
11
-
12
- ```jsonc
13
- {
14
- "dependencies": {
15
- "@morpho-org/evm-simulation": "workspace:*"
16
- }
17
- }
10
+ ```bash
11
+ pnpm add @morpho-org/evm-simulation
18
12
  ```
19
13
 
20
14
  ## Usage
@@ -40,11 +34,14 @@ const config: SimulationConfig = {
40
34
  };
41
35
 
42
36
  try {
43
- const { transfers, simulationTxs } = await simulate(config, {
44
- chainId: 1,
45
- transactions: [{ from: user, to: vault, data: encodedDeposit }],
46
- authorizations: [{ type: "signature", token: usdc, spender: vault }],
47
- });
37
+ const { simulationTxs, calls, transfers, assetChanges } = await simulate(
38
+ config,
39
+ {
40
+ chainId: 1,
41
+ transactions: [{ from: user, to: vault, data: encodedDeposit }],
42
+ authorizations: [{ type: "signature", token: usdc, spender: vault }],
43
+ },
44
+ );
48
45
  } catch (err) {
49
46
  if (err instanceof SimulationRevertedError) {
50
47
  // show err.reason to the user
@@ -61,7 +58,8 @@ All symbols below are re-exported from the package root.
61
58
 
62
59
  - `simulate(config, params)` — run a bundle through the simulation pipeline.
63
60
  - Config types: `SimulationConfig`, `TenderlyRpcConfig`, `ChainSimulationConfig`, `SimulationLogger`.
64
- - Data types: `SimulationTransaction`, `SimulationAuthorization`, `Transfer`, `SimulateParams`, `SimulationResult`.
61
+ - Input types: `SimulateParams`, `SimulationTransaction`, `SimulationAuthorization`.
62
+ - Result types: `SimulationResult`, `SimulationCall`, `Transfer`, `AccountAssetChanges`, `AssetChange`, `RawLog`.
65
63
  - Errors: `SimulationPackageError` (abstract base — `instanceof` it to catch any package error), `SimulationRevertedError`, `BlacklistViolationError`, `ExternalServiceError`, `SimulationValidationError`, `UnsupportedChainError`.
66
64
 
67
65
  ### Deeper docs
@@ -10,9 +10,9 @@ export declare abstract class SimulationPackageError extends Error {
10
10
  /** Transaction would revert on-chain. Not bypassable. */
11
11
  export declare class SimulationRevertedError extends SimulationPackageError {
12
12
  readonly reason: string | undefined;
13
- readonly details?: unknown | undefined;
13
+ readonly details?: unknown;
14
14
  readonly code = "SIMULATION_REVERTED";
15
- constructor(reason: string | undefined, details?: unknown | undefined);
15
+ constructor(reason: string | undefined, details?: unknown);
16
16
  }
17
17
  interface RetainedAsset {
18
18
  address: string | undefined;
@@ -10,7 +10,8 @@ import type { SimulateParams, SimulationConfig, SimulationResult } from "../type
10
10
  * - `transfers` → user-facing preview / server-side verification.
11
11
  * - `simulationTxs` + `transfers` → server-side verification before broadcast.
12
12
  * - `calls[i]` → per-tx raw backend output (`logs`, `status`, `returnData`, `gasUsed`).
13
- * Aligned 1:1 with `simulationTxs[i]`.
13
+ * Aligned 1:1 with `simulationTxs[i]`. `gasUsed` is not a safe gas limit; consumers
14
+ * deriving one must add their own headroom.
14
15
  * - `assetChanges` → net per-asset balance changes grouped by account (sender and
15
16
  * counterparties) over the whole bundle, normalized to the same shape across backends.
16
17
  * - `transfers[k].txIdx` → index into `simulationTxs` of the tx that emitted the
@@ -15,7 +15,8 @@ const index_js_2 = require("./pipeline/index.js");
15
15
  * - `transfers` → user-facing preview / server-side verification.
16
16
  * - `simulationTxs` + `transfers` → server-side verification before broadcast.
17
17
  * - `calls[i]` → per-tx raw backend output (`logs`, `status`, `returnData`, `gasUsed`).
18
- * Aligned 1:1 with `simulationTxs[i]`.
18
+ * Aligned 1:1 with `simulationTxs[i]`. `gasUsed` is not a safe gas limit; consumers
19
+ * deriving one must add their own headroom.
19
20
  * - `assetChanges` → net per-asset balance changes grouped by account (sender and
20
21
  * counterparties) over the whole bundle, normalized to the same shape across backends.
21
22
  * - `transfers[k].txIdx` → index into `simulationTxs` of the tx that emitted the
@@ -201,6 +201,11 @@ export interface SimulationCall {
201
201
  readonly status: boolean;
202
202
  /** Return data from the top-level call. */
203
203
  readonly returnData: Hex;
204
- /** Gas used by this call (root frame). */
204
+ /**
205
+ * Gas consumed by this call's root frame, not a safe gas limit. This is
206
+ * post-refund consumption and does not account for EIP-150's 63/64 rule in
207
+ * nested calls, so consumers deriving a limit must add their own headroom,
208
+ * larger than headroom derived from `eth_estimateGas`.
209
+ */
205
210
  readonly gasUsed: bigint;
206
211
  }
@@ -10,9 +10,9 @@ export declare abstract class SimulationPackageError extends Error {
10
10
  /** Transaction would revert on-chain. Not bypassable. */
11
11
  export declare class SimulationRevertedError extends SimulationPackageError {
12
12
  readonly reason: string | undefined;
13
- readonly details?: unknown | undefined;
13
+ readonly details?: unknown;
14
14
  readonly code = "SIMULATION_REVERTED";
15
- constructor(reason: string | undefined, details?: unknown | undefined);
15
+ constructor(reason: string | undefined, details?: unknown);
16
16
  }
17
17
  interface RetainedAsset {
18
18
  address: string | undefined;
@@ -10,7 +10,8 @@ import type { SimulateParams, SimulationConfig, SimulationResult } from "../type
10
10
  * - `transfers` → user-facing preview / server-side verification.
11
11
  * - `simulationTxs` + `transfers` → server-side verification before broadcast.
12
12
  * - `calls[i]` → per-tx raw backend output (`logs`, `status`, `returnData`, `gasUsed`).
13
- * Aligned 1:1 with `simulationTxs[i]`.
13
+ * Aligned 1:1 with `simulationTxs[i]`. `gasUsed` is not a safe gas limit; consumers
14
+ * deriving one must add their own headroom.
14
15
  * - `assetChanges` → net per-asset balance changes grouped by account (sender and
15
16
  * counterparties) over the whole bundle, normalized to the same shape across backends.
16
17
  * - `transfers[k].txIdx` → index into `simulationTxs` of the tx that emitted the
@@ -12,7 +12,8 @@ import { assertNoBundlerRetention, buildSimulationTxs, executeSimulation, valida
12
12
  * - `transfers` → user-facing preview / server-side verification.
13
13
  * - `simulationTxs` + `transfers` → server-side verification before broadcast.
14
14
  * - `calls[i]` → per-tx raw backend output (`logs`, `status`, `returnData`, `gasUsed`).
15
- * Aligned 1:1 with `simulationTxs[i]`.
15
+ * Aligned 1:1 with `simulationTxs[i]`. `gasUsed` is not a safe gas limit; consumers
16
+ * deriving one must add their own headroom.
16
17
  * - `assetChanges` → net per-asset balance changes grouped by account (sender and
17
18
  * counterparties) over the whole bundle, normalized to the same shape across backends.
18
19
  * - `transfers[k].txIdx` → index into `simulationTxs` of the tx that emitted the
@@ -201,6 +201,11 @@ export interface SimulationCall {
201
201
  readonly status: boolean;
202
202
  /** Return data from the top-level call. */
203
203
  readonly returnData: Hex;
204
- /** Gas used by this call (root frame). */
204
+ /**
205
+ * Gas consumed by this call's root frame, not a safe gas limit. This is
206
+ * post-refund consumption and does not account for EIP-150's 63/64 rule in
207
+ * nested calls, so consumers deriving a limit must add their own headroom,
208
+ * larger than headroom derived from `eth_estimateGas`.
209
+ */
205
210
  readonly gasUsed: bigint;
206
211
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/evm-simulation",
3
3
  "description": "EVM simulation engine for Morpho transactions.",
4
- "version": "4.1.2",
4
+ "version": "4.1.4",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -25,17 +25,17 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "zod": "^4.4.3",
28
- "@morpho-org/blue-sdk": "^6.3.1",
29
- "@morpho-org/morpho-ts": "^2.8.0"
28
+ "@morpho-org/blue-sdk": "^6.6.0",
29
+ "@morpho-org/morpho-ts": "^2.10.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "viem": "^2.0.0"
33
33
  },
34
34
  "devDependencies": {
35
- "typescript": "^6.0.3",
36
- "viem": "^2.54.2",
37
- "vitest": "^4.1.9",
38
- "@morpho-org/test": "^2.8.2"
35
+ "typescript": "^7.0.2",
36
+ "viem": "^2.55.10",
37
+ "vitest": "^4.1.10",
38
+ "@morpho-org/test": "^2.8.4"
39
39
  },
40
40
  "scripts": {
41
41
  "prepublish": "$npm_execpath build",