@gearbox-protocol/sdk 14.11.0-next.9 → 14.11.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/dist/cjs/common-utils/utils/index.js +0 -2
- package/dist/cjs/dev/index.js +1 -3
- package/dist/cjs/dev/isOutOfSyncError.js +3 -1
- package/dist/cjs/history/assembleOperations.js +6 -6
- package/dist/cjs/history/classifyMulticallOperations.js +25 -31
- package/dist/cjs/{preview/trace → history}/errors.js +26 -0
- package/dist/cjs/history/extractProtocolCalls.js +53 -0
- package/dist/cjs/{preview/trace → history}/extractTransfers.js +23 -11
- package/dist/cjs/{preview/trace → history}/findFacadeCalls.js +3 -3
- package/dist/cjs/history/index.js +2 -0
- package/dist/cjs/{preview/parse/types-facades.js → history/inner-operations.js} +2 -2
- package/dist/cjs/{preview/parse/types-adapters.js → history/internal-types.js} +2 -2
- package/dist/cjs/history/parseCreditAccountTransaction.js +6 -5
- package/dist/cjs/history/toLegacyOperation.js +2 -6
- package/dist/cjs/{common-utils/utils/trace.js → history/trace-utils.js} +5 -62
- package/dist/cjs/permissionless/bindings/pricefeeds/curve-twap.js +2 -2
- package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +37 -25
- package/dist/cjs/plugins/adapters/contracts/AccountMigratorAdapterContract.js +0 -9
- package/dist/esm/common-utils/utils/index.js +0 -1
- package/dist/esm/dev/index.js +0 -1
- package/dist/esm/dev/isOutOfSyncError.js +3 -1
- package/dist/esm/history/assembleOperations.js +6 -8
- package/dist/esm/history/classifyMulticallOperations.js +23 -29
- package/dist/esm/{preview/trace → history}/errors.js +24 -0
- package/dist/esm/history/extractProtocolCalls.js +32 -0
- package/dist/esm/{preview/trace → history}/extractTransfers.js +23 -11
- package/dist/esm/{preview/trace → history}/findFacadeCalls.js +2 -4
- package/dist/esm/history/index.js +1 -0
- package/dist/esm/history/parseCreditAccountTransaction.js +4 -3
- package/dist/esm/history/toLegacyOperation.js +2 -6
- package/dist/esm/history/trace-utils.js +36 -0
- package/dist/esm/permissionless/bindings/pricefeeds/curve-twap.js +2 -2
- package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +38 -28
- package/dist/esm/plugins/adapters/contracts/AccountMigratorAdapterContract.js +0 -9
- package/dist/types/common-utils/utils/index.d.ts +0 -1
- package/dist/types/dev/index.d.ts +0 -1
- package/dist/types/history/assembleOperations.d.ts +6 -11
- package/dist/types/history/classifyMulticallOperations.d.ts +9 -21
- package/dist/types/{preview/trace → history}/errors.d.ts +10 -0
- package/dist/types/history/extractProtocolCalls.d.ts +8 -0
- package/dist/types/{preview/trace → history}/extractTransfers.d.ts +7 -15
- package/dist/types/{preview/trace → history}/findFacadeCalls.d.ts +2 -3
- package/dist/types/history/index.d.ts +1 -0
- package/dist/types/history/inner-operations.d.ts +57 -0
- package/dist/types/history/internal-types.d.ts +47 -0
- package/dist/types/history/mapOperations.d.ts +9 -7
- package/dist/types/history/trace-utils.d.ts +12 -0
- package/dist/types/history/types.d.ts +71 -22
- package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +17 -16
- package/dist/types/plugins/adapters/contracts/AccountMigratorAdapterContract.d.ts +1 -10
- package/dist/types/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/Curve2AssetsAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/Curve3AssetsAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/Curve4AssetsAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/CurveV1AdapterDeposit.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/CurveV1AdapterStETHContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/CurveV1StableNGAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/DaiUsdsAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/ERC4626AdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/ERC4626ReferralAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/LidoV1AdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/MellowDVVAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/UniswapV2AdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/UniswapV4AdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/WstETHV1AdapterContract.d.ts +1 -1
- package/dist/types/plugins/adapters/transferHelpers.d.ts +1 -1
- package/dist/types/plugins/adapters/types.d.ts +46 -8
- package/package.json +1 -6
- package/dist/cjs/dev/verifyTestnet.js +0 -124
- package/dist/cjs/plugins/adapters/transfers.js +0 -16
- package/dist/cjs/preview/index.js +0 -28
- package/dist/cjs/preview/package.json +0 -1
- package/dist/cjs/preview/parse/classifyInnerOperations.js +0 -92
- package/dist/cjs/preview/parse/errors.js +0 -47
- package/dist/cjs/preview/parse/extractExpectedBalanceChanges.js +0 -48
- package/dist/cjs/preview/parse/index.js +0 -34
- package/dist/cjs/preview/parse/parseFacadeOperationCalldata.js +0 -115
- package/dist/cjs/preview/parse/parseOperationCalldata.js +0 -46
- package/dist/cjs/preview/parse/parsePoolOperationCalldata.js +0 -77
- package/dist/cjs/preview/parse/types-pools.js +0 -16
- package/dist/cjs/preview/parse/types.js +0 -37
- package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +0 -78
- package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +0 -77
- package/dist/cjs/preview/prerequisites/Prerequisite.js +0 -85
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +0 -187
- package/dist/cjs/preview/prerequisites/index.js +0 -34
- package/dist/cjs/preview/prerequisites/prepareAction.js +0 -48
- package/dist/cjs/preview/prerequisites/runPrerequisites.js +0 -71
- package/dist/cjs/preview/prerequisites/types.js +0 -16
- package/dist/cjs/preview/simulate/constants.js +0 -28
- package/dist/cjs/preview/simulate/errors.js +0 -98
- package/dist/cjs/preview/simulate/extractERC20Transfers.js +0 -47
- package/dist/cjs/preview/simulate/holders.js +0 -45
- package/dist/cjs/preview/simulate/index.js +0 -40
- package/dist/cjs/preview/simulate/simulateFacadeOperation.js +0 -30
- package/dist/cjs/preview/simulate/simulateOperation.js +0 -37
- package/dist/cjs/preview/simulate/simulatePoolOpMulticall.js +0 -155
- package/dist/cjs/preview/simulate/simulatePoolOpV1.js +0 -106
- package/dist/cjs/preview/simulate/simulatePoolOperation.js +0 -62
- package/dist/cjs/preview/simulate/types.js +0 -16
- package/dist/cjs/preview/trace/extractAdapterCallTraces.js +0 -58
- package/dist/cjs/preview/trace/index.js +0 -30
- package/dist/cjs/preview/trace/types.js +0 -16
- package/dist/esm/common-utils/utils/trace.js +0 -93
- package/dist/esm/dev/verifyTestnet.js +0 -98
- package/dist/esm/preview/index.js +0 -4
- package/dist/esm/preview/package.json +0 -1
- package/dist/esm/preview/parse/classifyInnerOperations.js +0 -68
- package/dist/esm/preview/parse/errors.js +0 -22
- package/dist/esm/preview/parse/extractExpectedBalanceChanges.js +0 -24
- package/dist/esm/preview/parse/index.js +0 -7
- package/dist/esm/preview/parse/parseFacadeOperationCalldata.js +0 -91
- package/dist/esm/preview/parse/parseOperationCalldata.js +0 -25
- package/dist/esm/preview/parse/parsePoolOperationCalldata.js +0 -53
- package/dist/esm/preview/parse/types-facades.js +0 -0
- package/dist/esm/preview/parse/types-pools.js +0 -0
- package/dist/esm/preview/parse/types.js +0 -9
- package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +0 -57
- package/dist/esm/preview/prerequisites/BalancePrerequisite.js +0 -56
- package/dist/esm/preview/prerequisites/Prerequisite.js +0 -63
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +0 -163
- package/dist/esm/preview/prerequisites/index.js +0 -7
- package/dist/esm/preview/prerequisites/prepareAction.js +0 -23
- package/dist/esm/preview/prerequisites/runPrerequisites.js +0 -47
- package/dist/esm/preview/prerequisites/types.js +0 -0
- package/dist/esm/preview/simulate/constants.js +0 -4
- package/dist/esm/preview/simulate/errors.js +0 -75
- package/dist/esm/preview/simulate/extractERC20Transfers.js +0 -23
- package/dist/esm/preview/simulate/holders.js +0 -21
- package/dist/esm/preview/simulate/index.js +0 -12
- package/dist/esm/preview/simulate/simulateFacadeOperation.js +0 -6
- package/dist/esm/preview/simulate/simulateOperation.js +0 -13
- package/dist/esm/preview/simulate/simulatePoolOpMulticall.js +0 -130
- package/dist/esm/preview/simulate/simulatePoolOpV1.js +0 -82
- package/dist/esm/preview/simulate/simulatePoolOperation.js +0 -41
- package/dist/esm/preview/simulate/types.js +0 -0
- package/dist/esm/preview/trace/extractAdapterCallTraces.js +0 -40
- package/dist/esm/preview/trace/index.js +0 -5
- package/dist/esm/preview/trace/types.js +0 -0
- package/dist/types/common-utils/utils/trace.d.ts +0 -73
- package/dist/types/dev/verifyTestnet.d.ts +0 -82
- package/dist/types/plugins/adapters/transfers.d.ts +0 -17
- package/dist/types/preview/index.d.ts +0 -4
- package/dist/types/preview/parse/classifyInnerOperations.d.ts +0 -21
- package/dist/types/preview/parse/errors.d.ts +0 -17
- package/dist/types/preview/parse/extractExpectedBalanceChanges.d.ts +0 -22
- package/dist/types/preview/parse/index.d.ts +0 -7
- package/dist/types/preview/parse/parseFacadeOperationCalldata.d.ts +0 -19
- package/dist/types/preview/parse/parseOperationCalldata.d.ts +0 -23
- package/dist/types/preview/parse/parsePoolOperationCalldata.d.ts +0 -17
- package/dist/types/preview/parse/types-adapters.d.ts +0 -69
- package/dist/types/preview/parse/types-facades.d.ts +0 -157
- package/dist/types/preview/parse/types-pools.d.ts +0 -55
- package/dist/types/preview/parse/types.d.ts +0 -44
- package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +0 -24
- package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +0 -23
- package/dist/types/preview/prerequisites/Prerequisite.d.ts +0 -60
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +0 -16
- package/dist/types/preview/prerequisites/index.d.ts +0 -7
- package/dist/types/preview/prerequisites/prepareAction.d.ts +0 -52
- package/dist/types/preview/prerequisites/runPrerequisites.d.ts +0 -12
- package/dist/types/preview/prerequisites/types.d.ts +0 -78
- package/dist/types/preview/simulate/constants.d.ts +0 -6
- package/dist/types/preview/simulate/errors.d.ts +0 -51
- package/dist/types/preview/simulate/extractERC20Transfers.d.ts +0 -11
- package/dist/types/preview/simulate/holders.d.ts +0 -7
- package/dist/types/preview/simulate/index.d.ts +0 -9
- package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +0 -25
- package/dist/types/preview/simulate/simulateOperation.d.ts +0 -20
- package/dist/types/preview/simulate/simulatePoolOpMulticall.d.ts +0 -28
- package/dist/types/preview/simulate/simulatePoolOpV1.d.ts +0 -14
- package/dist/types/preview/simulate/simulatePoolOperation.d.ts +0 -8
- package/dist/types/preview/simulate/types.d.ts +0 -79
- package/dist/types/preview/trace/extractAdapterCallTraces.d.ts +0 -23
- package/dist/types/preview/trace/index.d.ts +0 -5
- package/dist/types/preview/trace/types.d.ts +0 -21
- /package/dist/esm/{plugins/adapters/transfers.js → history/inner-operations.js} +0 -0
- /package/dist/esm/{preview/parse/types-adapters.js → history/internal-types.js} +0 -0
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Address, type Log } from "viem";
|
|
2
|
-
import type { TokenTransfer } from "../parse/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Parses ERC-20 `Transfer` logs and keeps only those involving one of the
|
|
5
|
-
* watched addresses (as sender or receiver). A log that touches several watched
|
|
6
|
-
* addresses is still emitted once.
|
|
7
|
-
*
|
|
8
|
-
* @param logs - raw logs from the simulated call
|
|
9
|
-
* @param watch - addresses whose transfers we care about (e.g. wallet + recipient)
|
|
10
|
-
*/
|
|
11
|
-
export declare function extractERC20Transfers(logs: Log[], watch: Address[]): TokenTransfer[];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { PoolOperation } from "../parse/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Distinct addresses whose balances change during the operation: the funds
|
|
5
|
-
* source (payer or share owner) and the receiver.
|
|
6
|
-
*/
|
|
7
|
-
export declare function watchedHolders(operation: PoolOperation, wallet: Address): Address[];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { ETH_SIMULATE_V1_NETWORKS } from "./constants.js";
|
|
2
|
-
export type { SimulationError, SimulationFlowFailure, SimulationFlowSource, } from "./errors.js";
|
|
3
|
-
export { PreviewSimulationError } from "./errors.js";
|
|
4
|
-
export type { SimulateFacadeOperationInput } from "./simulateFacadeOperation.js";
|
|
5
|
-
export { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
6
|
-
export type { SimulateOperationInput } from "./simulateOperation.js";
|
|
7
|
-
export { simulateOperation } from "./simulateOperation.js";
|
|
8
|
-
export { simulatePoolOperation } from "./simulatePoolOperation.js";
|
|
9
|
-
export type { AddressBalanceChanges, OperationSimulationOptions, PoolOperationSimulation, PoolOperationSimulationInput, PoolOperationSimulationResult, TokenBalanceChange, } from "./types.js";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
2
|
-
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
-
import type { OuterFacadeOperation } from "../parse/index.js";
|
|
4
|
-
import type { OperationSimulationOptions, PoolOperationSimulation } from "./types.js";
|
|
5
|
-
export interface SimulateFacadeOperationInput {
|
|
6
|
-
/** Only `client`/`networkType` are used, so any OnchainSDK works. */
|
|
7
|
-
sdk: OnchainSDK;
|
|
8
|
-
/** Parsed credit-facade operation to simulate. */
|
|
9
|
-
operation: OuterFacadeOperation;
|
|
10
|
-
/** Target contract the calldata is sent to (the credit facade). */
|
|
11
|
-
to: Address;
|
|
12
|
-
/** Raw credit-facade calldata to simulate. */
|
|
13
|
-
calldata: Hex;
|
|
14
|
-
/** Wallet whose balance changes and transfers we track. */
|
|
15
|
-
wallet: Address;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Simulates a credit-facade operation.
|
|
19
|
-
*
|
|
20
|
-
* Not yet implemented: credit-facade simulation requires multicall-aware
|
|
21
|
-
* balance/transfer accounting that the pool simulation does not cover. The
|
|
22
|
-
* signature mirrors {@link simulatePoolOperation} so the
|
|
23
|
-
* {@link simulateOperation} wrapper can delegate uniformly once implemented.
|
|
24
|
-
*/
|
|
25
|
-
export declare function simulateFacadeOperation(_input: SimulateFacadeOperationInput, _options?: OperationSimulationOptions): Promise<PoolOperationSimulation>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
2
|
-
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
-
import { type Operation } from "../parse/index.js";
|
|
4
|
-
import type { OperationSimulationOptions, PoolOperationSimulation } from "./types.js";
|
|
5
|
-
export interface SimulateOperationInput {
|
|
6
|
-
/** Gearbox SDK instance. */
|
|
7
|
-
sdk: OnchainSDK;
|
|
8
|
-
/** Parsed pool or credit account operation */
|
|
9
|
-
operation: Operation;
|
|
10
|
-
/** Target contract the calldata is sent to. */
|
|
11
|
-
to: Address;
|
|
12
|
-
/** Raw operation calldata to simulate. */
|
|
13
|
-
calldata: Hex;
|
|
14
|
-
/** Wallet whose balance changes and transfers we track. */
|
|
15
|
-
wallet: Address;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Simulates a parsed pool or credit account operation {@link Operation}
|
|
19
|
-
*/
|
|
20
|
-
export declare function simulateOperation(input: SimulateOperationInput, options?: OperationSimulationOptions): Promise<PoolOperationSimulation>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { PoolOperation } from "../parse/index.js";
|
|
3
|
-
import type { AddressBalanceChanges, OperationSimulationOptions, PoolOperationSimulationInput, PoolOperationSimulationResult } from "./types.js";
|
|
4
|
-
/** Reads a watched holder's "before" balance of a token. */
|
|
5
|
-
export type BalanceLookup = (token: Address, holder: Address) => bigint;
|
|
6
|
-
/**
|
|
7
|
-
* Multicall pool-operation flow, used where `eth_simulateV1` is unavailable or
|
|
8
|
-
* as a fallback alongside it.
|
|
9
|
-
*
|
|
10
|
-
* Reads the watched holders' "before" balances together with the matching
|
|
11
|
-
* ERC4626 preview (`previewDeposit`/`previewMint`/`previewWithdraw`/
|
|
12
|
-
* `previewRedeem`) in a single multicall, then computes the theoretical balance
|
|
13
|
-
* changes via {@link computePoolOpBalanceChanges}.
|
|
14
|
-
*
|
|
15
|
-
* Unlike the `eth_simulateV1` flow it does not execute the calldata, so it
|
|
16
|
-
* cannot recover ERC-20 transfers (`transfers` is always `undefined`) and it
|
|
17
|
-
* ignores balance/allowance prerequisites (preview reads succeed regardless).
|
|
18
|
-
*
|
|
19
|
-
* @throws {@link PreviewSimulationError} when the multicall round-trip throws or
|
|
20
|
-
* any call (a balance read or the preview read) reverts.
|
|
21
|
-
*/
|
|
22
|
-
export declare function simulatePoolOpMulticall(input: PoolOperationSimulationInput, options?: OperationSimulationOptions): Promise<PoolOperationSimulationResult>;
|
|
23
|
-
/**
|
|
24
|
-
* Pure computation of {@link AddressBalanceChanges} for a pool operation from
|
|
25
|
-
* its ERC4626 preview result and the watched holders' "before" balances. Legs
|
|
26
|
-
* sharing the same address are grouped together.
|
|
27
|
-
*/
|
|
28
|
-
export declare function computePoolOpBalanceChanges(operation: PoolOperation, wallet: Address, previewAmount: bigint, before: BalanceLookup): AddressBalanceChanges[];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { OperationSimulationOptions, PoolOperationSimulationInput, PoolOperationSimulationResult } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* `eth_simulateV1` pool-operation flow.
|
|
4
|
-
*
|
|
5
|
-
* Sandwiches the raw calldata between `balanceOf` reads of the underlying and
|
|
6
|
-
* pool (share) tokens for every watched holder, then derives the balance changes
|
|
7
|
-
* from the before/after diff and the wallet-relevant ERC-20 transfers from the
|
|
8
|
-
* emitted logs. Simulation runs against real chain state (no overrides), so an
|
|
9
|
-
* unmet prerequisite surfaces here as a revert.
|
|
10
|
-
*
|
|
11
|
-
* @throws {@link PreviewSimulationError} when the round-trip throws or the
|
|
12
|
-
* simulated transaction reverts.
|
|
13
|
-
*/
|
|
14
|
-
export declare function simulatePoolOpV1(input: PoolOperationSimulationInput, options?: OperationSimulationOptions): Promise<PoolOperationSimulationResult>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { OperationSimulationOptions, PoolOperationSimulation, PoolOperationSimulationInput } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Simulates a pool deposit/mint/withdraw/redeem and returns the resulting
|
|
4
|
-
* balance changes (and, when available, ERC-20 transfers), or a decoded failure.
|
|
5
|
-
*
|
|
6
|
-
* @throws {@link PreviewSimulationError} when the simulation fails.
|
|
7
|
-
*/
|
|
8
|
-
export declare function simulatePoolOperation(input: PoolOperationSimulationInput, options?: OperationSimulationOptions): Promise<PoolOperationSimulation>;
|
|
@@ -1,79 +0,0 @@
|
|
|
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";
|
|
6
|
-
/**
|
|
7
|
-
* Change in an address's balance of a single token over the simulated call.
|
|
8
|
-
* `delta` is `after - before` (negative when the address spent the token).
|
|
9
|
-
*/
|
|
10
|
-
export interface TokenBalanceChange {
|
|
11
|
-
token: Address;
|
|
12
|
-
before: bigint;
|
|
13
|
-
after: bigint;
|
|
14
|
-
delta: bigint;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Balance changes for a single watched address (e.g. the wallet or the
|
|
18
|
-
* operation recipient). Keyed purely by address; UI labeling is resolved
|
|
19
|
-
* separately by the presentation layer.
|
|
20
|
-
*/
|
|
21
|
-
export interface AddressBalanceChanges {
|
|
22
|
-
address: Address;
|
|
23
|
-
changes: TokenBalanceChange[];
|
|
24
|
-
}
|
|
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;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
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.
|
|
56
|
-
*/
|
|
57
|
-
export interface PoolOperationSimulationResult {
|
|
58
|
-
/**
|
|
59
|
-
* Balance changes grouped by watched address (wallet, recipient, owner).
|
|
60
|
-
**/
|
|
61
|
-
balanceChanges: AddressBalanceChanges[];
|
|
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) | {
|
|
77
|
-
status: "failure";
|
|
78
|
-
error: PreviewSimulationError;
|
|
79
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type CallTrace } from "../../common-utils/utils/trace.js";
|
|
2
|
-
/**
|
|
3
|
-
* Extracts the user multicall's adapter-level call traces from a single facade
|
|
4
|
-
* call trace.
|
|
5
|
-
*
|
|
6
|
-
* Returns the direct children of the facade trace that perform an external
|
|
7
|
-
* protocol call (their subtree resolves to a `CreditManager.execute(bytes)`
|
|
8
|
-
* that reaches a leaf CALL to a target contract), in trace order.
|
|
9
|
-
*
|
|
10
|
-
* Scoping to direct children of the facade trace (rather than flattening the
|
|
11
|
-
* whole subtree) avoids over-counting in nested credit-manager scenarios such
|
|
12
|
-
* as account migration, where a single migrate-adapter subtree nests another
|
|
13
|
-
* account's `execute(bytes)` calls.
|
|
14
|
-
*
|
|
15
|
-
* Facade-synthesized phantom-token withdrawals are excluded: while processing
|
|
16
|
-
* `withdrawCollateral` on a phantom token the facade issues its own
|
|
17
|
-
* `withdrawPhantomToken` adapter call, which also reaches an external target
|
|
18
|
-
* but does not correspond to a user multicall inner call. These are detected
|
|
19
|
-
* via the preceding `getPhantomTokenInfo()` probe (see
|
|
20
|
-
* {@link isSynthesizedPhantomWithdrawal}), so the returned traces line up 1:1,
|
|
21
|
-
* in order, with the multicall's adapter inner calls.
|
|
22
|
-
*/
|
|
23
|
-
export declare function extractAdapterCallTraces(facadeTrace: CallTrace): CallTrace[];
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { CallTrace } from "../../common-utils/utils/trace.js";
|
|
3
|
-
import type { ParsedCallV2 } from "../../sdk/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* The set of credit facade entry-point functions that produce history operations.
|
|
6
|
-
*/
|
|
7
|
-
export type FacadeCallType = "MultiCall" | "BotMulticall" | "OpenCreditAccount" | "CloseCreditAccount" | "LiquidateCreditAccount" | "PartiallyLiquidateCreditAccount";
|
|
8
|
-
/**
|
|
9
|
-
* A parsed credit facade call extracted from a call trace,
|
|
10
|
-
* with inner multicall calls already decoded.
|
|
11
|
-
*/
|
|
12
|
-
export interface FacadeParsedCall {
|
|
13
|
-
operation: FacadeCallType;
|
|
14
|
-
creditAccount: Address;
|
|
15
|
-
/** The full ParsedCallV2 from facade calldata parsing. */
|
|
16
|
-
parsed: ParsedCallV2;
|
|
17
|
-
/** Inner multicall entries from rawArgs.calls (empty for partiallyLiquidateCreditAccount). */
|
|
18
|
-
innerCalls: ParsedCallV2[];
|
|
19
|
-
/** The full call trace node for this facade call (used to extract protocol-level calldata). */
|
|
20
|
-
trace: CallTrace;
|
|
21
|
-
}
|
|
File without changes
|
|
File without changes
|