@gearbox-protocol/sdk 14.11.0-next.5 → 14.11.0-next.7
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/dist/cjs/preview/parse/extractExpectedBalanceChanges.js +48 -0
- package/dist/cjs/preview/parse/index.js +2 -0
- package/dist/cjs/preview/parse/parseFacadeOperationCalldata.js +12 -5
- package/dist/cjs/preview/parse/parsePoolOperationCalldata.js +21 -6
- package/dist/cjs/preview/parse/types.js +1 -1
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +46 -0
- package/dist/cjs/preview/simulate/constants.js +28 -0
- package/dist/cjs/preview/simulate/{decodeSimulationError.js → errors.js} +37 -3
- package/dist/cjs/preview/simulate/holders.js +45 -0
- package/dist/cjs/preview/simulate/index.js +21 -13
- package/dist/cjs/preview/simulate/simulateFacadeOperation.js +1 -1
- package/dist/cjs/preview/simulate/simulateOperation.js +3 -3
- package/dist/cjs/preview/simulate/simulatePoolOpMulticall.js +155 -0
- package/dist/cjs/preview/simulate/simulatePoolOpV1.js +106 -0
- package/dist/cjs/preview/simulate/simulatePoolOperation.js +27 -62
- package/dist/esm/preview/parse/extractExpectedBalanceChanges.js +24 -0
- package/dist/esm/preview/parse/index.js +1 -0
- package/dist/esm/preview/parse/parseFacadeOperationCalldata.js +12 -5
- package/dist/esm/preview/parse/parsePoolOperationCalldata.js +21 -6
- package/dist/esm/preview/parse/types.js +1 -1
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +46 -0
- package/dist/esm/preview/simulate/constants.js +4 -0
- package/dist/esm/preview/simulate/{decodeSimulationError.js → errors.js} +31 -0
- package/dist/esm/preview/simulate/holders.js +21 -0
- package/dist/esm/preview/simulate/index.js +12 -6
- package/dist/esm/preview/simulate/simulateFacadeOperation.js +1 -1
- package/dist/esm/preview/simulate/simulateOperation.js +3 -3
- package/dist/esm/preview/simulate/simulatePoolOpMulticall.js +130 -0
- package/dist/esm/preview/simulate/simulatePoolOpV1.js +82 -0
- package/dist/esm/preview/simulate/simulatePoolOperation.js +30 -62
- package/dist/types/history/types.d.ts +4 -4
- package/dist/types/preview/parse/extractExpectedBalanceChanges.d.ts +22 -0
- package/dist/types/preview/parse/index.d.ts +1 -0
- package/dist/types/preview/parse/parsePoolOperationCalldata.d.ts +4 -2
- package/dist/types/preview/parse/types-facades.d.ts +33 -0
- package/dist/types/preview/parse/types-pools.d.ts +29 -16
- package/dist/types/preview/parse/types.d.ts +3 -3
- package/dist/types/preview/simulate/constants.d.ts +6 -0
- package/dist/types/preview/simulate/errors.d.ts +51 -0
- package/dist/types/preview/simulate/holders.d.ts +7 -0
- package/dist/types/preview/simulate/index.d.ts +9 -6
- package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +3 -5
- package/dist/types/preview/simulate/simulateOperation.d.ts +5 -11
- package/dist/types/preview/simulate/simulatePoolOpMulticall.d.ts +28 -0
- package/dist/types/preview/simulate/simulatePoolOpV1.d.ts +14 -0
- package/dist/types/preview/simulate/simulatePoolOperation.d.ts +5 -27
- package/dist/types/preview/simulate/types.d.ts +54 -18
- package/package.json +1 -1
- package/dist/types/preview/simulate/decodeSimulationError.d.ts +0 -18
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import type { ILogger } from "../../sdk/types/logger.js";
|
|
4
|
+
import type { PoolOperation, TokenTransfer } from "../parse/index.js";
|
|
5
|
+
import type { PreviewSimulationError } from "./errors.js";
|
|
3
6
|
/**
|
|
4
7
|
* Change in an address's balance of a single token over the simulated call.
|
|
5
8
|
* `delta` is `after - before` (negative when the address spent the token).
|
|
@@ -19,25 +22,58 @@ export interface AddressBalanceChanges {
|
|
|
19
22
|
address: Address;
|
|
20
23
|
changes: TokenBalanceChange[];
|
|
21
24
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
export interface PoolOperationSimulationInput {
|
|
26
|
+
/** Only `client`/`networkType` are used, so any OnchainSDK works. */
|
|
27
|
+
sdk: OnchainSDK;
|
|
28
|
+
/** Parsed operation, used to resolve the underlying and pool tokens. */
|
|
29
|
+
operation: PoolOperation;
|
|
30
|
+
/** Target contract the calldata is sent to (the pool). */
|
|
31
|
+
to: Address;
|
|
32
|
+
/** Raw deposit/mint/withdraw/redeem calldata to simulate. */
|
|
33
|
+
calldata: Hex;
|
|
34
|
+
/** Wallet whose balance changes and transfers we track. */
|
|
35
|
+
wallet: Address;
|
|
36
|
+
}
|
|
37
|
+
export interface OperationSimulationOptions {
|
|
38
|
+
/** Block to simulate at; defaults to latest. */
|
|
39
|
+
blockNumber?: bigint;
|
|
40
|
+
/**
|
|
41
|
+
* Whether to run the `eth_simulateV1` flow (preferred, recovers transfers).
|
|
42
|
+
* When `undefined`, defaults to whether the SDK's network is in
|
|
43
|
+
* {@link ETH_SIMULATE_V1_NETWORKS}.
|
|
44
|
+
*/
|
|
45
|
+
useSimulateV1?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Optional logger.
|
|
48
|
+
**/
|
|
49
|
+
logger?: ILogger;
|
|
28
50
|
}
|
|
29
51
|
/**
|
|
30
|
-
*
|
|
31
|
-
* wallet-filtered ERC-20 transfers
|
|
32
|
-
*
|
|
33
|
-
*
|
|
52
|
+
* Successful simulation of a pool operation: the balance changes grouped by
|
|
53
|
+
* watched address and, when available, the wallet-filtered ERC-20 transfers.
|
|
54
|
+
* This is the success payload of {@link PoolOperationSimulation} without the
|
|
55
|
+
* `status` discriminant.
|
|
34
56
|
*/
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
export interface PoolOperationSimulationResult {
|
|
58
|
+
/**
|
|
59
|
+
* Balance changes grouped by watched address (wallet, recipient, owner).
|
|
60
|
+
**/
|
|
38
61
|
balanceChanges: AddressBalanceChanges[];
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
/**
|
|
63
|
+
* ERC-20 transfers involving the watched addresses.
|
|
64
|
+
*
|
|
65
|
+
* NOTE: transfers are **not guaranteed** to be returned.
|
|
66
|
+
*/
|
|
67
|
+
transfers?: TokenTransfer[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Outcome of simulating a pool operation. On success it carries a
|
|
71
|
+
* {@link PoolOperationSimulationResult}; on failure it carries a
|
|
72
|
+
* {@link PreviewSimulationError}.
|
|
73
|
+
*/
|
|
74
|
+
export type PoolOperationSimulation = ({
|
|
75
|
+
status: "success";
|
|
76
|
+
} & PoolOperationSimulationResult) | {
|
|
41
77
|
status: "failure";
|
|
42
|
-
error:
|
|
78
|
+
error: PreviewSimulationError;
|
|
43
79
|
};
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Hex } from "viem";
|
|
2
|
-
import type { SimulationError } from "./types.js";
|
|
3
|
-
/** Per-call slice of a `simulateCalls` failure we need to decode. */
|
|
4
|
-
export interface SimulationRevert {
|
|
5
|
-
error?: Error;
|
|
6
|
-
/** Raw revert return data, when present. */
|
|
7
|
-
data?: Hex;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Decodes a simulated transaction revert into a {@link SimulationError}.
|
|
11
|
-
*
|
|
12
|
-
* The simulated call is raw calldata (no ABI), so viem cannot decode the revert
|
|
13
|
-
* itself. We first try to decode the raw return bytes against the SDK's
|
|
14
|
-
* {@link errorAbis} (Gearbox protocol exceptions plus standard ERC-20 custom
|
|
15
|
-
* errors); failing that, we walk viem's error chain for a
|
|
16
|
-
* {@link ContractFunctionRevertedError} (covers `Error(string)` / `Panic`).
|
|
17
|
-
*/
|
|
18
|
-
export declare function decodeSimulationError(revert: SimulationRevert): SimulationError;
|