sol-parser-sdk-python 0.5.5__py3-none-any.whl → 0.5.7__py3-none-any.whl

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.
@@ -0,0 +1,129 @@
1
+ """EventType inventory parity with Rust ``sol_parser_sdk::grpc::EventType``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .grpc_types import all_event_types
6
+
7
+ RUST_EVENT_TYPES = [
8
+ "BlockMeta",
9
+ "RaydiumLaunchlabTrade",
10
+ "RaydiumLaunchlabPoolCreate",
11
+ "RaydiumLaunchlabMigrateAmm",
12
+ "PumpFunTrade",
13
+ "PumpFunBuy",
14
+ "PumpFunSell",
15
+ "PumpFunBuyExactSolIn",
16
+ "PumpFunCreate",
17
+ "PumpFunCreateV2",
18
+ "PumpFunComplete",
19
+ "PumpFunMigrate",
20
+ "PumpFeesCreateFeeSharingConfig",
21
+ "PumpFeesInitializeFeeConfig",
22
+ "PumpFeesResetFeeSharingConfig",
23
+ "PumpFeesRevokeFeeSharingAuthority",
24
+ "PumpFeesTransferFeeSharingAuthority",
25
+ "PumpFeesUpdateAdmin",
26
+ "PumpFeesUpdateFeeConfig",
27
+ "PumpFeesUpdateFeeShares",
28
+ "PumpFeesUpsertFeeTiers",
29
+ "PumpFunMigrateBondingCurveCreator",
30
+ "PumpSwapTrade",
31
+ "PumpSwapBuy",
32
+ "PumpSwapSell",
33
+ "PumpSwapCreatePool",
34
+ "PumpSwapLiquidityAdded",
35
+ "PumpSwapLiquidityRemoved",
36
+ "RaydiumCpmmSwap",
37
+ "RaydiumCpmmDeposit",
38
+ "RaydiumCpmmWithdraw",
39
+ "RaydiumCpmmInitialize",
40
+ "RaydiumClmmSwap",
41
+ "RaydiumClmmCreatePool",
42
+ "RaydiumClmmOpenPosition",
43
+ "RaydiumClmmClosePosition",
44
+ "RaydiumClmmIncreaseLiquidity",
45
+ "RaydiumClmmDecreaseLiquidity",
46
+ "RaydiumClmmLiquidityChange",
47
+ "RaydiumClmmConfigChange",
48
+ "RaydiumClmmCreatePersonalPosition",
49
+ "RaydiumClmmLiquidityCalculate",
50
+ "RaydiumClmmOpenLimitOrder",
51
+ "RaydiumClmmIncreaseLimitOrder",
52
+ "RaydiumClmmDecreaseLimitOrder",
53
+ "RaydiumClmmSettleLimitOrder",
54
+ "RaydiumClmmUpdateRewardInfos",
55
+ "RaydiumClmmOpenPositionWithTokenExtNft",
56
+ "RaydiumClmmCollectFee",
57
+ "RaydiumAmmV4Swap",
58
+ "RaydiumAmmV4Deposit",
59
+ "RaydiumAmmV4Withdraw",
60
+ "RaydiumAmmV4Initialize2",
61
+ "RaydiumAmmV4WithdrawPnl",
62
+ "OrcaWhirlpoolSwap",
63
+ "OrcaWhirlpoolLiquidityIncreased",
64
+ "OrcaWhirlpoolLiquidityDecreased",
65
+ "OrcaWhirlpoolPoolInitialized",
66
+ "MeteoraPoolsSwap",
67
+ "MeteoraPoolsAddLiquidity",
68
+ "MeteoraPoolsRemoveLiquidity",
69
+ "MeteoraPoolsBootstrapLiquidity",
70
+ "MeteoraPoolsPoolCreated",
71
+ "MeteoraPoolsSetPoolFees",
72
+ "MeteoraDammV2Swap",
73
+ "MeteoraDammV2AddLiquidity",
74
+ "MeteoraDammV2RemoveLiquidity",
75
+ "MeteoraDammV2InitializePool",
76
+ "MeteoraDammV2CreatePosition",
77
+ "MeteoraDammV2ClosePosition",
78
+ "MeteoraDbcSwap",
79
+ "MeteoraDbcInitializePool",
80
+ "MeteoraDbcCurveComplete",
81
+ "MeteoraDlmmSwap",
82
+ "MeteoraDlmmAddLiquidity",
83
+ "MeteoraDlmmRemoveLiquidity",
84
+ "MeteoraDlmmInitializePool",
85
+ "MeteoraDlmmInitializeBinArray",
86
+ "MeteoraDlmmCreatePosition",
87
+ "MeteoraDlmmClosePosition",
88
+ "MeteoraDlmmClaimFee",
89
+ "TokenAccount",
90
+ "TokenInfo",
91
+ "NonceAccount",
92
+ "AccountPumpFunGlobal",
93
+ "AccountPumpFunBondingCurve",
94
+ "AccountPumpFunFeeConfig",
95
+ "AccountPumpFunSharingConfig",
96
+ "AccountPumpFunGlobalVolumeAccumulator",
97
+ "AccountPumpFunUserVolumeAccumulator",
98
+ "AccountPumpSwapGlobalConfig",
99
+ "AccountPumpSwapPool",
100
+ "AccountRaydiumClmmAmmConfig",
101
+ "AccountRaydiumClmmPoolState",
102
+ "AccountRaydiumClmmTickArrayState",
103
+ "AccountRaydiumCpmmAmmConfig",
104
+ "AccountRaydiumCpmmPoolState",
105
+ "AccountOrcaWhirlpool",
106
+ "AccountOrcaPosition",
107
+ "AccountOrcaTickArray",
108
+ "AccountOrcaFeeTier",
109
+ "AccountOrcaWhirlpoolsConfig",
110
+ ]
111
+
112
+
113
+ def run_event_type_parity_check() -> int:
114
+ actual = [event_type.value for event_type in all_event_types()]
115
+ if actual == RUST_EVENT_TYPES:
116
+ print(f"[event-type-parity] OK:EventType 与 Rust 清单一致(共 {len(actual)} 个)")
117
+ return 0
118
+ only_expected = [x for x in RUST_EVENT_TYPES if x not in actual]
119
+ only_actual = [x for x in actual if x not in RUST_EVENT_TYPES]
120
+ print("[event-type-parity] EventType 与 Rust 清单不一致")
121
+ if only_expected:
122
+ print(" Python 缺:", ", ".join(only_expected))
123
+ if only_actual:
124
+ print(" Python 多:", ", ".join(only_actual))
125
+ return 1
126
+
127
+
128
+ if __name__ == "__main__":
129
+ raise SystemExit(run_event_type_parity_check())
sol_parser/event_types.py CHANGED
@@ -53,6 +53,7 @@ class DexEvent:
53
53
  EventType.RAYDIUM_AMM_V4_SWAP, EventType.RAYDIUM_CLMM_SWAP, EventType.RAYDIUM_CPMM_SWAP,
54
54
  EventType.ORCA_WHIRLPOOL_SWAP, EventType.METEORA_DLMM_SWAP,
55
55
  EventType.METEORA_POOLS_SWAP, EventType.METEORA_DAMM_V2_SWAP,
56
+ EventType.METEORA_DBC_SWAP,
56
57
  EventType.RAYDIUM_LAUNCHLAB_TRADE,
57
58
  )
58
59
 
@@ -206,6 +207,8 @@ class PumpFunCreateEvent(DexEventBase):
206
207
  is_mayhem_mode: bool = False
207
208
  is_cashback_enabled: bool = False
208
209
  quote_mint: str = ""
210
+ quote_vault: str = ""
211
+ quote_token_program: str = ""
209
212
  virtual_quote_reserves: int = 0
210
213
 
211
214
 
@@ -232,6 +235,8 @@ class PumpFunCreateV2TokenEvent(DexEventBase):
232
235
  is_mayhem_mode: bool = False
233
236
  is_cashback_enabled: bool = False
234
237
  quote_mint: str = ""
238
+ quote_vault: str = ""
239
+ quote_token_program: str = ""
235
240
  virtual_quote_reserves: int = 0
236
241
  mint_authority: str = ""
237
242
  associated_bonding_curve: str = ""
@@ -697,6 +702,10 @@ class RaydiumClmmIncreaseLiquidityEvent(DexEventBase):
697
702
  position_nft_mint: str = ""
698
703
  user: str = ""
699
704
  liquidity: str = ""
705
+ amount_0: int = 0
706
+ amount_1: int = 0
707
+ amount_0_transfer_fee: int = 0
708
+ amount_1_transfer_fee: int = 0
700
709
  amount0_max: int = 0
701
710
  amount1_max: int = 0
702
711
 
@@ -708,6 +717,13 @@ class RaydiumClmmDecreaseLiquidityEvent(DexEventBase):
708
717
  position_nft_mint: str = ""
709
718
  user: str = ""
710
719
  liquidity: str = ""
720
+ decrease_amount_0: int = 0
721
+ decrease_amount_1: int = 0
722
+ fee_amount_0: int = 0
723
+ fee_amount_1: int = 0
724
+ reward_amounts: List[int] = field(default_factory=list)
725
+ transfer_fee_0: int = 0
726
+ transfer_fee_1: int = 0
711
727
  amount0_min: int = 0
712
728
  amount1_min: int = 0
713
729
 
@@ -752,6 +768,9 @@ class RaydiumClmmCreatePoolEvent(DexEventBase):
752
768
  tick_spacing: int = 0
753
769
  fee_rate: int = 0
754
770
  sqrt_price_x64: str = ""
771
+ tick: int = 0
772
+ token_vault_0: str = ""
773
+ token_vault_1: str = ""
755
774
  open_time: int = 0
756
775
 
757
776
 
@@ -760,10 +779,109 @@ class RaydiumClmmCollectFeeEvent(DexEventBase):
760
779
  """Raydium CLMM 收取费用事件"""
761
780
  pool_state: str = ""
762
781
  position_nft_mint: str = ""
782
+ recipient_token_account_0: str = ""
783
+ recipient_token_account_1: str = ""
763
784
  amount_0: int = 0
764
785
  amount_1: int = 0
765
786
 
766
787
 
788
+ @dataclass
789
+ class RaydiumClmmLiquidityChangeEvent(DexEventBase):
790
+ pool_state: str = ""
791
+ tick: int = 0
792
+ tick_lower: int = 0
793
+ tick_upper: int = 0
794
+ liquidity_before: str = ""
795
+ liquidity_after: str = ""
796
+
797
+
798
+ @dataclass
799
+ class RaydiumClmmConfigChangeEvent(DexEventBase):
800
+ index: int = 0
801
+ owner: str = ""
802
+ protocol_fee_rate: int = 0
803
+ trade_fee_rate: int = 0
804
+ tick_spacing: int = 0
805
+ fund_fee_rate: int = 0
806
+ fund_owner: str = ""
807
+
808
+
809
+ @dataclass
810
+ class RaydiumClmmCreatePersonalPositionEvent(DexEventBase):
811
+ pool_state: str = ""
812
+ minter: str = ""
813
+ nft_owner: str = ""
814
+ tick_lower_index: int = 0
815
+ tick_upper_index: int = 0
816
+ liquidity: str = ""
817
+ deposit_amount_0: int = 0
818
+ deposit_amount_1: int = 0
819
+ deposit_amount_0_transfer_fee: int = 0
820
+ deposit_amount_1_transfer_fee: int = 0
821
+
822
+
823
+ @dataclass
824
+ class RaydiumClmmLiquidityCalculateEvent(DexEventBase):
825
+ pool_liquidity: str = ""
826
+ pool_sqrt_price_x64: str = ""
827
+ pool_tick: int = 0
828
+ calc_amount_0: int = 0
829
+ calc_amount_1: int = 0
830
+ trade_fee_owed_0: int = 0
831
+ trade_fee_owed_1: int = 0
832
+ transfer_fee_0: int = 0
833
+ transfer_fee_1: int = 0
834
+
835
+
836
+ @dataclass
837
+ class RaydiumClmmOpenLimitOrderEvent(DexEventBase):
838
+ pool_id: str = ""
839
+ limit_order: str = ""
840
+ zero_for_one: bool = False
841
+ tick_index: int = 0
842
+ total_amount: int = 0
843
+ transfer_fee: int = 0
844
+
845
+
846
+ @dataclass
847
+ class RaydiumClmmIncreaseLimitOrderEvent(DexEventBase):
848
+ pool_id: str = ""
849
+ limit_order: str = ""
850
+ zero_for_one: bool = False
851
+ tick_index: int = 0
852
+ total_amount: int = 0
853
+ increased_amount: int = 0
854
+ transfer_fee: int = 0
855
+
856
+
857
+ @dataclass
858
+ class RaydiumClmmDecreaseLimitOrderEvent(DexEventBase):
859
+ pool_id: str = ""
860
+ limit_order: str = ""
861
+ zero_for_one: bool = False
862
+ tick_index: int = 0
863
+ total_amount: int = 0
864
+ filled_amount: int = 0
865
+ settled_output_amount: int = 0
866
+ decreased_amount: int = 0
867
+
868
+
869
+ @dataclass
870
+ class RaydiumClmmSettleLimitOrderEvent(DexEventBase):
871
+ pool_id: str = ""
872
+ limit_order: str = ""
873
+ zero_for_one: bool = False
874
+ tick_index: int = 0
875
+ total_amount: int = 0
876
+ filled_amount: int = 0
877
+ settled_amount_out: int = 0
878
+
879
+
880
+ @dataclass
881
+ class RaydiumClmmUpdateRewardInfosEvent(DexEventBase):
882
+ reward_growth_global_x64: List[str] = field(default_factory=list)
883
+
884
+
767
885
  # ============================================================
768
886
  # Raydium CPMM 事件
769
887
  # ============================================================
@@ -1095,6 +1213,8 @@ class MeteoraDammV2RemoveLiquidityEvent(DexEventBase):
1095
1213
  class MeteoraDammV2InitializePoolEvent(DexEventBase):
1096
1214
  """Meteora DAMM v2 初始化池子事件"""
1097
1215
  pool: str = ""
1216
+ position: str = ""
1217
+ position_nft_mint: str = ""
1098
1218
  token_a_mint: str = ""
1099
1219
  token_b_mint: str = ""
1100
1220
  creator: str = ""
@@ -1117,6 +1237,44 @@ class MeteoraDammV2InitializePoolEvent(DexEventBase):
1117
1237
  pool_type: int = 0
1118
1238
 
1119
1239
 
1240
+ @dataclass
1241
+ class MeteoraDbcSwapEvent(DexEventBase):
1242
+ """Meteora DBC 交易事件"""
1243
+ pool: str = ""
1244
+ config: str = ""
1245
+ trade_direction: int = 0
1246
+ has_referral: bool = False
1247
+ amount_in: int = 0
1248
+ minimum_amount_out: int = 0
1249
+ actual_input_amount: int = 0
1250
+ output_amount: int = 0
1251
+ next_sqrt_price: int = 0
1252
+ trading_fee: int = 0
1253
+ protocol_fee: int = 0
1254
+ referral_fee: int = 0
1255
+ current_timestamp: int = 0
1256
+
1257
+
1258
+ @dataclass
1259
+ class MeteoraDbcInitializePoolEvent(DexEventBase):
1260
+ """Meteora DBC 初始化池子事件"""
1261
+ pool: str = ""
1262
+ config: str = ""
1263
+ creator: str = ""
1264
+ base_mint: str = ""
1265
+ pool_type: int = 0
1266
+ activation_point: int = 0
1267
+
1268
+
1269
+ @dataclass
1270
+ class MeteoraDbcCurveCompleteEvent(DexEventBase):
1271
+ """Meteora DBC 曲线完成事件"""
1272
+ pool: str = ""
1273
+ config: str = ""
1274
+ base_reserve: int = 0
1275
+ quote_reserve: int = 0
1276
+
1277
+
1120
1278
  # ============================================================
1121
1279
  # RaydiumLaunchlab 事件
1122
1280
  # ============================================================
@@ -1412,6 +1570,8 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1412
1570
  is_mayhem_mode=_get_bool(data, "is_mayhem_mode"),
1413
1571
  is_cashback_enabled=_get_bool(data, "is_cashback_enabled"),
1414
1572
  quote_mint=_get_str(data, "quote_mint"),
1573
+ quote_vault=_get_str(data, "quote_vault"),
1574
+ quote_token_program=_get_str(data, "quote_token_program"),
1415
1575
  virtual_quote_reserves=_get_int(data, "virtual_quote_reserves"),
1416
1576
  )
1417
1577
 
@@ -1435,6 +1595,8 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1435
1595
  is_mayhem_mode=_get_bool(data, "is_mayhem_mode"),
1436
1596
  is_cashback_enabled=_get_bool(data, "is_cashback_enabled"),
1437
1597
  quote_mint=_get_str(data, "quote_mint"),
1598
+ quote_vault=_get_str(data, "quote_vault"),
1599
+ quote_token_program=_get_str(data, "quote_token_program"),
1438
1600
  virtual_quote_reserves=_get_int(data, "virtual_quote_reserves"),
1439
1601
  mint_authority=_get_str(data, "mint_authority"),
1440
1602
  associated_bonding_curve=_get_str(data, "associated_bonding_curve"),
@@ -1663,6 +1825,10 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1663
1825
  position_nft_mint=_get_str(data, "position_nft_mint"),
1664
1826
  user=_get_str(data, "user"),
1665
1827
  liquidity=_get_str(data, "liquidity"),
1828
+ amount_0=_get_int(data, "amount_0"),
1829
+ amount_1=_get_int(data, "amount_1"),
1830
+ amount_0_transfer_fee=_get_int(data, "amount_0_transfer_fee"),
1831
+ amount_1_transfer_fee=_get_int(data, "amount_1_transfer_fee"),
1666
1832
  amount0_max=_get_int(data, "amount0_max"),
1667
1833
  amount1_max=_get_int(data, "amount1_max"),
1668
1834
  )
@@ -1673,6 +1839,13 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1673
1839
  position_nft_mint=_get_str(data, "position_nft_mint"),
1674
1840
  user=_get_str(data, "user"),
1675
1841
  liquidity=_get_str(data, "liquidity"),
1842
+ decrease_amount_0=_get_int(data, "decrease_amount_0"),
1843
+ decrease_amount_1=_get_int(data, "decrease_amount_1"),
1844
+ fee_amount_0=_get_int(data, "fee_amount_0"),
1845
+ fee_amount_1=_get_int(data, "fee_amount_1"),
1846
+ reward_amounts=list(data.get("reward_amounts", [])) if isinstance(data, dict) else [],
1847
+ transfer_fee_0=_get_int(data, "transfer_fee_0"),
1848
+ transfer_fee_1=_get_int(data, "transfer_fee_1"),
1676
1849
  amount0_min=_get_int(data, "amount0_min"),
1677
1850
  amount1_min=_get_int(data, "amount1_min"),
1678
1851
  )
@@ -1686,6 +1859,9 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1686
1859
  tick_spacing=_get_int(data, "tick_spacing"),
1687
1860
  fee_rate=_get_int(data, "fee_rate"),
1688
1861
  sqrt_price_x64=_get_str(data, "sqrt_price_x64"),
1862
+ tick=_get_int(data, "tick"),
1863
+ token_vault_0=_get_str(data, "token_vault_0"),
1864
+ token_vault_1=_get_str(data, "token_vault_1"),
1689
1865
  open_time=_get_int(data, "open_time"),
1690
1866
  )
1691
1867
  if event_type == EventType.RAYDIUM_CLMM_OPEN_POSITION:
@@ -1720,9 +1896,110 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1720
1896
  metadata=meta,
1721
1897
  pool_state=_get_str(data, "pool_state"),
1722
1898
  position_nft_mint=_get_str(data, "position_nft_mint"),
1899
+ recipient_token_account_0=_get_str(data, "recipient_token_account_0"),
1900
+ recipient_token_account_1=_get_str(data, "recipient_token_account_1"),
1723
1901
  amount_0=_get_int(data, "amount_0"),
1724
1902
  amount_1=_get_int(data, "amount_1"),
1725
1903
  )
1904
+ if event_type == EventType.RAYDIUM_CLMM_LIQUIDITY_CHANGE:
1905
+ return RaydiumClmmLiquidityChangeEvent(
1906
+ metadata=meta,
1907
+ pool_state=_get_str(data, "pool_state"),
1908
+ tick=_get_int(data, "tick"),
1909
+ tick_lower=_get_int(data, "tick_lower"),
1910
+ tick_upper=_get_int(data, "tick_upper"),
1911
+ liquidity_before=_get_str(data, "liquidity_before"),
1912
+ liquidity_after=_get_str(data, "liquidity_after"),
1913
+ )
1914
+ if event_type == EventType.RAYDIUM_CLMM_CONFIG_CHANGE:
1915
+ return RaydiumClmmConfigChangeEvent(
1916
+ metadata=meta,
1917
+ index=_get_int(data, "index"),
1918
+ owner=_get_str(data, "owner"),
1919
+ protocol_fee_rate=_get_int(data, "protocol_fee_rate"),
1920
+ trade_fee_rate=_get_int(data, "trade_fee_rate"),
1921
+ tick_spacing=_get_int(data, "tick_spacing"),
1922
+ fund_fee_rate=_get_int(data, "fund_fee_rate"),
1923
+ fund_owner=_get_str(data, "fund_owner"),
1924
+ )
1925
+ if event_type == EventType.RAYDIUM_CLMM_CREATE_PERSONAL_POSITION:
1926
+ return RaydiumClmmCreatePersonalPositionEvent(
1927
+ metadata=meta,
1928
+ pool_state=_get_str(data, "pool_state"),
1929
+ minter=_get_str(data, "minter"),
1930
+ nft_owner=_get_str(data, "nft_owner"),
1931
+ tick_lower_index=_get_int(data, "tick_lower_index"),
1932
+ tick_upper_index=_get_int(data, "tick_upper_index"),
1933
+ liquidity=_get_str(data, "liquidity"),
1934
+ deposit_amount_0=_get_int(data, "deposit_amount_0"),
1935
+ deposit_amount_1=_get_int(data, "deposit_amount_1"),
1936
+ deposit_amount_0_transfer_fee=_get_int(data, "deposit_amount_0_transfer_fee"),
1937
+ deposit_amount_1_transfer_fee=_get_int(data, "deposit_amount_1_transfer_fee"),
1938
+ )
1939
+ if event_type == EventType.RAYDIUM_CLMM_LIQUIDITY_CALCULATE:
1940
+ return RaydiumClmmLiquidityCalculateEvent(
1941
+ metadata=meta,
1942
+ pool_liquidity=_get_str(data, "pool_liquidity"),
1943
+ pool_sqrt_price_x64=_get_str(data, "pool_sqrt_price_x64"),
1944
+ pool_tick=_get_int(data, "pool_tick"),
1945
+ calc_amount_0=_get_int(data, "calc_amount_0"),
1946
+ calc_amount_1=_get_int(data, "calc_amount_1"),
1947
+ trade_fee_owed_0=_get_int(data, "trade_fee_owed_0"),
1948
+ trade_fee_owed_1=_get_int(data, "trade_fee_owed_1"),
1949
+ transfer_fee_0=_get_int(data, "transfer_fee_0"),
1950
+ transfer_fee_1=_get_int(data, "transfer_fee_1"),
1951
+ )
1952
+ if event_type == EventType.RAYDIUM_CLMM_OPEN_LIMIT_ORDER:
1953
+ return RaydiumClmmOpenLimitOrderEvent(
1954
+ metadata=meta,
1955
+ pool_id=_get_str(data, "pool_id"),
1956
+ limit_order=_get_str(data, "limit_order"),
1957
+ zero_for_one=_get_bool(data, "zero_for_one"),
1958
+ tick_index=_get_int(data, "tick_index"),
1959
+ total_amount=_get_int(data, "total_amount"),
1960
+ transfer_fee=_get_int(data, "transfer_fee"),
1961
+ )
1962
+ if event_type == EventType.RAYDIUM_CLMM_INCREASE_LIMIT_ORDER:
1963
+ return RaydiumClmmIncreaseLimitOrderEvent(
1964
+ metadata=meta,
1965
+ pool_id=_get_str(data, "pool_id"),
1966
+ limit_order=_get_str(data, "limit_order"),
1967
+ zero_for_one=_get_bool(data, "zero_for_one"),
1968
+ tick_index=_get_int(data, "tick_index"),
1969
+ total_amount=_get_int(data, "total_amount"),
1970
+ increased_amount=_get_int(data, "increased_amount"),
1971
+ transfer_fee=_get_int(data, "transfer_fee"),
1972
+ )
1973
+ if event_type == EventType.RAYDIUM_CLMM_DECREASE_LIMIT_ORDER:
1974
+ return RaydiumClmmDecreaseLimitOrderEvent(
1975
+ metadata=meta,
1976
+ pool_id=_get_str(data, "pool_id"),
1977
+ limit_order=_get_str(data, "limit_order"),
1978
+ zero_for_one=_get_bool(data, "zero_for_one"),
1979
+ tick_index=_get_int(data, "tick_index"),
1980
+ total_amount=_get_int(data, "total_amount"),
1981
+ filled_amount=_get_int(data, "filled_amount"),
1982
+ settled_output_amount=_get_int(data, "settled_output_amount"),
1983
+ decreased_amount=_get_int(data, "decreased_amount"),
1984
+ )
1985
+ if event_type == EventType.RAYDIUM_CLMM_SETTLE_LIMIT_ORDER:
1986
+ return RaydiumClmmSettleLimitOrderEvent(
1987
+ metadata=meta,
1988
+ pool_id=_get_str(data, "pool_id"),
1989
+ limit_order=_get_str(data, "limit_order"),
1990
+ zero_for_one=_get_bool(data, "zero_for_one"),
1991
+ tick_index=_get_int(data, "tick_index"),
1992
+ total_amount=_get_int(data, "total_amount"),
1993
+ filled_amount=_get_int(data, "filled_amount"),
1994
+ settled_amount_out=_get_int(data, "settled_amount_out"),
1995
+ )
1996
+ if event_type == EventType.RAYDIUM_CLMM_UPDATE_REWARD_INFOS:
1997
+ raw = data.get("reward_growth_global_x64", [])
1998
+ rewards = [str(v) for v in raw] if isinstance(raw, list) else []
1999
+ return RaydiumClmmUpdateRewardInfosEvent(
2000
+ metadata=meta,
2001
+ reward_growth_global_x64=rewards,
2002
+ )
1726
2003
 
1727
2004
  if event_type == EventType.RAYDIUM_CPMM_SWAP:
1728
2005
  return RaydiumCpmmSwapEvent(
@@ -1821,6 +2098,20 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1821
2098
  token_a_transfer_fee=_get_int(data, "token_a_transfer_fee"),
1822
2099
  token_b_transfer_fee=_get_int(data, "token_b_transfer_fee"),
1823
2100
  )
2101
+ if event_type == EventType.ORCA_WHIRLPOOL_POOL_INITIALIZED:
2102
+ return OrcaWhirlpoolPoolInitializedEvent(
2103
+ metadata=meta,
2104
+ whirlpool=_get_str(data, "whirlpool"),
2105
+ whirlpools_config=_get_str(data, "whirlpools_config"),
2106
+ token_mint_a=_get_str(data, "token_mint_a"),
2107
+ token_mint_b=_get_str(data, "token_mint_b"),
2108
+ tick_spacing=_get_int(data, "tick_spacing"),
2109
+ token_program_a=_get_str(data, "token_program_a"),
2110
+ token_program_b=_get_str(data, "token_program_b"),
2111
+ decimals_a=_get_int(data, "decimals_a"),
2112
+ decimals_b=_get_int(data, "decimals_b"),
2113
+ initial_sqrt_price=_get_str(data, "initial_sqrt_price"),
2114
+ )
1824
2115
 
1825
2116
  # RaydiumLaunchlab events
1826
2117
  if event_type == EventType.RAYDIUM_LAUNCHLAB_TRADE:
sol_parser/grpc_client.py CHANGED
@@ -449,10 +449,11 @@ class YellowstoneGrpc:
449
449
  signature = base58.b58encode(bytes(info.signature)).decode("ascii") if info.signature else ""
450
450
 
451
451
  from .grpc_instruction_parser import (
452
+ detect_pumpfun_create_from_logs,
452
453
  enrich_dex_events_with_subscribe_tx_info,
453
454
  parse_instructions_enhanced_from_subscribe_tx_info,
454
455
  )
455
- from .parser import parse_log_optimized
456
+ from .parser import parse_invoke_info, parse_log_optimized_with_program_id, parse_program_complete_info
456
457
  from .log_instr_dedup import dedupe_log_instruction_events
457
458
  from .pumpfun_fee_enrich import enrich_pumpfun_same_tx_post_merge
458
459
  from .grpc_types import EventType
@@ -466,9 +467,16 @@ class YellowstoneGrpc:
466
467
  )
467
468
 
468
469
  log_events = []
469
- is_created_buy = False
470
+ has_pumpfun_create_log = detect_pumpfun_create_from_logs(list(info.log_messages))
471
+ active_program_stack = []
470
472
  for log in info.log_messages:
471
- ev = parse_log_optimized(
473
+ invoke = parse_invoke_info(log)
474
+ if invoke is not None:
475
+ program_id, depth = invoke
476
+ del active_program_stack[max(0, depth - 1):]
477
+ active_program_stack.append(program_id)
478
+
479
+ ev = parse_log_optimized_with_program_id(
472
480
  log,
473
481
  signature,
474
482
  slot,
@@ -476,14 +484,25 @@ class YellowstoneGrpc:
476
484
  block_time_us,
477
485
  grpc_recv_us,
478
486
  event_type_filter,
479
- is_created_buy,
487
+ has_pumpfun_create_log,
480
488
  "",
489
+ active_program_stack[-1] if active_program_stack else None,
481
490
  )
482
491
  if ev is None:
492
+ completed = parse_program_complete_info(log)
493
+ if completed is not None:
494
+ for i in range(len(active_program_stack) - 1, -1, -1):
495
+ if active_program_stack[i] == completed:
496
+ del active_program_stack[i:]
497
+ break
483
498
  continue
484
- if ev.type in (EventType.PUMP_FUN_CREATE, EventType.PUMP_FUN_CREATE_V2):
485
- is_created_buy = True
486
499
  log_events.append(ev)
500
+ completed = parse_program_complete_info(log)
501
+ if completed is not None:
502
+ for i in range(len(active_program_stack) - 1, -1, -1):
503
+ if active_program_stack[i] == completed:
504
+ del active_program_stack[i:]
505
+ break
487
506
 
488
507
  enrich_dex_events_with_subscribe_tx_info(instruction_events, info)
489
508
  enrich_dex_events_with_subscribe_tx_info(log_events, info)
@@ -11,13 +11,12 @@ from .account_dispatcher import fill_accounts_with_owned_keys, fill_data
11
11
  from .event_types import DexEvent
12
12
  from .grpc_types import (
13
13
  EventMetadata,
14
- EventType,
15
14
  EventTypeFilter,
16
- IncludeOnlyFilter,
17
15
  SubscribeUpdateTransactionInfo,
16
+ event_type_filter_allows_instruction_parsing,
18
17
  )
19
18
  from .inner_instruction_parser import parse_inner_instruction
20
- from .instructions import parse_instruction_unified
19
+ from .instructions import parse_inner_compiled_instruction_if_supported, parse_instruction_unified
21
20
  from .merger import merge_dex_events
22
21
  from .pumpfun_fee_enrich import enrich_pumpfun_same_tx_post_merge
23
22
 
@@ -118,18 +117,11 @@ def should_parse_instructions(filter: Optional[EventTypeFilter]) -> bool:
118
117
  if filter is None:
119
118
  return True
120
119
  inc = getattr(filter, "include_only", None)
121
- if inc is None or not inc:
120
+ if inc is None:
122
121
  return True
123
- need = {
124
- EventType.PUMP_FUN_MIGRATE,
125
- EventType.METEORA_DAMM_V2_SWAP,
126
- EventType.METEORA_DAMM_V2_ADD_LIQUIDITY,
127
- EventType.METEORA_DAMM_V2_CREATE_POSITION,
128
- EventType.METEORA_DAMM_V2_CLOSE_POSITION,
129
- EventType.METEORA_DAMM_V2_REMOVE_LIQUIDITY,
130
- EventType.METEORA_DAMM_V2_INITIALIZE_POOL,
131
- }
132
- return any(t in need for t in inc)
122
+ if not inc:
123
+ return False
124
+ return event_type_filter_allows_instruction_parsing(list(inc))
133
125
 
134
126
 
135
127
  def merge_instruction_events(
@@ -153,7 +145,7 @@ def merge_instruction_events(
153
145
  pending_outer = None
154
146
  if po_idx == outer_idx:
155
147
  merge_dex_events(mut_outer, event)
156
- result.append(mut_outer)
148
+ pending_outer = (outer_idx, mut_outer)
157
149
  else:
158
150
  result.append(mut_outer)
159
151
  result.append(event)
@@ -228,8 +220,6 @@ def parse_instructions_enhanced_from_parsed(
228
220
  return []
229
221
 
230
222
  grpc_us = int(time.time() * 1_000_000) if grpc_recv_us is None else grpc_recv_us
231
- f: EventTypeFilter = filter if filter is not None else IncludeOnlyFilter([])
232
-
233
223
  try:
234
224
  from . import solana_storage_pb2 as sol_pb
235
225
  except ImportError:
@@ -279,7 +269,7 @@ def parse_instructions_enhanced_from_parsed(
279
269
  acct_bytes = bytes(ix.accounts)
280
270
  accounts = [get_key_b58(b) for b in acct_bytes]
281
271
  ev = parse_instruction_unified(
282
- data, accounts, signature, slot, tx_index, block_time_us, grpc_us, f, pid
272
+ data, accounts, signature, slot, tx_index, block_time_us, grpc_us, filter, pid
283
273
  )
284
274
  if ev:
285
275
  result.append((i, None, ev))
@@ -289,11 +279,22 @@ def parse_instructions_enhanced_from_parsed(
289
279
  for j, inner_ix in enumerate(inner.instructions):
290
280
  pid = get_key_b58(inner_ix.program_id_index)
291
281
  data = bytes(inner_ix.data)
292
- ev = parse_inner_instruction(
282
+ accounts = [get_key_b58(b) for b in bytes(inner_ix.accounts)]
283
+ ev = parse_inner_compiled_instruction_if_supported(
284
+ data,
285
+ accounts,
286
+ signature,
287
+ slot,
288
+ tx_index,
289
+ block_time_us,
290
+ grpc_us,
291
+ filter,
292
+ pid,
293
+ ) or parse_inner_instruction(
293
294
  data,
294
295
  pid,
295
296
  _meta_dict(signature, slot, tx_index, block_time_us, grpc_us, recent_bh),
296
- f,
297
+ filter,
297
298
  is_created_buy,
298
299
  )
299
300
  if ev: