@gearbox-protocol/sdk 14.11.0-next.3 → 14.11.0-next.5
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/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 +3 -1
- package/dist/cjs/preview/parse/classifyInnerOperations.js +5 -43
- package/dist/cjs/preview/parse/parseFacadeOperationCalldata.js +1 -4
- 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 +8 -1
- package/dist/cjs/preview/prerequisites/index.js +2 -0
- package/dist/cjs/preview/prerequisites/prepareAction.js +48 -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 +10 -13
- 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/esm/common-utils/utils/index.js +1 -0
- package/dist/esm/common-utils/utils/trace.js +93 -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 +1 -0
- package/dist/esm/preview/parse/classifyInnerOperations.js +6 -46
- package/dist/esm/preview/parse/parseFacadeOperationCalldata.js +2 -9
- 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 +3 -0
- package/dist/esm/preview/prerequisites/index.js +1 -0
- package/dist/esm/preview/prerequisites/prepareAction.js +23 -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 +10 -13
- 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/types/common-utils/utils/index.d.ts +1 -0
- package/dist/types/common-utils/utils/trace.d.ts +73 -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 -65
- 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 +1 -0
- package/dist/types/preview/parse/classifyInnerOperations.d.ts +8 -8
- package/dist/types/preview/parse/parseFacadeOperationCalldata.d.ts +4 -3
- package/dist/types/preview/parse/types-adapters.d.ts +69 -0
- package/dist/types/preview/parse/types-facades.d.ts +124 -0
- package/dist/types/preview/parse/types-pools.d.ts +42 -0
- package/dist/types/preview/parse/types.d.ts +12 -46
- package/dist/types/preview/prerequisites/index.d.ts +1 -0
- package/dist/types/preview/prerequisites/prepareAction.d.ts +52 -0
- package/dist/types/preview/simulate/extractERC20Transfers.d.ts +1 -1
- package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +1 -1
- package/dist/types/preview/simulate/types.d.ts +1 -1
- 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/package.json +1 -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
|
@@ -1,71 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { InnerOperation } from "
|
|
1
|
+
import type { LegacyAdapterOperation } from "../plugins/adapters/index.js";
|
|
2
|
+
import type { AdapterOperation as BaseAdapterOperation, CloseCreditAccountOperation as BaseCloseCreditAccountOperation, DirectTokenTransferOperation as BaseDirectTokenTransferOperation, InnerOperation as BaseInnerOperation, LiquidateCreditAccountOperation as BaseLiquidateCreditAccountOperation, MulticallOperation as BaseMulticallOperation, OpenCreditAccountOperation as BaseOpenCreditAccountOperation, PartialLiquidationOperation as BasePartialLiquidationOperation, FacadeOperationMetadata, OperationMetadata, TraceAdapterExt } from "../preview/parse/index.js";
|
|
3
|
+
export type { AddCollateralOp, DecreaseDebtOp, FacadeOperationMetadata, IncreaseDebtOp, InnerFacadeOperation, OperationMetadata, UpdateQuotaOp, WithdrawCollateralOp, } from "../preview/parse/index.js";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* History-specific adapter-operation extension: trace-derived data
|
|
6
|
+
* ({@link TraceAdapterExt}) plus the backward-compatible `legacy` classification
|
|
7
|
+
* used by charts_server serialization. The `legacy` field lives only in
|
|
8
|
+
* `history`; the base `preview` operations carry no `legacy`.
|
|
6
9
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
amount: bigint;
|
|
11
|
-
}
|
|
12
|
-
export interface OperationMetadata {
|
|
13
|
-
txHash: Hex;
|
|
14
|
-
blockNumber: number;
|
|
15
|
-
timestamp: number;
|
|
16
|
-
}
|
|
17
|
-
export interface FacadeOperationMetadata extends OperationMetadata {
|
|
18
|
-
creditManager: Address;
|
|
19
|
-
creditFacade: Address;
|
|
20
|
-
}
|
|
21
|
-
export interface MulticallOperation extends FacadeOperationMetadata {
|
|
22
|
-
operation: "MultiCall" | "BotMulticall";
|
|
23
|
-
creditAccount: Address;
|
|
24
|
-
multicall: InnerOperation[];
|
|
25
|
-
}
|
|
26
|
-
export interface OpenCreditAccountOperation extends FacadeOperationMetadata {
|
|
27
|
-
operation: "OpenCreditAccount";
|
|
28
|
-
creditAccount: Address;
|
|
29
|
-
onBehalfOf: Address;
|
|
30
|
-
referralCode: bigint;
|
|
31
|
-
multicall: InnerOperation[];
|
|
32
|
-
}
|
|
33
|
-
export interface CloseCreditAccountOperation extends FacadeOperationMetadata {
|
|
34
|
-
operation: "CloseCreditAccount";
|
|
35
|
-
creditAccount: Address;
|
|
36
|
-
multicall: InnerOperation[];
|
|
37
|
-
}
|
|
38
|
-
export interface LiquidateCreditAccountOperation extends FacadeOperationMetadata {
|
|
39
|
-
operation: "LiquidateCreditAccount";
|
|
40
|
-
creditAccount: Address;
|
|
41
|
-
to: Address;
|
|
42
|
-
token: Address;
|
|
43
|
-
remainingFunds: bigint;
|
|
44
|
-
multicall: InnerOperation[];
|
|
45
|
-
}
|
|
46
|
-
export interface PartialLiquidationOperation extends FacadeOperationMetadata {
|
|
47
|
-
operation: "PartiallyLiquidateCreditAccount";
|
|
48
|
-
creditAccount: Address;
|
|
49
|
-
token: Address;
|
|
50
|
-
repaidAmount: bigint;
|
|
51
|
-
minSeizedAmount: bigint;
|
|
52
|
-
to: Address;
|
|
53
|
-
}
|
|
54
|
-
export interface DirectTokenTransferOperation extends OperationMetadata {
|
|
55
|
-
operation: "DirectTokenTransfer";
|
|
56
|
-
protocol: Address;
|
|
57
|
-
token: Address;
|
|
58
|
-
from: Address;
|
|
59
|
-
creditAccount: Address;
|
|
60
|
-
amount: bigint;
|
|
61
|
-
}
|
|
10
|
+
export type HistoryAdapterExt = TraceAdapterExt & {
|
|
11
|
+
legacy: LegacyAdapterOperation;
|
|
12
|
+
};
|
|
62
13
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
14
|
+
* Facade context available in `history` mode: the base facade metadata
|
|
15
|
+
* (`creditManager`/`creditFacade`) plus the transaction-level
|
|
16
|
+
* {@link OperationMetadata} that is only known once the transaction is mined.
|
|
65
17
|
*/
|
|
18
|
+
export type HistoryFacadeMetadata = FacadeOperationMetadata & OperationMetadata;
|
|
19
|
+
export type AdapterOperation = BaseAdapterOperation<HistoryAdapterExt>;
|
|
20
|
+
export type InnerOperation = BaseInnerOperation<HistoryAdapterExt>;
|
|
21
|
+
export type MulticallOperation = BaseMulticallOperation<HistoryAdapterExt> & OperationMetadata;
|
|
22
|
+
export type OpenCreditAccountOperation = BaseOpenCreditAccountOperation<HistoryAdapterExt> & OperationMetadata;
|
|
23
|
+
export type CloseCreditAccountOperation = BaseCloseCreditAccountOperation<HistoryAdapterExt> & OperationMetadata;
|
|
24
|
+
export type LiquidateCreditAccountOperation = BaseLiquidateCreditAccountOperation<HistoryAdapterExt> & OperationMetadata;
|
|
25
|
+
export type PartialLiquidationOperation = BasePartialLiquidationOperation & OperationMetadata;
|
|
26
|
+
export type DirectTokenTransferOperation = BaseDirectTokenTransferOperation & OperationMetadata;
|
|
66
27
|
export type OuterFacadeOperation = MulticallOperation | OpenCreditAccountOperation | CloseCreditAccountOperation | LiquidateCreditAccountOperation | PartialLiquidationOperation;
|
|
67
|
-
/**
|
|
68
|
-
* Discriminated union of all credit account operation types
|
|
69
|
-
* (facade operations + direct token transfers).
|
|
70
|
-
*/
|
|
71
28
|
export type CreditAccountOperation = OuterFacadeOperation | DirectTokenTransferOperation;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type Abi, type Address
|
|
1
|
+
import { type Abi, type Address } from "viem";
|
|
2
|
+
import { type CallTrace } from "../../../common-utils/utils/trace.js";
|
|
2
3
|
import type { ConstructOptions, ParsedCallV2, RelaxedBaseParams } from "../../../sdk/index.js";
|
|
3
4
|
import { BaseContract } from "../../../sdk/index.js";
|
|
4
5
|
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
5
|
-
import type { AdapterContractStateHuman, AdapterContractType,
|
|
6
|
+
import type { AdapterContractStateHuman, AdapterContractType, AdapterProtocolOperation } from "../types.js";
|
|
6
7
|
export interface ConcreteAdapterContractOptions {
|
|
7
8
|
baseParams: RelaxedBaseParams;
|
|
8
9
|
}
|
|
@@ -22,23 +23,19 @@ export declare class AbstractAdapterContract<const abi extends Abi | readonly un
|
|
|
22
23
|
get adapterType(): AdapterContractType;
|
|
23
24
|
stateHuman(raw?: boolean): AdapterContractStateHuman;
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Decodes the protocol-level call (target contract + function name + args)
|
|
27
|
+
* performed by this adapter, recovered from its adapter-level call trace.
|
|
26
28
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
+
* Both the `targetContract` and the protocol calldata are taken from the
|
|
30
|
+
* execution trace.
|
|
29
31
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* Decodes protocol-level function name and args from the raw calldata
|
|
36
|
-
* sent to targetContract.
|
|
32
|
+
* Returns `undefined` (in non-strict mode) when no external protocol call can
|
|
33
|
+
* be recovered, in strict mode throws instead.
|
|
34
|
+
*
|
|
35
|
+
* @param trace Adapter-level call trace (a direct child of the facade trace)
|
|
36
|
+
* @param strict When true, throws instead of returning `undefined`
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
protocolFunctionName: string;
|
|
40
|
-
protocolArgs: Record<string, unknown>;
|
|
41
|
-
};
|
|
38
|
+
parseProtocolCall(trace: CallTrace, strict?: boolean): AdapterProtocolOperation | undefined;
|
|
42
39
|
/**
|
|
43
40
|
* Classifies an adapter call into a {@link LegacyAdapterOperation} using the
|
|
44
41
|
* parsed call and credit-account transfer deltas.
|
|
@@ -50,6 +47,8 @@ export declare class AbstractAdapterContract<const abi extends Abi | readonly un
|
|
|
50
47
|
* Override in protocol-specific subclasses for richer classification.
|
|
51
48
|
*
|
|
52
49
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/account_operation.go#L238-L264
|
|
50
|
+
*
|
|
51
|
+
* @deprecated Eventually will be gone, exists to produce output that legacy UI can display
|
|
53
52
|
*/
|
|
54
|
-
|
|
53
|
+
classifyLegacyOperation(_parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
55
54
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { CallTrace } from "../../../common-utils/utils/trace.js";
|
|
1
2
|
import type { ConstructOptions, ParsedCallV2 } from "../../../sdk/index.js";
|
|
2
3
|
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
4
|
+
import type { AdapterProtocolOperation } from "../types.js";
|
|
3
5
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
4
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
5
7
|
declare const abi: readonly [{
|
|
@@ -467,6 +469,13 @@ type protocolAbi = typeof protocolAbi;
|
|
|
467
469
|
export declare class AccountMigratorAdapterContract extends AbstractAdapterContract<abi, protocolAbi> {
|
|
468
470
|
constructor(options: ConstructOptions, args: ConcreteAdapterContractOptions);
|
|
469
471
|
/** Legacy adapter not present in integrations-v3. */
|
|
470
|
-
|
|
472
|
+
classifyLegacyOperation(_parsed: ParsedCallV2, _transfers: Transfers): LegacyAdapterOperation;
|
|
473
|
+
/**
|
|
474
|
+
* The account-migrator adapter's `execute` targets the migrator bot, not an
|
|
475
|
+
* external protocol, so there is no protocol-level call to recover. Returning
|
|
476
|
+
* `undefined` keeps the `protocol` field aligned with its external-protocol
|
|
477
|
+
* semantics (see {@link TraceAdapterExt}).
|
|
478
|
+
*/
|
|
479
|
+
parseProtocolCall(_trace: CallTrace, _strict?: boolean): AdapterProtocolOperation | undefined;
|
|
471
480
|
}
|
|
472
481
|
export {};
|
|
@@ -689,6 +689,6 @@ export declare class ConvexV1BaseRewardPoolAdapterContract extends AbstractAdapt
|
|
|
689
689
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L200-L262
|
|
690
690
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L76-L83
|
|
691
691
|
*/
|
|
692
|
-
|
|
692
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
693
693
|
}
|
|
694
694
|
export {};
|
|
@@ -420,6 +420,6 @@ export declare class ConvexV1BoosterAdapterContract extends AbstractAdapterContr
|
|
|
420
420
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L166-L199
|
|
421
421
|
* @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L84-L91
|
|
422
422
|
*/
|
|
423
|
-
|
|
423
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
424
424
|
}
|
|
425
425
|
export {};
|
|
@@ -1776,6 +1776,6 @@ export declare class Curve2AssetsAdapterContract extends AbstractAdapterContract
|
|
|
1776
1776
|
contractType?: string;
|
|
1777
1777
|
};
|
|
1778
1778
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L132-L164 */
|
|
1779
|
-
|
|
1779
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
1780
1780
|
}
|
|
1781
1781
|
export {};
|
|
@@ -1776,6 +1776,6 @@ export declare class Curve3AssetsAdapterContract extends AbstractAdapterContract
|
|
|
1776
1776
|
contractType?: string;
|
|
1777
1777
|
};
|
|
1778
1778
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L132-L164 */
|
|
1779
|
-
|
|
1779
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
1780
1780
|
}
|
|
1781
1781
|
export {};
|
|
@@ -1776,6 +1776,6 @@ export declare class Curve4AssetsAdapterContract extends AbstractAdapterContract
|
|
|
1776
1776
|
contractType?: string;
|
|
1777
1777
|
};
|
|
1778
1778
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L132-L164 */
|
|
1779
|
-
|
|
1779
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
1780
1780
|
}
|
|
1781
1781
|
export {};
|
|
@@ -1040,6 +1040,6 @@ export declare class CurveV1AdapterDeposit extends AbstractAdapterContract<abi,
|
|
|
1040
1040
|
get tokens(): [Address, Address, Address, Address];
|
|
1041
1041
|
get underlyings(): [Address, Address, Address, Address];
|
|
1042
1042
|
/** Legacy adapter not present in integrations-v3. Go: Curve operations via operation_type.go L132-L164 */
|
|
1043
|
-
|
|
1043
|
+
classifyLegacyOperation(_parsed: ParsedCallV2, _transfers: Transfers): LegacyAdapterOperation;
|
|
1044
1044
|
}
|
|
1045
1045
|
export {};
|
|
@@ -1763,6 +1763,6 @@ export declare class CurveV1AdapterStETHContract extends AbstractAdapterContract
|
|
|
1763
1763
|
get use256(): boolean;
|
|
1764
1764
|
get tokens(): [Address, Address];
|
|
1765
1765
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L132-L164 */
|
|
1766
|
-
|
|
1766
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
1767
1767
|
}
|
|
1768
1768
|
export {};
|
|
@@ -1746,6 +1746,6 @@ export declare class CurveV1StableNGAdapterContract extends AbstractAdapterContr
|
|
|
1746
1746
|
contractType?: string;
|
|
1747
1747
|
};
|
|
1748
1748
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L132-L164 */
|
|
1749
|
-
|
|
1749
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
1750
1750
|
}
|
|
1751
1751
|
export {};
|
|
@@ -204,6 +204,6 @@ export declare class DaiUsdsAdapterContract extends AbstractAdapterContract<abi,
|
|
|
204
204
|
contractType?: string;
|
|
205
205
|
};
|
|
206
206
|
/** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L51-L68 */
|
|
207
|
-
|
|
207
|
+
classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
|
|
208
208
|
}
|
|
209
209
|
export {};
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { InnerOperation } from "../../history/index.js";
|
|
1
|
+
import type { Address } from "viem";
|
|
3
2
|
import type { OnchainSDK, ParsedCallV2 } from "../../sdk/index.js";
|
|
3
|
+
import type { InnerOperation } from "./types.js";
|
|
4
4
|
export interface ClassifyInnerOperationsProps {
|
|
5
5
|
sdk: OnchainSDK;
|
|
6
6
|
/** Underlying token of the credit manager, used for debt operations. */
|
|
@@ -10,12 +10,12 @@ export interface ClassifyInnerOperationsProps {
|
|
|
10
10
|
* Calldata-only counterpart of the SDK's `classifyMulticallOperations`.
|
|
11
11
|
*
|
|
12
12
|
* Maps each inner multicall entry to an {@link InnerOperation}:
|
|
13
|
-
* - adapter targets become
|
|
14
|
-
*
|
|
15
|
-
* -
|
|
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
16
|
*
|
|
17
|
-
*
|
|
18
|
-
* `legacy`
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
export declare function classifyInnerOperations(calls: ParsedCallV2[], props: ClassifyInnerOperationsProps): InnerOperation[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Hex } from "viem";
|
|
2
|
-
import type { OuterFacadeOperation } from "../../history/index.js";
|
|
3
2
|
import type { CreditFacadeV310Contract, OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import type { OuterFacadeOperation } from "./types.js";
|
|
4
4
|
export interface ParseFacadeOperationCalldataProps {
|
|
5
5
|
sdk: OnchainSDK;
|
|
6
6
|
/** Resolved credit facade contract for the transaction target. */
|
|
@@ -11,8 +11,9 @@ export interface ParseFacadeOperationCalldataProps {
|
|
|
11
11
|
* Decodes a credit-facade entry-point call into the matching
|
|
12
12
|
* {@link OuterFacadeOperation}.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* those are only known once the
|
|
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
|
|
16
17
|
* `zeroAddress` for `openCreditAccount` (the address is assigned on-chain).
|
|
17
18
|
*/
|
|
18
19
|
export declare function parseFacadeOperationCalldata(props: ParseFacadeOperationCalldataProps): OuterFacadeOperation;
|
|
@@ -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
|
+
}
|