@gearbox-protocol/sdk 14.11.3 → 14.12.0-next.1
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 +2 -0
- package/dist/cjs/{history/trace-utils.js → common-utils/utils/trace.js} +62 -5
- package/dist/cjs/dev/index.js +3 -1
- package/dist/cjs/dev/verifyTestnet.js +52 -0
- package/dist/cjs/history/assembleOperations.js +6 -6
- package/dist/cjs/history/classifyMulticallOperations.js +31 -25
- package/dist/cjs/history/index.js +0 -2
- package/dist/cjs/history/parseCreditAccountTransaction.js +5 -6
- package/dist/cjs/history/toLegacyOperation.js +5 -1
- package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +25 -37
- package/dist/cjs/plugins/adapters/contracts/AccountMigratorAdapterContract.js +9 -0
- package/dist/cjs/{history/internal-types.js → plugins/adapters/transfers.js} +2 -2
- package/dist/cjs/preview/index.js +28 -0
- package/dist/cjs/preview/package.json +1 -0
- package/dist/cjs/preview/parse/classifyInnerOperations.js +92 -0
- package/dist/cjs/preview/parse/errors.js +47 -0
- package/dist/cjs/preview/parse/extractExpectedBalanceChanges.js +48 -0
- package/dist/cjs/preview/parse/index.js +34 -0
- package/dist/cjs/preview/parse/parseFacadeOperationCalldata.js +115 -0
- package/dist/cjs/preview/parse/parseOperationCalldata.js +46 -0
- package/dist/cjs/preview/parse/parsePoolOperationCalldata.js +77 -0
- package/dist/cjs/{history/inner-operations.js → preview/parse/types-adapters.js} +2 -2
- package/dist/cjs/preview/parse/types-facades.js +16 -0
- package/dist/cjs/preview/parse/types-pools.js +16 -0
- package/dist/cjs/preview/parse/types.js +37 -0
- package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +78 -0
- package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +77 -0
- package/dist/cjs/preview/prerequisites/Prerequisite.js +85 -0
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +187 -0
- package/dist/cjs/preview/prerequisites/index.js +34 -0
- package/dist/cjs/preview/prerequisites/prepareAction.js +48 -0
- package/dist/cjs/preview/prerequisites/runPrerequisites.js +71 -0
- package/dist/cjs/preview/prerequisites/types.js +16 -0
- package/dist/cjs/preview/simulate/constants.js +28 -0
- package/dist/cjs/preview/simulate/errors.js +98 -0
- package/dist/cjs/preview/simulate/extractERC20Transfers.js +47 -0
- package/dist/cjs/preview/simulate/holders.js +45 -0
- package/dist/cjs/preview/simulate/index.js +40 -0
- package/dist/cjs/preview/simulate/simulateFacadeOperation.js +30 -0
- package/dist/cjs/preview/simulate/simulateOperation.js +37 -0
- 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 +62 -0
- package/dist/cjs/preview/simulate/types.js +16 -0
- package/dist/cjs/{history → preview/trace}/errors.js +0 -26
- package/dist/cjs/preview/trace/extractAdapterCallTraces.js +58 -0
- package/dist/cjs/{history → preview/trace}/extractTransfers.js +9 -12
- package/dist/cjs/{history → preview/trace}/findFacadeCalls.js +3 -3
- package/dist/cjs/preview/trace/index.js +30 -0
- package/dist/cjs/preview/trace/types.js +16 -0
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +154 -0
- package/dist/esm/common-utils/utils/index.js +1 -0
- package/dist/esm/common-utils/utils/trace.js +93 -0
- package/dist/esm/dev/index.js +1 -0
- package/dist/esm/dev/verifyTestnet.js +27 -0
- package/dist/esm/history/assembleOperations.js +8 -6
- package/dist/esm/history/classifyMulticallOperations.js +29 -23
- package/dist/esm/history/index.js +0 -1
- package/dist/esm/history/parseCreditAccountTransaction.js +3 -4
- package/dist/esm/history/toLegacyOperation.js +5 -1
- package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +28 -38
- package/dist/esm/plugins/adapters/contracts/AccountMigratorAdapterContract.js +9 -0
- package/dist/esm/preview/index.js +4 -0
- package/dist/esm/preview/package.json +1 -0
- package/dist/esm/preview/parse/classifyInnerOperations.js +68 -0
- package/dist/esm/preview/parse/errors.js +22 -0
- package/dist/esm/preview/parse/extractExpectedBalanceChanges.js +24 -0
- package/dist/esm/preview/parse/index.js +7 -0
- package/dist/esm/preview/parse/parseFacadeOperationCalldata.js +91 -0
- package/dist/esm/preview/parse/parseOperationCalldata.js +25 -0
- package/dist/esm/preview/parse/parsePoolOperationCalldata.js +53 -0
- 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 +9 -0
- package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +57 -0
- package/dist/esm/preview/prerequisites/BalancePrerequisite.js +56 -0
- package/dist/esm/preview/prerequisites/Prerequisite.js +63 -0
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +163 -0
- package/dist/esm/preview/prerequisites/index.js +7 -0
- package/dist/esm/preview/prerequisites/prepareAction.js +23 -0
- package/dist/esm/preview/prerequisites/runPrerequisites.js +47 -0
- package/dist/esm/preview/prerequisites/types.js +0 -0
- package/dist/esm/preview/simulate/constants.js +4 -0
- package/dist/esm/preview/simulate/errors.js +75 -0
- package/dist/esm/preview/simulate/extractERC20Transfers.js +23 -0
- package/dist/esm/preview/simulate/holders.js +21 -0
- package/dist/esm/preview/simulate/index.js +12 -0
- package/dist/esm/preview/simulate/simulateFacadeOperation.js +6 -0
- package/dist/esm/preview/simulate/simulateOperation.js +13 -0
- 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 +41 -0
- package/dist/esm/preview/simulate/types.js +0 -0
- package/dist/esm/{history → preview/trace}/errors.js +0 -24
- package/dist/esm/preview/trace/extractAdapterCallTraces.js +40 -0
- package/dist/esm/{history → preview/trace}/extractTransfers.js +9 -12
- package/dist/esm/{history → preview/trace}/findFacadeCalls.js +4 -2
- package/dist/esm/preview/trace/index.js +5 -0
- package/dist/esm/preview/trace/types.js +0 -0
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +154 -0
- package/dist/types/common-utils/utils/index.d.ts +1 -0
- package/dist/types/common-utils/utils/trace.d.ts +73 -0
- package/dist/types/dev/index.d.ts +1 -0
- package/dist/types/dev/verifyTestnet.d.ts +24 -0
- package/dist/types/history/assembleOperations.d.ts +11 -6
- package/dist/types/history/classifyMulticallOperations.d.ts +21 -9
- package/dist/types/history/index.d.ts +0 -1
- package/dist/types/history/mapOperations.d.ts +7 -9
- package/dist/types/history/types.d.ts +22 -71
- package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +16 -17
- package/dist/types/plugins/adapters/contracts/AccountMigratorAdapterContract.d.ts +10 -1
- 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/transfers.d.ts +17 -0
- package/dist/types/plugins/adapters/types.d.ts +8 -46
- package/dist/types/preview/index.d.ts +4 -0
- package/dist/types/preview/parse/classifyInnerOperations.d.ts +21 -0
- package/dist/types/preview/parse/errors.d.ts +17 -0
- package/dist/types/preview/parse/extractExpectedBalanceChanges.d.ts +22 -0
- package/dist/types/preview/parse/index.d.ts +7 -0
- package/dist/types/preview/parse/parseFacadeOperationCalldata.d.ts +19 -0
- package/dist/types/preview/parse/parseOperationCalldata.d.ts +23 -0
- package/dist/types/preview/parse/parsePoolOperationCalldata.d.ts +17 -0
- package/dist/types/preview/parse/types-adapters.d.ts +69 -0
- package/dist/types/preview/parse/types-facades.d.ts +158 -0
- package/dist/types/preview/parse/types-pools.d.ts +55 -0
- package/dist/types/preview/parse/types.d.ts +44 -0
- package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +24 -0
- package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +23 -0
- package/dist/types/preview/prerequisites/Prerequisite.d.ts +60 -0
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +16 -0
- package/dist/types/preview/prerequisites/index.d.ts +7 -0
- package/dist/types/preview/prerequisites/prepareAction.d.ts +52 -0
- package/dist/types/preview/prerequisites/runPrerequisites.d.ts +12 -0
- package/dist/types/preview/prerequisites/types.d.ts +78 -0
- 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/extractERC20Transfers.d.ts +11 -0
- package/dist/types/preview/simulate/holders.d.ts +7 -0
- package/dist/types/preview/simulate/index.d.ts +9 -0
- package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +25 -0
- package/dist/types/preview/simulate/simulateOperation.d.ts +20 -0
- 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 +8 -0
- package/dist/types/preview/simulate/types.d.ts +79 -0
- package/dist/types/{history → preview/trace}/errors.d.ts +0 -10
- package/dist/types/preview/trace/extractAdapterCallTraces.d.ts +23 -0
- package/dist/types/{history → preview/trace}/extractTransfers.d.ts +14 -5
- package/dist/types/{history → preview/trace}/findFacadeCalls.d.ts +3 -2
- package/dist/types/preview/trace/index.d.ts +5 -0
- package/dist/types/preview/trace/types.d.ts +21 -0
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +21 -1
- package/dist/types/sdk/accounts/types.d.ts +82 -0
- package/package.json +6 -1
- package/dist/cjs/history/extractProtocolCalls.js +0 -53
- package/dist/esm/history/extractProtocolCalls.js +0 -32
- package/dist/esm/history/trace-utils.js +0 -36
- package/dist/types/history/extractProtocolCalls.d.ts +0 -8
- package/dist/types/history/inner-operations.d.ts +0 -57
- package/dist/types/history/internal-types.d.ts +0 -47
- package/dist/types/history/trace-utils.d.ts +0 -12
- /package/dist/esm/{history/inner-operations.js → plugins/adapters/transfers.js} +0 -0
- /package/dist/esm/{history/internal-types.js → preview/parse/types-adapters.js} +0 -0
|
@@ -671,6 +671,6 @@ export declare class ERC4626AdapterContract extends AbstractAdapterContract<abi,
|
|
|
671
671
|
*
|
|
672
672
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L32-L38
|
|
673
673
|
*/
|
|
674
|
-
|
|
674
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
675
675
|
}
|
|
676
676
|
export {};
|
|
@@ -298,6 +298,6 @@ export declare class ERC4626ReferralAdapterContract extends AbstractAdapterContr
|
|
|
298
298
|
/**
|
|
299
299
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L32-L38
|
|
300
300
|
*/
|
|
301
|
-
|
|
301
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
302
302
|
}
|
|
303
303
|
export {};
|
|
@@ -213,6 +213,6 @@ export declare class LidoV1AdapterContract extends AbstractAdapterContract<abi,
|
|
|
213
213
|
contractType?: string;
|
|
214
214
|
};
|
|
215
215
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L277-L282 */
|
|
216
|
-
|
|
216
|
+
classifyLegacyOperation(_parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
217
217
|
}
|
|
218
218
|
export {};
|
|
@@ -709,6 +709,6 @@ export declare class MellowDVVAdapterContract extends AbstractAdapterContract<ab
|
|
|
709
709
|
/**
|
|
710
710
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L32-L38
|
|
711
711
|
*/
|
|
712
|
-
|
|
712
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
713
713
|
}
|
|
714
714
|
export {};
|
|
@@ -676,6 +676,6 @@ export declare class MellowERC4626VaultAdapterContract extends AbstractAdapterCo
|
|
|
676
676
|
*
|
|
677
677
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L32-L38
|
|
678
678
|
*/
|
|
679
|
-
|
|
679
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
680
680
|
}
|
|
681
681
|
export {};
|
|
@@ -964,6 +964,6 @@ export declare class UniswapV2AdapterContract extends AbstractAdapterContract<ab
|
|
|
964
964
|
};
|
|
965
965
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
966
966
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L81-L91 */
|
|
967
|
-
|
|
967
|
+
classifyLegacyOperation(_parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
968
968
|
}
|
|
969
969
|
export {};
|
|
@@ -420,6 +420,6 @@ export declare class UniswapV4AdapterContract extends AbstractAdapterContract<ab
|
|
|
420
420
|
contractType?: string;
|
|
421
421
|
};
|
|
422
422
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L81-L91 */
|
|
423
|
-
|
|
423
|
+
classifyLegacyOperation(_parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
424
424
|
}
|
|
425
425
|
export {};
|
|
@@ -392,6 +392,6 @@ export declare class WstETHV1AdapterContract extends AbstractAdapterContract<abi
|
|
|
392
392
|
contractType?: string;
|
|
393
393
|
};
|
|
394
394
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L264-L275 */
|
|
395
|
-
|
|
395
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
396
396
|
}
|
|
397
397
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
2
|
import type { BasicSwapCall, CurveAddLiquidity, CurveRemoveLiquidity, LegacyAdapterOperation, TokenAmount, Transfers } from "./legacyAdapterOperations.js";
|
|
3
|
-
import type { TokenTransfer } from "./
|
|
3
|
+
import type { TokenTransfer } from "./transfers.js";
|
|
4
4
|
/**
|
|
5
5
|
* Converts an ordered array of {@link TokenTransfer} into net signed balance
|
|
6
6
|
* changes ({@link Transfers}) for the given credit account.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* A single ERC-20 Transfer event captured between Execute boundaries.
|
|
4
|
+
*
|
|
5
|
+
* Internal to `plugins/adapters` (kept here so {@link toNetTransfers} stays
|
|
6
|
+
* typed) and intentionally **not** re-exported from the package barrel: the
|
|
7
|
+
* canonical, public `TokenTransfer` lives in the `preview` module. The two are
|
|
8
|
+
* structurally identical, so values flow between the modules without casts.
|
|
9
|
+
*
|
|
10
|
+
* @deprecated Will be deprecated when we get rid of classifyLegacyOperation
|
|
11
|
+
*/
|
|
12
|
+
export interface TokenTransfer {
|
|
13
|
+
token: Address;
|
|
14
|
+
amount: bigint;
|
|
15
|
+
from: Address;
|
|
16
|
+
to: Address;
|
|
17
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AbiParameter, Address } from "viem";
|
|
2
2
|
import type { BaseContractStateHuman } from "../../sdk/types/state-human.js";
|
|
3
|
-
import type { LegacyAdapterOperation } from "./legacyAdapterOperations.js";
|
|
4
3
|
export type VersionedAbi = Record<number, readonly AbiParameter[]>;
|
|
5
4
|
export type AdapterContractType = "ADAPTER::ACCOUNT_MIGRATOR" | "ADAPTER::BALANCER_V3_ROUTER" | "ADAPTER::BALANCER_V3_WRAPPER" | "ADAPTER::BALANCER_VAULT" | "ADAPTER::CAMELOT_V3_ROUTER" | "ADAPTER::CURVE_STABLE_NG" | "ADAPTER::CURVE_V1_2ASSETS" | "ADAPTER::CURVE_V1_3ASSETS" | "ADAPTER::CURVE_V1_4ASSETS" | "ADAPTER::CURVE_V1_STECRV_POOL" | "ADAPTER::CURVE_V1_WRAPPER" | "ADAPTER::CVX_V1_BASE_REWARD_POOL" | "ADAPTER::CVX_V1_BOOSTER" | "ADAPTER::DAI_USDS_EXCHANGE" | "ADAPTER::EQUALIZER_ROUTER" | "ADAPTER::ERC4626_VAULT" | "ADAPTER::ERC4626_VAULT_REFERRAL" | "ADAPTER::FLUID_DEX" | "ADAPTER::INFINIFI_GATEWAY" | "ADAPTER::INFINIFI_UNWINDING" | "ADAPTER::INFRARED_VAULT" | "ADAPTER::KELP_DEPOSIT_POOL" | "ADAPTER::KELP_WITHDRAWAL" | "ADAPTER::KODIAK_ISLAND_GATEWAY" | "ADAPTER::LIDO_V1" | "ADAPTER::LIDO_WSTETH_V1" | "ADAPTER::MELLOW_CLAIMER" | "ADAPTER::MELLOW_DVV" | "ADAPTER::MELLOW_ERC4626_VAULT" | "ADAPTER::MELLOW_LRT_VAULT" | "ADAPTER::MELLOW_WRAPPER" | "ADAPTER::MELLOW_DEPOSIT_QUEUE_QUEUE" | "ADAPTER::MELLOW_REDEEM_QUEUE_QUEUE" | "ADAPTER::MIDAS_ISSUANCE_VAULT" | "ADAPTER::MIDAS_REDEMPTION_VAULT" | "ADAPTER::PENDLE_ROUTER" | "ADAPTER::SECURITIZE_ONRAMP" | "ADAPTER::SECURITIZE_REDEMPTION" | "ADAPTER::SECURITIZE_SWAP" | "ADAPTER::STAKING_REWARDS" | "ADAPTER::TRADER_JOE_ROUTER" | "ADAPTER::UNISWAP_V2_ROUTER" | "ADAPTER::UNISWAP_V3_ROUTER" | "ADAPTER::UNISWAP_V4_GATEWAY" | "ADAPTER::UPSHIFT_VAULT" | "ADAPTER::VELODROME_V2_ROUTER" | "ADAPTER::YEARN_V2";
|
|
6
5
|
export declare enum AdapterType {
|
|
@@ -57,59 +56,22 @@ export interface AdapterContractStateHuman extends BaseContractStateHuman {
|
|
|
57
56
|
targetContract?: string;
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
60
|
-
*
|
|
59
|
+
* Protocol-level call performed by an adapter: the target (protocol) contract
|
|
60
|
+
* together with the decoded function name and arguments of the actual CALL the
|
|
61
|
+
* adapter made to it. Recovered from an execution trace, so it is only present
|
|
62
|
+
* when a trace is available (history, facade simulation).
|
|
61
63
|
*/
|
|
62
|
-
export interface
|
|
63
|
-
token: Address;
|
|
64
|
-
amount: bigint;
|
|
65
|
-
from: Address;
|
|
66
|
-
to: Address;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Parsed adapter operation to display in credit account transactions history
|
|
70
|
-
*/
|
|
71
|
-
export interface AdapterOperation {
|
|
72
|
-
operation: "Execute";
|
|
73
|
-
/**
|
|
74
|
-
* Address of Gearbox Adapter contract
|
|
75
|
-
*/
|
|
76
|
-
adapter: Address;
|
|
64
|
+
export interface AdapterProtocolOperation {
|
|
77
65
|
/**
|
|
78
66
|
* Address of protocol contract (targetContract of adapter contract)
|
|
79
67
|
*/
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Namespaced adapter type
|
|
83
|
-
* E.g. "ADAPTER::FLUID_DEX"
|
|
84
|
-
*/
|
|
85
|
-
adapterType: string;
|
|
86
|
-
/**
|
|
87
|
-
* Adapter contract version
|
|
88
|
-
*/
|
|
89
|
-
version: number;
|
|
90
|
-
/**
|
|
91
|
-
* Label of protocol contract (NOT adapter contract)
|
|
92
|
-
*/
|
|
93
|
-
label?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Function name of adapter contract
|
|
96
|
-
*/
|
|
97
|
-
adapterFunctionName: string;
|
|
98
|
-
/**
|
|
99
|
-
* Arguments of adapter contract
|
|
100
|
-
*/
|
|
101
|
-
adapterArgs: Record<string, unknown>;
|
|
68
|
+
contract: Address;
|
|
102
69
|
/**
|
|
103
70
|
* Function name protocol called by adapter
|
|
104
71
|
*/
|
|
105
|
-
|
|
72
|
+
functionName: string;
|
|
106
73
|
/**
|
|
107
74
|
* Arguments of protocol called by adapter
|
|
108
75
|
*/
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* ERC20 transfer to and from credit account made during adapter call
|
|
112
|
-
*/
|
|
113
|
-
transfers: TokenTransfer[];
|
|
114
|
-
legacy: LegacyAdapterOperation;
|
|
76
|
+
functionArgs: Record<string, unknown>;
|
|
115
77
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { OnchainSDK, ParsedCallV2 } from "../../sdk/index.js";
|
|
3
|
+
import type { InnerOperation } from "./types.js";
|
|
4
|
+
export interface ClassifyInnerOperationsProps {
|
|
5
|
+
sdk: OnchainSDK;
|
|
6
|
+
/** Underlying token of the credit manager, used for debt operations. */
|
|
7
|
+
underlying: Address;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Calldata-only counterpart of the SDK's `classifyMulticallOperations`.
|
|
11
|
+
*
|
|
12
|
+
* Maps each inner multicall entry to an {@link InnerOperation}:
|
|
13
|
+
* - adapter and unknown targets become a pure-descriptor `Execute`
|
|
14
|
+
* {@link AdapterOperation};
|
|
15
|
+
* - credit-facade self-calls map to the matching inner facade operation.
|
|
16
|
+
*
|
|
17
|
+
* Raw calldata has no execution trace, so the trace-derived adapter data
|
|
18
|
+
* (`protocol`, `transfers`) and `legacy` are intentionally absent; they are only
|
|
19
|
+
* recovered by trace-based flows (history, facade simulation).
|
|
20
|
+
*/
|
|
21
|
+
export declare function classifyInnerOperations(calls: ParsedCallV2[], props: ClassifyInnerOperationsProps): InnerOperation[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when the target of a transaction is neither a known Gearbox pool nor a
|
|
4
|
+
* credit facade.
|
|
5
|
+
*/
|
|
6
|
+
export declare class UnsupportedTargetError extends Error {
|
|
7
|
+
readonly target: Address;
|
|
8
|
+
constructor(target: Address);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Thrown when a pool call uses a function other than ERC4626 `deposit`/`redeem`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class UnsupportedPoolFunctionError extends Error {
|
|
14
|
+
readonly pool: Address;
|
|
15
|
+
readonly functionName: string;
|
|
16
|
+
constructor(pool: Address, functionName: string);
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ParsedCallV2 } from "../../sdk/index.js";
|
|
2
|
+
import type { ExpectedBalanceChange } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Recovers the potential balance changes declared by a router-generated
|
|
5
|
+
* `storeExpectedBalances`/`compareBalances` pair inside a credit-facade
|
|
6
|
+
* multicall.
|
|
7
|
+
*
|
|
8
|
+
* The detection is intentionally limited to the router shape:
|
|
9
|
+
* - `onDemandPriceUpdates` calls are dropped first (they may only appear at the
|
|
10
|
+
* front of a multicall);
|
|
11
|
+
* - the remaining calls must start with `storeExpectedBalances` and end with
|
|
12
|
+
* `compareBalances`.
|
|
13
|
+
*
|
|
14
|
+
* When the multicall does not match this shape, `undefined` is returned. On a
|
|
15
|
+
* match, the `BalanceDelta[]` argument of `storeExpectedBalances` is decoded
|
|
16
|
+
* into {@link ExpectedBalanceChange}[] (the `amount` is the signed `int256`
|
|
17
|
+
* delta and may be negative).
|
|
18
|
+
*
|
|
19
|
+
* @param innerCalls - Raw (already-decoded) inner multicall calls.
|
|
20
|
+
* @returns The declared balance changes, or `undefined` when not router-shaped.
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractExpectedBalanceChanges(innerCalls: ParsedCallV2[]): ExpectedBalanceChange[] | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./classifyInnerOperations.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./extractExpectedBalanceChanges.js";
|
|
4
|
+
export * from "./parseFacadeOperationCalldata.js";
|
|
5
|
+
export * from "./parseOperationCalldata.js";
|
|
6
|
+
export * from "./parsePoolOperationCalldata.js";
|
|
7
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Hex } from "viem";
|
|
2
|
+
import type { CreditFacadeV310Contract, OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import type { OuterFacadeOperation } from "./types.js";
|
|
4
|
+
export interface ParseFacadeOperationCalldataProps {
|
|
5
|
+
sdk: OnchainSDK;
|
|
6
|
+
/** Resolved credit facade contract for the transaction target. */
|
|
7
|
+
facade: CreditFacadeV310Contract;
|
|
8
|
+
calldata: Hex;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Decodes a credit-facade entry-point call into the matching
|
|
12
|
+
* {@link OuterFacadeOperation}.
|
|
13
|
+
*
|
|
14
|
+
* Transaction-level metadata (`txHash`, `blockNumber`, `timestamp`) is not part
|
|
15
|
+
* of the base `preview` operation: those values are only known once the
|
|
16
|
+
* transaction is mined and are added in `history` mode. `creditAccount` is
|
|
17
|
+
* `zeroAddress` for `openCreditAccount` (the address is assigned on-chain).
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseFacadeOperationCalldata(props: ParseFacadeOperationCalldataProps): OuterFacadeOperation;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import { type PluginsMap } from "../../sdk/index.js";
|
|
3
|
+
import type { Operation, SdkWithAdapters } from "./types.js";
|
|
4
|
+
export interface ParseOperationCalldataInput<P extends PluginsMap = PluginsMap> {
|
|
5
|
+
/**
|
|
6
|
+
* Already-attached SDK; chain, RPC and block are baked in at attach time.
|
|
7
|
+
* Must be created with the adapters plugin (enforced at compile time) so
|
|
8
|
+
* adapter contracts resolve during multicall classification.
|
|
9
|
+
*/
|
|
10
|
+
sdk: SdkWithAdapters<P>;
|
|
11
|
+
to: Address;
|
|
12
|
+
calldata: Hex;
|
|
13
|
+
/** Transaction sender, contextual only. */
|
|
14
|
+
sender: Address;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Decodes raw operation calldata into an {@link Operation}.
|
|
18
|
+
*
|
|
19
|
+
* Routes by the resolved contract at `to`: a pool yields a deposit/redeem
|
|
20
|
+
* operation, a credit facade yields one facade operation. Anything else throws
|
|
21
|
+
* {@link UnsupportedTargetError}.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseOperationCalldata<P extends PluginsMap>(input: ParseOperationCalldataInput<P>): Operation;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Hex } from "viem";
|
|
2
|
+
import type { OnchainSDK, PoolV310Contract } from "../../sdk/index.js";
|
|
3
|
+
import type { PoolOperation } from "./types.js";
|
|
4
|
+
export interface ParsePoolOperationCalldataProps {
|
|
5
|
+
sdk: OnchainSDK;
|
|
6
|
+
/** Resolved pool contract for the transaction target. */
|
|
7
|
+
pool: PoolV310Contract;
|
|
8
|
+
calldata: Hex;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Decodes ERC4626 pool calldata into a {@link PoolOperation}. Supports every
|
|
12
|
+
* deposit/mint/withdraw/redeem variant of `IPoolV3` (and the `IERC4626` base it
|
|
13
|
+
* extends): `deposit`/`depositWithReferral`, `mint`/`mintWithReferral`,
|
|
14
|
+
* `withdraw` and `redeem`. Any other selector throws
|
|
15
|
+
* {@link UnsupportedPoolFunctionError}.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parsePoolOperationCalldata(props: ParsePoolOperationCalldataProps): PoolOperation;
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
to: Address;
|
|
146
|
+
creditAccount: Address;
|
|
147
|
+
amount: bigint;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Discriminated union of all facade-level operation types.
|
|
151
|
+
* One per facade entry-point call within a transaction.
|
|
152
|
+
*/
|
|
153
|
+
export type OuterFacadeOperation<Ext extends object = {}> = MulticallOperation<Ext> | OpenCreditAccountOperation<Ext> | CloseCreditAccountOperation<Ext> | LiquidateCreditAccountOperation<Ext> | PartialLiquidationOperation;
|
|
154
|
+
/**
|
|
155
|
+
* Discriminated union of all credit account operation types
|
|
156
|
+
* (facade operations + direct token transfers).
|
|
157
|
+
*/
|
|
158
|
+
export type CreditAccountOperation<Ext extends object = {}> = OuterFacadeOperation<Ext> | DirectTokenTransferOperation;
|
|
@@ -0,0 +1,55 @@
|
|
|
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;
|
|
@@ -0,0 +1,44 @@
|
|
|
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;
|