sol-parser-sdk-python 0.4.4__py3-none-any.whl → 0.4.5__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/dex_parsers.py CHANGED
@@ -73,6 +73,41 @@ def _pub(b: bytes, o: int) -> str:
73
73
  return base58.b58encode(b[o : o + 32]).decode()
74
74
 
75
75
 
76
+ def _optional_u64(b: bytes, o: List[int]) -> int:
77
+ if o[0] + 8 > len(b):
78
+ return 0
79
+ v = _u64le(b, o[0])
80
+ o[0] += 8
81
+ return v
82
+
83
+
84
+ def _optional_pub(b: bytes, o: List[int]) -> str:
85
+ if o[0] + 32 > len(b):
86
+ return Z
87
+ v = _pub(b, o[0])
88
+ o[0] += 32
89
+ return v
90
+
91
+
92
+ def _trade_shareholders(b: bytes, o: List[int]) -> Optional[List[PumpFeesShareholder]]:
93
+ if o[0] + 4 > len(b):
94
+ return []
95
+ n = _u32le(b, o[0])
96
+ if n > 64:
97
+ return None
98
+ o[0] += 4
99
+ if o[0] + n * 34 > len(b):
100
+ return None
101
+ out: List[PumpFeesShareholder] = []
102
+ for _ in range(n):
103
+ address = _pub(b, o[0])
104
+ o[0] += 32
105
+ share_bps = _u16le(b, o[0])
106
+ o[0] += 2
107
+ out.append(PumpFeesShareholder(address=address, share_bps=share_bps))
108
+ return out
109
+
110
+
76
111
  def _bool(b: bytes, o: int) -> bool:
77
112
  return b[o] == 1
78
113
 
@@ -188,6 +223,17 @@ def parse_trade_from_data(data: bytes, meta: dict, is_created_buy: bool) -> DexE
188
223
  cb_bps = _u64le(data, o) if o + 8 <= len(data) else 0
189
224
  o += 8
190
225
  cb = _u64le(data, o) if o + 8 <= len(data) else 0
226
+ o += 8
227
+ tail = [o]
228
+ buyback_fee_basis_points = _optional_u64(data, tail)
229
+ buyback_fee = _optional_u64(data, tail)
230
+ shareholders = _trade_shareholders(data, tail)
231
+ if shareholders is None:
232
+ return DexEvent()
233
+ quote_mint = _optional_pub(data, tail)
234
+ quote_amount = _optional_u64(data, tail)
235
+ virtual_quote_reserves = _optional_u64(data, tail)
236
+ real_quote_reserves = _optional_u64(data, tail)
191
237
 
192
238
  event_data = PumpFunTradeEvent(
193
239
  metadata=_make_meta(meta),
@@ -217,6 +263,13 @@ def parse_trade_from_data(data: bytes, meta: dict, is_created_buy: bool) -> DexE
217
263
  mayhem_mode=mm,
218
264
  cashback_fee_basis_points=cb_bps,
219
265
  cashback=cb,
266
+ buyback_fee_basis_points=buyback_fee_basis_points,
267
+ buyback_fee=buyback_fee,
268
+ shareholders=shareholders,
269
+ quote_mint=quote_mint,
270
+ quote_amount=quote_amount,
271
+ virtual_quote_reserves=virtual_quote_reserves,
272
+ real_quote_reserves=real_quote_reserves,
220
273
  is_cashback_coin=cb_bps > 0,
221
274
  bonding_curve=Z,
222
275
  associated_bonding_curve=Z,
@@ -228,7 +281,7 @@ def parse_trade_from_data(data: bytes, meta: dict, is_created_buy: bool) -> DexE
228
281
  return DexEvent(type=EventType.PUMP_FUN_BUY, data=event_data)
229
282
  if ix_name in ("sell", "sell_v2"):
230
283
  return DexEvent(type=EventType.PUMP_FUN_SELL, data=event_data)
231
- if ix_name in ("buy_exact_sol_in", "buy_exact_quote_in_v2"):
284
+ if ix_name in ("buy_exact_sol_in", "buy_exact_quote_in", "buy_exact_quote_in_v2"):
232
285
  return DexEvent(type=EventType.PUMP_FUN_BUY_EXACT_SOL_IN, data=event_data)
233
286
  return DexEvent(type=EventType.PUMP_FUN_TRADE, data=event_data)
234
287
 
sol_parser/event_types.py CHANGED
@@ -144,12 +144,45 @@ class PumpFunTradeEvent(DexEventBase):
144
144
  mayhem_mode: bool = False
145
145
  cashback_fee_basis_points: int = 0
146
146
  cashback: int = 0
147
+ buyback_fee_basis_points: int = 0
148
+ buyback_fee: int = 0
149
+ shareholders: List[PumpFeesShareholder] = field(default_factory=list)
150
+ quote_mint: str = ""
151
+ quote_amount: int = 0
152
+ virtual_quote_reserves: int = 0
153
+ real_quote_reserves: int = 0
147
154
  is_cashback_coin: bool = False
155
+ amount: int = 0
156
+ max_sol_cost: int = 0
157
+ min_sol_output: int = 0
158
+ spendable_sol_in: int = 0
159
+ spendable_quote_in: int = 0
160
+ min_tokens_out: int = 0
161
+ global_account: str = ""
148
162
  bonding_curve: str = ""
163
+ bonding_curve_v2: str = ""
149
164
  associated_bonding_curve: str = ""
165
+ associated_user: str = ""
166
+ system_program: str = ""
150
167
  token_program: str = ""
168
+ quote_token_program: str = ""
169
+ associated_token_program: str = ""
151
170
  creator_vault: str = ""
152
- #: 17 个账户(索引 16),部分交易存在(Creator Rewards / fee 等);由 ``fill_trade_accounts`` 从指令账户填充。
171
+ associated_quote_fee_recipient: str = ""
172
+ buyback_fee_recipient: str = ""
173
+ associated_quote_buyback_fee_recipient: str = ""
174
+ associated_quote_bonding_curve: str = ""
175
+ associated_quote_user: str = ""
176
+ associated_creator_vault: str = ""
177
+ sharing_config: str = ""
178
+ event_authority: str = ""
179
+ program: str = ""
180
+ global_volume_accumulator: str = ""
181
+ user_volume_accumulator: str = ""
182
+ associated_user_volume_accumulator: str = ""
183
+ fee_config: str = ""
184
+ fee_program: str = ""
185
+ #: Legacy fallback alias for the last post-upgrade extra account. Prefer structured fields above.
153
186
  extra_instruction_account: str = ""
154
187
 
155
188
 
@@ -384,6 +417,9 @@ class PumpSwapBuyEvent(DexEventBase):
384
417
  coin_creator_vault_authority: str = ""
385
418
  base_token_program: str = ""
386
419
  quote_token_program: str = ""
420
+ pool_v2: str = ""
421
+ fee_recipient: str = ""
422
+ fee_recipient_quote_token_account: str = ""
387
423
  is_pump_pool: bool = False
388
424
 
389
425
 
@@ -423,6 +459,9 @@ class PumpSwapSellEvent(DexEventBase):
423
459
  coin_creator_vault_authority: str = ""
424
460
  base_token_program: str = ""
425
461
  quote_token_program: str = ""
462
+ pool_v2: str = ""
463
+ fee_recipient: str = ""
464
+ fee_recipient_quote_token_account: str = ""
426
465
  is_pump_pool: bool = False
427
466
 
428
467
 
@@ -1229,6 +1268,24 @@ def _get_dict_any(m: dict, key: str) -> Optional[Dict[str, Any]]:
1229
1268
  return v if isinstance(v, dict) else None
1230
1269
 
1231
1270
 
1271
+ def _get_pump_shareholders(m: dict, key: str) -> List[PumpFeesShareholder]:
1272
+ v = m.get(key, [])
1273
+ if not isinstance(v, (list, tuple)):
1274
+ return []
1275
+ out: List[PumpFeesShareholder] = []
1276
+ for item in v:
1277
+ if isinstance(item, PumpFeesShareholder):
1278
+ out.append(item)
1279
+ elif isinstance(item, dict):
1280
+ out.append(
1281
+ PumpFeesShareholder(
1282
+ address=_get_str(item, "address"),
1283
+ share_bps=_get_int(item, "share_bps"),
1284
+ )
1285
+ )
1286
+ return out
1287
+
1288
+
1232
1289
  def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1233
1290
  """将旧版 DexEvent dict 转换为强类型事件
1234
1291
 
@@ -1290,11 +1347,45 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1290
1347
  mayhem_mode=_get_bool(data, "mayhem_mode"),
1291
1348
  cashback_fee_basis_points=_get_int(data, "cashback_fee_basis_points"),
1292
1349
  cashback=_get_int(data, "cashback"),
1350
+ buyback_fee_basis_points=_get_int(data, "buyback_fee_basis_points"),
1351
+ buyback_fee=_get_int(data, "buyback_fee"),
1352
+ shareholders=_get_pump_shareholders(data, "shareholders"),
1353
+ quote_mint=_get_str(data, "quote_mint"),
1354
+ quote_amount=_get_int(data, "quote_amount"),
1355
+ virtual_quote_reserves=_get_int(data, "virtual_quote_reserves"),
1356
+ real_quote_reserves=_get_int(data, "real_quote_reserves"),
1293
1357
  is_cashback_coin=_get_bool(data, "is_cashback_coin"),
1358
+ amount=_get_int(data, "amount"),
1359
+ max_sol_cost=_get_int(data, "max_sol_cost"),
1360
+ min_sol_output=_get_int(data, "min_sol_output"),
1361
+ spendable_sol_in=_get_int(data, "spendable_sol_in"),
1362
+ spendable_quote_in=_get_int(data, "spendable_quote_in"),
1363
+ min_tokens_out=_get_int(data, "min_tokens_out"),
1364
+ global_account=_get_str(data, "global") or _get_str(data, "global_account"),
1294
1365
  bonding_curve=_get_str(data, "bonding_curve"),
1366
+ bonding_curve_v2=_get_str(data, "bonding_curve_v2"),
1295
1367
  associated_bonding_curve=_get_str(data, "associated_bonding_curve"),
1368
+ associated_user=_get_str(data, "associated_user"),
1369
+ system_program=_get_str(data, "system_program"),
1296
1370
  token_program=_get_str(data, "token_program"),
1371
+ quote_token_program=_get_str(data, "quote_token_program"),
1372
+ associated_token_program=_get_str(data, "associated_token_program"),
1297
1373
  creator_vault=_get_str(data, "creator_vault"),
1374
+ associated_quote_fee_recipient=_get_str(data, "associated_quote_fee_recipient"),
1375
+ buyback_fee_recipient=_get_str(data, "buyback_fee_recipient"),
1376
+ associated_quote_buyback_fee_recipient=_get_str(data, "associated_quote_buyback_fee_recipient"),
1377
+ associated_quote_bonding_curve=_get_str(data, "associated_quote_bonding_curve"),
1378
+ associated_quote_user=_get_str(data, "associated_quote_user"),
1379
+ associated_creator_vault=_get_str(data, "associated_creator_vault"),
1380
+ sharing_config=_get_str(data, "sharing_config"),
1381
+ event_authority=_get_str(data, "event_authority"),
1382
+ program=_get_str(data, "program"),
1383
+ global_volume_accumulator=_get_str(data, "global_volume_accumulator"),
1384
+ user_volume_accumulator=_get_str(data, "user_volume_accumulator"),
1385
+ associated_user_volume_accumulator=_get_str(data, "associated_user_volume_accumulator"),
1386
+ fee_config=_get_str(data, "fee_config"),
1387
+ fee_program=_get_str(data, "fee_program"),
1388
+ extra_instruction_account=_get_str(data, "account") or _get_str(data, "extra_instruction_account"),
1298
1389
  )
1299
1390
 
1300
1391
  if event_type == EventType.PUMP_FUN_CREATE:
@@ -1403,6 +1494,17 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1403
1494
  cashback=_get_int(data, "cashback"),
1404
1495
  is_cashback_coin=_get_bool(data, "is_cashback_coin"),
1405
1496
  is_pump_pool=_get_bool(data, "is_pump_pool"),
1497
+ base_mint=_get_str(data, "base_mint"),
1498
+ quote_mint=_get_str(data, "quote_mint"),
1499
+ pool_base_token_account=_get_str(data, "pool_base_token_account"),
1500
+ pool_quote_token_account=_get_str(data, "pool_quote_token_account"),
1501
+ coin_creator_vault_ata=_get_str(data, "coin_creator_vault_ata"),
1502
+ coin_creator_vault_authority=_get_str(data, "coin_creator_vault_authority"),
1503
+ base_token_program=_get_str(data, "base_token_program"),
1504
+ quote_token_program=_get_str(data, "quote_token_program"),
1505
+ pool_v2=_get_str(data, "pool_v2"),
1506
+ fee_recipient=_get_str(data, "fee_recipient"),
1507
+ fee_recipient_quote_token_account=_get_str(data, "fee_recipient_quote_token_account"),
1406
1508
  )
1407
1509
 
1408
1510
  if event_type == EventType.PUMP_SWAP_SELL:
@@ -1434,6 +1536,17 @@ def to_typed_event(event: dict) -> Optional[TypedDexEvent]:
1434
1536
  cashback_fee_basis_points=_get_int(data, "cashback_fee_basis_points"),
1435
1537
  cashback=_get_int(data, "cashback"),
1436
1538
  is_pump_pool=_get_bool(data, "is_pump_pool"),
1539
+ base_mint=_get_str(data, "base_mint"),
1540
+ quote_mint=_get_str(data, "quote_mint"),
1541
+ pool_base_token_account=_get_str(data, "pool_base_token_account"),
1542
+ pool_quote_token_account=_get_str(data, "pool_quote_token_account"),
1543
+ coin_creator_vault_ata=_get_str(data, "coin_creator_vault_ata"),
1544
+ coin_creator_vault_authority=_get_str(data, "coin_creator_vault_authority"),
1545
+ base_token_program=_get_str(data, "base_token_program"),
1546
+ quote_token_program=_get_str(data, "quote_token_program"),
1547
+ pool_v2=_get_str(data, "pool_v2"),
1548
+ fee_recipient=_get_str(data, "fee_recipient"),
1549
+ fee_recipient_quote_token_account=_get_str(data, "fee_recipient_quote_token_account"),
1437
1550
  )
1438
1551
 
1439
1552
  if event_type == EventType.PUMP_SWAP_CREATE_POOL:
sol_parser/grpc_types.py CHANGED
@@ -119,6 +119,11 @@ class EventType(str, Enum):
119
119
  TOKEN_INFO = "TokenInfo"
120
120
  NONCE_ACCOUNT = "NonceAccount"
121
121
  ACCOUNT_PUMP_FUN_GLOBAL = "AccountPumpFunGlobal"
122
+ ACCOUNT_PUMP_FUN_BONDING_CURVE = "AccountPumpFunBondingCurve"
123
+ ACCOUNT_PUMP_FUN_FEE_CONFIG = "AccountPumpFunFeeConfig"
124
+ ACCOUNT_PUMP_FUN_SHARING_CONFIG = "AccountPumpFunSharingConfig"
125
+ ACCOUNT_PUMP_FUN_GLOBAL_VOLUME_ACCUMULATOR = "AccountPumpFunGlobalVolumeAccumulator"
126
+ ACCOUNT_PUMP_FUN_USER_VOLUME_ACCUMULATOR = "AccountPumpFunUserVolumeAccumulator"
122
127
  ACCOUNT_PUMP_SWAP_GLOBAL_CONFIG = "AccountPumpSwapGlobalConfig"
123
128
  ACCOUNT_PUMP_SWAP_POOL = "AccountPumpSwapPool"
124
129
 
@@ -211,6 +216,11 @@ def all_event_types() -> List[EventType]:
211
216
  EventType.TOKEN_INFO,
212
217
  EventType.NONCE_ACCOUNT,
213
218
  EventType.ACCOUNT_PUMP_FUN_GLOBAL,
219
+ EventType.ACCOUNT_PUMP_FUN_BONDING_CURVE,
220
+ EventType.ACCOUNT_PUMP_FUN_FEE_CONFIG,
221
+ EventType.ACCOUNT_PUMP_FUN_SHARING_CONFIG,
222
+ EventType.ACCOUNT_PUMP_FUN_GLOBAL_VOLUME_ACCUMULATOR,
223
+ EventType.ACCOUNT_PUMP_FUN_USER_VOLUME_ACCUMULATOR,
214
224
  EventType.ACCOUNT_PUMP_SWAP_GLOBAL_CONFIG,
215
225
  EventType.ACCOUNT_PUMP_SWAP_POOL,
216
226
  ]
@@ -415,6 +425,11 @@ def event_type_filter_includes_pumpfun(filter: EventTypeFilter) -> bool:
415
425
  EventType.PUMP_FEES_UPSERT_FEE_TIERS,
416
426
  EventType.PUMP_FUN_MIGRATE_BONDING_CURVE_CREATOR,
417
427
  EventType.ACCOUNT_PUMP_FUN_GLOBAL,
428
+ EventType.ACCOUNT_PUMP_FUN_BONDING_CURVE,
429
+ EventType.ACCOUNT_PUMP_FUN_FEE_CONFIG,
430
+ EventType.ACCOUNT_PUMP_FUN_SHARING_CONFIG,
431
+ EventType.ACCOUNT_PUMP_FUN_GLOBAL_VOLUME_ACCUMULATOR,
432
+ EventType.ACCOUNT_PUMP_FUN_USER_VOLUME_ACCUMULATOR,
418
433
  ]
419
434
  return _event_type_filter_includes_any(filter, pumpfun_types)
420
435
 
@@ -461,6 +476,11 @@ def event_type_filter_allows_instruction_parsing(include_only: List[EventType])
461
476
  EventType.PUMP_FUN_MIGRATE,
462
477
  EventType.PUMP_FUN_MIGRATE_BONDING_CURVE_CREATOR,
463
478
  EventType.ACCOUNT_PUMP_FUN_GLOBAL,
479
+ EventType.ACCOUNT_PUMP_FUN_BONDING_CURVE,
480
+ EventType.ACCOUNT_PUMP_FUN_FEE_CONFIG,
481
+ EventType.ACCOUNT_PUMP_FUN_SHARING_CONFIG,
482
+ EventType.ACCOUNT_PUMP_FUN_GLOBAL_VOLUME_ACCUMULATOR,
483
+ EventType.ACCOUNT_PUMP_FUN_USER_VOLUME_ACCUMULATOR,
464
484
  *PUMP_FEES_EVENT_TYPES,
465
485
  EventType.PUMP_SWAP_BUY,
466
486
  EventType.PUMP_SWAP_SELL,