@morpho-org/evm-simulation 4.2.0 → 5.0.0
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 +109 -17
- package/lib/cjs/authorizations.d.ts +95 -0
- package/lib/cjs/authorizations.js +2 -0
- package/lib/cjs/errors.d.ts +207 -13
- package/lib/cjs/errors.js +197 -13
- package/lib/cjs/index.d.ts +10 -2
- package/lib/cjs/index.js +19 -3
- package/lib/cjs/limits.d.ts +112 -0
- package/lib/cjs/limits.js +50 -0
- package/lib/cjs/params.d.ts +25 -0
- package/lib/cjs/params.js +5 -0
- package/lib/cjs/requirements/index.d.ts +1 -0
- package/lib/cjs/requirements/index.js +5 -0
- package/lib/cjs/requirements/requirements.d.ts +64 -0
- package/lib/cjs/requirements/requirements.js +149 -0
- package/lib/cjs/result.d.ts +49 -0
- package/lib/cjs/result.js +2 -0
- package/lib/cjs/simulate/asset-changes.d.ts +7 -5
- package/lib/cjs/simulate/asset-changes.js +6 -5
- package/lib/cjs/simulate/backends/client.d.ts +16 -0
- package/lib/cjs/simulate/backends/client.js +27 -0
- package/lib/cjs/simulate/backends/eth-simulate-v1.d.ts +66 -20
- package/lib/cjs/simulate/backends/eth-simulate-v1.js +172 -98
- package/lib/cjs/simulate/backends/index.d.ts +1 -2
- package/lib/cjs/simulate/backends/index.js +3 -4
- package/lib/cjs/simulate/backends/parse-response.d.ts +69 -0
- package/lib/cjs/simulate/backends/parse-response.js +168 -0
- package/lib/cjs/simulate/backends/resolve-assets.d.ts +26 -0
- package/lib/cjs/simulate/backends/resolve-assets.js +111 -0
- package/lib/cjs/simulate/backends/resolve-pinned-block.d.ts +33 -0
- package/lib/cjs/simulate/backends/resolve-pinned-block.js +46 -0
- package/lib/cjs/simulate/context.d.ts +14 -0
- package/lib/cjs/simulate/context.js +2 -0
- package/lib/cjs/simulate/measurement-plan.d.ts +29 -0
- package/lib/cjs/simulate/measurement-plan.js +115 -0
- package/lib/cjs/simulate/parsing/transfers.d.ts +4 -3
- package/lib/cjs/simulate/parsing/transfers.js +4 -6
- package/lib/cjs/simulate/pipeline/bundles-retention.d.ts +7 -10
- package/lib/cjs/simulate/pipeline/bundles-retention.js +11 -14
- package/lib/cjs/simulate/pipeline/resolve-chain.d.ts +5 -11
- package/lib/cjs/simulate/pipeline/resolve-chain.js +5 -10
- package/lib/cjs/simulate/plan/plan-execution.d.ts +58 -0
- package/lib/cjs/simulate/plan/plan-execution.js +75 -0
- package/lib/cjs/simulate/prepare.d.ts +30 -0
- package/lib/cjs/simulate/prepare.js +80 -0
- package/lib/cjs/simulate/request/index.d.ts +1 -0
- package/lib/cjs/simulate/request/index.js +5 -0
- package/lib/cjs/simulate/request/parse-request.d.ts +44 -0
- package/lib/cjs/simulate/request/parse-request.js +759 -0
- package/lib/cjs/simulate/result.d.ts +19 -0
- package/lib/cjs/simulate/result.js +29 -0
- package/lib/cjs/simulate/run-simulation.d.ts +18 -0
- package/lib/cjs/simulate/run-simulation.js +151 -0
- package/lib/cjs/simulate/simulate.d.ts +100 -50
- package/lib/cjs/simulate/simulate.js +99 -81
- package/lib/cjs/simulate/slippage.d.ts +18 -0
- package/lib/cjs/simulate/slippage.js +41 -0
- package/lib/cjs/simulate/state/contract.d.ts +19 -0
- package/lib/cjs/simulate/state/contract.js +2 -0
- package/lib/cjs/simulate/state/read-state.d.ts +60 -0
- package/lib/cjs/simulate/state/read-state.js +148 -0
- package/lib/cjs/simulate/verify-slippage.d.ts +24 -0
- package/lib/cjs/simulate/verify-slippage.js +85 -0
- package/lib/cjs/types.d.ts +35 -95
- package/lib/esm/authorizations.d.ts +95 -0
- package/lib/esm/authorizations.js +1 -0
- package/lib/esm/errors.d.ts +207 -13
- package/lib/esm/errors.js +189 -12
- package/lib/esm/index.d.ts +10 -2
- package/lib/esm/index.js +4 -1
- package/lib/esm/limits.d.ts +112 -0
- package/lib/esm/limits.js +47 -0
- package/lib/esm/params.d.ts +25 -0
- package/lib/esm/params.js +2 -0
- package/lib/esm/requirements/index.d.ts +1 -0
- package/lib/esm/requirements/index.js +1 -0
- package/lib/esm/requirements/requirements.d.ts +64 -0
- package/lib/esm/requirements/requirements.js +146 -0
- package/lib/esm/result.d.ts +49 -0
- package/lib/esm/result.js +1 -0
- package/lib/esm/simulate/asset-changes.d.ts +7 -5
- package/lib/esm/simulate/asset-changes.js +6 -5
- package/lib/esm/simulate/backends/client.d.ts +16 -0
- package/lib/esm/simulate/backends/client.js +24 -0
- package/lib/esm/simulate/backends/eth-simulate-v1.d.ts +66 -20
- package/lib/esm/simulate/backends/eth-simulate-v1.js +170 -99
- package/lib/esm/simulate/backends/index.d.ts +1 -2
- package/lib/esm/simulate/backends/index.js +1 -2
- package/lib/esm/simulate/backends/parse-response.d.ts +69 -0
- package/lib/esm/simulate/backends/parse-response.js +165 -0
- package/lib/esm/simulate/backends/resolve-assets.d.ts +26 -0
- package/lib/esm/simulate/backends/resolve-assets.js +108 -0
- package/lib/esm/simulate/backends/resolve-pinned-block.d.ts +33 -0
- package/lib/esm/simulate/backends/resolve-pinned-block.js +43 -0
- package/lib/esm/simulate/context.d.ts +14 -0
- package/lib/esm/simulate/context.js +1 -0
- package/lib/esm/simulate/measurement-plan.d.ts +29 -0
- package/lib/esm/simulate/measurement-plan.js +112 -0
- package/lib/esm/simulate/parsing/transfers.d.ts +4 -3
- package/lib/esm/simulate/parsing/transfers.js +4 -6
- package/lib/esm/simulate/pipeline/bundles-retention.d.ts +7 -10
- package/lib/esm/simulate/pipeline/bundles-retention.js +11 -14
- package/lib/esm/simulate/pipeline/resolve-chain.d.ts +5 -11
- package/lib/esm/simulate/pipeline/resolve-chain.js +5 -10
- package/lib/esm/simulate/plan/plan-execution.d.ts +58 -0
- package/lib/esm/simulate/plan/plan-execution.js +72 -0
- package/lib/esm/simulate/prepare.d.ts +30 -0
- package/lib/esm/simulate/prepare.js +77 -0
- package/lib/esm/simulate/request/index.d.ts +1 -0
- package/lib/esm/simulate/request/index.js +1 -0
- package/lib/esm/simulate/request/parse-request.d.ts +44 -0
- package/lib/esm/simulate/request/parse-request.js +756 -0
- package/lib/esm/simulate/result.d.ts +19 -0
- package/lib/esm/simulate/result.js +26 -0
- package/lib/esm/simulate/run-simulation.d.ts +18 -0
- package/lib/esm/simulate/run-simulation.js +148 -0
- package/lib/esm/simulate/simulate.d.ts +100 -50
- package/lib/esm/simulate/simulate.js +99 -81
- package/lib/esm/simulate/slippage.d.ts +18 -0
- package/lib/esm/simulate/slippage.js +38 -0
- package/lib/esm/simulate/state/contract.d.ts +19 -0
- package/lib/esm/simulate/state/contract.js +1 -0
- package/lib/esm/simulate/state/read-state.d.ts +60 -0
- package/lib/esm/simulate/state/read-state.js +144 -0
- package/lib/esm/simulate/verify-slippage.d.ts +24 -0
- package/lib/esm/simulate/verify-slippage.js +82 -0
- package/lib/esm/types.d.ts +35 -95
- package/package.json +7 -6
- package/lib/cjs/simulate/authorizations/index.d.ts +0 -2
- package/lib/cjs/simulate/authorizations/index.js +0 -7
- package/lib/cjs/simulate/authorizations/resolve.d.ts +0 -9
- package/lib/cjs/simulate/authorizations/resolve.js +0 -29
- package/lib/cjs/simulate/authorizations/validate.d.ts +0 -6
- package/lib/cjs/simulate/authorizations/validate.js +0 -23
- package/lib/cjs/simulate/backends/tenderly-rpc.d.ts +0 -23
- package/lib/cjs/simulate/backends/tenderly-rpc.js +0 -234
- package/lib/cjs/simulate/pipeline/build-simulation-txs.d.ts +0 -17
- package/lib/cjs/simulate/pipeline/build-simulation-txs.js +0 -50
- package/lib/cjs/simulate/pipeline/execute-simulation.d.ts +0 -22
- package/lib/cjs/simulate/pipeline/execute-simulation.js +0 -82
- package/lib/cjs/simulate/pipeline/index.d.ts +0 -4
- package/lib/cjs/simulate/pipeline/index.js +0 -11
- package/lib/cjs/simulate/pipeline/validate-input.d.ts +0 -10
- package/lib/cjs/simulate/pipeline/validate-input.js +0 -55
- package/lib/esm/simulate/authorizations/index.d.ts +0 -2
- package/lib/esm/simulate/authorizations/index.js +0 -2
- package/lib/esm/simulate/authorizations/resolve.d.ts +0 -9
- package/lib/esm/simulate/authorizations/resolve.js +0 -26
- package/lib/esm/simulate/authorizations/validate.d.ts +0 -6
- package/lib/esm/simulate/authorizations/validate.js +0 -20
- package/lib/esm/simulate/backends/tenderly-rpc.d.ts +0 -23
- package/lib/esm/simulate/backends/tenderly-rpc.js +0 -231
- package/lib/esm/simulate/pipeline/build-simulation-txs.d.ts +0 -17
- package/lib/esm/simulate/pipeline/build-simulation-txs.js +0 -47
- package/lib/esm/simulate/pipeline/execute-simulation.d.ts +0 -22
- package/lib/esm/simulate/pipeline/execute-simulation.js +0 -79
- package/lib/esm/simulate/pipeline/index.d.ts +0 -4
- package/lib/esm/simulate/pipeline/index.js +0 -4
- package/lib/esm/simulate/pipeline/validate-input.d.ts +0 -10
- package/lib/esm/simulate/pipeline/validate-input.js +0 -52
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
/** EIP-712 domain separator fields of a signature payload. */
|
|
3
|
+
export interface Eip712Domain {
|
|
4
|
+
readonly name?: string;
|
|
5
|
+
readonly version?: string;
|
|
6
|
+
readonly chainId: number | bigint;
|
|
7
|
+
readonly verifyingContract: Address;
|
|
8
|
+
readonly salt?: Hex;
|
|
9
|
+
}
|
|
10
|
+
/** One entry of an EIP-712 `types` field list. */
|
|
11
|
+
export interface Eip712Field {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly type: string;
|
|
14
|
+
}
|
|
15
|
+
/** ERC-2612 `Permit` typed data; `domain.verifyingContract` is the token. */
|
|
16
|
+
export interface Erc2612PermitTypedData {
|
|
17
|
+
readonly domain: Eip712Domain;
|
|
18
|
+
readonly primaryType: "Permit";
|
|
19
|
+
readonly types: {
|
|
20
|
+
readonly Permit: readonly Eip712Field[];
|
|
21
|
+
};
|
|
22
|
+
readonly message: {
|
|
23
|
+
readonly owner: Address;
|
|
24
|
+
readonly spender: Address;
|
|
25
|
+
readonly value: bigint;
|
|
26
|
+
readonly nonce: bigint;
|
|
27
|
+
readonly deadline: bigint;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Permit2 `PermitTransferFrom` typed data; the owner is not in the message. */
|
|
31
|
+
export interface Permit2TransferTypedData {
|
|
32
|
+
readonly domain: Eip712Domain;
|
|
33
|
+
readonly primaryType: "PermitTransferFrom";
|
|
34
|
+
readonly types: {
|
|
35
|
+
readonly PermitTransferFrom: readonly Eip712Field[];
|
|
36
|
+
readonly TokenPermissions: readonly Eip712Field[];
|
|
37
|
+
};
|
|
38
|
+
readonly message: {
|
|
39
|
+
readonly permitted: {
|
|
40
|
+
readonly token: Address;
|
|
41
|
+
readonly amount: bigint;
|
|
42
|
+
};
|
|
43
|
+
readonly spender: Address;
|
|
44
|
+
readonly nonce: bigint;
|
|
45
|
+
readonly deadline: bigint;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Morpho `Authorization` typed data consumed by `setAuthorizationWithSig`. */
|
|
49
|
+
export interface BlueAuthorizationTypedData {
|
|
50
|
+
readonly domain: Eip712Domain;
|
|
51
|
+
readonly primaryType: "Authorization";
|
|
52
|
+
readonly types: {
|
|
53
|
+
readonly Authorization: readonly Eip712Field[];
|
|
54
|
+
};
|
|
55
|
+
readonly message: {
|
|
56
|
+
readonly authorizer: Address;
|
|
57
|
+
readonly authorized: Address;
|
|
58
|
+
readonly isAuthorized: boolean;
|
|
59
|
+
readonly nonce: bigint;
|
|
60
|
+
readonly deadline: bigint;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Raw ERC-20 `approve` request. */
|
|
64
|
+
export interface Erc20ApprovalAuthorization {
|
|
65
|
+
readonly type: "erc20Approval";
|
|
66
|
+
readonly token: Address;
|
|
67
|
+
readonly owner: Address;
|
|
68
|
+
readonly spender: Address;
|
|
69
|
+
readonly amount: bigint;
|
|
70
|
+
}
|
|
71
|
+
/** ERC-2612 permit request. */
|
|
72
|
+
export interface Erc2612PermitAuthorization {
|
|
73
|
+
readonly type: "erc2612Permit";
|
|
74
|
+
readonly typedData: Erc2612PermitTypedData;
|
|
75
|
+
}
|
|
76
|
+
/** Permit2 signature transfer request. */
|
|
77
|
+
export interface Permit2TransferAuthorization {
|
|
78
|
+
readonly type: "permit2SignatureTransfer";
|
|
79
|
+
readonly owner: Address;
|
|
80
|
+
readonly typedData: Permit2TransferTypedData;
|
|
81
|
+
}
|
|
82
|
+
/** Direct Morpho `setAuthorization` request. */
|
|
83
|
+
export interface BlueAuthorization {
|
|
84
|
+
readonly type: "blueAuthorization";
|
|
85
|
+
readonly authorizer: Address;
|
|
86
|
+
readonly authorized: Address;
|
|
87
|
+
readonly isAuthorized: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** Morpho `setAuthorizationWithSig` request. */
|
|
90
|
+
export interface BlueAuthorizationSignature {
|
|
91
|
+
readonly type: "blueAuthorizationSignature";
|
|
92
|
+
readonly typedData: BlueAuthorizationTypedData;
|
|
93
|
+
}
|
|
94
|
+
/** A pending wallet request passed to `simulate()` — the five typed variants. */
|
|
95
|
+
export type SimulationAuthorization = Erc20ApprovalAuthorization | Erc2612PermitAuthorization | Permit2TransferAuthorization | BlueAuthorization | BlueAuthorizationSignature;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/errors.d.ts
CHANGED
|
@@ -1,44 +1,238 @@
|
|
|
1
|
+
import type { Address, Hash } from "viem";
|
|
2
|
+
import type { SimulationOperationSubject } from "./limits.js";
|
|
3
|
+
import type { SimulationMode } from "./params.js";
|
|
4
|
+
/** Stable error codes thrown by this package, part of the public API. */
|
|
5
|
+
export declare const SIMULATION_ERROR_CODES: readonly ["VALIDATION_ERROR", "UNSUPPORTED_CHAIN", "EXTERNAL_SERVICE_ERROR", "SIMULATION_REVERTED", "BLACKLIST_ERROR", "UNSUPPORTED_OPERATION", "INVALID_SIMULATION_RESPONSE", "MISSING_VERIFICATION_EVIDENCE", "AUTHORIZATION_REQUEST_MISMATCH", "CONSUMER_LIMIT_VIOLATION", "UNEXPECTED_SIMULATION_ERROR"];
|
|
6
|
+
/** Stable string discriminator for log aggregation and external mapping. */
|
|
7
|
+
export type SimulationErrorCode = (typeof SIMULATION_ERROR_CODES)[number];
|
|
8
|
+
/**
|
|
9
|
+
* Machine-readable cause of an execution failure (ADR-2026-09-18 §Errors).
|
|
10
|
+
* `UNKNOWN_REVERT` is used when the revert maps to no known Morpho condition;
|
|
11
|
+
* consumers branch on it and never parse `reason`.
|
|
12
|
+
*/
|
|
13
|
+
export type SimulationExecutionReason = "INSUFFICIENT_BALANCE" | "INSUFFICIENT_ALLOWANCE" | "INSUFFICIENT_LIQUIDITY" | "POSITION_UNHEALTHY" | "SLIPPAGE_EXCEEDED" | "SIGNATURE_EXPIRED" | "SIGNATURE_INVALID" | "NONCE_ALREADY_USED" | "CAP_EXCEEDED" | "ACCESS_RESTRICTED" | "UNKNOWN_REVERT";
|
|
14
|
+
declare const SIMULATION_STAGES: readonly ["validation", "preparation", "execution", "verification", "transport"];
|
|
15
|
+
/** Pipeline stage a failure belongs to; `transport` covers RPC and response failures. */
|
|
16
|
+
export type SimulationStage = (typeof SIMULATION_STAGES)[number];
|
|
17
|
+
interface SimulationContextBase {
|
|
18
|
+
/** Request mode the failure happened in. */
|
|
19
|
+
readonly mode: SimulationMode;
|
|
20
|
+
/** Chain the request targeted. */
|
|
21
|
+
readonly chainId: number;
|
|
22
|
+
/** Block the simulation was pinned to. */
|
|
23
|
+
readonly blockNumber: bigint;
|
|
24
|
+
}
|
|
25
|
+
interface SimulationCheckContext extends SimulationContextBase {
|
|
26
|
+
/** Token whose balance, allowance or transfer was checked. */
|
|
27
|
+
readonly token?: Address;
|
|
28
|
+
/** Account whose position, balance or authorization was checked (usually the sender). */
|
|
29
|
+
readonly account?: Address;
|
|
30
|
+
/** Spender or operator granted by the checked permission. */
|
|
31
|
+
readonly spender?: Address;
|
|
32
|
+
/**
|
|
33
|
+
* Name of the checked field (e.g. `"assetsReceived"`). Unbound verification
|
|
34
|
+
* contexts instead carry the failed state read's id
|
|
35
|
+
* (`balance:<token>:<account>` or `position:<marketId>:<account>`).
|
|
36
|
+
*/
|
|
37
|
+
readonly field?: string;
|
|
38
|
+
/** Bound or value `field` was checked against; 32-byte hashes only, never calldata or signatures. */
|
|
39
|
+
readonly expected?: bigint | boolean | Address | Hash;
|
|
40
|
+
/** Value observed in the simulation, same domain as `expected`. */
|
|
41
|
+
readonly observed?: bigint | boolean | Address | Hash;
|
|
42
|
+
/**
|
|
43
|
+
* Reserved; not populated for caller-transaction reverts, whose index is on
|
|
44
|
+
* `SimulationRevertedError.details[].transactionIndex`.
|
|
45
|
+
*/
|
|
46
|
+
readonly failedTransactionIndex?: number;
|
|
47
|
+
}
|
|
48
|
+
/** Context of a failure while validating the request. */
|
|
49
|
+
export type SimulationValidationContext = SimulationContextBase & {
|
|
50
|
+
readonly stage: "validation";
|
|
51
|
+
};
|
|
52
|
+
/** Context of a failure while reaching the `eth_simulateV1` backend. */
|
|
53
|
+
export type SimulationTransportContext = SimulationContextBase & {
|
|
54
|
+
readonly stage: "transport";
|
|
55
|
+
};
|
|
56
|
+
/** Context of a failure while preparing a preview authorization. */
|
|
57
|
+
export type SimulationPreparationContext = SimulationContextBase & {
|
|
58
|
+
readonly stage: "preparation";
|
|
59
|
+
/** Index into `authorizations`. */
|
|
60
|
+
readonly authorizationIndex: number;
|
|
61
|
+
/** Index into that authorization's preparation calls. */
|
|
62
|
+
readonly preparationCallIndex?: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Reserved execution-stage context; `SimulationRevertedError` carries none for
|
|
66
|
+
* caller-transaction or node reverts (see `details[].transactionIndex`).
|
|
67
|
+
*/
|
|
68
|
+
export type SimulationExecutionContext = SimulationCheckContext & SimulationOperationSubject & {
|
|
69
|
+
readonly stage: "execution";
|
|
70
|
+
};
|
|
71
|
+
/** Context of a verification check that did not hold. */
|
|
72
|
+
export type SimulationVerificationContext = SimulationCheckContext & SimulationOperationSubject & {
|
|
73
|
+
readonly stage: "verification";
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Where and why a simulation failed, keyed by `stage`
|
|
77
|
+
* (ADR-2026-10-01-evm-simulation-quoted-slippage-limits).
|
|
78
|
+
* Every stage carries `mode`, `chainId` and `blockNumber`. Preparation
|
|
79
|
+
* contexts carry `authorizationIndex` and `preparationCallIndex`. Verification
|
|
80
|
+
* contexts bound to a limit take `operation` and the subject fields
|
|
81
|
+
* (`marketId`, `sourceMarketId`/`targetMarketId`, `vault`,
|
|
82
|
+
* `sourceVault`/`targetVault`) from that `OperationLimit`, not
|
|
83
|
+
* from decoded calldata; unbound ones carry only a `field` string naming the
|
|
84
|
+
* failed state read (`balance:<token>:<account>` or
|
|
85
|
+
* `position:<marketId>:<account>`).
|
|
86
|
+
* `"execution"` stays in the union, but `SimulationRevertedError` carries no
|
|
87
|
+
* `context` for caller-transaction or node reverts — the failing
|
|
88
|
+
* `transactionIndex` is reported on the error's `details`. Never contains
|
|
89
|
+
* signatures, RPC URLs, credentials, raw calldata or raw causes (`cause`
|
|
90
|
+
* stays on the error).
|
|
91
|
+
*/
|
|
92
|
+
export type SimulationErrorContext = SimulationValidationContext | SimulationTransportContext | SimulationPreparationContext | SimulationExecutionContext | SimulationVerificationContext | (SimulationCheckContext & {
|
|
93
|
+
readonly stage: "verification";
|
|
94
|
+
readonly field: string;
|
|
95
|
+
readonly operation?: never;
|
|
96
|
+
});
|
|
1
97
|
/**
|
|
2
98
|
* Base class for every error this package throws. Transport-agnostic — no HTTP status codes.
|
|
3
99
|
* Consumers pattern-match with `instanceof` on the concrete subclass.
|
|
4
100
|
*/
|
|
5
101
|
export declare abstract class SimulationPackageError extends Error {
|
|
6
102
|
/** Stable string discriminator for log aggregation and external mapping. */
|
|
7
|
-
abstract readonly code:
|
|
8
|
-
|
|
103
|
+
abstract readonly code: SimulationErrorCode;
|
|
104
|
+
/** Frozen copy of the failure context, when one was supplied. */
|
|
105
|
+
readonly context?: SimulationErrorContext;
|
|
106
|
+
constructor(message: string, options?: ErrorOptions & {
|
|
107
|
+
context?: SimulationErrorContext;
|
|
108
|
+
});
|
|
9
109
|
}
|
|
10
110
|
/** Transaction would revert on-chain. Not bypassable. */
|
|
11
111
|
export declare class SimulationRevertedError extends SimulationPackageError {
|
|
112
|
+
/** Raw revert string as reported by the backend, when any. */
|
|
12
113
|
readonly reason: string | undefined;
|
|
13
114
|
readonly details?: unknown;
|
|
115
|
+
/** Machine-readable cause; `UNKNOWN_REVERT` when the revert maps to no known Morpho condition. */
|
|
116
|
+
readonly reasonCode: SimulationExecutionReason;
|
|
117
|
+
readonly name = "SimulationRevertedError";
|
|
14
118
|
readonly code = "SIMULATION_REVERTED";
|
|
15
|
-
|
|
119
|
+
readonly context?: SimulationPreparationContext | SimulationExecutionContext;
|
|
120
|
+
constructor(
|
|
121
|
+
/** Raw revert string as reported by the backend, when any. */
|
|
122
|
+
reason: string | undefined, details?: unknown,
|
|
123
|
+
/** Machine-readable cause; `UNKNOWN_REVERT` when the revert maps to no known Morpho condition. */
|
|
124
|
+
reasonCode?: SimulationExecutionReason,
|
|
125
|
+
/** Which transaction/authorization reverted and the operation it belonged to. */
|
|
126
|
+
context?: SimulationPreparationContext | SimulationExecutionContext);
|
|
16
127
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
128
|
+
/** Per-asset net retained amount keyed by restricted contract and token. */
|
|
129
|
+
export interface RetainedAsset {
|
|
130
|
+
/** Restricted bundles contract that ended up holding the token. */
|
|
131
|
+
readonly address: Address;
|
|
132
|
+
/** Token retained (native ETH uses viem's `ethAddress`). */
|
|
133
|
+
readonly token: Address;
|
|
134
|
+
/** Net balance increase in the token's base units; always positive. */
|
|
135
|
+
readonly netRetained: bigint;
|
|
21
136
|
}
|
|
22
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Thrown when net value above the dust threshold is retained by a restricted bundles contract
|
|
139
|
+
* (VaultExitBundlesV1, VaultBundlesV1, BlueBundlesV1 or MidnightBundlesV1) after simulation;
|
|
140
|
+
* pass-through flows and net outflows are allowed. Never bypassable.
|
|
141
|
+
*/
|
|
23
142
|
export declare class BlacklistViolationError extends SimulationPackageError {
|
|
24
|
-
|
|
143
|
+
/** Per-asset net retained amounts keyed by restricted contract and token. */
|
|
144
|
+
readonly assetChanges?: readonly RetainedAsset[] | undefined;
|
|
145
|
+
readonly name = "BlacklistViolationError";
|
|
25
146
|
readonly code = "BLACKLIST_ERROR";
|
|
26
|
-
constructor(message: string,
|
|
147
|
+
constructor(message: string,
|
|
148
|
+
/** Per-asset net retained amounts keyed by restricted contract and token. */
|
|
149
|
+
assetChanges?: readonly RetainedAsset[] | undefined, context?: SimulationErrorContext);
|
|
27
150
|
}
|
|
28
|
-
/**
|
|
151
|
+
/** RPC service is down or unreachable. Bypassable — user can proceed. */
|
|
29
152
|
export declare class ExternalServiceError extends SimulationPackageError {
|
|
153
|
+
readonly name = "ExternalServiceError";
|
|
30
154
|
readonly code = "EXTERNAL_SERVICE_ERROR";
|
|
31
155
|
}
|
|
32
156
|
/** Bad input to the simulation functions. Not bypassable. */
|
|
33
157
|
export declare class SimulationValidationError extends SimulationPackageError {
|
|
34
158
|
readonly fieldErrors?: string[] | undefined;
|
|
159
|
+
readonly name = "SimulationValidationError";
|
|
35
160
|
readonly code = "VALIDATION_ERROR";
|
|
36
|
-
constructor(message: string, fieldErrors?: string[] | undefined);
|
|
161
|
+
constructor(message: string, fieldErrors?: string[] | undefined, context?: SimulationErrorContext);
|
|
37
162
|
}
|
|
38
163
|
/** Chain ID not configured for any simulation method. Not bypassable. */
|
|
39
164
|
export declare class UnsupportedChainError extends SimulationPackageError {
|
|
40
165
|
readonly chainId: number;
|
|
166
|
+
readonly name = "UnsupportedChainError";
|
|
41
167
|
readonly code = "UNSUPPORTED_CHAIN";
|
|
42
|
-
constructor(chainId: number);
|
|
168
|
+
constructor(chainId: number, context?: SimulationErrorContext);
|
|
43
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* An SDK requirement passed to `toSimulationAuthorizations` cannot be
|
|
172
|
+
* converted into a simulation authorization.
|
|
173
|
+
*/
|
|
174
|
+
export declare class UnsupportedOperationError extends SimulationPackageError {
|
|
175
|
+
readonly name = "UnsupportedOperationError";
|
|
176
|
+
readonly code = "UNSUPPORTED_OPERATION";
|
|
177
|
+
}
|
|
178
|
+
/** The simulation backend returned a response that cannot be parsed. */
|
|
179
|
+
export declare class InvalidSimulationResponseError extends SimulationPackageError {
|
|
180
|
+
readonly name = "InvalidSimulationResponseError";
|
|
181
|
+
readonly code = "INVALID_SIMULATION_RESPONSE";
|
|
182
|
+
}
|
|
183
|
+
/** State needed to verify an operation could not be fetched or derived. */
|
|
184
|
+
export declare class MissingVerificationEvidenceError extends SimulationPackageError {
|
|
185
|
+
readonly name = "MissingVerificationEvidenceError";
|
|
186
|
+
readonly code = "MISSING_VERIFICATION_EVIDENCE";
|
|
187
|
+
}
|
|
188
|
+
/** A pending authorization does not match the request it was prepared for. */
|
|
189
|
+
export declare class AuthorizationRequestMismatchError extends SimulationPackageError {
|
|
190
|
+
readonly name = "AuthorizationRequestMismatchError";
|
|
191
|
+
readonly code = "AUTHORIZATION_REQUEST_MISMATCH";
|
|
192
|
+
}
|
|
193
|
+
/** A consumer-supplied limit was violated. */
|
|
194
|
+
export declare class ConsumerLimitViolationError extends SimulationPackageError {
|
|
195
|
+
readonly name = "ConsumerLimitViolationError";
|
|
196
|
+
readonly code = "CONSUMER_LIMIT_VIOLATION";
|
|
197
|
+
}
|
|
198
|
+
/** The simulation failed for a reason that fits no other code. */
|
|
199
|
+
export declare class UnexpectedSimulationError extends SimulationPackageError {
|
|
200
|
+
readonly name = "UnexpectedSimulationError";
|
|
201
|
+
readonly code = "UNEXPECTED_SIMULATION_ERROR";
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Structural guard for consumers where `instanceof` fails across bundles.
|
|
205
|
+
*
|
|
206
|
+
* @param value - Anything caught.
|
|
207
|
+
* @returns `true` for `SimulationPackageError` instances and for objects
|
|
208
|
+
* carrying a `message` string, a known `code`, the `name` of the class
|
|
209
|
+
* owning that `code`, and an absent or
|
|
210
|
+
* well-formed `context` (known `stage`, `mode`, numeric `chainId`,
|
|
211
|
+
* `bigint` `blockNumber`, `authorizationIndex` for `preparation`, and a
|
|
212
|
+
* known `operation` with its subject fields for `execution`/`verification`,
|
|
213
|
+
* or a verification `field` string with no `operation`).
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* import { isSimulationPackageError, simulate } from "@morpho-org/evm-simulation";
|
|
217
|
+
* import type { Address, Hex } from "viem";
|
|
218
|
+
*
|
|
219
|
+
* declare const user: Address;
|
|
220
|
+
* declare const vault: Address;
|
|
221
|
+
* declare const encodedDeposit: Hex;
|
|
222
|
+
* const config = {
|
|
223
|
+
* chains: new Map([[1, { simulateV1Url: "https://rpc.example" }]]),
|
|
224
|
+
* };
|
|
225
|
+
* try {
|
|
226
|
+
* await simulate(config, {
|
|
227
|
+
* chainId: 1,
|
|
228
|
+
* transactions: [{ from: user, to: vault, data: encodedDeposit }],
|
|
229
|
+
* });
|
|
230
|
+
* } catch (e) {
|
|
231
|
+
* if (!isSimulationPackageError(e)) throw e;
|
|
232
|
+
* if (e.code !== "SIMULATION_REVERTED") throw e;
|
|
233
|
+
* console.log(e.context?.stage, e.message);
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export declare function isSimulationPackageError(value: unknown): value is SimulationPackageError;
|
|
44
238
|
export {};
|
package/lib/esm/errors.js
CHANGED
|
@@ -1,52 +1,229 @@
|
|
|
1
|
+
import { BLUE_MARKET_OPERATION_TYPES, OPERATION_TYPES, VAULT_OPERATION_TYPES, } from "./limits.js";
|
|
2
|
+
import { SIMULATION_MODES } from "./params.js";
|
|
3
|
+
/** Stable error codes thrown by this package, part of the public API. */
|
|
4
|
+
export const SIMULATION_ERROR_CODES = [
|
|
5
|
+
"VALIDATION_ERROR",
|
|
6
|
+
"UNSUPPORTED_CHAIN",
|
|
7
|
+
"EXTERNAL_SERVICE_ERROR",
|
|
8
|
+
"SIMULATION_REVERTED",
|
|
9
|
+
"BLACKLIST_ERROR",
|
|
10
|
+
"UNSUPPORTED_OPERATION",
|
|
11
|
+
"INVALID_SIMULATION_RESPONSE",
|
|
12
|
+
"MISSING_VERIFICATION_EVIDENCE",
|
|
13
|
+
"AUTHORIZATION_REQUEST_MISMATCH",
|
|
14
|
+
"CONSUMER_LIMIT_VIOLATION",
|
|
15
|
+
"UNEXPECTED_SIMULATION_ERROR",
|
|
16
|
+
];
|
|
17
|
+
const SIMULATION_STAGES = [
|
|
18
|
+
"validation",
|
|
19
|
+
"preparation",
|
|
20
|
+
"execution",
|
|
21
|
+
"verification",
|
|
22
|
+
"transport",
|
|
23
|
+
];
|
|
1
24
|
/**
|
|
2
25
|
* Base class for every error this package throws. Transport-agnostic — no HTTP status codes.
|
|
3
26
|
* Consumers pattern-match with `instanceof` on the concrete subclass.
|
|
4
27
|
*/
|
|
5
28
|
export class SimulationPackageError extends Error {
|
|
29
|
+
/** Frozen copy of the failure context, when one was supplied. */
|
|
30
|
+
context;
|
|
6
31
|
constructor(message, options) {
|
|
7
|
-
|
|
8
|
-
|
|
32
|
+
const { context, ...errorOptions } = options ?? {};
|
|
33
|
+
super(message, errorOptions);
|
|
34
|
+
this.name = new.target.name;
|
|
35
|
+
if (context !== undefined) {
|
|
36
|
+
this.context = Object.freeze({ ...context });
|
|
37
|
+
}
|
|
9
38
|
}
|
|
10
39
|
}
|
|
11
40
|
/** Transaction would revert on-chain. Not bypassable. */
|
|
12
41
|
export class SimulationRevertedError extends SimulationPackageError {
|
|
13
42
|
reason;
|
|
14
43
|
details;
|
|
44
|
+
reasonCode;
|
|
45
|
+
name = "SimulationRevertedError";
|
|
15
46
|
code = "SIMULATION_REVERTED";
|
|
16
|
-
constructor
|
|
17
|
-
|
|
47
|
+
// biome-ignore lint/complexity/useMaxParams: public error constructor signature
|
|
48
|
+
constructor(
|
|
49
|
+
/** Raw revert string as reported by the backend, when any. */
|
|
50
|
+
reason, details,
|
|
51
|
+
/** Machine-readable cause; `UNKNOWN_REVERT` when the revert maps to no known Morpho condition. */
|
|
52
|
+
reasonCode = "UNKNOWN_REVERT",
|
|
53
|
+
/** Which transaction/authorization reverted and the operation it belonged to. */
|
|
54
|
+
context) {
|
|
55
|
+
super(reason ?? "Transaction simulation reverted", details instanceof Error ? { cause: details, context } : { context });
|
|
18
56
|
this.reason = reason;
|
|
19
57
|
this.details = details;
|
|
58
|
+
this.reasonCode = reasonCode;
|
|
20
59
|
}
|
|
21
60
|
}
|
|
22
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Thrown when net value above the dust threshold is retained by a restricted bundles contract
|
|
63
|
+
* (VaultExitBundlesV1, VaultBundlesV1, BlueBundlesV1 or MidnightBundlesV1) after simulation;
|
|
64
|
+
* pass-through flows and net outflows are allowed. Never bypassable.
|
|
65
|
+
*/
|
|
23
66
|
export class BlacklistViolationError extends SimulationPackageError {
|
|
24
67
|
assetChanges;
|
|
68
|
+
name = "BlacklistViolationError";
|
|
25
69
|
code = "BLACKLIST_ERROR";
|
|
26
|
-
constructor
|
|
27
|
-
|
|
70
|
+
// biome-ignore lint/complexity/useMaxParams: public error constructor signature
|
|
71
|
+
constructor(message,
|
|
72
|
+
/** Per-asset net retained amounts keyed by restricted contract and token. */
|
|
73
|
+
assetChanges, context) {
|
|
74
|
+
super(message, { context });
|
|
28
75
|
this.assetChanges = assetChanges;
|
|
29
76
|
}
|
|
30
77
|
}
|
|
31
|
-
/**
|
|
78
|
+
/** RPC service is down or unreachable. Bypassable — user can proceed. */
|
|
32
79
|
export class ExternalServiceError extends SimulationPackageError {
|
|
80
|
+
name = "ExternalServiceError";
|
|
33
81
|
code = "EXTERNAL_SERVICE_ERROR";
|
|
34
82
|
}
|
|
35
83
|
/** Bad input to the simulation functions. Not bypassable. */
|
|
36
84
|
export class SimulationValidationError extends SimulationPackageError {
|
|
37
85
|
fieldErrors;
|
|
86
|
+
name = "SimulationValidationError";
|
|
38
87
|
code = "VALIDATION_ERROR";
|
|
39
|
-
constructor
|
|
40
|
-
|
|
88
|
+
// biome-ignore lint/complexity/useMaxParams: public error constructor signature
|
|
89
|
+
constructor(message, fieldErrors, context) {
|
|
90
|
+
super(message, { context });
|
|
41
91
|
this.fieldErrors = fieldErrors;
|
|
42
92
|
}
|
|
43
93
|
}
|
|
44
94
|
/** Chain ID not configured for any simulation method. Not bypassable. */
|
|
45
95
|
export class UnsupportedChainError extends SimulationPackageError {
|
|
46
96
|
chainId;
|
|
97
|
+
name = "UnsupportedChainError";
|
|
47
98
|
code = "UNSUPPORTED_CHAIN";
|
|
48
|
-
constructor(chainId) {
|
|
49
|
-
super(`Chain ${chainId} is not configured for simulation
|
|
99
|
+
constructor(chainId, context) {
|
|
100
|
+
super(`Chain ${chainId} is not configured for simulation`, { context });
|
|
50
101
|
this.chainId = chainId;
|
|
51
102
|
}
|
|
52
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* An SDK requirement passed to `toSimulationAuthorizations` cannot be
|
|
106
|
+
* converted into a simulation authorization.
|
|
107
|
+
*/
|
|
108
|
+
export class UnsupportedOperationError extends SimulationPackageError {
|
|
109
|
+
name = "UnsupportedOperationError";
|
|
110
|
+
code = "UNSUPPORTED_OPERATION";
|
|
111
|
+
}
|
|
112
|
+
/** The simulation backend returned a response that cannot be parsed. */
|
|
113
|
+
export class InvalidSimulationResponseError extends SimulationPackageError {
|
|
114
|
+
name = "InvalidSimulationResponseError";
|
|
115
|
+
code = "INVALID_SIMULATION_RESPONSE";
|
|
116
|
+
}
|
|
117
|
+
/** State needed to verify an operation could not be fetched or derived. */
|
|
118
|
+
export class MissingVerificationEvidenceError extends SimulationPackageError {
|
|
119
|
+
name = "MissingVerificationEvidenceError";
|
|
120
|
+
code = "MISSING_VERIFICATION_EVIDENCE";
|
|
121
|
+
}
|
|
122
|
+
/** A pending authorization does not match the request it was prepared for. */
|
|
123
|
+
export class AuthorizationRequestMismatchError extends SimulationPackageError {
|
|
124
|
+
name = "AuthorizationRequestMismatchError";
|
|
125
|
+
code = "AUTHORIZATION_REQUEST_MISMATCH";
|
|
126
|
+
}
|
|
127
|
+
/** A consumer-supplied limit was violated. */
|
|
128
|
+
export class ConsumerLimitViolationError extends SimulationPackageError {
|
|
129
|
+
name = "ConsumerLimitViolationError";
|
|
130
|
+
code = "CONSUMER_LIMIT_VIOLATION";
|
|
131
|
+
}
|
|
132
|
+
/** The simulation failed for a reason that fits no other code. */
|
|
133
|
+
export class UnexpectedSimulationError extends SimulationPackageError {
|
|
134
|
+
name = "UnexpectedSimulationError";
|
|
135
|
+
code = "UNEXPECTED_SIMULATION_ERROR";
|
|
136
|
+
}
|
|
137
|
+
const ERROR_NAME_BY_CODE = Object.freeze({
|
|
138
|
+
VALIDATION_ERROR: "SimulationValidationError",
|
|
139
|
+
UNSUPPORTED_CHAIN: "UnsupportedChainError",
|
|
140
|
+
EXTERNAL_SERVICE_ERROR: "ExternalServiceError",
|
|
141
|
+
SIMULATION_REVERTED: "SimulationRevertedError",
|
|
142
|
+
BLACKLIST_ERROR: "BlacklistViolationError",
|
|
143
|
+
UNSUPPORTED_OPERATION: "UnsupportedOperationError",
|
|
144
|
+
INVALID_SIMULATION_RESPONSE: "InvalidSimulationResponseError",
|
|
145
|
+
MISSING_VERIFICATION_EVIDENCE: "MissingVerificationEvidenceError",
|
|
146
|
+
AUTHORIZATION_REQUEST_MISMATCH: "AuthorizationRequestMismatchError",
|
|
147
|
+
CONSUMER_LIMIT_VIOLATION: "ConsumerLimitViolationError",
|
|
148
|
+
UNEXPECTED_SIMULATION_ERROR: "UnexpectedSimulationError",
|
|
149
|
+
});
|
|
150
|
+
/**
|
|
151
|
+
* Structural guard for consumers where `instanceof` fails across bundles.
|
|
152
|
+
*
|
|
153
|
+
* @param value - Anything caught.
|
|
154
|
+
* @returns `true` for `SimulationPackageError` instances and for objects
|
|
155
|
+
* carrying a `message` string, a known `code`, the `name` of the class
|
|
156
|
+
* owning that `code`, and an absent or
|
|
157
|
+
* well-formed `context` (known `stage`, `mode`, numeric `chainId`,
|
|
158
|
+
* `bigint` `blockNumber`, `authorizationIndex` for `preparation`, and a
|
|
159
|
+
* known `operation` with its subject fields for `execution`/`verification`,
|
|
160
|
+
* or a verification `field` string with no `operation`).
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { isSimulationPackageError, simulate } from "@morpho-org/evm-simulation";
|
|
164
|
+
* import type { Address, Hex } from "viem";
|
|
165
|
+
*
|
|
166
|
+
* declare const user: Address;
|
|
167
|
+
* declare const vault: Address;
|
|
168
|
+
* declare const encodedDeposit: Hex;
|
|
169
|
+
* const config = {
|
|
170
|
+
* chains: new Map([[1, { simulateV1Url: "https://rpc.example" }]]),
|
|
171
|
+
* };
|
|
172
|
+
* try {
|
|
173
|
+
* await simulate(config, {
|
|
174
|
+
* chainId: 1,
|
|
175
|
+
* transactions: [{ from: user, to: vault, data: encodedDeposit }],
|
|
176
|
+
* });
|
|
177
|
+
* } catch (e) {
|
|
178
|
+
* if (!isSimulationPackageError(e)) throw e;
|
|
179
|
+
* if (e.code !== "SIMULATION_REVERTED") throw e;
|
|
180
|
+
* console.log(e.context?.stage, e.message);
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export function isSimulationPackageError(value) {
|
|
185
|
+
if (value instanceof SimulationPackageError)
|
|
186
|
+
return true;
|
|
187
|
+
if (typeof value !== "object" || value === null)
|
|
188
|
+
return false;
|
|
189
|
+
const { name, message, code, context } = value;
|
|
190
|
+
if (typeof message !== "string")
|
|
191
|
+
return false;
|
|
192
|
+
if (typeof code !== "string" ||
|
|
193
|
+
!SIMULATION_ERROR_CODES.includes(code) ||
|
|
194
|
+
name !== ERROR_NAME_BY_CODE[code])
|
|
195
|
+
return false;
|
|
196
|
+
if (context === undefined)
|
|
197
|
+
return true;
|
|
198
|
+
if (typeof context !== "object" || context === null || Array.isArray(context))
|
|
199
|
+
return false;
|
|
200
|
+
const { stage, mode, chainId, blockNumber, authorizationIndex } = context;
|
|
201
|
+
if (typeof stage !== "string" ||
|
|
202
|
+
!SIMULATION_STAGES.includes(stage) ||
|
|
203
|
+
typeof mode !== "string" ||
|
|
204
|
+
!SIMULATION_MODES.includes(mode) ||
|
|
205
|
+
typeof chainId !== "number" ||
|
|
206
|
+
typeof blockNumber !== "bigint")
|
|
207
|
+
return false;
|
|
208
|
+
const c = context;
|
|
209
|
+
if (stage === "preparation")
|
|
210
|
+
return typeof authorizationIndex === "number";
|
|
211
|
+
if (stage === "verification" && c.operation === undefined)
|
|
212
|
+
return typeof c.field === "string";
|
|
213
|
+
if (stage !== "execution" && stage !== "verification")
|
|
214
|
+
return true;
|
|
215
|
+
const operation = c.operation;
|
|
216
|
+
if (typeof operation !== "string" ||
|
|
217
|
+
!OPERATION_TYPES.includes(operation))
|
|
218
|
+
return false;
|
|
219
|
+
const isString = (key) => typeof c[key] === "string";
|
|
220
|
+
if (operation === "blueRefinance")
|
|
221
|
+
return isString("sourceMarketId") && isString("targetMarketId");
|
|
222
|
+
if (operation === "vaultV1MigrateToV2")
|
|
223
|
+
return isString("sourceVault") && isString("targetVault");
|
|
224
|
+
if (BLUE_MARKET_OPERATION_TYPES.includes(operation))
|
|
225
|
+
return isString("marketId");
|
|
226
|
+
if (VAULT_OPERATION_TYPES.includes(operation))
|
|
227
|
+
return isString("vault");
|
|
228
|
+
return false;
|
|
229
|
+
}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { BlueAuthorization, BlueAuthorizationSignature, BlueAuthorizationTypedData, Eip712Domain, Eip712Field, Erc20ApprovalAuthorization, Erc2612PermitAuthorization, Erc2612PermitTypedData, Permit2TransferAuthorization, Permit2TransferTypedData, SimulationAuthorization, } from "./authorizations.js";
|
|
2
|
+
export type { RetainedAsset, SimulationErrorCode, SimulationErrorContext, SimulationExecutionContext, SimulationExecutionReason, SimulationPreparationContext, SimulationStage, SimulationTransportContext, SimulationValidationContext, SimulationVerificationContext, } from "./errors.js";
|
|
3
|
+
export { AuthorizationRequestMismatchError, BlacklistViolationError, ConsumerLimitViolationError, ExternalServiceError, InvalidSimulationResponseError, isSimulationPackageError, MissingVerificationEvidenceError, SIMULATION_ERROR_CODES, SimulationPackageError, SimulationRevertedError, SimulationValidationError, UnexpectedSimulationError, UnsupportedChainError, UnsupportedOperationError, } from "./errors.js";
|
|
4
|
+
export type { BlueMarketOperationSubject, BlueMarketOperationType, BlueRefinanceSubject, OperationLimit, OperationType, SimulationLimits, SimulationOperationSubject, SlippageLimits, SlippageQuote, VaultOperationSubject, VaultOperationType, VaultV1MigrateToV2Subject, } from "./limits.js";
|
|
5
|
+
export { BLUE_MARKET_OPERATION_TYPES, OPERATION_TYPES, VAULT_OPERATION_TYPES, } from "./limits.js";
|
|
6
|
+
export type { SimulateParams, SimulationMode, } from "./params.js";
|
|
7
|
+
export { SIMULATION_MODES } from "./params.js";
|
|
8
|
+
export { toSimulationAuthorizations } from "./requirements/index.js";
|
|
9
|
+
export type { AuthorizationPreparation, SimulatedOperation, SimulationVerification, VerifiedSimulationResult, } from "./result.js";
|
|
2
10
|
export { simulate } from "./simulate/index.js";
|
|
3
|
-
export type { AccountAssetChanges, AssetChange, ChainSimulationConfig, RawLog,
|
|
11
|
+
export type { AccountAssetChanges, AssetChange, ChainSimulationConfig, RawLog, SimulationCall, SimulationConfig, SimulationLogger, SimulationResult, SimulationTransaction, Transfer, } from "./types.js";
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// Public fns (via feature-folder barrels)
|
|
2
2
|
// Errors (for instanceof checks by consumers)
|
|
3
|
-
export { BlacklistViolationError, ExternalServiceError, SimulationPackageError, SimulationRevertedError, SimulationValidationError, UnsupportedChainError, } from "./errors.js";
|
|
3
|
+
export { AuthorizationRequestMismatchError, BlacklistViolationError, ConsumerLimitViolationError, ExternalServiceError, InvalidSimulationResponseError, isSimulationPackageError, MissingVerificationEvidenceError, SIMULATION_ERROR_CODES, SimulationPackageError, SimulationRevertedError, SimulationValidationError, UnexpectedSimulationError, UnsupportedChainError, UnsupportedOperationError, } from "./errors.js";
|
|
4
|
+
export { BLUE_MARKET_OPERATION_TYPES, OPERATION_TYPES, VAULT_OPERATION_TYPES, } from "./limits.js";
|
|
5
|
+
export { SIMULATION_MODES } from "./params.js";
|
|
6
|
+
export { toSimulationAuthorizations } from "./requirements/index.js";
|
|
4
7
|
export { simulate } from "./simulate/index.js";
|