sol-parser-sdk-python 0.5.7__py3-none-any.whl → 0.5.9__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.
- sol_parser/__init__.py +34 -0
- sol_parser/account_dispatcher.py +98 -4
- sol_parser/account_fillers/meteora.py +10 -2
- sol_parser/account_fillers/raydium.py +9 -4
- sol_parser/account_fillers/raydium_launchlab.py +54 -0
- sol_parser/accounts/__init__.py +52 -2
- sol_parser/block_meta.py +29 -0
- sol_parser/dex_parsers.py +662 -69
- sol_parser/entries_decode.py +6 -80
- sol_parser/event_type_parity.py +4 -0
- sol_parser/event_types.py +269 -3
- sol_parser/grpc/subscribe_builder.py +8 -0
- sol_parser/grpc_client.py +114 -20
- sol_parser/grpc_instruction_parser.py +85 -26
- sol_parser/grpc_types.py +31 -0
- sol_parser/inner_instruction_parser.py +5 -7
- sol_parser/instructions.py +259 -53
- sol_parser/json_util.py +15 -1
- sol_parser/liquidity_snapshot.py +101 -0
- sol_parser/log_instr_dedup.py +56 -12
- sol_parser/merger.py +73 -85
- sol_parser/parser.py +11 -0
- sol_parser/pumpfun_fee_enrich.py +2 -0
- sol_parser/rpc_parser.py +30 -4
- sol_parser/simulation_route.py +233 -0
- sol_parser/stonkfun_registry.py +139 -0
- sol_parser/transaction_route.py +510 -0
- sol_parser/wire_transaction.py +172 -0
- {sol_parser_sdk_python-0.5.7.dist-info → sol_parser_sdk_python-0.5.9.dist-info}/METADATA +44 -9
- {sol_parser_sdk_python-0.5.7.dist-info → sol_parser_sdk_python-0.5.9.dist-info}/RECORD +32 -26
- {sol_parser_sdk_python-0.5.7.dist-info → sol_parser_sdk_python-0.5.9.dist-info}/WHEEL +1 -1
- {sol_parser_sdk_python-0.5.7.dist-info → sol_parser_sdk_python-0.5.9.dist-info}/entry_points.txt +0 -0
sol_parser/entries_decode.py
CHANGED
|
@@ -46,87 +46,13 @@ class _ParsedTx:
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
def parse_transaction_wire(buf: bytes, pos: int) -> Optional[_ParsedTx]:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
p = pos + sig_count_enc[1]
|
|
56
|
-
sig_count = sig_count_enc[0]
|
|
57
|
-
sigs_end = p + sig_count * 64
|
|
58
|
-
if sigs_end > len(buf):
|
|
59
|
-
return None
|
|
60
|
-
sigs: List[bytes] = []
|
|
61
|
-
for _ in range(sig_count):
|
|
62
|
-
sigs.append(buf[p : p + 64])
|
|
63
|
-
p += 64
|
|
64
|
-
if p >= len(buf):
|
|
65
|
-
return None
|
|
66
|
-
msg_first = buf[p]
|
|
67
|
-
is_v0 = msg_first >= 0x80
|
|
68
|
-
if is_v0:
|
|
69
|
-
p += 1
|
|
70
|
-
p += 3
|
|
71
|
-
if p > len(buf):
|
|
72
|
-
return None
|
|
73
|
-
acct_enc = decode_compact_u16(buf, p)
|
|
74
|
-
if not acct_enc:
|
|
75
|
-
return None
|
|
76
|
-
p += acct_enc[1]
|
|
77
|
-
p += acct_enc[0] * 32
|
|
78
|
-
if p > len(buf):
|
|
79
|
-
return None
|
|
80
|
-
ix_count_enc = decode_compact_u16(buf, p)
|
|
81
|
-
if not ix_count_enc:
|
|
49
|
+
from .wire_transaction import decode_wire_transaction
|
|
50
|
+
import base58
|
|
51
|
+
try:
|
|
52
|
+
transaction, length = decode_wire_transaction(buf, pos, require_complete=False)
|
|
53
|
+
return _ParsedTx(length, [base58.b58decode(s) for s in transaction['signatures']])
|
|
54
|
+
except (ValueError, IndexError):
|
|
82
55
|
return None
|
|
83
|
-
p += ix_count_enc[1]
|
|
84
|
-
ix_count = ix_count_enc[0]
|
|
85
|
-
for _ in range(ix_count):
|
|
86
|
-
p += 1
|
|
87
|
-
if p > len(buf):
|
|
88
|
-
return None
|
|
89
|
-
acct_len_enc = decode_compact_u16(buf, p)
|
|
90
|
-
if not acct_len_enc:
|
|
91
|
-
return None
|
|
92
|
-
p += acct_len_enc[1]
|
|
93
|
-
p += acct_len_enc[0]
|
|
94
|
-
if p > len(buf):
|
|
95
|
-
return None
|
|
96
|
-
data_len_enc = decode_compact_u16(buf, p)
|
|
97
|
-
if not data_len_enc:
|
|
98
|
-
return None
|
|
99
|
-
p += data_len_enc[1]
|
|
100
|
-
p += data_len_enc[0]
|
|
101
|
-
if p > len(buf):
|
|
102
|
-
return None
|
|
103
|
-
if is_v0:
|
|
104
|
-
if p >= len(buf):
|
|
105
|
-
return None
|
|
106
|
-
atl_count_enc = decode_compact_u16(buf, p)
|
|
107
|
-
if not atl_count_enc:
|
|
108
|
-
return None
|
|
109
|
-
p += atl_count_enc[1]
|
|
110
|
-
atl_count = atl_count_enc[0]
|
|
111
|
-
for _ in range(atl_count):
|
|
112
|
-
p += 32
|
|
113
|
-
if p > len(buf):
|
|
114
|
-
return None
|
|
115
|
-
w_len_enc = decode_compact_u16(buf, p)
|
|
116
|
-
if not w_len_enc:
|
|
117
|
-
return None
|
|
118
|
-
p += w_len_enc[1]
|
|
119
|
-
p += w_len_enc[0]
|
|
120
|
-
if p > len(buf):
|
|
121
|
-
return None
|
|
122
|
-
r_len_enc = decode_compact_u16(buf, p)
|
|
123
|
-
if not r_len_enc:
|
|
124
|
-
return None
|
|
125
|
-
p += r_len_enc[1]
|
|
126
|
-
p += r_len_enc[0]
|
|
127
|
-
if p > len(buf):
|
|
128
|
-
return None
|
|
129
|
-
return _ParsedTx(tx_len=p - start, signatures=sigs)
|
|
130
56
|
|
|
131
57
|
|
|
132
58
|
class _BatchDecoder:
|
sol_parser/event_type_parity.py
CHANGED
|
@@ -75,6 +75,10 @@ RUST_EVENT_TYPES = [
|
|
|
75
75
|
"MeteoraDammV2InitializePool",
|
|
76
76
|
"MeteoraDammV2CreatePosition",
|
|
77
77
|
"MeteoraDammV2ClosePosition",
|
|
78
|
+
"MeteoraDammV2UpdateDelegatePermission",
|
|
79
|
+
"MeteoraDammV2WithdrawDeadLiquidityReward",
|
|
80
|
+
"MeteoraDammV2CreateConfig",
|
|
81
|
+
"MeteoraDammV2CreateDynamicConfig",
|
|
78
82
|
"MeteoraDbcSwap",
|
|
79
83
|
"MeteoraDbcInitializePool",
|
|
80
84
|
"MeteoraDbcCurveComplete",
|
sol_parser/event_types.py
CHANGED
|
@@ -153,6 +153,8 @@ class PumpFunTradeEvent(DexEventBase):
|
|
|
153
153
|
quote_amount: int = 0
|
|
154
154
|
virtual_quote_reserves: int = 0
|
|
155
155
|
real_quote_reserves: int = 0
|
|
156
|
+
holder_rewards_bps: int = 0
|
|
157
|
+
holder_rewards: int = 0
|
|
156
158
|
is_cashback_coin: bool = False
|
|
157
159
|
amount: int = 0
|
|
158
160
|
max_sol_cost: int = 0
|
|
@@ -160,6 +162,11 @@ class PumpFunTradeEvent(DexEventBase):
|
|
|
160
162
|
spendable_sol_in: int = 0
|
|
161
163
|
spendable_quote_in: int = 0
|
|
162
164
|
min_tokens_out: int = 0
|
|
165
|
+
# Transaction balance fields (raw units; None when meta unavailable)
|
|
166
|
+
pre_token_balance: Optional[int] = None
|
|
167
|
+
post_token_balance: Optional[int] = None
|
|
168
|
+
pre_sol_balance: Optional[int] = None
|
|
169
|
+
post_sol_balance: Optional[int] = None
|
|
163
170
|
global_account: str = ""
|
|
164
171
|
bonding_curve: str = ""
|
|
165
172
|
bonding_curve_v2: str = ""
|
|
@@ -210,6 +217,8 @@ class PumpFunCreateEvent(DexEventBase):
|
|
|
210
217
|
quote_vault: str = ""
|
|
211
218
|
quote_token_program: str = ""
|
|
212
219
|
virtual_quote_reserves: int = 0
|
|
220
|
+
creator_fee_bps: int = 0
|
|
221
|
+
is_holder_reward: bool = False
|
|
213
222
|
|
|
214
223
|
|
|
215
224
|
@dataclass
|
|
@@ -238,6 +247,8 @@ class PumpFunCreateV2TokenEvent(DexEventBase):
|
|
|
238
247
|
quote_vault: str = ""
|
|
239
248
|
quote_token_program: str = ""
|
|
240
249
|
virtual_quote_reserves: int = 0
|
|
250
|
+
creator_fee_bps: int = 0
|
|
251
|
+
is_holder_reward: bool = False
|
|
241
252
|
mint_authority: str = ""
|
|
242
253
|
associated_bonding_curve: str = ""
|
|
243
254
|
global_account: str = "" # Rust `global` PumpFun global config
|
|
@@ -418,6 +429,13 @@ class PumpSwapBuyEvent(DexEventBase):
|
|
|
418
429
|
mayhem_mode: bool = False
|
|
419
430
|
cashback_fee_basis_points: int = 0
|
|
420
431
|
cashback: int = 0
|
|
432
|
+
buyback_fee_basis_points: int = 0
|
|
433
|
+
buyback_fee: int = 0
|
|
434
|
+
virtual_quote_reserves: int = 0
|
|
435
|
+
can_boost: bool = False
|
|
436
|
+
base_supply: int = 0
|
|
437
|
+
holder_rewards_bps: int = 0
|
|
438
|
+
holder_rewards: int = 0
|
|
421
439
|
is_cashback_coin: bool = False
|
|
422
440
|
base_mint: str = ""
|
|
423
441
|
quote_mint: str = ""
|
|
@@ -461,6 +479,13 @@ class PumpSwapSellEvent(DexEventBase):
|
|
|
461
479
|
coin_creator_fee: int = 0
|
|
462
480
|
cashback_fee_basis_points: int = 0
|
|
463
481
|
cashback: int = 0
|
|
482
|
+
buyback_fee_basis_points: int = 0
|
|
483
|
+
buyback_fee: int = 0
|
|
484
|
+
virtual_quote_reserves: int = 0
|
|
485
|
+
can_boost: bool = False
|
|
486
|
+
base_supply: int = 0
|
|
487
|
+
holder_rewards_bps: int = 0
|
|
488
|
+
holder_rewards: int = 0
|
|
464
489
|
base_mint: str = ""
|
|
465
490
|
quote_mint: str = ""
|
|
466
491
|
pool_base_token_account: str = ""
|
|
@@ -499,6 +524,10 @@ class PumpSwapCreatePoolEvent(DexEventBase):
|
|
|
499
524
|
user_quote_token_account: str = ""
|
|
500
525
|
coin_creator: str = ""
|
|
501
526
|
is_mayhem_mode: bool = False
|
|
527
|
+
is_cashback_coin: bool = False
|
|
528
|
+
creator_fee_bps: int = 0
|
|
529
|
+
can_edit_creator_fee: bool = False
|
|
530
|
+
is_holder_reward: bool = False
|
|
502
531
|
|
|
503
532
|
|
|
504
533
|
@dataclass
|
|
@@ -997,6 +1026,12 @@ class OrcaWhirlpoolPoolInitializedEvent(DexEventBase):
|
|
|
997
1026
|
@dataclass
|
|
998
1027
|
class MeteoraDlmmSwapEvent(DexEventBase):
|
|
999
1028
|
"""Meteora DLMM 交换事件"""
|
|
1029
|
+
# Instruction / account context (not in Borsh event payload)
|
|
1030
|
+
token_x_mint: str = ""
|
|
1031
|
+
token_y_mint: str = ""
|
|
1032
|
+
user_token_in: str = ""
|
|
1033
|
+
user_token_out: str = ""
|
|
1034
|
+
min_amount_out: int = 0
|
|
1000
1035
|
pool: str = ""
|
|
1001
1036
|
from_addr: str = ""
|
|
1002
1037
|
start_bin_id: int = 0
|
|
@@ -1141,10 +1176,14 @@ class MeteoraPoolsPoolCreatedEvent(DexEventBase):
|
|
|
1141
1176
|
|
|
1142
1177
|
@dataclass
|
|
1143
1178
|
class MeteoraDammV2SwapEvent(DexEventBase):
|
|
1144
|
-
"""Meteora DAMM v2
|
|
1179
|
+
"""Meteora DAMM v2 交换事件(含 EvtSwap / EvtSwap2 全字段)"""
|
|
1145
1180
|
pool: str = ""
|
|
1146
1181
|
trade_direction: int = 0
|
|
1182
|
+
collect_fee_mode: int = 0
|
|
1147
1183
|
has_referral: bool = False
|
|
1184
|
+
amount_0: int = 0
|
|
1185
|
+
amount_1: int = 0
|
|
1186
|
+
swap_mode: int = 0
|
|
1148
1187
|
amount_in: int = 0
|
|
1149
1188
|
minimum_amount_out: int = 0
|
|
1150
1189
|
output_amount: int = 0
|
|
@@ -1154,7 +1193,16 @@ class MeteoraDammV2SwapEvent(DexEventBase):
|
|
|
1154
1193
|
partner_fee: int = 0
|
|
1155
1194
|
referral_fee: int = 0
|
|
1156
1195
|
actual_amount_in: int = 0
|
|
1196
|
+
excluded_fee_input_amount: int = 0
|
|
1197
|
+
amount_left: int = 0
|
|
1198
|
+
claiming_fee: int = 0
|
|
1199
|
+
compounding_fee: int = 0
|
|
1200
|
+
included_transfer_fee_amount_in: int = 0
|
|
1201
|
+
included_transfer_fee_amount_out: int = 0
|
|
1202
|
+
excluded_transfer_fee_amount_out: int = 0
|
|
1157
1203
|
current_timestamp: int = 0
|
|
1204
|
+
reserve_a_amount: int = 0
|
|
1205
|
+
reserve_b_amount: int = 0
|
|
1158
1206
|
token_a_vault: str = ""
|
|
1159
1207
|
token_b_vault: str = ""
|
|
1160
1208
|
token_a_mint: str = ""
|
|
@@ -1194,6 +1242,8 @@ class MeteoraDammV2AddLiquidityEvent(DexEventBase):
|
|
|
1194
1242
|
token_b_amount: int = 0
|
|
1195
1243
|
total_amount_a: int = 0
|
|
1196
1244
|
total_amount_b: int = 0
|
|
1245
|
+
reserve_a_amount: int = 0
|
|
1246
|
+
reserve_b_amount: int = 0
|
|
1197
1247
|
|
|
1198
1248
|
|
|
1199
1249
|
@dataclass
|
|
@@ -1207,6 +1257,10 @@ class MeteoraDammV2RemoveLiquidityEvent(DexEventBase):
|
|
|
1207
1257
|
token_b_amount_threshold: int = 0
|
|
1208
1258
|
token_a_amount: int = 0
|
|
1209
1259
|
token_b_amount: int = 0
|
|
1260
|
+
total_amount_a: int = 0
|
|
1261
|
+
total_amount_b: int = 0
|
|
1262
|
+
reserve_a_amount: int = 0
|
|
1263
|
+
reserve_b_amount: int = 0
|
|
1210
1264
|
|
|
1211
1265
|
|
|
1212
1266
|
@dataclass
|
|
@@ -1237,6 +1291,62 @@ class MeteoraDammV2InitializePoolEvent(DexEventBase):
|
|
|
1237
1291
|
pool_type: int = 0
|
|
1238
1292
|
|
|
1239
1293
|
|
|
1294
|
+
@dataclass
|
|
1295
|
+
class MeteoraDammV2DynamicFeeParameters:
|
|
1296
|
+
"""DAMM v2 PoolFeeParameters.dynamic_fee"""
|
|
1297
|
+
bin_step: int = 0
|
|
1298
|
+
bin_step_u128: str = "0"
|
|
1299
|
+
filter_period: int = 0
|
|
1300
|
+
decay_period: int = 0
|
|
1301
|
+
reduction_factor: int = 0
|
|
1302
|
+
max_volatility_accumulator: int = 0
|
|
1303
|
+
variable_fee_control: int = 0
|
|
1304
|
+
|
|
1305
|
+
|
|
1306
|
+
@dataclass
|
|
1307
|
+
class MeteoraDammV2UpdateDelegatePermissionEvent(DexEventBase):
|
|
1308
|
+
"""Meteora DAMM v2 EvtUpdateDelegatePermission"""
|
|
1309
|
+
position: str = ""
|
|
1310
|
+
owner: str = ""
|
|
1311
|
+
permission: int = 0
|
|
1312
|
+
delegate: Optional[str] = None
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
@dataclass
|
|
1316
|
+
class MeteoraDammV2WithdrawDeadLiquidityRewardEvent(DexEventBase):
|
|
1317
|
+
"""Meteora DAMM v2 EvtWithdrawDeadLiquidityReward"""
|
|
1318
|
+
pool: str = ""
|
|
1319
|
+
reward_mint: str = ""
|
|
1320
|
+
amount: int = 0
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
@dataclass
|
|
1324
|
+
class MeteoraDammV2CreateConfigEvent(DexEventBase):
|
|
1325
|
+
"""Meteora DAMM v2 EvtCreateConfig(含 0.2.4 permission)"""
|
|
1326
|
+
base_fee_data: bytes = field(default_factory=lambda: bytes(27))
|
|
1327
|
+
compounding_fee_bps: int = 0
|
|
1328
|
+
padding: int = 0
|
|
1329
|
+
dynamic_fee: Optional[MeteoraDammV2DynamicFeeParameters] = None
|
|
1330
|
+
vault_config_key: str = ""
|
|
1331
|
+
pool_creator_authority: str = ""
|
|
1332
|
+
activation_type: int = 0
|
|
1333
|
+
sqrt_min_price: str = "0"
|
|
1334
|
+
sqrt_max_price: str = "0"
|
|
1335
|
+
collect_fee_mode: int = 0
|
|
1336
|
+
index: int = 0
|
|
1337
|
+
config: str = ""
|
|
1338
|
+
permission: str = "0"
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
@dataclass
|
|
1342
|
+
class MeteoraDammV2CreateDynamicConfigEvent(DexEventBase):
|
|
1343
|
+
"""Meteora DAMM v2 EvtCreateDynamicConfig"""
|
|
1344
|
+
config: str = ""
|
|
1345
|
+
pool_creator_authority: str = ""
|
|
1346
|
+
index: int = 0
|
|
1347
|
+
permission: str = "0"
|
|
1348
|
+
|
|
1349
|
+
|
|
1240
1350
|
@dataclass
|
|
1241
1351
|
class MeteoraDbcSwapEvent(DexEventBase):
|
|
1242
1352
|
"""Meteora DBC 交易事件"""
|
|
@@ -1289,7 +1399,39 @@ class RaydiumLaunchlabTradeEvent(DexEventBase):
|
|
|
1289
1399
|
is_buy: bool = False
|
|
1290
1400
|
trade_direction: str = ""
|
|
1291
1401
|
exact_in: bool = False
|
|
1402
|
+
global_config: str = ""
|
|
1403
|
+
platform_config: str = ""
|
|
1404
|
+
user_base_token: str = ""
|
|
1405
|
+
user_quote_token: str = ""
|
|
1406
|
+
base_vault: str = ""
|
|
1407
|
+
quote_vault: str = ""
|
|
1408
|
+
base_mint: str = ""
|
|
1409
|
+
quote_mint: str = ""
|
|
1410
|
+
base_token_program: str = ""
|
|
1411
|
+
quote_token_program: str = ""
|
|
1412
|
+
|
|
1413
|
+
total_base_sell: int = 0
|
|
1414
|
+
virtual_base: int = 0
|
|
1415
|
+
virtual_quote: int = 0
|
|
1416
|
+
real_base_before: int = 0
|
|
1417
|
+
real_quote_before: int = 0
|
|
1418
|
+
real_base_after: int = 0
|
|
1419
|
+
real_quote_after: int = 0
|
|
1420
|
+
protocol_fee: int = 0
|
|
1421
|
+
platform_fee: int = 0
|
|
1422
|
+
creator_fee: int = 0
|
|
1423
|
+
share_fee: int = 0
|
|
1424
|
+
pool_status: str = "Fund"
|
|
1425
|
+
system_program: str = ""
|
|
1426
|
+
platform_associated_account: str = ""
|
|
1427
|
+
creator_associated_account: str = ""
|
|
1428
|
+
|
|
1429
|
+
def stonkfun_mode(self):
|
|
1430
|
+
from .transaction_route import stonkfun_mode_from_platform_config
|
|
1431
|
+
return stonkfun_mode_from_platform_config(self.platform_config)
|
|
1292
1432
|
|
|
1433
|
+
def is_stonkfun(self):
|
|
1434
|
+
return self.stonkfun_mode() is not None
|
|
1293
1435
|
|
|
1294
1436
|
@dataclass
|
|
1295
1437
|
class RaydiumLaunchlabPoolCreateEvent(DexEventBase):
|
|
@@ -1297,7 +1439,24 @@ class RaydiumLaunchlabPoolCreateEvent(DexEventBase):
|
|
|
1297
1439
|
pool_state: str = ""
|
|
1298
1440
|
creator: str = ""
|
|
1299
1441
|
base_mint_param: Optional[Dict[str, Any]] = None
|
|
1442
|
+
payer: str = ""
|
|
1443
|
+
global_config: str = ""
|
|
1444
|
+
platform_config: str = ""
|
|
1445
|
+
base_mint: str = ""
|
|
1446
|
+
quote_mint: str = ""
|
|
1447
|
+
base_vault: str = ""
|
|
1448
|
+
quote_vault: str = ""
|
|
1449
|
+
base_token_program: str = ""
|
|
1450
|
+
quote_token_program: str = ""
|
|
1451
|
+
|
|
1452
|
+
|
|
1300
1453
|
|
|
1454
|
+
def stonkfun_mode(self):
|
|
1455
|
+
from .transaction_route import stonkfun_mode_from_platform_config
|
|
1456
|
+
return stonkfun_mode_from_platform_config(self.platform_config)
|
|
1457
|
+
|
|
1458
|
+
def is_stonkfun(self):
|
|
1459
|
+
return self.stonkfun_mode() is not None
|
|
1301
1460
|
|
|
1302
1461
|
@dataclass
|
|
1303
1462
|
class RaydiumLaunchlabMigrateAmmEvent(DexEventBase):
|
|
@@ -1307,6 +1466,18 @@ class RaydiumLaunchlabMigrateAmmEvent(DexEventBase):
|
|
|
1307
1466
|
user: str = ""
|
|
1308
1467
|
liquidity_amount: int = 0
|
|
1309
1468
|
|
|
1469
|
+
liquidity_amount_known: bool = False
|
|
1470
|
+
base_mint: str = ""
|
|
1471
|
+
quote_mint: str = ""
|
|
1472
|
+
platform_config: str = ""
|
|
1473
|
+
destination_program: str = ""
|
|
1474
|
+
|
|
1475
|
+
def stonkfun_mode(self):
|
|
1476
|
+
from .transaction_route import stonkfun_mode_from_platform_config
|
|
1477
|
+
return stonkfun_mode_from_platform_config(self.platform_config)
|
|
1478
|
+
|
|
1479
|
+
def is_stonkfun(self):
|
|
1480
|
+
return self.stonkfun_mode() is not None
|
|
1310
1481
|
|
|
1311
1482
|
# ============================================================
|
|
1312
1483
|
# 类型联合
|
|
@@ -1373,6 +1544,10 @@ TypedDexEvent = Union[
|
|
|
1373
1544
|
MeteoraDammV2AddLiquidityEvent,
|
|
1374
1545
|
MeteoraDammV2RemoveLiquidityEvent,
|
|
1375
1546
|
MeteoraDammV2InitializePoolEvent,
|
|
1547
|
+
MeteoraDammV2UpdateDelegatePermissionEvent,
|
|
1548
|
+
MeteoraDammV2WithdrawDeadLiquidityRewardEvent,
|
|
1549
|
+
MeteoraDammV2CreateConfigEvent,
|
|
1550
|
+
MeteoraDammV2CreateDynamicConfigEvent,
|
|
1376
1551
|
RaydiumLaunchlabTradeEvent,
|
|
1377
1552
|
RaydiumLaunchlabPoolCreateEvent,
|
|
1378
1553
|
RaydiumLaunchlabMigrateAmmEvent,
|
|
@@ -1409,11 +1584,20 @@ def _get_int(m: dict, key: str) -> int:
|
|
|
1409
1584
|
v = m.get(key, 0)
|
|
1410
1585
|
if isinstance(v, int):
|
|
1411
1586
|
return v
|
|
1412
|
-
if isinstance(v, str)
|
|
1413
|
-
|
|
1587
|
+
if isinstance(v, str):
|
|
1588
|
+
try:
|
|
1589
|
+
return int(v, 10)
|
|
1590
|
+
except ValueError:
|
|
1591
|
+
pass
|
|
1414
1592
|
return 0
|
|
1415
1593
|
|
|
1416
1594
|
|
|
1595
|
+
def _get_optional_int(m: dict, key: str) -> Optional[int]:
|
|
1596
|
+
if key not in m or m.get(key) is None:
|
|
1597
|
+
return None
|
|
1598
|
+
return _get_int(m, key)
|
|
1599
|
+
|
|
1600
|
+
|
|
1417
1601
|
def _get_bool(m: dict, key: str) -> bool:
|
|
1418
1602
|
v = m.get(key, False)
|
|
1419
1603
|
return bool(v)
|
|
@@ -1517,6 +1701,8 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
1517
1701
|
quote_amount=_get_int(data, "quote_amount"),
|
|
1518
1702
|
virtual_quote_reserves=_get_int(data, "virtual_quote_reserves"),
|
|
1519
1703
|
real_quote_reserves=_get_int(data, "real_quote_reserves"),
|
|
1704
|
+
holder_rewards_bps=_get_int(data, "holder_rewards_bps"),
|
|
1705
|
+
holder_rewards=_get_int(data, "holder_rewards"),
|
|
1520
1706
|
is_cashback_coin=_get_bool(data, "is_cashback_coin"),
|
|
1521
1707
|
amount=_get_int(data, "amount"),
|
|
1522
1708
|
max_sol_cost=_get_int(data, "max_sol_cost"),
|
|
@@ -1524,6 +1710,10 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
1524
1710
|
spendable_sol_in=_get_int(data, "spendable_sol_in"),
|
|
1525
1711
|
spendable_quote_in=_get_int(data, "spendable_quote_in"),
|
|
1526
1712
|
min_tokens_out=_get_int(data, "min_tokens_out"),
|
|
1713
|
+
pre_token_balance=_get_optional_int(data, "pre_token_balance"),
|
|
1714
|
+
post_token_balance=_get_optional_int(data, "post_token_balance"),
|
|
1715
|
+
pre_sol_balance=_get_optional_int(data, "pre_sol_balance"),
|
|
1716
|
+
post_sol_balance=_get_optional_int(data, "post_sol_balance"),
|
|
1527
1717
|
global_account=_get_str(data, "global") or _get_str(data, "global_account"),
|
|
1528
1718
|
bonding_curve=_get_str(data, "bonding_curve"),
|
|
1529
1719
|
bonding_curve_v2=_get_str(data, "bonding_curve_v2"),
|
|
@@ -1573,6 +1763,8 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
1573
1763
|
quote_vault=_get_str(data, "quote_vault"),
|
|
1574
1764
|
quote_token_program=_get_str(data, "quote_token_program"),
|
|
1575
1765
|
virtual_quote_reserves=_get_int(data, "virtual_quote_reserves"),
|
|
1766
|
+
creator_fee_bps=_get_int(data, "creator_fee_bps"),
|
|
1767
|
+
is_holder_reward=_get_bool(data, "is_holder_reward"),
|
|
1576
1768
|
)
|
|
1577
1769
|
|
|
1578
1770
|
if event_type == EventType.PUMP_FUN_CREATE_V2:
|
|
@@ -1598,6 +1790,8 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
1598
1790
|
quote_vault=_get_str(data, "quote_vault"),
|
|
1599
1791
|
quote_token_program=_get_str(data, "quote_token_program"),
|
|
1600
1792
|
virtual_quote_reserves=_get_int(data, "virtual_quote_reserves"),
|
|
1793
|
+
creator_fee_bps=_get_int(data, "creator_fee_bps"),
|
|
1794
|
+
is_holder_reward=_get_bool(data, "is_holder_reward"),
|
|
1601
1795
|
mint_authority=_get_str(data, "mint_authority"),
|
|
1602
1796
|
associated_bonding_curve=_get_str(data, "associated_bonding_curve"),
|
|
1603
1797
|
global_account=g,
|
|
@@ -1663,6 +1857,13 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
1663
1857
|
mayhem_mode=_get_bool(data, "mayhem_mode"),
|
|
1664
1858
|
cashback_fee_basis_points=_get_int(data, "cashback_fee_basis_points"),
|
|
1665
1859
|
cashback=_get_int(data, "cashback"),
|
|
1860
|
+
buyback_fee_basis_points=_get_int(data, "buyback_fee_basis_points"),
|
|
1861
|
+
buyback_fee=_get_int(data, "buyback_fee"),
|
|
1862
|
+
virtual_quote_reserves=_get_int(data, "virtual_quote_reserves"),
|
|
1863
|
+
can_boost=_get_bool(data, "can_boost"),
|
|
1864
|
+
base_supply=_get_int(data, "base_supply"),
|
|
1865
|
+
holder_rewards_bps=_get_int(data, "holder_rewards_bps"),
|
|
1866
|
+
holder_rewards=_get_int(data, "holder_rewards"),
|
|
1666
1867
|
is_cashback_coin=_get_bool(data, "is_cashback_coin"),
|
|
1667
1868
|
is_pump_pool=_get_bool(data, "is_pump_pool"),
|
|
1668
1869
|
base_mint=_get_str(data, "base_mint"),
|
|
@@ -1706,6 +1907,13 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
1706
1907
|
coin_creator_fee=_get_int(data, "coin_creator_fee"),
|
|
1707
1908
|
cashback_fee_basis_points=_get_int(data, "cashback_fee_basis_points"),
|
|
1708
1909
|
cashback=_get_int(data, "cashback"),
|
|
1910
|
+
buyback_fee_basis_points=_get_int(data, "buyback_fee_basis_points"),
|
|
1911
|
+
buyback_fee=_get_int(data, "buyback_fee"),
|
|
1912
|
+
virtual_quote_reserves=_get_int(data, "virtual_quote_reserves"),
|
|
1913
|
+
can_boost=_get_bool(data, "can_boost"),
|
|
1914
|
+
base_supply=_get_int(data, "base_supply"),
|
|
1915
|
+
holder_rewards_bps=_get_int(data, "holder_rewards_bps"),
|
|
1916
|
+
holder_rewards=_get_int(data, "holder_rewards"),
|
|
1709
1917
|
is_pump_pool=_get_bool(data, "is_pump_pool"),
|
|
1710
1918
|
base_mint=_get_str(data, "base_mint"),
|
|
1711
1919
|
quote_mint=_get_str(data, "quote_mint"),
|
|
@@ -1744,6 +1952,10 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
1744
1952
|
user_quote_token_account=_get_str(data, "user_quote_token_account"),
|
|
1745
1953
|
coin_creator=_get_str(data, "coin_creator"),
|
|
1746
1954
|
is_mayhem_mode=_get_bool(data, "is_mayhem_mode"),
|
|
1955
|
+
is_cashback_coin=_get_bool(data, "is_cashback_coin"),
|
|
1956
|
+
creator_fee_bps=_get_int(data, "creator_fee_bps"),
|
|
1957
|
+
can_edit_creator_fee=_get_bool(data, "can_edit_creator_fee"),
|
|
1958
|
+
is_holder_reward=_get_bool(data, "is_holder_reward"),
|
|
1747
1959
|
)
|
|
1748
1960
|
|
|
1749
1961
|
if event_type == EventType.PUMP_SWAP_LIQUIDITY_ADDED:
|
|
@@ -1801,6 +2013,35 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
1801
2013
|
return MeteoraDammV2ClosePositionEvent(metadata=meta, pool=_get_str(data, "pool"))
|
|
1802
2014
|
if event_type == EventType.METEORA_DAMM_V2_INITIALIZE_POOL:
|
|
1803
2015
|
return MeteoraDammV2InitializePoolEvent(metadata=meta, pool=_get_str(data, "pool"))
|
|
2016
|
+
if event_type == EventType.METEORA_DAMM_V2_UPDATE_DELEGATE_PERMISSION:
|
|
2017
|
+
return MeteoraDammV2UpdateDelegatePermissionEvent(
|
|
2018
|
+
metadata=meta,
|
|
2019
|
+
position=_get_str(data, "position"),
|
|
2020
|
+
owner=_get_str(data, "owner"),
|
|
2021
|
+
permission=_get_int(data, "permission"),
|
|
2022
|
+
delegate=data.get("delegate"),
|
|
2023
|
+
)
|
|
2024
|
+
if event_type == EventType.METEORA_DAMM_V2_WITHDRAW_DEAD_LIQUIDITY_REWARD:
|
|
2025
|
+
return MeteoraDammV2WithdrawDeadLiquidityRewardEvent(
|
|
2026
|
+
metadata=meta,
|
|
2027
|
+
pool=_get_str(data, "pool"),
|
|
2028
|
+
reward_mint=_get_str(data, "reward_mint"),
|
|
2029
|
+
amount=_get_int(data, "amount"),
|
|
2030
|
+
)
|
|
2031
|
+
if event_type == EventType.METEORA_DAMM_V2_CREATE_CONFIG:
|
|
2032
|
+
return MeteoraDammV2CreateConfigEvent(
|
|
2033
|
+
metadata=meta,
|
|
2034
|
+
config=_get_str(data, "config"),
|
|
2035
|
+
permission=str(data.get("permission", "0")),
|
|
2036
|
+
)
|
|
2037
|
+
if event_type == EventType.METEORA_DAMM_V2_CREATE_DYNAMIC_CONFIG:
|
|
2038
|
+
return MeteoraDammV2CreateDynamicConfigEvent(
|
|
2039
|
+
metadata=meta,
|
|
2040
|
+
config=_get_str(data, "config"),
|
|
2041
|
+
pool_creator_authority=_get_str(data, "pool_creator_authority"),
|
|
2042
|
+
index=_get_int(data, "index"),
|
|
2043
|
+
permission=str(data.get("permission", "0")),
|
|
2044
|
+
)
|
|
1804
2045
|
|
|
1805
2046
|
if event_type == EventType.RAYDIUM_CLMM_SWAP:
|
|
1806
2047
|
return RaydiumClmmSwapEvent(
|
|
@@ -2124,6 +2365,16 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
2124
2365
|
is_buy=_get_bool(data, "is_buy"),
|
|
2125
2366
|
trade_direction=_get_str(data, "trade_direction"),
|
|
2126
2367
|
exact_in=_get_bool(data, "exact_in"),
|
|
2368
|
+
global_config=_get_str(data, "global_config"),
|
|
2369
|
+
platform_config=_get_str(data, "platform_config"),
|
|
2370
|
+
user_base_token=_get_str(data, "user_base_token"),
|
|
2371
|
+
user_quote_token=_get_str(data, "user_quote_token"),
|
|
2372
|
+
base_vault=_get_str(data, "base_vault"),
|
|
2373
|
+
quote_vault=_get_str(data, "quote_vault"),
|
|
2374
|
+
base_mint=_get_str(data, "base_mint"),
|
|
2375
|
+
quote_mint=_get_str(data, "quote_mint"),
|
|
2376
|
+
base_token_program=_get_str(data, "base_token_program"),
|
|
2377
|
+
quote_token_program=_get_str(data, "quote_token_program"),
|
|
2127
2378
|
)
|
|
2128
2379
|
|
|
2129
2380
|
if event_type == EventType.RAYDIUM_LAUNCHLAB_POOL_CREATE:
|
|
@@ -2132,6 +2383,15 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
|
|
|
2132
2383
|
pool_state=_get_str(data, "pool_state"),
|
|
2133
2384
|
creator=_get_str(data, "creator"),
|
|
2134
2385
|
base_mint_param=_get_dict_any(data, "base_mint_param"),
|
|
2386
|
+
payer=_get_str(data, "payer"),
|
|
2387
|
+
global_config=_get_str(data, "global_config"),
|
|
2388
|
+
platform_config=_get_str(data, "platform_config"),
|
|
2389
|
+
base_mint=_get_str(data, "base_mint"),
|
|
2390
|
+
quote_mint=_get_str(data, "quote_mint"),
|
|
2391
|
+
base_vault=_get_str(data, "base_vault"),
|
|
2392
|
+
quote_vault=_get_str(data, "quote_vault"),
|
|
2393
|
+
base_token_program=_get_str(data, "base_token_program"),
|
|
2394
|
+
quote_token_program=_get_str(data, "quote_token_program"),
|
|
2135
2395
|
)
|
|
2136
2396
|
|
|
2137
2397
|
if event_type == EventType.RAYDIUM_LAUNCHLAB_MIGRATE_AMM:
|
|
@@ -2161,3 +2421,9 @@ def legacy_dict_to_dex_event(d: dict) -> Optional[DexEvent]:
|
|
|
2161
2421
|
except ValueError:
|
|
2162
2422
|
return None
|
|
2163
2423
|
return DexEvent(type=et, data=typed)
|
|
2424
|
+
|
|
2425
|
+
# Same classes: preserve isinstance, serialization and platform attribution.
|
|
2426
|
+
LaunchLabPoolCreateEvent = RaydiumLaunchlabPoolCreateEvent
|
|
2427
|
+
StonkFunPoolCreateEvent = RaydiumLaunchlabPoolCreateEvent
|
|
2428
|
+
LaunchLabTradeEvent = RaydiumLaunchlabTradeEvent
|
|
2429
|
+
StonkFunTradeEvent = RaydiumLaunchlabTradeEvent
|
|
@@ -131,3 +131,11 @@ __all__ = [
|
|
|
131
131
|
"build_subscribe_request_with_commitment",
|
|
132
132
|
"build_subscribe_transaction_filters_named",
|
|
133
133
|
]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def build_subscribe_request_with_event_filter(tx_filters, acc_filters, event_type_filter=None):
|
|
137
|
+
from ..grpc_types import EventType
|
|
138
|
+
request=build_subscribe_request(tx_filters,acc_filters)
|
|
139
|
+
if event_type_filter is not None and event_type_filter.should_include(EventType.BLOCK_META):
|
|
140
|
+
request.blocks_meta["block_meta"].CopyFrom(geyser_pb2.SubscribeRequestFilterBlocksMeta())
|
|
141
|
+
return request
|