sol-parser-sdk-nodejs 0.3.0 → 0.4.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/.env.example +24 -0
- package/README.md +94 -352
- package/README_CN.md +101 -253
- package/dist/accounts/mod.d.ts +2 -0
- package/dist/accounts/mod.js +5 -1
- package/dist/accounts/rpc_wallet.d.ts +5 -0
- package/dist/accounts/rpc_wallet.js +18 -0
- package/dist/accounts/rust_aliases.d.ts +9 -0
- package/dist/accounts/rust_aliases.js +19 -0
- package/dist/accounts/wallet_resolve.d.ts +1 -0
- package/dist/accounts/wallet_resolve.js +28 -0
- package/dist/common/constants.d.ts +10 -0
- package/dist/common/constants.js +13 -0
- package/dist/core/account_dispatcher_rpc.js +26 -5
- package/dist/core/account_fill_meteora.d.ts +4 -2
- package/dist/core/account_fill_meteora.js +5 -2
- package/dist/core/account_pubkey_cache.d.ts +12 -0
- package/dist/core/account_pubkey_cache.js +26 -0
- package/dist/core/clock.d.ts +6 -0
- package/dist/core/clock.js +13 -0
- package/dist/core/dex_event.d.ts +25 -44
- package/dist/core/metadata.d.ts +1 -0
- package/dist/core/unified_parser.d.ts +2 -2
- package/dist/core/unified_parser.js +6 -6
- package/dist/grpc/client.d.ts +6 -0
- package/dist/grpc/client.js +121 -64
- package/dist/grpc/event_parser.d.ts +6 -0
- package/dist/grpc/event_parser.js +15 -0
- package/dist/grpc/geyser_connect.d.ts +30 -0
- package/dist/grpc/geyser_connect.js +40 -0
- package/dist/grpc/program_ids.d.ts +25 -0
- package/dist/grpc/program_ids.js +54 -0
- package/dist/grpc/rpc_to_grpc.d.ts +18 -0
- package/dist/grpc/rpc_to_grpc.js +127 -0
- package/dist/grpc/subscribe_builder.d.ts +13 -0
- package/dist/grpc/subscribe_builder.js +66 -0
- package/dist/grpc/transaction_meta.d.ts +29 -0
- package/dist/grpc/transaction_meta.js +208 -0
- package/dist/grpc/types.d.ts +53 -2
- package/dist/grpc/types.js +98 -7
- package/dist/grpc/yellowstone_parse.d.ts +5 -0
- package/dist/grpc/yellowstone_parse.js +15 -2
- package/dist/index.d.ts +36 -6
- package/dist/index.js +172 -2
- package/dist/instr/bonk_ix.d.ts +4 -1
- package/dist/instr/bonk_ix.js +106 -27
- package/dist/instr/meteora_damm_ix.d.ts +4 -2
- package/dist/instr/meteora_damm_ix.js +248 -13
- package/dist/instr/mod.js +7 -2
- package/dist/instr/orca_whirlpool_ix.d.ts +4 -1
- package/dist/instr/orca_whirlpool_ix.js +45 -16
- package/dist/instr/program_ids.d.ts +7 -13
- package/dist/instr/program_ids.js +19 -15
- package/dist/instr/pumpswap_ix.d.ts +1 -1
- package/dist/instr/pumpswap_ix.js +78 -57
- package/dist/instr/raydium_amm_v4_ix.d.ts +1 -1
- package/dist/instr/raydium_amm_v4_ix.js +94 -28
- package/dist/instr/raydium_clmm_ix.d.ts +1 -1
- package/dist/instr/raydium_clmm_ix.js +59 -26
- package/dist/instr/raydium_cpmm_ix.d.ts +1 -1
- package/dist/instr/raydium_cpmm_ix.js +46 -12
- package/dist/instr/rust_aliases.d.ts +7 -0
- package/dist/instr/rust_aliases.js +14 -0
- package/dist/instr/utils.d.ts +1 -1
- package/dist/instr/utils.js +2 -1
- package/dist/logs/discriminator_lut.d.ts +19 -0
- package/dist/logs/discriminator_lut.js +60 -0
- package/dist/logs/meteora_damm.d.ts +3 -4
- package/dist/logs/meteora_damm.js +3 -369
- package/dist/logs/optimized_matcher.d.ts +2 -2
- package/dist/logs/optimized_matcher.js +3 -3
- package/dist/logs/rust_aliases.d.ts +6 -0
- package/dist/logs/rust_aliases.js +13 -0
- package/dist/rpc_parser.d.ts +1 -0
- package/dist/rpc_parser.js +4 -1
- package/dist/shredstream/alt_lookup.d.ts +9 -0
- package/dist/shredstream/alt_lookup.js +70 -0
- package/dist/shredstream/client.d.ts +62 -0
- package/dist/shredstream/client.js +399 -0
- package/dist/shredstream/config.d.ts +30 -0
- package/dist/shredstream/config.js +34 -0
- package/dist/shredstream/entries_decode.d.ts +28 -0
- package/dist/shredstream/entries_decode.js +251 -0
- package/dist/shredstream/index.d.ts +17 -0
- package/dist/shredstream/index.js +33 -0
- package/dist/shredstream/instruction_parse.d.ts +34 -0
- package/dist/shredstream/instruction_parse.js +47 -0
- package/dist/shredstream/proto_types.d.ts +9 -0
- package/dist/shredstream/proto_types.js +2 -0
- package/dist/shredstream/shredstream.proto +15 -0
- package/dist/shredstream/wire_to_shred_tx.d.ts +2 -0
- package/dist/shredstream/wire_to_shred_tx.js +59 -0
- package/package.json +28 -11
package/dist/grpc/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { SubscribeRequestFilterAccountsFilter } from "@triton-one/yellowstone-grpc";
|
|
1
2
|
/** gRPC 订阅顺序模式 */
|
|
2
3
|
export type OrderMode = "Unordered" | "Ordered" | "StreamingOrdered" | "MicroBatch";
|
|
4
|
+
/** 与 Rust `grpc::types::Protocol` 一致 */
|
|
5
|
+
export type Protocol = "PumpFun" | "PumpSwap" | "Bonk" | "RaydiumCpmm" | "RaydiumClmm" | "RaydiumAmmV4" | "MeteoraDammV2";
|
|
3
6
|
export type SlotStatus = "Processed" | "Confirmed" | "Finalized" | "FirstShredReceived" | "Completed" | "CreatedBank" | "Dead";
|
|
4
7
|
export interface SubscribeUpdateAccountInfo {
|
|
5
8
|
pubkey: Uint8Array;
|
|
@@ -75,6 +78,11 @@ export interface SubscribeCallbacks {
|
|
|
75
78
|
onUpdate?: (update: SubscribeUpdate) => void;
|
|
76
79
|
onError?: (err: Error) => void;
|
|
77
80
|
onEnd?: () => void;
|
|
81
|
+
/**
|
|
82
|
+
* 是否在流断开后自动重连(指数退避,与 Rust `subscribe_dex_events` 一致)。
|
|
83
|
+
* 默认 `true`。为 `false` 时保持单次连接的旧行为。
|
|
84
|
+
*/
|
|
85
|
+
autoReconnect?: boolean;
|
|
78
86
|
}
|
|
79
87
|
export interface ClientConfig {
|
|
80
88
|
enable_metrics: boolean;
|
|
@@ -91,15 +99,56 @@ export interface ClientConfig {
|
|
|
91
99
|
order_timeout_ms: number;
|
|
92
100
|
micro_batch_us: number;
|
|
93
101
|
}
|
|
102
|
+
/** 与 Rust `grpc::config` 中 `StreamingConfig` 别名(即 `ClientConfig`)一致 */
|
|
103
|
+
export type StreamingConfig = ClientConfig;
|
|
94
104
|
export declare function defaultClientConfig(): ClientConfig;
|
|
105
|
+
/** 与 Rust `ClientConfig::low_latency` 一致 */
|
|
106
|
+
export declare function lowLatencyClientConfig(): ClientConfig;
|
|
107
|
+
/** 与 Rust `ClientConfig::high_throughput` 一致 */
|
|
108
|
+
export declare function highThroughputClientConfig(): ClientConfig;
|
|
95
109
|
export interface TransactionFilter {
|
|
96
110
|
account_include: string[];
|
|
97
111
|
account_exclude: string[];
|
|
98
112
|
account_required: string[];
|
|
99
113
|
}
|
|
100
114
|
export declare function newTransactionFilter(): TransactionFilter;
|
|
115
|
+
/** 与 Rust `TransactionFilter::from_program_ids` 一致 */
|
|
116
|
+
export declare function transactionFilterFromProgramIds(programIds: string[]): TransactionFilter;
|
|
117
|
+
/** 与 Rust `grpc::AccountFilter` 一致(Yellowstone 账户订阅) */
|
|
118
|
+
export interface AccountFilter {
|
|
119
|
+
account: string[];
|
|
120
|
+
owner: string[];
|
|
121
|
+
filters: SubscribeRequestFilterAccountsFilter[];
|
|
122
|
+
}
|
|
123
|
+
/** 与 Rust `grpc::types::AccountFilterMemcmp` / `AccountFilterData` 一致(文档与扩展用) */
|
|
124
|
+
export interface AccountFilterMemcmp {
|
|
125
|
+
offset: number;
|
|
126
|
+
bytes: Uint8Array;
|
|
127
|
+
}
|
|
128
|
+
export interface AccountFilterData {
|
|
129
|
+
memcmp?: AccountFilterMemcmp;
|
|
130
|
+
datasize?: number;
|
|
131
|
+
}
|
|
132
|
+
export declare function newAccountFilter(): AccountFilter;
|
|
133
|
+
/** 与 Rust `grpc::types::SlotFilter` 一致 */
|
|
134
|
+
export interface SlotFilter {
|
|
135
|
+
min_slot?: number;
|
|
136
|
+
max_slot?: number;
|
|
137
|
+
}
|
|
138
|
+
export declare function newSlotFilter(): SlotFilter;
|
|
139
|
+
export declare function slotFilterMinSlot(filter: SlotFilter, slot: number): SlotFilter;
|
|
140
|
+
export declare function slotFilterMaxSlot(filter: SlotFilter, slot: number): SlotFilter;
|
|
141
|
+
/** 与 Rust `AccountFilter::from_program_owners` 一致 */
|
|
142
|
+
export declare function accountFilterFromProgramOwners(programIds: string[]): AccountFilter;
|
|
143
|
+
/**
|
|
144
|
+
* 构造 memcmp 账户过滤器(与 Rust `account_filter_memcmp` 一致)。
|
|
145
|
+
* ATA 常在 offset 0 放 mint;PumpSwap 池子等常在 offset 32。
|
|
146
|
+
*/
|
|
147
|
+
export declare function accountFilterMemcmp(offset: number, bytes: Uint8Array): SubscribeRequestFilterAccountsFilter;
|
|
101
148
|
/** 事件类型过滤标签 */
|
|
102
|
-
export type EventType = "BlockMeta" | "PumpFunTrade" | "PumpFunBuy" | "PumpFunSell" | "PumpFunBuyExactSolIn" | "PumpFunCreate" | "PumpFunCreateV2" | "PumpFunComplete" | "PumpFunMigrate" | "PumpSwapTrade" | "PumpSwapBuy" | "PumpSwapSell" | "PumpSwapCreatePool" | "PumpSwapLiquidityAdded" | "PumpSwapLiquidityRemoved" | "RaydiumClmmSwap" | "RaydiumClmmIncreaseLiquidity" | "RaydiumClmmDecreaseLiquidity" | "RaydiumClmmCreatePool" | "RaydiumClmmOpenPosition" | "RaydiumClmmOpenPositionWithTokenExtNft" | "RaydiumClmmClosePosition" | "RaydiumClmmCollectFee" | "RaydiumCpmmSwap" | "RaydiumCpmmDeposit" | "RaydiumCpmmWithdraw" | "RaydiumCpmmInitialize" | "RaydiumAmmV4Swap" | "RaydiumAmmV4Deposit" | "RaydiumAmmV4Withdraw" | "RaydiumAmmV4WithdrawPnl" | "RaydiumAmmV4Initialize2" | "OrcaWhirlpoolSwap" | "OrcaWhirlpoolLiquidityIncreased" | "OrcaWhirlpoolLiquidityDecreased" | "OrcaWhirlpoolPoolInitialized" | "MeteoraPoolsSwap" | "MeteoraPoolsAddLiquidity" | "MeteoraPoolsRemoveLiquidity" | "MeteoraPoolsBootstrapLiquidity" | "MeteoraPoolsPoolCreated" | "MeteoraPoolsSetPoolFees" | "MeteoraDammV2Swap" | "MeteoraDammV2AddLiquidity" | "MeteoraDammV2RemoveLiquidity" | "
|
|
149
|
+
export type EventType = "BlockMeta" | "PumpFunTrade" | "PumpFunBuy" | "PumpFunSell" | "PumpFunBuyExactSolIn" | "PumpFunCreate" | "PumpFunCreateV2" | "PumpFunComplete" | "PumpFunMigrate" | "PumpSwapTrade" | "PumpSwapBuy" | "PumpSwapSell" | "PumpSwapCreatePool" | "PumpSwapLiquidityAdded" | "PumpSwapLiquidityRemoved" | "RaydiumClmmSwap" | "RaydiumClmmIncreaseLiquidity" | "RaydiumClmmDecreaseLiquidity" | "RaydiumClmmCreatePool" | "RaydiumClmmOpenPosition" | "RaydiumClmmOpenPositionWithTokenExtNft" | "RaydiumClmmClosePosition" | "RaydiumClmmCollectFee" | "RaydiumCpmmSwap" | "RaydiumCpmmDeposit" | "RaydiumCpmmWithdraw" | "RaydiumCpmmInitialize" | "RaydiumAmmV4Swap" | "RaydiumAmmV4Deposit" | "RaydiumAmmV4Withdraw" | "RaydiumAmmV4WithdrawPnl" | "RaydiumAmmV4Initialize2" | "OrcaWhirlpoolSwap" | "OrcaWhirlpoolLiquidityIncreased" | "OrcaWhirlpoolLiquidityDecreased" | "OrcaWhirlpoolPoolInitialized" | "MeteoraPoolsSwap" | "MeteoraPoolsAddLiquidity" | "MeteoraPoolsRemoveLiquidity" | "MeteoraPoolsBootstrapLiquidity" | "MeteoraPoolsPoolCreated" | "MeteoraPoolsSetPoolFees" | "MeteoraDammV2Swap" | "MeteoraDammV2AddLiquidity" | "MeteoraDammV2RemoveLiquidity" | "MeteoraDammV2RemoveAllLiquidity" | "MeteoraDammV2CreatePosition" | "MeteoraDammV2InitializePool" | "MeteoraDammV2ClosePosition" | "MeteoraDlmmSwap" | "MeteoraDlmmAddLiquidity" | "MeteoraDlmmRemoveLiquidity" | "MeteoraDlmmInitializePool" | "MeteoraDlmmInitializeBinArray" | "MeteoraDlmmCreatePosition" | "MeteoraDlmmClosePosition" | "MeteoraDlmmClaimFee" | "BonkTrade" | "BonkPoolCreate" | "BonkMigrateAmm" | "TokenAccount" | "TokenInfo" | "NonceAccount" | "AccountPumpSwapGlobalConfig" | "AccountPumpSwapPool";
|
|
150
|
+
/** 与 Rust `grpc::EventType`(由 `StreamingEventType` 导出)一致 */
|
|
151
|
+
export type StreamingEventType = EventType;
|
|
103
152
|
/** 所有事件类型列表 */
|
|
104
153
|
export declare const ALL_EVENT_TYPES: EventType[];
|
|
105
154
|
export interface EventTypeFilter {
|
|
@@ -123,8 +172,10 @@ export declare function eventTypeFilterIncludesRaydiumCpmm(filter: EventTypeFilt
|
|
|
123
172
|
export declare function eventTypeFilterIncludesRaydiumAmmV4(filter: EventTypeFilter): boolean;
|
|
124
173
|
/** 过滤器是否包含 Orca Whirlpool 相关类型 */
|
|
125
174
|
export declare function eventTypeFilterIncludesOrcaWhirlpool(filter: EventTypeFilter): boolean;
|
|
126
|
-
/** 过滤器是否包含 Bonk Launchpad
|
|
175
|
+
/** 过滤器是否包含 Bonk Launchpad 相关类型(与 Rust `includes_raydium_launchpad` / Bonk 集合一致) */
|
|
127
176
|
export declare function eventTypeFilterIncludesBonk(filter: EventTypeFilter): boolean;
|
|
177
|
+
/** 与 Rust `EventTypeFilter::includes_raydium_launchpad` 同名语义 */
|
|
178
|
+
export declare function eventTypeFilterIncludesRaydiumLaunchpad(filter: EventTypeFilter): boolean;
|
|
128
179
|
/**
|
|
129
180
|
* `parseInstructionUnified` 前置白名单:仅当 `include_only` 与下列指令相关类型有交集时才解析指令。
|
|
130
181
|
* 若白名单中不含下列任一类型,则整条指令解析入口返回 null。
|
package/dist/grpc/types.js
CHANGED
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ALL_EVENT_TYPES = void 0;
|
|
4
4
|
exports.defaultClientConfig = defaultClientConfig;
|
|
5
|
+
exports.lowLatencyClientConfig = lowLatencyClientConfig;
|
|
6
|
+
exports.highThroughputClientConfig = highThroughputClientConfig;
|
|
5
7
|
exports.newTransactionFilter = newTransactionFilter;
|
|
8
|
+
exports.transactionFilterFromProgramIds = transactionFilterFromProgramIds;
|
|
9
|
+
exports.newAccountFilter = newAccountFilter;
|
|
10
|
+
exports.newSlotFilter = newSlotFilter;
|
|
11
|
+
exports.slotFilterMinSlot = slotFilterMinSlot;
|
|
12
|
+
exports.slotFilterMaxSlot = slotFilterMaxSlot;
|
|
13
|
+
exports.accountFilterFromProgramOwners = accountFilterFromProgramOwners;
|
|
14
|
+
exports.accountFilterMemcmp = accountFilterMemcmp;
|
|
6
15
|
exports.eventTypeFilterIncludeOnly = eventTypeFilterIncludeOnly;
|
|
7
16
|
exports.eventTypeFilterExclude = eventTypeFilterExclude;
|
|
8
17
|
exports.eventTypeFilterIncludesPumpfun = eventTypeFilterIncludesPumpfun;
|
|
@@ -13,6 +22,7 @@ exports.eventTypeFilterIncludesRaydiumCpmm = eventTypeFilterIncludesRaydiumCpmm;
|
|
|
13
22
|
exports.eventTypeFilterIncludesRaydiumAmmV4 = eventTypeFilterIncludesRaydiumAmmV4;
|
|
14
23
|
exports.eventTypeFilterIncludesOrcaWhirlpool = eventTypeFilterIncludesOrcaWhirlpool;
|
|
15
24
|
exports.eventTypeFilterIncludesBonk = eventTypeFilterIncludesBonk;
|
|
25
|
+
exports.eventTypeFilterIncludesRaydiumLaunchpad = eventTypeFilterIncludesRaydiumLaunchpad;
|
|
16
26
|
exports.eventTypeFilterAllowsInstructionParsing = eventTypeFilterAllowsInstructionParsing;
|
|
17
27
|
function defaultClientConfig() {
|
|
18
28
|
return {
|
|
@@ -31,9 +41,81 @@ function defaultClientConfig() {
|
|
|
31
41
|
micro_batch_us: 100,
|
|
32
42
|
};
|
|
33
43
|
}
|
|
44
|
+
/** 与 Rust `ClientConfig::low_latency` 一致 */
|
|
45
|
+
function lowLatencyClientConfig() {
|
|
46
|
+
return {
|
|
47
|
+
enable_metrics: false,
|
|
48
|
+
connection_timeout_ms: 5000,
|
|
49
|
+
request_timeout_ms: 10_000,
|
|
50
|
+
enable_tls: true,
|
|
51
|
+
max_retries: 1,
|
|
52
|
+
retry_delay_ms: 100,
|
|
53
|
+
max_concurrent_streams: 200,
|
|
54
|
+
keep_alive_interval_ms: 10_000,
|
|
55
|
+
keep_alive_timeout_ms: 2000,
|
|
56
|
+
buffer_size: 16384,
|
|
57
|
+
order_mode: "Unordered",
|
|
58
|
+
order_timeout_ms: 50,
|
|
59
|
+
micro_batch_us: 50,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** 与 Rust `ClientConfig::high_throughput` 一致 */
|
|
63
|
+
function highThroughputClientConfig() {
|
|
64
|
+
return {
|
|
65
|
+
enable_metrics: true,
|
|
66
|
+
connection_timeout_ms: 10_000,
|
|
67
|
+
request_timeout_ms: 30_000,
|
|
68
|
+
enable_tls: true,
|
|
69
|
+
max_retries: 5,
|
|
70
|
+
retry_delay_ms: 2000,
|
|
71
|
+
max_concurrent_streams: 500,
|
|
72
|
+
keep_alive_interval_ms: 60_000,
|
|
73
|
+
keep_alive_timeout_ms: 10_000,
|
|
74
|
+
buffer_size: 32768,
|
|
75
|
+
order_mode: "Unordered",
|
|
76
|
+
order_timeout_ms: 200,
|
|
77
|
+
micro_batch_us: 200,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
34
80
|
function newTransactionFilter() {
|
|
35
81
|
return { account_include: [], account_exclude: [], account_required: [] };
|
|
36
82
|
}
|
|
83
|
+
/** 与 Rust `TransactionFilter::from_program_ids` 一致 */
|
|
84
|
+
function transactionFilterFromProgramIds(programIds) {
|
|
85
|
+
return {
|
|
86
|
+
account_include: [...programIds],
|
|
87
|
+
account_exclude: [],
|
|
88
|
+
account_required: [],
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function newAccountFilter() {
|
|
92
|
+
return { account: [], owner: [], filters: [] };
|
|
93
|
+
}
|
|
94
|
+
function newSlotFilter() {
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
function slotFilterMinSlot(filter, slot) {
|
|
98
|
+
return { ...filter, min_slot: slot };
|
|
99
|
+
}
|
|
100
|
+
function slotFilterMaxSlot(filter, slot) {
|
|
101
|
+
return { ...filter, max_slot: slot };
|
|
102
|
+
}
|
|
103
|
+
/** 与 Rust `AccountFilter::from_program_owners` 一致 */
|
|
104
|
+
function accountFilterFromProgramOwners(programIds) {
|
|
105
|
+
return { account: [], owner: [...programIds], filters: [] };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 构造 memcmp 账户过滤器(与 Rust `account_filter_memcmp` 一致)。
|
|
109
|
+
* ATA 常在 offset 0 放 mint;PumpSwap 池子等常在 offset 32。
|
|
110
|
+
*/
|
|
111
|
+
function accountFilterMemcmp(offset, bytes) {
|
|
112
|
+
return {
|
|
113
|
+
memcmp: {
|
|
114
|
+
offset: String(offset),
|
|
115
|
+
bytes,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
37
119
|
/** 所有事件类型列表 */
|
|
38
120
|
exports.ALL_EVENT_TYPES = [
|
|
39
121
|
// Block
|
|
@@ -90,9 +172,10 @@ exports.ALL_EVENT_TYPES = [
|
|
|
90
172
|
"MeteoraDammV2Swap",
|
|
91
173
|
"MeteoraDammV2AddLiquidity",
|
|
92
174
|
"MeteoraDammV2RemoveLiquidity",
|
|
175
|
+
"MeteoraDammV2RemoveAllLiquidity",
|
|
93
176
|
"MeteoraDammV2CreatePosition",
|
|
94
|
-
"MeteoraDammV2ClosePosition",
|
|
95
177
|
"MeteoraDammV2InitializePool",
|
|
178
|
+
"MeteoraDammV2ClosePosition",
|
|
96
179
|
// Meteora DLMM
|
|
97
180
|
"MeteoraDlmmSwap",
|
|
98
181
|
"MeteoraDlmmAddLiquidity",
|
|
@@ -193,9 +276,10 @@ function eventTypeFilterIncludesMeteoraDammV2(filter) {
|
|
|
193
276
|
"MeteoraDammV2Swap",
|
|
194
277
|
"MeteoraDammV2AddLiquidity",
|
|
195
278
|
"MeteoraDammV2CreatePosition",
|
|
196
|
-
"MeteoraDammV2ClosePosition",
|
|
197
279
|
"MeteoraDammV2InitializePool",
|
|
280
|
+
"MeteoraDammV2ClosePosition",
|
|
198
281
|
"MeteoraDammV2RemoveLiquidity",
|
|
282
|
+
"MeteoraDammV2RemoveAllLiquidity",
|
|
199
283
|
].includes(t));
|
|
200
284
|
}
|
|
201
285
|
if (filter.exclude_types) {
|
|
@@ -203,9 +287,10 @@ function eventTypeFilterIncludesMeteoraDammV2(filter) {
|
|
|
203
287
|
"MeteoraDammV2Swap",
|
|
204
288
|
"MeteoraDammV2AddLiquidity",
|
|
205
289
|
"MeteoraDammV2CreatePosition",
|
|
206
|
-
"MeteoraDammV2ClosePosition",
|
|
207
290
|
"MeteoraDammV2InitializePool",
|
|
291
|
+
"MeteoraDammV2ClosePosition",
|
|
208
292
|
"MeteoraDammV2RemoveLiquidity",
|
|
293
|
+
"MeteoraDammV2RemoveAllLiquidity",
|
|
209
294
|
].includes(t));
|
|
210
295
|
}
|
|
211
296
|
return true;
|
|
@@ -276,16 +361,21 @@ function eventTypeFilterIncludesOrcaWhirlpool(filter) {
|
|
|
276
361
|
}
|
|
277
362
|
return true;
|
|
278
363
|
}
|
|
279
|
-
/** 过滤器是否包含 Bonk Launchpad
|
|
364
|
+
/** 过滤器是否包含 Bonk Launchpad 相关类型(与 Rust `includes_raydium_launchpad` / Bonk 集合一致) */
|
|
280
365
|
function eventTypeFilterIncludesBonk(filter) {
|
|
366
|
+
const bonk = ["BonkTrade", "BonkPoolCreate", "BonkMigrateAmm"];
|
|
281
367
|
if (filter.include_only) {
|
|
282
|
-
return filter.include_only.some((t) =>
|
|
368
|
+
return filter.include_only.some((t) => bonk.includes(t));
|
|
283
369
|
}
|
|
284
370
|
if (filter.exclude_types) {
|
|
285
|
-
return !filter.exclude_types.some((t) =>
|
|
371
|
+
return !filter.exclude_types.some((t) => bonk.includes(t));
|
|
286
372
|
}
|
|
287
373
|
return true;
|
|
288
374
|
}
|
|
375
|
+
/** 与 Rust `EventTypeFilter::includes_raydium_launchpad` 同名语义 */
|
|
376
|
+
function eventTypeFilterIncludesRaydiumLaunchpad(filter) {
|
|
377
|
+
return eventTypeFilterIncludesBonk(filter);
|
|
378
|
+
}
|
|
289
379
|
/**
|
|
290
380
|
* `parseInstructionUnified` 前置白名单:仅当 `include_only` 与下列指令相关类型有交集时才解析指令。
|
|
291
381
|
* 若白名单中不含下列任一类型,则整条指令解析入口返回 null。
|
|
@@ -296,9 +386,10 @@ function eventTypeFilterAllowsInstructionParsing(includeOnly) {
|
|
|
296
386
|
"MeteoraDammV2Swap",
|
|
297
387
|
"MeteoraDammV2AddLiquidity",
|
|
298
388
|
"MeteoraDammV2CreatePosition",
|
|
299
|
-
"MeteoraDammV2ClosePosition",
|
|
300
389
|
"MeteoraDammV2InitializePool",
|
|
390
|
+
"MeteoraDammV2ClosePosition",
|
|
301
391
|
"MeteoraDammV2RemoveLiquidity",
|
|
392
|
+
"MeteoraDammV2RemoveAllLiquidity",
|
|
302
393
|
];
|
|
303
394
|
return includeOnly.some((t) => ix.includes(t));
|
|
304
395
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { DexEvent } from "../core/dex_event.js";
|
|
2
2
|
import type { SubscribeUpdateTransactionInfo } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Yellowstone `SubscribeUpdateTransactionInfo.index` → `EventMetadata.tx_index`。
|
|
5
|
+
* 与 Rust `sol-parser-sdk` gRPC 路径中 `let idx = info.index` 传入 `parse_logs(..., idx, ...)` 一致。
|
|
6
|
+
*/
|
|
7
|
+
export declare function grpcTxIndexFromInfo(info: Pick<SubscribeUpdateTransactionInfo, "index">): number;
|
|
3
8
|
/**
|
|
4
9
|
* 从 gRPC 回调中的 `SubscribeUpdateTransactionInfo`(须含 `transactionRaw` + `metaRaw` 原始 proto)
|
|
5
10
|
* 解析 `DexEvent[]`,并对 PumpSwap/PumpFun 等补齐 mint、池子 ATA 等(与 Rust 订阅路径一致)。
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.grpcTxIndexFromInfo = grpcTxIndexFromInfo;
|
|
6
7
|
exports.parseDexEventsFromGrpcTransactionInfo = parseDexEventsFromGrpcTransactionInfo;
|
|
7
8
|
/**
|
|
8
9
|
* Yellowstone gRPC 单笔交易:日志解析 + 与 Rust `parse_logs` 相同的账户/数据填充。
|
|
@@ -14,6 +15,17 @@ const bs58_1 = __importDefault(require("bs58"));
|
|
|
14
15
|
const web3_js_1 = require("@solana/web3.js");
|
|
15
16
|
const unified_parser_js_1 = require("../core/unified_parser.js");
|
|
16
17
|
const rpc_transaction_js_1 = require("../rpc_transaction.js");
|
|
18
|
+
/**
|
|
19
|
+
* Yellowstone `SubscribeUpdateTransactionInfo.index` → `EventMetadata.tx_index`。
|
|
20
|
+
* 与 Rust `sol-parser-sdk` gRPC 路径中 `let idx = info.index` 传入 `parse_logs(..., idx, ...)` 一致。
|
|
21
|
+
*/
|
|
22
|
+
function grpcTxIndexFromInfo(info) {
|
|
23
|
+
const index = info.index;
|
|
24
|
+
if (index === undefined)
|
|
25
|
+
return 0;
|
|
26
|
+
const n = typeof index === "bigint" ? Number(index) : Number(index);
|
|
27
|
+
return Number.isFinite(n) && n >= 0 ? Math.floor(n) : 0;
|
|
28
|
+
}
|
|
17
29
|
/**
|
|
18
30
|
* 从 gRPC 回调中的 `SubscribeUpdateTransactionInfo`(须含 `transactionRaw` + `metaRaw` 原始 proto)
|
|
19
31
|
* 解析 `DexEvent[]`,并对 PumpSwap/PumpFun 等补齐 mint、池子 ATA 等(与 Rust 订阅路径一致)。
|
|
@@ -37,8 +49,9 @@ function parseDexEventsFromGrpcTransactionInfo(info, slot, options) {
|
|
|
37
49
|
if (!Array.isArray(logs) || logs.length === 0)
|
|
38
50
|
return [];
|
|
39
51
|
const slotNum = typeof slot === "bigint" ? Number(slot) : Number(slot);
|
|
40
|
-
const
|
|
41
|
-
const
|
|
52
|
+
const signatureBase58 = bs58_1.default.encode(Uint8Array.from(info.signature));
|
|
53
|
+
const txIndex = grpcTxIndexFromInfo(info);
|
|
54
|
+
const events = (0, unified_parser_js_1.parseLogsOnly)(logs, signatureBase58, slotNum, options?.blockTimeUs, txIndex);
|
|
42
55
|
if (events.length === 0)
|
|
43
56
|
return [];
|
|
44
57
|
(0, rpc_transaction_js_1.applyAccountFillsToLogEvents)(events, vt.message, meta);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,48 @@
|
|
|
1
|
+
export { DEFAULT_CHANNEL_SIZE, DEFAULT_CONNECT_TIMEOUT, DEFAULT_MAX_DECODING_MESSAGE_SIZE, DEFAULT_METRICS_PRINT_INTERVAL_SECONDS, DEFAULT_METRICS_WINDOW_SECONDS, DEFAULT_REQUEST_TIMEOUT, SLOW_PROCESSING_THRESHOLD_US, } from "./common/constants.js";
|
|
1
2
|
export type { DexEvent } from "./core/dex_event.js";
|
|
3
|
+
export { metadataForDexEvent, defaultPubkey } from "./core/dex_event.js";
|
|
2
4
|
export { bigintToJsonReplacer, dexEventToJsonString } from "./core/json_utils.js";
|
|
3
5
|
export type { EventMetadata } from "./core/metadata.js";
|
|
4
6
|
export type { ParseError } from "./core/error.js";
|
|
5
7
|
export { formatParseError } from "./core/error.js";
|
|
6
|
-
export { parseTransactionEvents, parseLogsOnly, parseTransactionWithListener, parseTransactionEventsStreaming, parseLogsStreaming, parseTransactionWithStreamingListener, parseLog, nowUs, type EventListener, type StreamingEventListener, } from "./core/unified_parser.js";
|
|
8
|
+
export { parseTransactionEvents, parseLogsOnly, parseTransactionWithListener, parseTransactionEventsStreaming, parseLogsStreaming, parseTransactionWithStreamingListener, parseLog, parseLog as parse_log, nowUs, type EventListener, type StreamingEventListener, } from "./core/unified_parser.js";
|
|
9
|
+
export { nowMicros, nowNanos, elapsedMicrosSince } from "./core/clock.js";
|
|
10
|
+
export { AccountPubkeyCache, buildAccountPubkeysWithCache, buildAccountPubkeysWithCache as build_account_pubkeys_with_cache, } from "./core/account_pubkey_cache.js";
|
|
7
11
|
export { warmupParser, isWarmedUp } from "./warmup.js";
|
|
8
|
-
export { parseTransactionFromRpc, parseRpcTransaction, fillAccountsFromTransactionDataRpc, fillDataRpc, applyAccountFillsToLogEvents, } from "./rpc_parser.js";
|
|
9
|
-
export { parseDexEventsFromGrpcTransactionInfo } from "./grpc/yellowstone_parse.js";
|
|
10
|
-
export {
|
|
12
|
+
export { parseTransactionFromRpc, parseRpcTransaction, fillAccountsFromTransactionDataRpc, fillDataRpc, applyAccountFillsToLogEvents, convertRpcToGrpc, convert_rpc_to_grpc, type ConvertRpcToGrpcOk, type ConvertRpcToGrpcErr, } from "./rpc_parser.js";
|
|
13
|
+
export { parseDexEventsFromGrpcTransactionInfo, grpcTxIndexFromInfo, } from "./grpc/yellowstone_parse.js";
|
|
14
|
+
export { pubkeyBytesToBs58, collectAccountKeysBs58, lamportBalanceDeltas, heuristicSolCounterpartiesForWatchedKeys, tokenBalanceRawAmount, splTokenCounterpartyByOwner, collectWatchTransferCounterpartyPairs, tryYellowstoneSignature, } from "./grpc/transaction_meta.js";
|
|
15
|
+
/** Rust `grpc::transaction_meta` 蛇形命名别名(便于从 Rust 迁移) */
|
|
16
|
+
export { pubkeyBytesToBs58 as pubkey_bytes_to_bs58, collectAccountKeysBs58 as collect_account_keys_bs58, lamportBalanceDeltas as lamport_balance_deltas, heuristicSolCounterpartiesForWatchedKeys as heuristic_sol_counterparties_for_watched_keys, tokenBalanceRawAmount as token_balance_raw_amount, splTokenCounterpartyByOwner as spl_token_counterparty_by_owner, collectWatchTransferCounterpartyPairs as collect_watch_transfer_counterparty_pairs, tryYellowstoneSignature as try_yellowstone_signature, } from "./grpc/transaction_meta.js";
|
|
17
|
+
export { type OrderMode, type Protocol, type ClientConfig, type StreamingConfig, type TransactionFilter, type AccountFilter, type AccountFilterData, type AccountFilterMemcmp, type SlotFilter, type EventType, type StreamingEventType, type EventTypeFilter, defaultClientConfig, lowLatencyClientConfig, highThroughputClientConfig, newTransactionFilter, transactionFilterFromProgramIds, newAccountFilter, newSlotFilter, slotFilterMinSlot, slotFilterMaxSlot, accountFilterFromProgramOwners, accountFilterMemcmp, eventTypeFilterIncludeOnly, eventTypeFilterExclude, eventTypeFilterIncludesPumpfun, eventTypeFilterIncludesPumpswap, eventTypeFilterIncludesMeteoraDammV2, eventTypeFilterIncludesRaydiumClmm, eventTypeFilterIncludesRaydiumCpmm, eventTypeFilterIncludesRaydiumAmmV4, eventTypeFilterIncludesOrcaWhirlpool, eventTypeFilterIncludesBonk, eventTypeFilterIncludesRaydiumLaunchpad, eventTypeFilterAllowsInstructionParsing, ALL_EVENT_TYPES, } from "./grpc/types.js";
|
|
18
|
+
export { ALL_EVENT_TYPES as all_event_types } from "./grpc/types.js";
|
|
19
|
+
export type { StreamingConfig as streaming_config } from "./grpc/types.js";
|
|
20
|
+
export { PROTOCOL_PROGRAM_IDS, PUMPFUN_PROGRAM_ID, PUMPSWAP_PROGRAM_ID, PUMPSWAP_FEES_PROGRAM_ID, BONK_PROGRAM_ID, RAYDIUM_CPMM_PROGRAM_ID, RAYDIUM_CLMM_PROGRAM_ID, RAYDIUM_AMM_V4_PROGRAM_ID, ORCA_WHIRLPOOL_PROGRAM_ID, METEORA_POOLS_PROGRAM_ID, METEORA_DAMM_V2_PROGRAM_ID, METEORA_DLMM_PROGRAM_ID, getProgramIdsForProtocols, transactionFilterForProtocols, accountFilterForProtocols, } from "./grpc/program_ids.js";
|
|
21
|
+
export { PROTOCOL_PROGRAM_IDS as protocol_program_ids, getProgramIdsForProtocols as get_program_ids_for_protocols, transactionFilterForProtocols as transaction_filter_for_protocols, accountFilterForProtocols as account_filter_for_protocols, } from "./grpc/program_ids.js";
|
|
22
|
+
/** Rust `grpc::types` 蛇形命名别名 */
|
|
23
|
+
export { defaultClientConfig as default_client_config, lowLatencyClientConfig as low_latency_client_config, highThroughputClientConfig as high_throughput_client_config, newTransactionFilter as new_transaction_filter, transactionFilterFromProgramIds as transaction_filter_from_program_ids, newAccountFilter as new_account_filter, newSlotFilter as new_slot_filter, slotFilterMinSlot as slot_filter_min_slot, slotFilterMaxSlot as slot_filter_max_slot, accountFilterFromProgramOwners as account_filter_from_program_owners, accountFilterMemcmp as account_filter_memcmp, eventTypeFilterIncludeOnly as event_type_filter_include_only, eventTypeFilterExclude as event_type_filter_exclude, eventTypeFilterIncludeOnly as include_only, eventTypeFilterExclude as exclude_types, } from "./grpc/types.js";
|
|
24
|
+
export { buildSubscribeRequest, buildSubscribeRequestWithCommitment, buildSubscribeTransactionFiltersNamed, CommitmentLevel, } from "./grpc/subscribe_builder.js";
|
|
25
|
+
/** Rust `grpc::subscribe_builder` 蛇形命名 */
|
|
26
|
+
export { buildSubscribeRequest as build_subscribe_request, buildSubscribeRequestWithCommitment as build_subscribe_request_with_commitment, buildSubscribeTransactionFiltersNamed as build_subscribe_transaction_filters_named, } from "./grpc/subscribe_builder.js";
|
|
11
27
|
export { parseLogUnified, parseLogOptimized } from "./logs/optimized_matcher.js";
|
|
12
|
-
|
|
28
|
+
/** Rust `logs` 蛇形命名别名(`parse_meteora_damm_log` 等) */
|
|
29
|
+
export { parse_meteora_damm_log, parse_meteora_dlmm_log, parse_log_optimized, parse_log_unified, } from "./logs/rust_aliases.js";
|
|
30
|
+
/** 与 Rust `logs::discriminator_lut` 名称 / 协议查询对齐 */
|
|
31
|
+
export { discriminatorToName, discriminator_to_name, discriminatorToProtocol, discriminator_to_protocol, lookupDiscriminator, lookup_discriminator, type LogProtocol, type LutDiscriminatorInfo, } from "./logs/discriminator_lut.js";
|
|
32
|
+
export { parseMeteoraDammLog } from "./logs/meteora_damm.js";
|
|
13
33
|
export { PROGRAM_LOG_DISC, PUMPSWAP_DISC, u64leDiscriminator, type ProgramLogDiscriminatorKey, } from "./logs/program_log_discriminators.js";
|
|
14
34
|
export type { ParsedEvent } from "./parser_alias.js";
|
|
15
|
-
export { parseAccountUnified, type AccountData, parseNonceAccount, isNonceAccount, parseTokenAccount, parsePumpswapGlobalConfig, parsePumpswapPool, parsePumpswapAccount, isGlobalConfigAccount, isPoolAccount, hasDiscriminator, } from "./accounts/mod.js";
|
|
35
|
+
export { parseAccountUnified, type AccountData, parseNonceAccount, isNonceAccount, parseTokenAccount, parsePumpswapGlobalConfig, parsePumpswapPool, parsePumpswapAccount, isGlobalConfigAccount, isPoolAccount, hasDiscriminator, userWalletPubkeyForOnchainAccount, rpcResolveUserWalletPubkey, } from "./accounts/mod.js";
|
|
36
|
+
/** Rust `accounts` 蛇形命名别名 */
|
|
37
|
+
export { parse_account_unified, parse_nonce_account, parse_token_account, parse_pumpswap_global_config, parse_pumpswap_pool, rpc_resolve_user_wallet_pubkey, user_wallet_pubkey_for_onchain_account, } from "./accounts/rust_aliases.js";
|
|
16
38
|
export { parseInstructionUnified, parsePumpfunInstruction, parsePumpswapInstruction, parseMeteoraDammInstruction, } from "./instr/mod.js";
|
|
39
|
+
/** Rust `instr` 根模块蛇形命名别名 */
|
|
40
|
+
export { parse_instruction_unified, parse_pumpfun_instruction, parse_pumpswap_instruction, parse_meteora_damm_instruction, } from "./instr/rust_aliases.js";
|
|
17
41
|
export * as programIds from "./instr/program_ids.js";
|
|
18
42
|
export { YellowstoneGrpc, type SubscribeCallbacks } from "./grpc/client.js";
|
|
43
|
+
export { connectYellowstoneGeyser, defaultGeyserConnectConfig, geyserGrpcChannelOptions, type GeyserConnectConfig, } from "./grpc/geyser_connect.js";
|
|
44
|
+
/** 与 Rust `sol_parser_sdk::grpc::event_parser` 模块对应 */
|
|
45
|
+
export * as event_parser from "./grpc/event_parser.js";
|
|
46
|
+
export { connectYellowstoneGeyser as connect_yellowstone_geyser, defaultGeyserConnectConfig as default_geyser_connect_config, geyserGrpcChannelOptions as geyser_grpc_channel_options, } from "./grpc/geyser_connect.js";
|
|
47
|
+
export { ShredStreamClient, ShredEventQueue, dexEventsFromShredWasmTx, dexEventsFromShredWasmTxWithFullKeys, fullAccountKeyStringsFromShredTx, loadAddressLookupTableAccounts, bincodeVecEntryCount, decodeEntriesBincodeFlat, decodeEntriesBincodeNested, decodeShredstreamEntriesBincode, wireBytesToShredWasmTx, type ShredStreamReceiveStats, type ShredWasmTx, type ShredWasmCompiledIx, type ShredStreamConfig, type DecodedWireTransaction, defaultShredStreamConfig, lowLatencyShredStreamConfig, highThroughputShredStreamConfig, type SubscribeEntriesRequest, type ShredstreamEntryMessage, } from "./shredstream/index.js";
|
|
48
|
+
export { defaultShredStreamConfig as default_shred_stream_config, lowLatencyShredStreamConfig as low_latency_shred_stream_config, highThroughputShredStreamConfig as high_throughput_shred_stream_config, } from "./shredstream/index.js";
|