@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,69 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { AdapterProtocolOperation } from "../../plugins/adapters/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* A single ERC-20 Transfer event captured between Execute boundaries.
|
|
5
|
-
*
|
|
6
|
-
* Canonical, public definition owned by the `preview` module; `plugins/adapters`
|
|
7
|
-
* keeps a structurally identical internal copy for its legacy helpers.
|
|
8
|
-
*/
|
|
9
|
-
export interface TokenTransfer {
|
|
10
|
-
token: Address;
|
|
11
|
-
amount: bigint;
|
|
12
|
-
from: Address;
|
|
13
|
-
to: Address;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Pure adapter-call descriptor: everything that can be recovered without an
|
|
17
|
-
* execution trace (from raw calldata alone).
|
|
18
|
-
*/
|
|
19
|
-
export interface AdapterOperationBase {
|
|
20
|
-
operation: "Execute";
|
|
21
|
-
/**
|
|
22
|
-
* Address of Gearbox Adapter contract
|
|
23
|
-
*/
|
|
24
|
-
adapter: Address;
|
|
25
|
-
/**
|
|
26
|
-
* Namespaced adapter type
|
|
27
|
-
* E.g. "ADAPTER::FLUID_DEX"
|
|
28
|
-
*/
|
|
29
|
-
adapterType: string;
|
|
30
|
-
/**
|
|
31
|
-
* Adapter contract version
|
|
32
|
-
*/
|
|
33
|
-
version: number;
|
|
34
|
-
/**
|
|
35
|
-
* Label of protocol contract (NOT adapter contract)
|
|
36
|
-
*/
|
|
37
|
-
label?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Function name of adapter contract
|
|
40
|
-
*/
|
|
41
|
-
adapterFunctionName: string;
|
|
42
|
-
/**
|
|
43
|
-
* Arguments of adapter contract
|
|
44
|
-
*/
|
|
45
|
-
adapterArgs: Record<string, unknown>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Adapter `Execute` operation, generic over the extra data added by consumers.
|
|
49
|
-
*
|
|
50
|
-
* - calldata-only parse uses `Ext = {}` (pure descriptor);
|
|
51
|
-
* - trace-based flows (history, facade simulation) use {@link TraceAdapterExt};
|
|
52
|
-
* - history additionally intersects `{ legacy: LegacyAdapterOperation }`.
|
|
53
|
-
*/
|
|
54
|
-
export type AdapterOperation<Ext extends object = {}> = AdapterOperationBase & Ext;
|
|
55
|
-
/**
|
|
56
|
-
* Trace-derived adapter data: the protocol-level call and the ERC-20 transfers
|
|
57
|
-
* made during the adapter call. Both are only available from an execution
|
|
58
|
-
* trace, so they always travel together.
|
|
59
|
-
*
|
|
60
|
-
* `protocol` is optional: it is absent when no external protocol call was
|
|
61
|
-
* recovered for the adapter `Execute`. This happens for the account-migrator
|
|
62
|
-
* adapter (its `execute` targets the migrator bot, not an external protocol),
|
|
63
|
-
* for unknown adapters in non-strict mode (no ABI to decode against), and when
|
|
64
|
-
* the protocol calldata cannot be decoded.
|
|
65
|
-
*/
|
|
66
|
-
export interface TraceAdapterExt {
|
|
67
|
-
protocol?: AdapterProtocolOperation;
|
|
68
|
-
transfers: TokenTransfer[];
|
|
69
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
2
|
-
import type { AdapterOperation } from "./types-adapters.js";
|
|
3
|
-
/**
|
|
4
|
-
* Increase debt (borrow more).
|
|
5
|
-
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L149-L154
|
|
6
|
-
*/
|
|
7
|
-
export interface IncreaseDebtOp {
|
|
8
|
-
operation: "IncreaseBorrowedAmount";
|
|
9
|
-
token: Address;
|
|
10
|
-
amount: bigint;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Decrease debt (repay).
|
|
14
|
-
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L155-L161
|
|
15
|
-
*/
|
|
16
|
-
export interface DecreaseDebtOp {
|
|
17
|
-
operation: "DecreaseBorrowedAmount";
|
|
18
|
-
token: Address;
|
|
19
|
-
amount: bigint;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Add collateral to credit account.
|
|
23
|
-
*/
|
|
24
|
-
export interface AddCollateralOp {
|
|
25
|
-
operation: "AddCollateral";
|
|
26
|
-
token: Address;
|
|
27
|
-
amount: bigint;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Withdraw collateral from credit account.
|
|
31
|
-
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L162-L171
|
|
32
|
-
*/
|
|
33
|
-
export interface WithdrawCollateralOp {
|
|
34
|
-
operation: "WithdrawCollateral";
|
|
35
|
-
token: Address;
|
|
36
|
-
amount: bigint;
|
|
37
|
-
to: Address;
|
|
38
|
-
phantomToken?: Address;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Update token quota on credit account.
|
|
42
|
-
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L172-L178
|
|
43
|
-
*/
|
|
44
|
-
export interface UpdateQuotaOp {
|
|
45
|
-
operation: "UpdateQuota";
|
|
46
|
-
token: Address;
|
|
47
|
-
change: bigint;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Union of facade inner-call operation types (non-adapter credit account operations).
|
|
51
|
-
* Discriminated on the `operation` field.
|
|
52
|
-
*/
|
|
53
|
-
export type InnerFacadeOperation = IncreaseDebtOp | DecreaseDebtOp | AddCollateralOp | WithdrawCollateralOp | UpdateQuotaOp;
|
|
54
|
-
/**
|
|
55
|
-
* All operations that can happen within a CreditFacade's multicall and that we're interested in.
|
|
56
|
-
*
|
|
57
|
-
* Generic over the adapter-operation extension `Ext` (see {@link AdapterOperation}).
|
|
58
|
-
*/
|
|
59
|
-
export type InnerOperation<Ext extends object = {}> = AdapterOperation<Ext> | InnerFacadeOperation;
|
|
60
|
-
/**
|
|
61
|
-
* Transaction-level metadata available only when parsing a mined transaction
|
|
62
|
-
* (the `history` mode). It is intentionally absent from base `preview`
|
|
63
|
-
* operations, which describe not-yet-mined calls where these values are unknown.
|
|
64
|
-
*/
|
|
65
|
-
export interface OperationMetadata {
|
|
66
|
-
txHash: Hex;
|
|
67
|
-
blockNumber: number;
|
|
68
|
-
timestamp: number;
|
|
69
|
-
}
|
|
70
|
-
export interface FacadeOperationMetadata {
|
|
71
|
-
creditManager: Address;
|
|
72
|
-
creditFacade: Address;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Signed token balance delta recovered from a router-generated
|
|
76
|
-
* `storeExpectedBalances` call (the `BalanceDelta` struct). `amount` is the
|
|
77
|
-
* signed `int256` delta, so it may be negative.
|
|
78
|
-
*/
|
|
79
|
-
export interface ExpectedBalanceChange {
|
|
80
|
-
token: Address;
|
|
81
|
-
delta: bigint;
|
|
82
|
-
}
|
|
83
|
-
export interface MulticallOperation<Ext extends object = {}> extends FacadeOperationMetadata {
|
|
84
|
-
operation: "MultiCall" | "BotMulticall";
|
|
85
|
-
creditAccount: Address;
|
|
86
|
-
multicall: InnerOperation<Ext>[];
|
|
87
|
-
/**
|
|
88
|
-
* Potential balance changes declared by a router-generated
|
|
89
|
-
* `storeExpectedBalances`/`compareBalances` pair, or `undefined` when the
|
|
90
|
-
* multicall is not router-shaped. See {@link ExpectedBalanceChange}.
|
|
91
|
-
*/
|
|
92
|
-
expectedBalanceChanges?: ExpectedBalanceChange[];
|
|
93
|
-
}
|
|
94
|
-
export interface OpenCreditAccountOperation<Ext extends object = {}> extends FacadeOperationMetadata {
|
|
95
|
-
operation: "OpenCreditAccount";
|
|
96
|
-
creditAccount: Address;
|
|
97
|
-
onBehalfOf: Address;
|
|
98
|
-
referralCode: bigint;
|
|
99
|
-
multicall: InnerOperation<Ext>[];
|
|
100
|
-
/**
|
|
101
|
-
* Potential balance changes declared by a router-generated
|
|
102
|
-
* `storeExpectedBalances`/`compareBalances` pair, or `undefined` when the
|
|
103
|
-
* multicall is not router-shaped. See {@link ExpectedBalanceChange}.
|
|
104
|
-
*/
|
|
105
|
-
expectedBalanceChanges?: ExpectedBalanceChange[];
|
|
106
|
-
}
|
|
107
|
-
export interface CloseCreditAccountOperation<Ext extends object = {}> extends FacadeOperationMetadata {
|
|
108
|
-
operation: "CloseCreditAccount";
|
|
109
|
-
creditAccount: Address;
|
|
110
|
-
multicall: InnerOperation<Ext>[];
|
|
111
|
-
/**
|
|
112
|
-
* Potential balance changes declared by a router-generated
|
|
113
|
-
* `storeExpectedBalances`/`compareBalances` pair, or `undefined` when the
|
|
114
|
-
* multicall is not router-shaped. See {@link ExpectedBalanceChange}.
|
|
115
|
-
*/
|
|
116
|
-
expectedBalanceChanges?: ExpectedBalanceChange[];
|
|
117
|
-
}
|
|
118
|
-
export interface LiquidateCreditAccountOperation<Ext extends object = {}> extends FacadeOperationMetadata {
|
|
119
|
-
operation: "LiquidateCreditAccount";
|
|
120
|
-
creditAccount: Address;
|
|
121
|
-
to: Address;
|
|
122
|
-
token: Address;
|
|
123
|
-
remainingFunds: bigint;
|
|
124
|
-
multicall: InnerOperation<Ext>[];
|
|
125
|
-
/**
|
|
126
|
-
* Potential balance changes declared by a router-generated
|
|
127
|
-
* `storeExpectedBalances`/`compareBalances` pair, or `undefined` when the
|
|
128
|
-
* multicall is not router-shaped. See {@link ExpectedBalanceChange}.
|
|
129
|
-
*/
|
|
130
|
-
expectedBalanceChanges?: ExpectedBalanceChange[];
|
|
131
|
-
}
|
|
132
|
-
export interface PartialLiquidationOperation extends FacadeOperationMetadata {
|
|
133
|
-
operation: "PartiallyLiquidateCreditAccount";
|
|
134
|
-
creditAccount: Address;
|
|
135
|
-
token: Address;
|
|
136
|
-
repaidAmount: bigint;
|
|
137
|
-
minSeizedAmount: bigint;
|
|
138
|
-
to: Address;
|
|
139
|
-
}
|
|
140
|
-
export interface DirectTokenTransferOperation {
|
|
141
|
-
operation: "DirectTokenTransfer";
|
|
142
|
-
protocol: Address;
|
|
143
|
-
token: Address;
|
|
144
|
-
from: Address;
|
|
145
|
-
creditAccount: Address;
|
|
146
|
-
amount: bigint;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Discriminated union of all facade-level operation types.
|
|
150
|
-
* One per facade entry-point call within a transaction.
|
|
151
|
-
*/
|
|
152
|
-
export type OuterFacadeOperation<Ext extends object = {}> = MulticallOperation<Ext> | OpenCreditAccountOperation<Ext> | CloseCreditAccountOperation<Ext> | LiquidateCreditAccountOperation<Ext> | PartialLiquidationOperation;
|
|
153
|
-
/**
|
|
154
|
-
* Discriminated union of all credit account operation types
|
|
155
|
-
* (facade operations + direct token transfers).
|
|
156
|
-
*/
|
|
157
|
-
export type CreditAccountOperation<Ext extends object = {}> = OuterFacadeOperation<Ext> | DirectTokenTransferOperation;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
/**
|
|
3
|
-
* ERC4626 `deposit` into a Gearbox pool.
|
|
4
|
-
*/
|
|
5
|
-
export interface PoolDepositOperation {
|
|
6
|
-
operation: "Deposit";
|
|
7
|
-
pool: Address;
|
|
8
|
-
receiver: Address;
|
|
9
|
-
/** Underlying assets supplied to the pool. */
|
|
10
|
-
assets: bigint;
|
|
11
|
-
underlying: Address;
|
|
12
|
-
/** Referral code, present only for `depositWithReferral` calls. */
|
|
13
|
-
referralCode?: bigint;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* ERC4626 `mint` into a Gearbox pool. Unlike `deposit`, the caller specifies the
|
|
17
|
-
* amount of shares to mint; the assets pulled are resolved by the pool.
|
|
18
|
-
*/
|
|
19
|
-
export interface PoolMintOperation {
|
|
20
|
-
operation: "Mint";
|
|
21
|
-
pool: Address;
|
|
22
|
-
receiver: Address;
|
|
23
|
-
/** Pool shares (diesel) minted to the receiver. */
|
|
24
|
-
shares: bigint;
|
|
25
|
-
underlying: Address;
|
|
26
|
-
/** Referral code, present only for `mintWithReferral` calls. */
|
|
27
|
-
referralCode?: bigint;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* ERC4626 `withdraw` from a Gearbox pool. Unlike `redeem`, the caller specifies
|
|
31
|
-
* the amount of underlying assets to withdraw; the shares burned are resolved by
|
|
32
|
-
* the pool.
|
|
33
|
-
*/
|
|
34
|
-
export interface PoolWithdrawOperation {
|
|
35
|
-
operation: "Withdraw";
|
|
36
|
-
pool: Address;
|
|
37
|
-
receiver: Address;
|
|
38
|
-
owner: Address;
|
|
39
|
-
/** Underlying assets withdrawn to the receiver. */
|
|
40
|
-
assets: bigint;
|
|
41
|
-
underlying: Address;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* ERC4626 `redeem` from a Gearbox pool.
|
|
45
|
-
*/
|
|
46
|
-
export interface PoolRedeemOperation {
|
|
47
|
-
operation: "Redeem";
|
|
48
|
-
pool: Address;
|
|
49
|
-
receiver: Address;
|
|
50
|
-
owner: Address;
|
|
51
|
-
/** Pool shares (diesel) burned. */
|
|
52
|
-
shares: bigint;
|
|
53
|
-
underlying: Address;
|
|
54
|
-
}
|
|
55
|
-
export type PoolOperation = PoolDepositOperation | PoolMintOperation | PoolWithdrawOperation | PoolRedeemOperation;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { AdaptersPlugin } from "../../plugins/adapters/index.js";
|
|
2
|
-
import type { OnchainSDK, PluginsMap } from "../../sdk/index.js";
|
|
3
|
-
import type { OuterFacadeOperation } from "./types-facades.js";
|
|
4
|
-
import type { PoolOperation } from "./types-pools.js";
|
|
5
|
-
export * from "./types-adapters.js";
|
|
6
|
-
export * from "./types-facades.js";
|
|
7
|
-
export * from "./types-pools.js";
|
|
8
|
-
/**
|
|
9
|
-
* True when the plugin map `P` contains the {@link AdaptersPlugin} under any
|
|
10
|
-
* key. Matched nominally (the plugin's private fields make it non-structural),
|
|
11
|
-
* so unrelated plugins never satisfy it.
|
|
12
|
-
*/
|
|
13
|
-
export type HasAdaptersPlugin<P extends PluginsMap> = Extract<P[keyof P], AdaptersPlugin> extends never ? false : true;
|
|
14
|
-
/**
|
|
15
|
-
* Compile-time guard for the adapters plugin. Resolves to a no-op (`unknown`)
|
|
16
|
-
* when `P` includes the {@link AdaptersPlugin}, otherwise to an error-shaped
|
|
17
|
-
* type that makes the surrounding call fail to type-check.
|
|
18
|
-
*
|
|
19
|
-
* Intended to be intersected with a function argument so callers must pass an
|
|
20
|
-
* SDK whose adapter contracts are registered (required for multicall
|
|
21
|
-
* classification).
|
|
22
|
-
*/
|
|
23
|
-
export type RequireAdaptersPlugin<P extends PluginsMap> = HasAdaptersPlugin<P> extends true ? unknown : {
|
|
24
|
-
"OnchainSDK must be created with the AdaptersPlugin": never;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* {@link OnchainSDK} whose plugin map is guaranteed at compile time to include
|
|
28
|
-
* the {@link AdaptersPlugin}.
|
|
29
|
-
*/
|
|
30
|
-
export type SdkWithAdapters<P extends PluginsMap = PluginsMap> = OnchainSDK<P> & RequireAdaptersPlugin<P>;
|
|
31
|
-
/**
|
|
32
|
-
* Result of decoding a single raw operation calldata: either a pool
|
|
33
|
-
* deposit/redeem or one of the credit-facade operations.
|
|
34
|
-
*
|
|
35
|
-
* Calldata-only parse produces base (descriptor) adapter operations, so the
|
|
36
|
-
* facade operations are used with the default `Ext = {}`.
|
|
37
|
-
*/
|
|
38
|
-
export type Operation = PoolOperation | OuterFacadeOperation;
|
|
39
|
-
/**
|
|
40
|
-
* Narrows an {@link Operation} to a {@link PoolOperation} (deposit, mint,
|
|
41
|
-
* withdraw or redeem). Used by the UI to decide whether a custom view exists for
|
|
42
|
-
* the parsed result; everything else falls back to the raw JSON view.
|
|
43
|
-
*/
|
|
44
|
-
export declare function isPoolOperation(tx: Operation): tx is PoolOperation;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type Address, type ContractFunctionParameters } from "viem";
|
|
2
|
-
import { type MulticallCallResult, Prerequisite } from "./Prerequisite.js";
|
|
3
|
-
import type { PrerequisiteDetail, PrerequisiteResult } from "./types.js";
|
|
4
|
-
export interface AllowancePrerequisiteProps {
|
|
5
|
-
token: Address;
|
|
6
|
-
owner: Address;
|
|
7
|
-
spender: Address;
|
|
8
|
-
required: bigint;
|
|
9
|
-
title?: string;
|
|
10
|
-
id?: string;
|
|
11
|
-
}
|
|
12
|
-
/** Checks that `owner` granted `spender` an ERC-20 allowance >= `required`. */
|
|
13
|
-
export declare class AllowancePrerequisite extends Prerequisite<"allowance"> {
|
|
14
|
-
private readonly _id;
|
|
15
|
-
private readonly _title;
|
|
16
|
-
private readonly _detail;
|
|
17
|
-
constructor(props: AllowancePrerequisiteProps);
|
|
18
|
-
get id(): string;
|
|
19
|
-
get kind(): "allowance";
|
|
20
|
-
get title(): string;
|
|
21
|
-
get detail(): PrerequisiteDetail<"allowance">;
|
|
22
|
-
calls(): ContractFunctionParameters[];
|
|
23
|
-
resolve(slice: MulticallCallResult[]): PrerequisiteResult<"allowance">;
|
|
24
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Address, type ContractFunctionParameters } from "viem";
|
|
2
|
-
import { type MulticallCallResult, Prerequisite } from "./Prerequisite.js";
|
|
3
|
-
import type { PrerequisiteDetail, PrerequisiteResult } from "./types.js";
|
|
4
|
-
export interface BalancePrerequisiteProps {
|
|
5
|
-
token: Address;
|
|
6
|
-
owner: Address;
|
|
7
|
-
required: bigint;
|
|
8
|
-
title?: string;
|
|
9
|
-
id?: string;
|
|
10
|
-
}
|
|
11
|
-
/** Checks that `owner` holds an ERC-20 balance >= `required`. */
|
|
12
|
-
export declare class BalancePrerequisite extends Prerequisite<"balance"> {
|
|
13
|
-
private readonly _id;
|
|
14
|
-
private readonly _title;
|
|
15
|
-
private readonly _detail;
|
|
16
|
-
constructor(props: BalancePrerequisiteProps);
|
|
17
|
-
get id(): string;
|
|
18
|
-
get kind(): "balance";
|
|
19
|
-
get title(): string;
|
|
20
|
-
get detail(): PrerequisiteDetail<"balance">;
|
|
21
|
-
calls(): ContractFunctionParameters[];
|
|
22
|
-
resolve(slice: MulticallCallResult[]): PrerequisiteResult<"balance">;
|
|
23
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { type ContractFunctionParameters } from "viem";
|
|
2
|
-
import type { PrerequisiteContext, PrerequisiteDetail, PrerequisiteError, PrerequisiteKind, PrerequisiteResult } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* One entry of a viem `multicall({ allowFailure: true })` response: either a
|
|
5
|
-
* decoded `result` or the `error` that the call reverted with.
|
|
6
|
-
*/
|
|
7
|
-
export type MulticallCallResult = {
|
|
8
|
-
status: "success";
|
|
9
|
-
result: unknown;
|
|
10
|
-
error?: undefined;
|
|
11
|
-
} | {
|
|
12
|
-
status: "failure";
|
|
13
|
-
result?: undefined;
|
|
14
|
-
error: Error;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Decodes an unknown error into a {@link PrerequisiteError} with a
|
|
18
|
-
* human-readable revert reason. Mirrors the SDK's `extractCallError`: walk the
|
|
19
|
-
* viem error chain for a {@link ContractFunctionRevertedError} and use its
|
|
20
|
-
* `errorName`, otherwise fall back to the error's short message / name.
|
|
21
|
-
*/
|
|
22
|
-
export declare function toPrerequisiteError(cause: unknown): PrerequisiteError;
|
|
23
|
-
/**
|
|
24
|
-
* A single verifiable prerequisite for a transaction. Subclasses describe the
|
|
25
|
-
* on-chain reads they need ({@link calls}) and how to turn the multicall slice
|
|
26
|
-
* into a {@link PrerequisiteResult} ({@link resolve}).
|
|
27
|
-
*
|
|
28
|
-
* Identity (`id`, `kind`, `title`) and build-time `detail` are exposed as
|
|
29
|
-
* read-only accessors; subclasses back them with private fields. The shared
|
|
30
|
-
* {@link satisfiedResult}/{@link errorResult} helpers are `protected` so each
|
|
31
|
-
* subclass builds results consistently.
|
|
32
|
-
*
|
|
33
|
-
* The same instance can be verified standalone via {@link verify} or batched
|
|
34
|
-
* together with others by `verifyPrerequisites`.
|
|
35
|
-
*/
|
|
36
|
-
export declare abstract class Prerequisite<K extends PrerequisiteKind> {
|
|
37
|
-
/** Stable identifier, used as a React key and for deduplication. */
|
|
38
|
-
abstract get id(): string;
|
|
39
|
-
/** Discriminant tying this check to its detail payload. */
|
|
40
|
-
abstract get kind(): K;
|
|
41
|
-
/** Human-readable label shown in the UI. */
|
|
42
|
-
abstract get title(): string;
|
|
43
|
-
/** Inputs known before reading the chain (no `actual` yet). */
|
|
44
|
-
abstract get detail(): PrerequisiteDetail<K>;
|
|
45
|
-
/** Contract reads this check needs (usually one). */
|
|
46
|
-
abstract calls(ctx: PrerequisiteContext): ContractFunctionParameters[];
|
|
47
|
-
/** Maps this check's slice of the multicall response into a result. */
|
|
48
|
-
abstract resolve(slice: MulticallCallResult[]): PrerequisiteResult<K>;
|
|
49
|
-
/**
|
|
50
|
-
* Verifies this prerequisite on its own using an `allowFailure` multicall.
|
|
51
|
-
* Prefer `verifyPrerequisites` to batch several checks into one round-trip.
|
|
52
|
-
*/
|
|
53
|
-
verify(ctx: PrerequisiteContext): Promise<PrerequisiteResult<K>>;
|
|
54
|
-
/** Builds a successful result; `detail` carries the on-chain `actual`. */
|
|
55
|
-
protected satisfiedResult(satisfied: boolean, detail: PrerequisiteDetail<K>): PrerequisiteResult<K>;
|
|
56
|
-
/** Builds a failed result from a decoded read error. */
|
|
57
|
-
protected errorResult(error: PrerequisiteError): PrerequisiteResult<K>;
|
|
58
|
-
}
|
|
59
|
-
/** Any prerequisite regardless of its kind, used for heterogeneous lists. */
|
|
60
|
-
export type AnyPrerequisite = Prerequisite<PrerequisiteKind>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Operation } from "../parse/index.js";
|
|
2
|
-
import type { AnyPrerequisite } from "./Prerequisite.js";
|
|
3
|
-
import type { PrerequisiteContext } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Derives the on-chain prerequisites for a parsed operation: the conditions
|
|
6
|
-
* that must hold for the call not to revert and that we can verify with the
|
|
7
|
-
* SDK (token approvals, wallet balances).
|
|
8
|
-
*
|
|
9
|
-
* Only *sender-actionable* prerequisites belong here: conditions the LP
|
|
10
|
-
* provider or borrower can fix themselves before retrying (e.g. approve a
|
|
11
|
-
* token, top up a balance). Non-actionable protocol/admin state (pool pause,
|
|
12
|
-
* available pool liquidity, health factor, liquidatability, degen NFT gating,
|
|
13
|
-
* bot permissions) is intentionally out of scope, since the user cannot
|
|
14
|
-
* resolve it. New {@link AnyPrerequisite} subclasses must follow the same rule.
|
|
15
|
-
*/
|
|
16
|
-
export declare function buildPrerequisites(tx: Operation, ctx: PrerequisiteContext): AnyPrerequisite[];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "./AllowancePrerequisite.js";
|
|
2
|
-
export * from "./BalancePrerequisite.js";
|
|
3
|
-
export * from "./buildPrerequisites.js";
|
|
4
|
-
export * from "./Prerequisite.js";
|
|
5
|
-
export * from "./prepareAction.js";
|
|
6
|
-
export * from "./runPrerequisites.js";
|
|
7
|
-
export * from "./types.js";
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from "viem";
|
|
2
|
-
import type { AnyPrerequisiteResult } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* A single transaction that satisfies a sender-actionable prerequisite.
|
|
5
|
-
*
|
|
6
|
-
* The shape is intentionally minimal (`to`/`data`/optional `value`) so it maps
|
|
7
|
-
* directly onto wallet send primitives (e.g. viem `sendTransaction`, wagmi
|
|
8
|
-
* `useSendTransaction`/`useWriteContract`). It is deliberately *not* the heavier
|
|
9
|
-
* {@link import("../../sdk/types/transactions.js").RawTx} used for Safe batches.
|
|
10
|
-
*
|
|
11
|
-
* The `kind` mirrors the prerequisite kind it remediates, so consumers can label
|
|
12
|
-
* the action (e.g. "Approve") without re-deriving it.
|
|
13
|
-
*/
|
|
14
|
-
export interface PrerequisiteAction {
|
|
15
|
-
/** Prerequisite kind this action remediates. */
|
|
16
|
-
kind: "allowance";
|
|
17
|
-
/** Contract the transaction is sent to (the ERC-20 token for allowances). */
|
|
18
|
-
to: Address;
|
|
19
|
-
/** Encoded calldata (e.g. `approve(spender, required)`). */
|
|
20
|
-
data: Hex;
|
|
21
|
-
/** Native value to send; omitted (treated as 0) for ERC-20 approvals. */
|
|
22
|
-
value?: bigint;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Builds the transaction that resolves an unsatisfied, sender-actionable
|
|
26
|
-
* prerequisite, or returns `null` when the prerequisite cannot be fixed with a
|
|
27
|
-
* single wallet transaction.
|
|
28
|
-
*
|
|
29
|
-
* Currently only `allowance` is actionable: it returns an ERC-20
|
|
30
|
-
* `approve(spender, required)` for the exact required amount. `balance`
|
|
31
|
-
* shortfalls (the user must acquire/free up funds) and errored reads are not
|
|
32
|
-
* actionable and return `null`. New actionable kinds (permits, native unwrap,
|
|
33
|
-
* approve-reset-to-zero for non-standard tokens, ...) should be encoded here so
|
|
34
|
-
* consumers do not have to special-case them.
|
|
35
|
-
*
|
|
36
|
-
* Operates on the serializable {@link AnyPrerequisiteResult} produced by
|
|
37
|
-
* `verifyPrerequisites` (not on {@link import("./Prerequisite.js").Prerequisite}
|
|
38
|
-
* instances), so it works against cached/persisted results.
|
|
39
|
-
*
|
|
40
|
-
* @param result - A verified prerequisite result.
|
|
41
|
-
* @returns The remediation transaction, or `null` if not auto-actionable.
|
|
42
|
-
*/
|
|
43
|
-
export declare function preparePrerequisiteAction(result: AnyPrerequisiteResult): PrerequisiteAction | null;
|
|
44
|
-
/**
|
|
45
|
-
* Whether a prerequisite result represents something the sender can fix with a
|
|
46
|
-
* single wallet transaction (i.e. {@link preparePrerequisiteAction} returns a
|
|
47
|
-
* transaction for it).
|
|
48
|
-
*
|
|
49
|
-
* Useful for UIs that distinguish "approve to continue" (actionable) from hard
|
|
50
|
-
* blocks like an insufficient balance (not actionable).
|
|
51
|
-
*/
|
|
52
|
-
export declare function isActionablePrerequisite(result: AnyPrerequisiteResult): boolean;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { AnyPrerequisite } from "./Prerequisite.js";
|
|
2
|
-
import type { AnyPrerequisiteResult, PrerequisiteContext } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Verifies all prerequisites in a single resilient multicall.
|
|
5
|
-
*
|
|
6
|
-
* Every prereq contributes its reads to one `multicall({ allowFailure: true })`
|
|
7
|
-
* batch, then resolves its own slice of the response. A read that reverts
|
|
8
|
-
* isolates to that prerequisite (an `error` result) without affecting the
|
|
9
|
-
* others; if the whole round-trip fails (RPC/network), every prerequisite
|
|
10
|
-
* resolves to an `error` carrying that reason.
|
|
11
|
-
*/
|
|
12
|
-
export declare function verifyPrerequisites(prereqs: AnyPrerequisite[], ctx: PrerequisiteContext): Promise<AnyPrerequisiteResult[]>;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Extension point that ties each prerequisite kind to its detail payload.
|
|
5
|
-
*
|
|
6
|
-
* Adding a new prerequisite kind only requires a new entry here: the generic
|
|
7
|
-
* machinery below and the UI renderer registry both key off this map, so TS
|
|
8
|
-
* forces every consumer to handle the new kind.
|
|
9
|
-
*
|
|
10
|
-
* IMPORTANT: only add prerequisites that are *actionable by the transaction
|
|
11
|
-
* sender* (the LP provider or borrower). A valid prerequisite is one the user
|
|
12
|
-
* can resolve themselves before retrying, e.g. approve a token (`allowance`)
|
|
13
|
-
* or acquire/free up funds (`balance`). Do NOT add protocol- or admin-level
|
|
14
|
-
* state the user cannot change, such as pool pause status or available pool
|
|
15
|
-
* liquidity; those are not actionable and must not be listed as prerequisites.
|
|
16
|
-
*/
|
|
17
|
-
export interface PrerequisiteDetailMap {
|
|
18
|
-
/** ERC-20 allowance from `owner` to `spender` must cover `required`. */
|
|
19
|
-
allowance: {
|
|
20
|
-
token: Address;
|
|
21
|
-
owner: Address;
|
|
22
|
-
spender: Address;
|
|
23
|
-
required: bigint;
|
|
24
|
-
/** On-chain allowance read; only present when the read succeeded. */
|
|
25
|
-
actual?: bigint;
|
|
26
|
-
};
|
|
27
|
-
/** ERC-20 balance of `owner` must cover `required`. */
|
|
28
|
-
balance: {
|
|
29
|
-
token: Address;
|
|
30
|
-
owner: Address;
|
|
31
|
-
required: bigint;
|
|
32
|
-
/** On-chain balance read; only present when the read succeeded. */
|
|
33
|
-
actual?: bigint;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export type PrerequisiteKind = keyof PrerequisiteDetailMap;
|
|
37
|
-
export type PrerequisiteDetail<K extends PrerequisiteKind = PrerequisiteKind> = PrerequisiteDetailMap[K];
|
|
38
|
-
/** Failure of the underlying on-chain read (revert, decode error, RPC error). */
|
|
39
|
-
export interface PrerequisiteError {
|
|
40
|
-
/** Decoded revert reason / error name, human-readable. */
|
|
41
|
-
reason: string;
|
|
42
|
-
/** Original error, kept for debugging. */
|
|
43
|
-
cause?: unknown;
|
|
44
|
-
}
|
|
45
|
-
export interface PrerequisiteBase<K extends PrerequisiteKind> {
|
|
46
|
-
id: string;
|
|
47
|
-
kind: K;
|
|
48
|
-
title: string;
|
|
49
|
-
detail: PrerequisiteDetail<K>;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Outcome of verifying a single prerequisite: either the read succeeded (a
|
|
53
|
-
* `satisfied` boolean) or it reverted/failed (an `error` with the revert
|
|
54
|
-
* reason). The two variants are mutually exclusive.
|
|
55
|
-
*/
|
|
56
|
-
export type PrerequisiteResult<K extends PrerequisiteKind = PrerequisiteKind> = PrerequisiteBase<K> & ({
|
|
57
|
-
satisfied: boolean;
|
|
58
|
-
error?: undefined;
|
|
59
|
-
} | {
|
|
60
|
-
satisfied?: undefined;
|
|
61
|
-
error: PrerequisiteError;
|
|
62
|
-
});
|
|
63
|
-
/**
|
|
64
|
-
* Discriminated union over every prerequisite kind. Switching on `kind`
|
|
65
|
-
* narrows `detail` to the matching payload, so React components can render
|
|
66
|
-
* kind-specific details with full type safety.
|
|
67
|
-
*/
|
|
68
|
-
export type AnyPrerequisiteResult = {
|
|
69
|
-
[K in PrerequisiteKind]: PrerequisiteResult<K>;
|
|
70
|
-
}[PrerequisiteKind];
|
|
71
|
-
/** Shared inputs for building and verifying prerequisites. */
|
|
72
|
-
export interface PrerequisiteContext {
|
|
73
|
-
sdk: OnchainSDK;
|
|
74
|
-
/** Address whose balances/allowances are checked (the tx sender). */
|
|
75
|
-
wallet: Address;
|
|
76
|
-
/** Block to read at; defaults to latest. Only set for testnet forks. */
|
|
77
|
-
blockNumber?: bigint;
|
|
78
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { NetworkType } from "../../sdk/chain/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Networks where the `eth_simulateV1` JSON-RPC method is available and usable
|
|
4
|
-
* for pool or credit account operation simulation.
|
|
5
|
-
**/
|
|
6
|
-
export declare const ETH_SIMULATE_V1_NETWORKS: ReadonlySet<NetworkType>;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { BaseError, type Hex } from "viem";
|
|
2
|
-
/** Which simulation flow produced a failure. */
|
|
3
|
-
export type SimulationFlowSource = "eth_simulateV1" | "multicall" | "unknown";
|
|
4
|
-
/** A single flow failure with its decoded revert detail. */
|
|
5
|
-
export interface SimulationFlowFailure {
|
|
6
|
-
source: SimulationFlowSource;
|
|
7
|
-
detail: SimulationError;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Error returned by the pool simulation when all attempted flows fail.
|
|
11
|
-
*
|
|
12
|
-
* On a single-flow failure it wraps that flow's decoded revert reason; when both
|
|
13
|
-
* the `eth_simulateV1` and multicall flows fail, it carries the details of both
|
|
14
|
-
* (see {@link failures}).
|
|
15
|
-
*/
|
|
16
|
-
export declare class PreviewSimulationError extends BaseError {
|
|
17
|
-
name: string;
|
|
18
|
-
/** Per-flow decoded failures behind this error. */
|
|
19
|
-
readonly failures: SimulationFlowFailure[];
|
|
20
|
-
constructor(failures: SimulationFlowFailure[]);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Normalises an unknown rejection reason into a {@link PreviewSimulationError}.
|
|
24
|
-
* Pass-through when it already is one; otherwise decodes it under `source`.
|
|
25
|
-
*/
|
|
26
|
-
export declare function asPreviewSimulationError(reason: unknown, source: SimulationFlowSource): PreviewSimulationError;
|
|
27
|
-
/** Merges several {@link PreviewSimulationError}s into one carrying all failures. */
|
|
28
|
-
export declare function combinePreviewSimulationErrors(...errors: (PreviewSimulationError | undefined)[]): PreviewSimulationError;
|
|
29
|
-
/** Decoded revert of the simulated transaction. */
|
|
30
|
-
export interface SimulationError {
|
|
31
|
-
/** Human-readable revert reason / error name. */
|
|
32
|
-
reason: string;
|
|
33
|
-
/** Original error, kept for debugging. */
|
|
34
|
-
cause?: unknown;
|
|
35
|
-
}
|
|
36
|
-
/** Per-call slice of a `simulateCalls` failure we need to decode. */
|
|
37
|
-
export interface SimulationRevert {
|
|
38
|
-
error?: Error;
|
|
39
|
-
/** Raw revert return data, when present. */
|
|
40
|
-
data?: Hex;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Decodes a simulated transaction revert into a {@link SimulationError}.
|
|
44
|
-
*
|
|
45
|
-
* The simulated call is raw calldata (no ABI), so viem cannot decode the revert
|
|
46
|
-
* itself. We first try to decode the raw return bytes against the SDK's
|
|
47
|
-
* {@link errorAbis} (Gearbox protocol exceptions plus standard ERC-20 custom
|
|
48
|
-
* errors); failing that, we walk viem's error chain for a
|
|
49
|
-
* {@link ContractFunctionRevertedError} (covers `Error(string)` / `Panic`).
|
|
50
|
-
*/
|
|
51
|
-
export declare function decodeSimulationError(revert: SimulationRevert): SimulationError;
|