sol-parser-sdk-nodejs 0.3.0 → 0.4.4
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 +100 -352
- package/README_CN.md +107 -253
- package/dist/accounts/mod.d.ts +3 -0
- package/dist/accounts/mod.js +18 -1
- package/dist/accounts/pumpfun.d.ts +6 -0
- package/dist/accounts/pumpfun.js +157 -0
- package/dist/accounts/rpc_wallet.d.ts +5 -0
- package/dist/accounts/rpc_wallet.js +18 -0
- package/dist/accounts/rust_aliases.d.ts +10 -0
- package/dist/accounts/rust_aliases.js +21 -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_fill_pumpfun.js +17 -0
- 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 +172 -44
- package/dist/core/metadata.d.ts +1 -0
- package/dist/core/pumpfun_fee_enrich.d.ts +4 -0
- package/dist/core/pumpfun_fee_enrich.js +80 -0
- package/dist/core/unified_parser.d.ts +2 -2
- package/dist/core/unified_parser.js +8 -6
- package/dist/grpc/client.d.ts +32 -1
- package/dist/grpc/client.js +400 -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/log_instr_dedup.d.ts +2 -0
- package/dist/grpc/log_instr_dedup.js +330 -0
- package/dist/grpc/order_buffer.d.ts +27 -0
- package/dist/grpc/order_buffer.js +166 -0
- package/dist/grpc/program_ids.d.ts +26 -0
- package/dist/grpc/program_ids.js +55 -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 +57 -2
- package/dist/grpc/types.js +199 -7
- package/dist/grpc/yellowstone_parse.d.ts +8 -1
- package/dist/grpc/yellowstone_parse.js +27 -11
- package/dist/index.d.ts +39 -8
- package/dist/index.js +184 -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.d.ts +1 -0
- package/dist/instr/mod.js +16 -3
- 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 +20 -15
- package/dist/instr/pump_fees_ix.d.ts +2 -0
- package/dist/instr/pump_fees_ix.js +166 -0
- package/dist/instr/pumpfun_ix.js +57 -0
- 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 +84 -30
- 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 +8 -0
- package/dist/instr/rust_aliases.js +16 -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 +62 -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 +123 -23
- package/dist/logs/program_log_discriminators.d.ts +10 -0
- package/dist/logs/program_log_discriminators.js +10 -0
- package/dist/logs/pump.d.ts +2 -0
- package/dist/logs/pump.js +51 -4
- package/dist/logs/pump_fees.d.ts +23 -0
- package/dist/logs/pump_fees.js +364 -0
- 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/rpc_transaction.d.ts +2 -0
- package/dist/rpc_transaction.js +14 -6
- 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 +49 -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/core/dex_event.d.ts
CHANGED
|
@@ -14,6 +14,26 @@ export type DexEvent = {
|
|
|
14
14
|
PumpFunBuyExactSolIn: PumpFunTradeEvent;
|
|
15
15
|
} | {
|
|
16
16
|
PumpFunMigrate: PumpFunMigrateEvent;
|
|
17
|
+
} | {
|
|
18
|
+
PumpFeesCreateFeeSharingConfig: PumpFeesCreateFeeSharingConfigEvent;
|
|
19
|
+
} | {
|
|
20
|
+
PumpFeesInitializeFeeConfig: PumpFeesInitializeFeeConfigEvent;
|
|
21
|
+
} | {
|
|
22
|
+
PumpFeesResetFeeSharingConfig: PumpFeesResetFeeSharingConfigEvent;
|
|
23
|
+
} | {
|
|
24
|
+
PumpFeesRevokeFeeSharingAuthority: PumpFeesRevokeFeeSharingAuthorityEvent;
|
|
25
|
+
} | {
|
|
26
|
+
PumpFeesTransferFeeSharingAuthority: PumpFeesTransferFeeSharingAuthorityEvent;
|
|
27
|
+
} | {
|
|
28
|
+
PumpFeesUpdateAdmin: PumpFeesUpdateAdminEvent;
|
|
29
|
+
} | {
|
|
30
|
+
PumpFeesUpdateFeeConfig: PumpFeesUpdateFeeConfigEvent;
|
|
31
|
+
} | {
|
|
32
|
+
PumpFeesUpdateFeeShares: PumpFeesUpdateFeeSharesEvent;
|
|
33
|
+
} | {
|
|
34
|
+
PumpFeesUpsertFeeTiers: PumpFeesUpsertFeeTiersEvent;
|
|
35
|
+
} | {
|
|
36
|
+
PumpFunMigrateBondingCurveCreator: PumpFunMigrateBondingCurveCreatorEvent;
|
|
17
37
|
} | {
|
|
18
38
|
PumpSwapTrade: PumpSwapTradeEvent;
|
|
19
39
|
} | {
|
|
@@ -87,11 +107,13 @@ export type DexEvent = {
|
|
|
87
107
|
} | {
|
|
88
108
|
MeteoraDammV2RemoveLiquidity: MeteoraDammV2RemoveLiquidityEvent;
|
|
89
109
|
} | {
|
|
90
|
-
|
|
110
|
+
MeteoraDammV2RemoveAllLiquidity: MeteoraDammV2RemoveAllLiquidityEvent;
|
|
91
111
|
} | {
|
|
92
|
-
|
|
112
|
+
MeteoraDammV2CreatePosition: MeteoraDammV2CreatePositionEvent;
|
|
93
113
|
} | {
|
|
94
114
|
MeteoraDammV2InitializePool: MeteoraDammV2InitializePoolEvent;
|
|
115
|
+
} | {
|
|
116
|
+
MeteoraDammV2ClosePosition: MeteoraDammV2ClosePositionEvent;
|
|
95
117
|
} | {
|
|
96
118
|
MeteoraDlmmSwap: MeteoraDlmmSwapEvent;
|
|
97
119
|
} | {
|
|
@@ -120,6 +142,8 @@ export type DexEvent = {
|
|
|
120
142
|
TokenAccount: TokenAccountEvent;
|
|
121
143
|
} | {
|
|
122
144
|
NonceAccount: NonceAccountEvent;
|
|
145
|
+
} | {
|
|
146
|
+
PumpFunGlobalAccount: PumpFunGlobalAccountEvent;
|
|
123
147
|
} | {
|
|
124
148
|
PumpSwapGlobalConfigAccount: PumpSwapGlobalConfigAccountEvent;
|
|
125
149
|
} | {
|
|
@@ -160,6 +184,7 @@ export interface PumpFunCreateV2TokenEvent extends PumpFunCreateTokenEvent {
|
|
|
160
184
|
mayhem_token_vault: string;
|
|
161
185
|
event_authority: string;
|
|
162
186
|
program: string;
|
|
187
|
+
observed_fee_recipient: string;
|
|
163
188
|
}
|
|
164
189
|
export interface PumpFunTradeEvent {
|
|
165
190
|
metadata: EventMetadata;
|
|
@@ -207,6 +232,103 @@ export interface PumpFunMigrateEvent {
|
|
|
207
232
|
timestamp: bigint;
|
|
208
233
|
pool: string;
|
|
209
234
|
}
|
|
235
|
+
export interface PumpFeesShareholder {
|
|
236
|
+
address: string;
|
|
237
|
+
share_bps: number;
|
|
238
|
+
}
|
|
239
|
+
export type PumpFeesConfigStatus = "Paused" | "Active";
|
|
240
|
+
export interface PumpFeesFees {
|
|
241
|
+
lp_fee_bps: bigint;
|
|
242
|
+
protocol_fee_bps: bigint;
|
|
243
|
+
creator_fee_bps: bigint;
|
|
244
|
+
}
|
|
245
|
+
export interface PumpFeesFeeTier {
|
|
246
|
+
market_cap_lamports_threshold: bigint;
|
|
247
|
+
fees: PumpFeesFees;
|
|
248
|
+
}
|
|
249
|
+
export interface PumpFeesCreateFeeSharingConfigEvent {
|
|
250
|
+
metadata: EventMetadata;
|
|
251
|
+
timestamp: bigint;
|
|
252
|
+
mint: string;
|
|
253
|
+
bonding_curve: string;
|
|
254
|
+
pool?: string;
|
|
255
|
+
sharing_config: string;
|
|
256
|
+
admin: string;
|
|
257
|
+
initial_shareholders: PumpFeesShareholder[];
|
|
258
|
+
status: PumpFeesConfigStatus;
|
|
259
|
+
}
|
|
260
|
+
export interface PumpFeesInitializeFeeConfigEvent {
|
|
261
|
+
metadata: EventMetadata;
|
|
262
|
+
timestamp: bigint;
|
|
263
|
+
admin: string;
|
|
264
|
+
fee_config: string;
|
|
265
|
+
}
|
|
266
|
+
export interface PumpFeesResetFeeSharingConfigEvent {
|
|
267
|
+
metadata: EventMetadata;
|
|
268
|
+
timestamp: bigint;
|
|
269
|
+
mint: string;
|
|
270
|
+
sharing_config: string;
|
|
271
|
+
old_admin: string;
|
|
272
|
+
old_shareholders: PumpFeesShareholder[];
|
|
273
|
+
new_admin: string;
|
|
274
|
+
new_shareholders: PumpFeesShareholder[];
|
|
275
|
+
}
|
|
276
|
+
export interface PumpFeesRevokeFeeSharingAuthorityEvent {
|
|
277
|
+
metadata: EventMetadata;
|
|
278
|
+
timestamp: bigint;
|
|
279
|
+
mint: string;
|
|
280
|
+
sharing_config: string;
|
|
281
|
+
admin: string;
|
|
282
|
+
}
|
|
283
|
+
export interface PumpFeesTransferFeeSharingAuthorityEvent {
|
|
284
|
+
metadata: EventMetadata;
|
|
285
|
+
timestamp: bigint;
|
|
286
|
+
mint: string;
|
|
287
|
+
sharing_config: string;
|
|
288
|
+
old_admin: string;
|
|
289
|
+
new_admin: string;
|
|
290
|
+
}
|
|
291
|
+
export interface PumpFeesUpdateAdminEvent {
|
|
292
|
+
metadata: EventMetadata;
|
|
293
|
+
timestamp: bigint;
|
|
294
|
+
old_admin: string;
|
|
295
|
+
new_admin: string;
|
|
296
|
+
}
|
|
297
|
+
export interface PumpFeesUpdateFeeConfigEvent {
|
|
298
|
+
metadata: EventMetadata;
|
|
299
|
+
timestamp: bigint;
|
|
300
|
+
admin: string;
|
|
301
|
+
fee_config: string;
|
|
302
|
+
fee_tiers: PumpFeesFeeTier[];
|
|
303
|
+
flat_fees: PumpFeesFees;
|
|
304
|
+
}
|
|
305
|
+
export interface PumpFeesUpdateFeeSharesEvent {
|
|
306
|
+
metadata: EventMetadata;
|
|
307
|
+
timestamp: bigint;
|
|
308
|
+
mint: string;
|
|
309
|
+
sharing_config: string;
|
|
310
|
+
admin: string;
|
|
311
|
+
bonding_curve: string;
|
|
312
|
+
pump_creator_vault: string;
|
|
313
|
+
new_shareholders: PumpFeesShareholder[];
|
|
314
|
+
}
|
|
315
|
+
export interface PumpFeesUpsertFeeTiersEvent {
|
|
316
|
+
metadata: EventMetadata;
|
|
317
|
+
timestamp: bigint;
|
|
318
|
+
admin: string;
|
|
319
|
+
fee_config: string;
|
|
320
|
+
fee_tiers: PumpFeesFeeTier[];
|
|
321
|
+
offset: number;
|
|
322
|
+
}
|
|
323
|
+
export interface PumpFunMigrateBondingCurveCreatorEvent {
|
|
324
|
+
metadata: EventMetadata;
|
|
325
|
+
timestamp: bigint;
|
|
326
|
+
mint: string;
|
|
327
|
+
bonding_curve: string;
|
|
328
|
+
sharing_config: string;
|
|
329
|
+
old_creator: string;
|
|
330
|
+
new_creator: string;
|
|
331
|
+
}
|
|
210
332
|
/** 与 `PumpSwapTradeEvent`(IDL TradeEvent)对齐 */
|
|
211
333
|
export interface PumpSwapTradeEvent {
|
|
212
334
|
metadata: EventMetadata;
|
|
@@ -761,67 +883,46 @@ export interface MeteoraDammV2RemoveLiquidityEvent {
|
|
|
761
883
|
token_a_amount_threshold: bigint;
|
|
762
884
|
token_b_amount_threshold: bigint;
|
|
763
885
|
}
|
|
764
|
-
/**
|
|
765
|
-
export interface
|
|
886
|
+
/** 外层 `remove_all_liquidity`;指令仅含两 u64 阈值,无 `liquidity_delta`。 */
|
|
887
|
+
export interface MeteoraDammV2RemoveAllLiquidityEvent {
|
|
766
888
|
metadata: EventMetadata;
|
|
767
889
|
pool: string;
|
|
768
|
-
owner: string;
|
|
769
890
|
position: string;
|
|
770
|
-
|
|
891
|
+
owner: string;
|
|
892
|
+
token_a_amount_threshold: bigint;
|
|
893
|
+
token_b_amount_threshold: bigint;
|
|
771
894
|
}
|
|
772
|
-
/** 与 `
|
|
773
|
-
export interface
|
|
895
|
+
/** 与 `MeteoraDammV2CreatePositionEvent` 对齐 */
|
|
896
|
+
export interface MeteoraDammV2CreatePositionEvent {
|
|
774
897
|
metadata: EventMetadata;
|
|
775
898
|
pool: string;
|
|
776
899
|
owner: string;
|
|
777
900
|
position: string;
|
|
778
901
|
position_nft_mint: string;
|
|
779
902
|
}
|
|
780
|
-
/** Meteora `cp-amm` `DynamicFeeParameters`(Anchor 序列化) */
|
|
781
|
-
export interface MeteoraDammV2DynamicFeeParameters {
|
|
782
|
-
bin_step: number;
|
|
783
|
-
bin_step_u128: bigint;
|
|
784
|
-
filter_period: number;
|
|
785
|
-
decay_period: number;
|
|
786
|
-
reduction_factor: number;
|
|
787
|
-
max_volatility_accumulator: number;
|
|
788
|
-
variable_fee_control: number;
|
|
789
|
-
}
|
|
790
|
-
/** Meteora `cp-amm` `PoolFeeParameters`(Anchor 序列化解析) */
|
|
791
|
-
export interface MeteoraDammV2PoolFeeParameters {
|
|
792
|
-
/** `BaseFeeParameters.data`,27 字节十六进制 */
|
|
793
|
-
base_fee_data: string;
|
|
794
|
-
compounding_fee_bps: number;
|
|
795
|
-
padding: number;
|
|
796
|
-
dynamic_fee: MeteoraDammV2DynamicFeeParameters | null;
|
|
797
|
-
}
|
|
798
903
|
/**
|
|
799
|
-
*
|
|
800
|
-
* Go/Python 中 `
|
|
904
|
+
* 外层 `initialize_pool`(`InitializePoolParameters`);无日志时仅含指令内字段与账户索引映射。
|
|
905
|
+
* Go/Python 中 `liquidity` / `sqrt_price` 为十进制字符串;`activation_point` 为 `None` 或十进制字符串。
|
|
801
906
|
*/
|
|
802
907
|
export interface MeteoraDammV2InitializePoolEvent {
|
|
803
908
|
metadata: EventMetadata;
|
|
909
|
+
creator: string;
|
|
910
|
+
position_nft_mint: string;
|
|
804
911
|
pool: string;
|
|
912
|
+
position: string;
|
|
805
913
|
token_a_mint: string;
|
|
806
914
|
token_b_mint: string;
|
|
807
|
-
creator: string;
|
|
808
|
-
payer: string;
|
|
809
|
-
alpha_vault: string;
|
|
810
|
-
pool_fees: MeteoraDammV2PoolFeeParameters;
|
|
811
|
-
sqrt_min_price: bigint;
|
|
812
|
-
sqrt_max_price: bigint;
|
|
813
|
-
activation_type: number;
|
|
814
|
-
collect_fee_mode: number;
|
|
815
915
|
liquidity: bigint;
|
|
816
916
|
sqrt_price: bigint;
|
|
817
|
-
activation_point: bigint;
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
917
|
+
activation_point: bigint | null;
|
|
918
|
+
}
|
|
919
|
+
/** 与 `MeteoraDammV2ClosePositionEvent` 对齐 */
|
|
920
|
+
export interface MeteoraDammV2ClosePositionEvent {
|
|
921
|
+
metadata: EventMetadata;
|
|
922
|
+
pool: string;
|
|
923
|
+
owner: string;
|
|
924
|
+
position: string;
|
|
925
|
+
position_nft_mint: string;
|
|
825
926
|
}
|
|
826
927
|
/** Meteora DLMM Swap:`fee_bps` 在 Go/Python 为十进制字符串。 */
|
|
827
928
|
export interface MeteoraDlmmSwapEvent {
|
|
@@ -957,6 +1058,33 @@ export interface NonceAccountEvent {
|
|
|
957
1058
|
nonce: string;
|
|
958
1059
|
authority: string;
|
|
959
1060
|
}
|
|
1061
|
+
export interface PumpFunGlobal {
|
|
1062
|
+
initialized: boolean;
|
|
1063
|
+
authority: string;
|
|
1064
|
+
fee_recipient: string;
|
|
1065
|
+
initial_virtual_token_reserves: bigint;
|
|
1066
|
+
initial_virtual_sol_reserves: bigint;
|
|
1067
|
+
initial_real_token_reserves: bigint;
|
|
1068
|
+
token_total_supply: bigint;
|
|
1069
|
+
fee_basis_points: bigint;
|
|
1070
|
+
withdraw_authority: string;
|
|
1071
|
+
enable_migrate: boolean;
|
|
1072
|
+
pool_migration_fee: bigint;
|
|
1073
|
+
creator_fee_basis_points: bigint;
|
|
1074
|
+
fee_recipients: string[];
|
|
1075
|
+
set_creator_authority: string;
|
|
1076
|
+
admin_set_creator_authority: string;
|
|
1077
|
+
create_v2_enabled: boolean;
|
|
1078
|
+
whitelist_pda: string;
|
|
1079
|
+
reserved_fee_recipient: string;
|
|
1080
|
+
mayhem_mode_enabled: boolean;
|
|
1081
|
+
reserved_fee_recipients: string[];
|
|
1082
|
+
}
|
|
1083
|
+
export interface PumpFunGlobalAccountEvent {
|
|
1084
|
+
metadata: EventMetadata;
|
|
1085
|
+
pubkey: string;
|
|
1086
|
+
global: PumpFunGlobal;
|
|
1087
|
+
}
|
|
960
1088
|
export interface PumpSwapGlobalConfig {
|
|
961
1089
|
admin: string;
|
|
962
1090
|
lp_fee_basis_points: bigint;
|
package/dist/core/metadata.d.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DexEvent } from "./dex_event.js";
|
|
2
|
+
export declare function enrichCreateV2ObservedFeeRecipient(events: DexEvent[]): void;
|
|
3
|
+
export declare function enrichPumpfunTradesFromCreateInstructions(events: DexEvent[]): void;
|
|
4
|
+
export declare function enrichPumpfunSameTxPostMerge(events: DexEvent[]): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enrichCreateV2ObservedFeeRecipient = enrichCreateV2ObservedFeeRecipient;
|
|
4
|
+
exports.enrichPumpfunTradesFromCreateInstructions = enrichPumpfunTradesFromCreateInstructions;
|
|
5
|
+
exports.enrichPumpfunSameTxPostMerge = enrichPumpfunSameTxPostMerge;
|
|
6
|
+
const dex_event_js_1 = require("./dex_event.js");
|
|
7
|
+
function pumpfunTradeEvent(ev) {
|
|
8
|
+
if ("PumpFunTrade" in ev)
|
|
9
|
+
return ev.PumpFunTrade;
|
|
10
|
+
if ("PumpFunBuy" in ev)
|
|
11
|
+
return ev.PumpFunBuy;
|
|
12
|
+
if ("PumpFunSell" in ev)
|
|
13
|
+
return ev.PumpFunSell;
|
|
14
|
+
if ("PumpFunBuyExactSolIn" in ev)
|
|
15
|
+
return ev.PumpFunBuyExactSolIn;
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
function pumpfunCreateFlags(ev) {
|
|
19
|
+
let c = null;
|
|
20
|
+
if ("PumpFunCreate" in ev)
|
|
21
|
+
c = ev.PumpFunCreate;
|
|
22
|
+
if ("PumpFunCreateV2" in ev)
|
|
23
|
+
c = ev.PumpFunCreateV2;
|
|
24
|
+
if (!c || !c.mint || c.mint === (0, dex_event_js_1.defaultPubkey)())
|
|
25
|
+
return null;
|
|
26
|
+
return [c.mint, c.is_cashback_enabled, c.is_mayhem_mode];
|
|
27
|
+
}
|
|
28
|
+
function enrichCreateV2ObservedFeeRecipient(events) {
|
|
29
|
+
const zero = (0, dex_event_js_1.defaultPubkey)();
|
|
30
|
+
const mintToFee = new Map();
|
|
31
|
+
for (const ev of events) {
|
|
32
|
+
const t = pumpfunTradeEvent(ev);
|
|
33
|
+
if (!t || !t.mint || t.mint === zero || !t.fee_recipient || t.fee_recipient === zero) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const buyLike = ("PumpFunTrade" in ev && t.is_buy) ||
|
|
37
|
+
"PumpFunBuy" in ev ||
|
|
38
|
+
"PumpFunBuyExactSolIn" in ev;
|
|
39
|
+
if (buyLike && !mintToFee.has(t.mint)) {
|
|
40
|
+
mintToFee.set(t.mint, t.fee_recipient);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (mintToFee.size === 0)
|
|
44
|
+
return;
|
|
45
|
+
for (const ev of events) {
|
|
46
|
+
if (!("PumpFunCreateV2" in ev))
|
|
47
|
+
continue;
|
|
48
|
+
const c = ev.PumpFunCreateV2;
|
|
49
|
+
if (!c.observed_fee_recipient || c.observed_fee_recipient === zero) {
|
|
50
|
+
c.observed_fee_recipient = mintToFee.get(c.mint) ?? c.observed_fee_recipient;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function enrichPumpfunTradesFromCreateInstructions(events) {
|
|
55
|
+
const flags = new Map();
|
|
56
|
+
for (const ev of events) {
|
|
57
|
+
const f = pumpfunCreateFlags(ev);
|
|
58
|
+
if (f && !flags.has(f[0]))
|
|
59
|
+
flags.set(f[0], [f[1], f[2]]);
|
|
60
|
+
}
|
|
61
|
+
if (flags.size === 0)
|
|
62
|
+
return;
|
|
63
|
+
for (const ev of events) {
|
|
64
|
+
const t = pumpfunTradeEvent(ev);
|
|
65
|
+
if (!t || !t.mint || t.mint === (0, dex_event_js_1.defaultPubkey)())
|
|
66
|
+
continue;
|
|
67
|
+
const f = flags.get(t.mint);
|
|
68
|
+
if (!f)
|
|
69
|
+
continue;
|
|
70
|
+
const [cashbackEnabled, mayhemMode] = f;
|
|
71
|
+
t.is_cashback_coin ||= cashbackEnabled;
|
|
72
|
+
t.mayhem_mode ||= mayhemMode;
|
|
73
|
+
if (cashbackEnabled)
|
|
74
|
+
t.track_volume = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function enrichPumpfunSameTxPostMerge(events) {
|
|
78
|
+
enrichCreateV2ObservedFeeRecipient(events);
|
|
79
|
+
enrichPumpfunTradesFromCreateInstructions(events);
|
|
80
|
+
}
|
|
@@ -9,10 +9,10 @@ export type StreamingEventListener = {
|
|
|
9
9
|
};
|
|
10
10
|
/** 从交易解析事件;当前主路径为日志解析 */
|
|
11
11
|
export declare function parseTransactionEvents(_instructionData: Uint8Array, _accounts: string[], logs: string[], signature: string, slot: number, _txIndex: number, blockTimeUs: number | undefined, _programId: string): DexEvent[];
|
|
12
|
-
export declare function parseLogsOnly(logs: string[], signature: string, slot: number, blockTimeUs: number | undefined): DexEvent[];
|
|
12
|
+
export declare function parseLogsOnly(logs: string[], signature: string, slot: number, blockTimeUs: number | undefined, txIndex?: number): DexEvent[];
|
|
13
13
|
export declare function parseTransactionWithListener(instructionData: Uint8Array, accounts: string[], logs: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, programId: string, listener: EventListener): void;
|
|
14
14
|
export declare function parseTransactionEventsStreaming(_instructionData: Uint8Array, _accounts: string[], logs: string[], signature: string, slot: number, _txIndex: number, blockTimeUs: number | undefined, _programId: string, callback: (event: DexEvent) => void): void;
|
|
15
|
-
export declare function parseLogsStreaming(logs: string[], signature: string, slot: number, blockTimeUs: number | undefined, callback: (event: DexEvent) => void): void;
|
|
15
|
+
export declare function parseLogsStreaming(logs: string[], signature: string, slot: number, blockTimeUs: number | undefined, callback: (event: DexEvent) => void, txIndex?: number): void;
|
|
16
16
|
export declare function parseTransactionWithStreamingListener(instructionData: Uint8Array, accounts: string[], logs: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, programId: string, listener: StreamingEventListener): void;
|
|
17
17
|
/** 带完整 gRPC 元数据字段的日志解析 */
|
|
18
18
|
export declare function parseLog(log: string, signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, eventTypeFilter: EventTypeFilter | undefined, isCreatedBuy: boolean, recentBlockhash?: Uint8Array): DexEvent | null;
|
|
@@ -8,20 +8,22 @@ exports.parseTransactionEventsStreaming = parseTransactionEventsStreaming;
|
|
|
8
8
|
exports.parseLogsStreaming = parseLogsStreaming;
|
|
9
9
|
exports.parseTransactionWithStreamingListener = parseTransactionWithStreamingListener;
|
|
10
10
|
exports.parseLog = parseLog;
|
|
11
|
+
const pumpfun_fee_enrich_js_1 = require("./pumpfun_fee_enrich.js");
|
|
11
12
|
const optimized_matcher_js_1 = require("../logs/optimized_matcher.js");
|
|
12
13
|
const clock_js_1 = require("./clock.js");
|
|
13
14
|
Object.defineProperty(exports, "nowUs", { enumerable: true, get: function () { return clock_js_1.nowUs; } });
|
|
14
15
|
/** 从交易解析事件;当前主路径为日志解析 */
|
|
15
16
|
function parseTransactionEvents(_instructionData, _accounts, logs, signature, slot, _txIndex, blockTimeUs, _programId) {
|
|
16
|
-
return parseLogsOnly(logs, signature, slot, blockTimeUs);
|
|
17
|
+
return parseLogsOnly(logs, signature, slot, blockTimeUs, _txIndex);
|
|
17
18
|
}
|
|
18
|
-
function parseLogsOnly(logs, signature, slot, blockTimeUs) {
|
|
19
|
+
function parseLogsOnly(logs, signature, slot, blockTimeUs, txIndex = 0) {
|
|
19
20
|
const out = [];
|
|
20
21
|
for (const log of logs) {
|
|
21
|
-
const e = (0, optimized_matcher_js_1.parseLogUnified)(log, signature, slot, blockTimeUs);
|
|
22
|
+
const e = (0, optimized_matcher_js_1.parseLogUnified)(log, signature, slot, blockTimeUs, txIndex);
|
|
22
23
|
if (e)
|
|
23
24
|
out.push(e);
|
|
24
25
|
}
|
|
26
|
+
(0, pumpfun_fee_enrich_js_1.enrichPumpfunSameTxPostMerge)(out);
|
|
25
27
|
return out;
|
|
26
28
|
}
|
|
27
29
|
function parseTransactionWithListener(instructionData, accounts, logs, signature, slot, txIndex, blockTimeUs, programId, listener) {
|
|
@@ -30,11 +32,11 @@ function parseTransactionWithListener(instructionData, accounts, logs, signature
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
function parseTransactionEventsStreaming(_instructionData, _accounts, logs, signature, slot, _txIndex, blockTimeUs, _programId, callback) {
|
|
33
|
-
parseLogsStreaming(logs, signature, slot, blockTimeUs, callback);
|
|
35
|
+
parseLogsStreaming(logs, signature, slot, blockTimeUs, callback, _txIndex);
|
|
34
36
|
}
|
|
35
|
-
function parseLogsStreaming(logs, signature, slot, blockTimeUs, callback) {
|
|
37
|
+
function parseLogsStreaming(logs, signature, slot, blockTimeUs, callback, txIndex = 0) {
|
|
36
38
|
for (const log of logs) {
|
|
37
|
-
const e = (0, optimized_matcher_js_1.parseLogUnified)(log, signature, slot, blockTimeUs);
|
|
39
|
+
const e = (0, optimized_matcher_js_1.parseLogUnified)(log, signature, slot, blockTimeUs, txIndex);
|
|
38
40
|
if (e)
|
|
39
41
|
callback(e);
|
|
40
42
|
}
|
package/dist/grpc/client.d.ts
CHANGED
|
@@ -2,14 +2,22 @@
|
|
|
2
2
|
* Yellowstone gRPC 客户端实现 - 基于 @triton-one/yellowstone-grpc
|
|
3
3
|
*/
|
|
4
4
|
import { CommitmentLevel } from "@triton-one/yellowstone-grpc";
|
|
5
|
-
import
|
|
5
|
+
import type { DexEvent } from "../core/dex_event.js";
|
|
6
|
+
import { type AccountFilter, type ClientConfig, type EventTypeFilter, type TransactionFilter, type SubscribeCallbacks } from "./types.js";
|
|
6
7
|
export { SubscribeCallbacks };
|
|
8
|
+
export interface DexEventSubscription extends AsyncIterable<DexEvent> {
|
|
9
|
+
id: string;
|
|
10
|
+
errors: AsyncIterable<Error>;
|
|
11
|
+
cancel(): void;
|
|
12
|
+
next(): Promise<IteratorResult<DexEvent>>;
|
|
13
|
+
}
|
|
7
14
|
/** Yellowstone gRPC 客户端包装器 */
|
|
8
15
|
export declare class YellowstoneGrpc {
|
|
9
16
|
private client;
|
|
10
17
|
private config;
|
|
11
18
|
private connected;
|
|
12
19
|
private subscribers;
|
|
20
|
+
private dexSubscribers;
|
|
13
21
|
constructor(endpoint: string, xToken: string, config?: ClientConfig);
|
|
14
22
|
/** 连接到 gRPC 服务器 */
|
|
15
23
|
connect(): Promise<void>;
|
|
@@ -23,13 +31,36 @@ export declare class YellowstoneGrpc {
|
|
|
23
31
|
private convertSlotStatus;
|
|
24
32
|
/** 转换订阅更新 */
|
|
25
33
|
private convertUpdate;
|
|
34
|
+
/**
|
|
35
|
+
* 应答 Geyser 在 SubscribeUpdate 中下发的 ping(与 `solana-streamer` / Rust 侧一致)。
|
|
36
|
+
* 若不回复,公共节点或 LB 可能在超时后 RST_STREAM(HTTP/2 CANCEL)。
|
|
37
|
+
*/
|
|
38
|
+
private subscribePingPongRequest;
|
|
39
|
+
private static toBytes;
|
|
40
|
+
private static toBigInt;
|
|
41
|
+
private static protobufNumber;
|
|
42
|
+
private static timestampToMicros;
|
|
43
|
+
private parseAccountEvent;
|
|
44
|
+
private initialSubscribeRequest;
|
|
26
45
|
/** 订阅交易 */
|
|
27
46
|
subscribeTransactions(filter: TransactionFilter, callbacks: SubscribeCallbacks): Promise<{
|
|
28
47
|
id: string;
|
|
29
48
|
cancel: () => void;
|
|
30
49
|
}>;
|
|
50
|
+
/**
|
|
51
|
+
* 订阅并直接产出 `DexEvent`。
|
|
52
|
+
*
|
|
53
|
+
* 交易更新走统一交易解析(外层/内层指令 + 日志 + 数据填充);账户更新走 `parseAccountUnified`。
|
|
54
|
+
* 事件队列满时丢弃新事件,避免回调阻塞 gRPC 读循环,保持低延迟。
|
|
55
|
+
*/
|
|
56
|
+
subscribeDexEvents(transactionFilters?: TransactionFilter[], accountFilters?: AccountFilter[], eventTypeFilter?: EventTypeFilter, options?: {
|
|
57
|
+
autoReconnect?: boolean;
|
|
58
|
+
}): Promise<DexEventSubscription>;
|
|
31
59
|
/** 取消订阅 */
|
|
32
60
|
unsubscribe(subId: string): void;
|
|
61
|
+
/** 动态更新当前 DEX 订阅过滤器(与 Rust update_subscription 语义对齐)。 */
|
|
62
|
+
updateSubscription(transactionFilters: TransactionFilter[], accountFilters: AccountFilter[]): Promise<void>;
|
|
63
|
+
update_subscription(transactionFilters: TransactionFilter[], accountFilters: AccountFilter[]): Promise<void>;
|
|
33
64
|
/** 获取最新区块哈希 */
|
|
34
65
|
getLatestBlockhash(commitment?: CommitmentLevel): Promise<{
|
|
35
66
|
slot: number;
|