chainstream-sdk 0.1.0__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.
Files changed (261) hide show
  1. chainstream/__init__.py +46 -0
  2. chainstream/client.py +104 -0
  3. chainstream/openapi_client/__init__.py +156 -0
  4. chainstream/openapi_client/api/__init__.py +20 -0
  5. chainstream/openapi_client/api/blockchain_api.py +549 -0
  6. chainstream/openapi_client/api/defi_sol_moonshot_api.py +590 -0
  7. chainstream/openapi_client/api/defi_sol_pumpfun_api.py +314 -0
  8. chainstream/openapi_client/api/dex_api.py +1576 -0
  9. chainstream/openapi_client/api/dex_pool_api.py +645 -0
  10. chainstream/openapi_client/api/endpoint_api.py +1934 -0
  11. chainstream/openapi_client/api/ipfs_api.py +283 -0
  12. chainstream/openapi_client/api/jobs_api.py +562 -0
  13. chainstream/openapi_client/api/kyt_api.py +3743 -0
  14. chainstream/openapi_client/api/ranking_api.py +2067 -0
  15. chainstream/openapi_client/api/red_packet_api.py +2444 -0
  16. chainstream/openapi_client/api/token_api.py +9211 -0
  17. chainstream/openapi_client/api/trade_api.py +1352 -0
  18. chainstream/openapi_client/api/transaction_api.py +882 -0
  19. chainstream/openapi_client/api/wallet_api.py +1608 -0
  20. chainstream/openapi_client/api/watchlist_api.py +316 -0
  21. chainstream/openapi_client/api_client.py +801 -0
  22. chainstream/openapi_client/api_response.py +21 -0
  23. chainstream/openapi_client/configuration.py +572 -0
  24. chainstream/openapi_client/exceptions.py +217 -0
  25. chainstream/openapi_client/models/__init__.py +122 -0
  26. chainstream/openapi_client/models/address_exposure.py +94 -0
  27. chainstream/openapi_client/models/address_risk_response_dto.py +112 -0
  28. chainstream/openapi_client/models/alert_detail.py +100 -0
  29. chainstream/openapi_client/models/alterya_identification.py +106 -0
  30. chainstream/openapi_client/models/balance_change_type.py +38 -0
  31. chainstream/openapi_client/models/balance_token_type.py +38 -0
  32. chainstream/openapi_client/models/balance_update_dto.py +130 -0
  33. chainstream/openapi_client/models/balance_update_page.py +104 -0
  34. chainstream/openapi_client/models/blockchain_dto.py +94 -0
  35. chainstream/openapi_client/models/blockchain_latest_block_dto.py +90 -0
  36. chainstream/openapi_client/models/boolean_result_dto.py +88 -0
  37. chainstream/openapi_client/models/calculate_pnl_input.py +88 -0
  38. chainstream/openapi_client/models/candle.py +101 -0
  39. chainstream/openapi_client/models/chain.py +39 -0
  40. chainstream/openapi_client/models/chain_symbol.py +39 -0
  41. chainstream/openapi_client/models/chainalysis_address_identification.py +92 -0
  42. chainstream/openapi_client/models/claim_red_packet_input.py +103 -0
  43. chainstream/openapi_client/models/create_endpoint_input.py +102 -0
  44. chainstream/openapi_client/models/create_red_packet_input.py +112 -0
  45. chainstream/openapi_client/models/create_red_packet_reply.py +90 -0
  46. chainstream/openapi_client/models/create_token_input.py +110 -0
  47. chainstream/openapi_client/models/create_token_reply.py +90 -0
  48. chainstream/openapi_client/models/dev_token_dto.py +106 -0
  49. chainstream/openapi_client/models/dex_dto.py +94 -0
  50. chainstream/openapi_client/models/dex_page.py +106 -0
  51. chainstream/openapi_client/models/dex_pool_dto.py +161 -0
  52. chainstream/openapi_client/models/dex_pool_snapshot_dto.py +111 -0
  53. chainstream/openapi_client/models/dex_pool_snapshot_page.py +104 -0
  54. chainstream/openapi_client/models/dex_pool_token_liquidity.py +100 -0
  55. chainstream/openapi_client/models/dex_pool_token_snapshot_dto.py +100 -0
  56. chainstream/openapi_client/models/dex_quote_response.py +98 -0
  57. chainstream/openapi_client/models/direct_exposure_detail.py +90 -0
  58. chainstream/openapi_client/models/endpoint_list_response.py +102 -0
  59. chainstream/openapi_client/models/endpoint_operation_response.py +88 -0
  60. chainstream/openapi_client/models/endpoint_response.py +108 -0
  61. chainstream/openapi_client/models/endpoint_secret_response.py +88 -0
  62. chainstream/openapi_client/models/estimate_gas_limit_input.py +94 -0
  63. chainstream/openapi_client/models/estimate_gas_limit_response.py +90 -0
  64. chainstream/openapi_client/models/filter_condition.py +102 -0
  65. chainstream/openapi_client/models/gas_price_response.py +90 -0
  66. chainstream/openapi_client/models/job_dto.py +90 -0
  67. chainstream/openapi_client/models/job_streaming_dto.py +90 -0
  68. chainstream/openapi_client/models/kyt_register_transfer_request.py +108 -0
  69. chainstream/openapi_client/models/kyt_register_withdrawal_request.py +111 -0
  70. chainstream/openapi_client/models/link.py +97 -0
  71. chainstream/openapi_client/models/moonshot_create_token_input.py +145 -0
  72. chainstream/openapi_client/models/moonshot_create_token_reply.py +90 -0
  73. chainstream/openapi_client/models/moonshot_submit_create_token200_response.py +90 -0
  74. chainstream/openapi_client/models/moonshot_submit_create_token_input.py +90 -0
  75. chainstream/openapi_client/models/network_identification_org.py +88 -0
  76. chainstream/openapi_client/models/on_chain_activity.py +88 -0
  77. chainstream/openapi_client/models/pump_create_token_input.py +155 -0
  78. chainstream/openapi_client/models/pump_create_token_reply.py +90 -0
  79. chainstream/openapi_client/models/red_packet_claim_dto.py +103 -0
  80. chainstream/openapi_client/models/red_packet_claims_page.py +104 -0
  81. chainstream/openapi_client/models/red_packet_dto.py +121 -0
  82. chainstream/openapi_client/models/red_packet_reply.py +88 -0
  83. chainstream/openapi_client/models/red_packet_send_tx_input.py +88 -0
  84. chainstream/openapi_client/models/red_packet_send_tx_response.py +88 -0
  85. chainstream/openapi_client/models/red_packets_page.py +104 -0
  86. chainstream/openapi_client/models/register_address_request.py +88 -0
  87. chainstream/openapi_client/models/register_address_response_dto.py +88 -0
  88. chainstream/openapi_client/models/resolution.py +46 -0
  89. chainstream/openapi_client/models/send_tx_input.py +102 -0
  90. chainstream/openapi_client/models/send_tx_response.py +92 -0
  91. chainstream/openapi_client/models/swap_input.py +119 -0
  92. chainstream/openapi_client/models/swap_reply.py +90 -0
  93. chainstream/openapi_client/models/swap_route_input.py +127 -0
  94. chainstream/openapi_client/models/swap_route_response.py +98 -0
  95. chainstream/openapi_client/models/token.py +158 -0
  96. chainstream/openapi_client/models/token_creation_dto.py +107 -0
  97. chainstream/openapi_client/models/token_creation_page.py +106 -0
  98. chainstream/openapi_client/models/token_creators_dto.py +92 -0
  99. chainstream/openapi_client/models/token_extra_dto.py +128 -0
  100. chainstream/openapi_client/models/token_holder.py +94 -0
  101. chainstream/openapi_client/models/token_holder_page.py +106 -0
  102. chainstream/openapi_client/models/token_liquidity_snapshot_dto.py +106 -0
  103. chainstream/openapi_client/models/token_liquidity_snapshot_page.py +104 -0
  104. chainstream/openapi_client/models/token_list_page.py +106 -0
  105. chainstream/openapi_client/models/token_market_data.py +174 -0
  106. chainstream/openapi_client/models/token_metadata.py +132 -0
  107. chainstream/openapi_client/models/token_page.py +108 -0
  108. chainstream/openapi_client/models/token_price_dto.py +94 -0
  109. chainstream/openapi_client/models/token_price_page.py +106 -0
  110. chainstream/openapi_client/models/token_social_medias_dto.py +112 -0
  111. chainstream/openapi_client/models/token_stat.py +340 -0
  112. chainstream/openapi_client/models/token_trader.py +113 -0
  113. chainstream/openapi_client/models/token_trader_tag.py +45 -0
  114. chainstream/openapi_client/models/top_traders_dto.py +110 -0
  115. chainstream/openapi_client/models/top_traders_page.py +106 -0
  116. chainstream/openapi_client/models/trade_detail_dto.py +136 -0
  117. chainstream/openapi_client/models/trade_event.py +113 -0
  118. chainstream/openapi_client/models/trade_page.py +106 -0
  119. chainstream/openapi_client/models/trade_type.py +38 -0
  120. chainstream/openapi_client/models/transfer_alerts_response_dto.py +96 -0
  121. chainstream/openapi_client/models/transfer_base_response_dto.py +112 -0
  122. chainstream/openapi_client/models/transfer_direct_exposure_response_dto.py +92 -0
  123. chainstream/openapi_client/models/transfer_network_identifications_response_dto.py +98 -0
  124. chainstream/openapi_client/models/update_endpoint_input.py +104 -0
  125. chainstream/openapi_client/models/wallet_balance_detail_dto.py +136 -0
  126. chainstream/openapi_client/models/wallet_balances_dto.py +100 -0
  127. chainstream/openapi_client/models/wallet_pnl_dto.py +132 -0
  128. chainstream/openapi_client/models/withdrawal_address_identifications_response_dto.py +98 -0
  129. chainstream/openapi_client/models/withdrawal_base_response_dto.py +106 -0
  130. chainstream/openapi_client/models/withdrawal_fraud_assessment_response_dto.py +96 -0
  131. chainstream/openapi_client/rest.py +213 -0
  132. chainstream/openapi_client/test/__init__.py +0 -0
  133. chainstream/openapi_client/test/test_address_exposure.py +59 -0
  134. chainstream/openapi_client/test/test_address_risk_response_dto.py +81 -0
  135. chainstream/openapi_client/test/test_alert_detail.py +65 -0
  136. chainstream/openapi_client/test/test_alterya_identification.py +69 -0
  137. chainstream/openapi_client/test/test_balance_change_type.py +34 -0
  138. chainstream/openapi_client/test/test_balance_token_type.py +34 -0
  139. chainstream/openapi_client/test/test_balance_update_dto.py +93 -0
  140. chainstream/openapi_client/test/test_balance_update_page.py +105 -0
  141. chainstream/openapi_client/test/test_blockchain_api.py +46 -0
  142. chainstream/openapi_client/test/test_blockchain_dto.py +59 -0
  143. chainstream/openapi_client/test/test_blockchain_latest_block_dto.py +55 -0
  144. chainstream/openapi_client/test/test_boolean_result_dto.py +53 -0
  145. chainstream/openapi_client/test/test_calculate_pnl_input.py +52 -0
  146. chainstream/openapi_client/test/test_candle.py +65 -0
  147. chainstream/openapi_client/test/test_chain.py +34 -0
  148. chainstream/openapi_client/test/test_chain_symbol.py +34 -0
  149. chainstream/openapi_client/test/test_chainalysis_address_identification.py +57 -0
  150. chainstream/openapi_client/test/test_claim_red_packet_input.py +58 -0
  151. chainstream/openapi_client/test/test_create_endpoint_input.py +63 -0
  152. chainstream/openapi_client/test/test_create_red_packet_input.py +64 -0
  153. chainstream/openapi_client/test/test_create_red_packet_reply.py +55 -0
  154. chainstream/openapi_client/test/test_create_token_input.py +63 -0
  155. chainstream/openapi_client/test/test_create_token_reply.py +55 -0
  156. chainstream/openapi_client/test/test_defi_sol_moonshot_api.py +46 -0
  157. chainstream/openapi_client/test/test_defi_sol_pumpfun_api.py +39 -0
  158. chainstream/openapi_client/test/test_dev_token_dto.py +441 -0
  159. chainstream/openapi_client/test/test_dex_api.py +67 -0
  160. chainstream/openapi_client/test/test_dex_dto.py +56 -0
  161. chainstream/openapi_client/test/test_dex_page.py +70 -0
  162. chainstream/openapi_client/test/test_dex_pool_api.py +46 -0
  163. chainstream/openapi_client/test/test_dex_pool_dto.py +88 -0
  164. chainstream/openapi_client/test/test_dex_pool_snapshot_dto.py +96 -0
  165. chainstream/openapi_client/test/test_dex_pool_snapshot_page.py +81 -0
  166. chainstream/openapi_client/test/test_dex_pool_token_liquidity.py +65 -0
  167. chainstream/openapi_client/test/test_dex_pool_token_snapshot_dto.py +65 -0
  168. chainstream/openapi_client/test/test_dex_quote_response.py +57 -0
  169. chainstream/openapi_client/test/test_direct_exposure_detail.py +55 -0
  170. chainstream/openapi_client/test/test_endpoint_api.py +81 -0
  171. chainstream/openapi_client/test/test_endpoint_list_response.py +72 -0
  172. chainstream/openapi_client/test/test_endpoint_operation_response.py +52 -0
  173. chainstream/openapi_client/test/test_endpoint_response.py +66 -0
  174. chainstream/openapi_client/test/test_endpoint_secret_response.py +52 -0
  175. chainstream/openapi_client/test/test_estimate_gas_limit_input.py +58 -0
  176. chainstream/openapi_client/test/test_estimate_gas_limit_response.py +55 -0
  177. chainstream/openapi_client/test/test_filter_condition.py +54 -0
  178. chainstream/openapi_client/test/test_gas_price_response.py +55 -0
  179. chainstream/openapi_client/test/test_ipfs_api.py +39 -0
  180. chainstream/openapi_client/test/test_job_dto.py +55 -0
  181. chainstream/openapi_client/test/test_job_streaming_dto.py +55 -0
  182. chainstream/openapi_client/test/test_jobs_api.py +46 -0
  183. chainstream/openapi_client/test/test_kyt_api.py +130 -0
  184. chainstream/openapi_client/test/test_kyt_register_transfer_request.py +59 -0
  185. chainstream/openapi_client/test/test_kyt_register_withdrawal_request.py +65 -0
  186. chainstream/openapi_client/test/test_link.py +55 -0
  187. chainstream/openapi_client/test/test_moonshot_create_token_input.py +79 -0
  188. chainstream/openapi_client/test/test_moonshot_create_token_reply.py +55 -0
  189. chainstream/openapi_client/test/test_moonshot_submit_create_token200_response.py +53 -0
  190. chainstream/openapi_client/test/test_moonshot_submit_create_token_input.py +54 -0
  191. chainstream/openapi_client/test/test_network_identification_org.py +53 -0
  192. chainstream/openapi_client/test/test_on_chain_activity.py +53 -0
  193. chainstream/openapi_client/test/test_pump_create_token_input.py +71 -0
  194. chainstream/openapi_client/test/test_pump_create_token_reply.py +54 -0
  195. chainstream/openapi_client/test/test_ranking_api.py +67 -0
  196. chainstream/openapi_client/test/test_red_packet_api.py +88 -0
  197. chainstream/openapi_client/test/test_red_packet_claim_dto.py +67 -0
  198. chainstream/openapi_client/test/test_red_packet_claims_page.py +81 -0
  199. chainstream/openapi_client/test/test_red_packet_dto.py +85 -0
  200. chainstream/openapi_client/test/test_red_packet_reply.py +53 -0
  201. chainstream/openapi_client/test/test_red_packet_send_tx_input.py +53 -0
  202. chainstream/openapi_client/test/test_red_packet_send_tx_response.py +53 -0
  203. chainstream/openapi_client/test/test_red_packets_page.py +99 -0
  204. chainstream/openapi_client/test/test_register_address_request.py +53 -0
  205. chainstream/openapi_client/test/test_register_address_response_dto.py +53 -0
  206. chainstream/openapi_client/test/test_resolution.py +34 -0
  207. chainstream/openapi_client/test/test_send_tx_input.py +55 -0
  208. chainstream/openapi_client/test/test_send_tx_response.py +57 -0
  209. chainstream/openapi_client/test/test_swap_input.py +65 -0
  210. chainstream/openapi_client/test/test_swap_reply.py +55 -0
  211. chainstream/openapi_client/test/test_swap_route_input.py +69 -0
  212. chainstream/openapi_client/test/test_swap_route_response.py +85 -0
  213. chainstream/openapi_client/test/test_token.py +352 -0
  214. chainstream/openapi_client/test/test_token_api.py +193 -0
  215. chainstream/openapi_client/test/test_token_creation_dto.py +64 -0
  216. chainstream/openapi_client/test/test_token_creation_page.py +76 -0
  217. chainstream/openapi_client/test/test_token_creators_dto.py +54 -0
  218. chainstream/openapi_client/test/test_token_extra_dto.py +72 -0
  219. chainstream/openapi_client/test/test_token_holder.py +59 -0
  220. chainstream/openapi_client/test/test_token_holder_page.py +70 -0
  221. chainstream/openapi_client/test/test_token_liquidity_snapshot_dto.py +71 -0
  222. chainstream/openapi_client/test/test_token_liquidity_snapshot_page.py +83 -0
  223. chainstream/openapi_client/test/test_token_list_page.py +154 -0
  224. chainstream/openapi_client/test/test_token_market_data.py +101 -0
  225. chainstream/openapi_client/test/test_token_metadata.py +110 -0
  226. chainstream/openapi_client/test/test_token_page.py +155 -0
  227. chainstream/openapi_client/test/test_token_price_dto.py +59 -0
  228. chainstream/openapi_client/test/test_token_price_page.py +70 -0
  229. chainstream/openapi_client/test/test_token_social_medias_dto.py +64 -0
  230. chainstream/openapi_client/test/test_token_stat.py +257 -0
  231. chainstream/openapi_client/test/test_token_trader.py +65 -0
  232. chainstream/openapi_client/test/test_token_trader_tag.py +34 -0
  233. chainstream/openapi_client/test/test_top_traders_dto.py +75 -0
  234. chainstream/openapi_client/test/test_top_traders_page.py +86 -0
  235. chainstream/openapi_client/test/test_trade_api.py +53 -0
  236. chainstream/openapi_client/test/test_trade_detail_dto.py +101 -0
  237. chainstream/openapi_client/test/test_trade_event.py +77 -0
  238. chainstream/openapi_client/test/test_trade_page.py +112 -0
  239. chainstream/openapi_client/test/test_trade_type.py +34 -0
  240. chainstream/openapi_client/test/test_transaction_api.py +53 -0
  241. chainstream/openapi_client/test/test_transfer_alerts_response_dto.py +71 -0
  242. chainstream/openapi_client/test/test_transfer_base_response_dto.py +77 -0
  243. chainstream/openapi_client/test/test_transfer_direct_exposure_response_dto.py +57 -0
  244. chainstream/openapi_client/test/test_transfer_network_identifications_response_dto.py +61 -0
  245. chainstream/openapi_client/test/test_update_endpoint_input.py +64 -0
  246. chainstream/openapi_client/test/test_wallet_api.py +67 -0
  247. chainstream/openapi_client/test/test_wallet_balance_detail_dto.py +101 -0
  248. chainstream/openapi_client/test/test_wallet_balances_dto.py +111 -0
  249. chainstream/openapi_client/test/test_wallet_pnl_dto.py +97 -0
  250. chainstream/openapi_client/test/test_watchlist_api.py +39 -0
  251. chainstream/openapi_client/test/test_withdrawal_address_identifications_response_dto.py +65 -0
  252. chainstream/openapi_client/test/test_withdrawal_base_response_dto.py +71 -0
  253. chainstream/openapi_client/test/test_withdrawal_fraud_assessment_response_dto.py +73 -0
  254. chainstream/stream/__init__.py +74 -0
  255. chainstream/stream/client.py +761 -0
  256. chainstream/stream/fields.py +284 -0
  257. chainstream/stream/models.py +415 -0
  258. chainstream_sdk-0.1.0.dist-info/METADATA +80 -0
  259. chainstream_sdk-0.1.0.dist-info/RECORD +261 -0
  260. chainstream_sdk-0.1.0.dist-info/WHEEL +4 -0
  261. chainstream_sdk-0.1.0.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,284 @@
1
+ """CEL field mappings for stream filter expressions."""
2
+
3
+ import re
4
+ from typing import Dict, List
5
+
6
+ # CEL field mappings organized by subscription method
7
+ CEL_FIELD_MAPPINGS: Dict[str, Dict[str, str]] = {
8
+ # Wallet balance subscription fields
9
+ "subscribe_wallet_balance": {
10
+ "wallet_address": "a",
11
+ "token_address": "ta",
12
+ "token_price_in_usd": "tpiu",
13
+ "balance": "b",
14
+ "timestamp": "t",
15
+ },
16
+ # Token candle subscription fields
17
+ "subscribe_token_candles": {
18
+ "open": "o",
19
+ "close": "c",
20
+ "high": "h",
21
+ "low": "l",
22
+ "volume": "v",
23
+ "resolution": "r",
24
+ "time": "t",
25
+ "number": "n",
26
+ },
27
+ # Token stats subscription fields
28
+ "subscribe_token_stats": {
29
+ "address": "a",
30
+ "timestamp": "t",
31
+ "buys_1m": "b1m",
32
+ "sells_1m": "s1m",
33
+ "buyers_1m": "be1m",
34
+ "sellers_1m": "se1m",
35
+ "buy_volume_in_usd_1m": "bviu1m",
36
+ "sell_volume_in_usd_1m": "sviu1m",
37
+ "price_1m": "p1m",
38
+ "open_in_usd_1m": "oiu1m",
39
+ "close_in_usd_1m": "ciu1m",
40
+ "buys_5m": "b5m",
41
+ "sells_5m": "s5m",
42
+ "buyers_5m": "be5m",
43
+ "sellers_5m": "se5m",
44
+ "buy_volume_in_usd_5m": "bviu5m",
45
+ "sell_volume_in_usd_5m": "sviu5m",
46
+ "price_5m": "p5m",
47
+ "open_in_usd_5m": "oiu5m",
48
+ "close_in_usd_5m": "ciu5m",
49
+ "buys_15m": "b15m",
50
+ "sells_15m": "s15m",
51
+ "buyers_15m": "be15m",
52
+ "sellers_15m": "se15m",
53
+ "buy_volume_in_usd_15m": "bviu15m",
54
+ "sell_volume_in_usd_15m": "sviu15m",
55
+ "price_15m": "p15m",
56
+ "open_in_usd_15m": "oiu15m",
57
+ "close_in_usd_15m": "ciu15m",
58
+ "buys_30m": "b30m",
59
+ "sells_30m": "s30m",
60
+ "buyers_30m": "be30m",
61
+ "sellers_30m": "se30m",
62
+ "buy_volume_in_usd_30m": "bviu30m",
63
+ "sell_volume_in_usd_30m": "sviu30m",
64
+ "price_30m": "p30m",
65
+ "open_in_usd_30m": "oiu30m",
66
+ "close_in_usd_30m": "ciu30m",
67
+ "buys_1h": "b1h",
68
+ "sells_1h": "s1h",
69
+ "buyers_1h": "be1h",
70
+ "sellers_1h": "se1h",
71
+ "buy_volume_in_usd_1h": "bviu1h",
72
+ "sell_volume_in_usd_1h": "sviu1h",
73
+ "price_1h": "p1h",
74
+ "open_in_usd_1h": "oiu1h",
75
+ "close_in_usd_1h": "ciu1h",
76
+ "buys_4h": "b4h",
77
+ "sells_4h": "s4h",
78
+ "buyers_4h": "be4h",
79
+ "sellers_4h": "se4h",
80
+ "buy_volume_in_usd_4h": "bviu4h",
81
+ "sell_volume_in_usd_4h": "sviu4h",
82
+ "price_4h": "p4h",
83
+ "open_in_usd_4h": "oiu4h",
84
+ "close_in_usd_4h": "ciu4h",
85
+ "buys_24h": "b24h",
86
+ "sells_24h": "s24h",
87
+ "buyers_24h": "be24h",
88
+ "sellers_24h": "se24h",
89
+ "buy_volume_in_usd_24h": "bviu24h",
90
+ "sell_volume_in_usd_24h": "sviu24h",
91
+ "price_24h": "p24h",
92
+ "price": "p",
93
+ "open_in_usd_24h": "oiu24h",
94
+ "close_in_usd_24h": "ciu24h",
95
+ },
96
+ # Token holder subscription fields
97
+ "subscribe_token_holders": {
98
+ "token_address": "a",
99
+ "holders": "h",
100
+ "top100_amount": "t100a",
101
+ "top10_amount": "t10a",
102
+ "top100_holders": "t100h",
103
+ "top10_holders": "t10h",
104
+ "top100_ratio": "t100r",
105
+ "top10_ratio": "t10r",
106
+ "timestamp": "ts",
107
+ },
108
+ # New token subscription fields
109
+ "subscribe_new_token": {
110
+ "token_address": "a",
111
+ "name": "n",
112
+ "symbol": "s",
113
+ "created_at_ms": "cts",
114
+ },
115
+ # Token supply subscription fields
116
+ "subscribe_token_supply": {
117
+ "token_address": "a",
118
+ "supply": "s",
119
+ "timestamp": "ts",
120
+ },
121
+ # DEX pool balance subscription fields
122
+ "subscribe_dex_pool_balance": {
123
+ "pool_address": "a",
124
+ "token_a_address": "taa",
125
+ "token_a_liquidity_in_usd": "taliu",
126
+ "token_b_address": "tba",
127
+ "token_b_liquidity_in_usd": "tbliu",
128
+ },
129
+ # Token liquidity subscription fields
130
+ "subscribe_token_liquidity": {
131
+ "token_address": "a",
132
+ "metric_type": "t",
133
+ "value": "v",
134
+ "timestamp": "ts",
135
+ },
136
+ # New token metadata subscription fields
137
+ "subscribe_new_tokens_metadata": {
138
+ "token_address": "a",
139
+ "name": "n",
140
+ "symbol": "s",
141
+ "image_url": "iu",
142
+ "description": "de",
143
+ "social_media": "sm",
144
+ "created_at_ms": "cts",
145
+ },
146
+ # Token trade subscription fields
147
+ "subscribe_token_trades": {
148
+ "token_address": "a",
149
+ "timestamp": "t",
150
+ "kind": "k",
151
+ "buy_amount": "ba",
152
+ "buy_amount_in_usd": "baiu",
153
+ "buy_token_address": "btma",
154
+ "buy_token_name": "btn",
155
+ "buy_token_symbol": "bts",
156
+ "buy_wallet_address": "bwa",
157
+ "sell_amount": "sa",
158
+ "sell_amount_in_usd": "saiu",
159
+ "sell_token_address": "stma",
160
+ "sell_token_name": "stn",
161
+ "sell_token_symbol": "sts",
162
+ "sell_wallet_address": "swa",
163
+ "tx_hash": "h",
164
+ },
165
+ # Wallet token PnL subscription fields
166
+ "subscribe_wallet_pnl": {
167
+ "wallet_address": "a",
168
+ "token_address": "ta",
169
+ "token_price_in_usd": "tpiu",
170
+ "timestamp": "t",
171
+ "open_time": "ot",
172
+ "last_time": "lt",
173
+ "close_time": "ct",
174
+ "buy_amount": "ba",
175
+ "buy_amount_in_usd": "baiu",
176
+ "buy_count": "bs",
177
+ "buy_count_30d": "bs30d",
178
+ "buy_count_7d": "bs7d",
179
+ "sell_amount": "sa",
180
+ "sell_amount_in_usd": "saiu",
181
+ "sell_count": "ss",
182
+ "sell_count_30d": "ss30d",
183
+ "sell_count_7d": "ss7d",
184
+ "held_duration_timestamp": "hdts",
185
+ "average_buy_price_in_usd": "abpiu",
186
+ "average_sell_price_in_usd": "aspiu",
187
+ "unrealized_profit_in_usd": "upiu",
188
+ "unrealized_profit_ratio": "upr",
189
+ "realized_profit_in_usd": "rpiu",
190
+ "realized_profit_ratio": "rpr",
191
+ "total_realized_profit_in_usd": "trpiu",
192
+ "total_realized_profit_ratio": "trr",
193
+ },
194
+ # Wallet trade subscription fields
195
+ "subscribe_wallet_trade": {
196
+ "token_address": "a",
197
+ "timestamp": "t",
198
+ "kind": "k",
199
+ "buy_amount": "ba",
200
+ "buy_amount_in_usd": "baiu",
201
+ "buy_token_address": "btma",
202
+ "buy_token_name": "btn",
203
+ "buy_token_symbol": "bts",
204
+ "buy_wallet_address": "bwa",
205
+ "sell_amount": "sa",
206
+ "sell_amount_in_usd": "saiu",
207
+ "sell_token_address": "stma",
208
+ "sell_token_name": "stn",
209
+ "sell_token_symbol": "sts",
210
+ "sell_wallet_address": "swa",
211
+ "tx_hash": "h",
212
+ },
213
+ # Token max liquidity subscription fields
214
+ "subscribe_token_max_liquidity": {
215
+ "token_address": "a",
216
+ "pool_address": "p",
217
+ "liquidity_in_usd": "liu",
218
+ "liquidity_in_native": "lin",
219
+ "timestamp": "ts",
220
+ },
221
+ # Token total liquidity subscription fields
222
+ "subscribe_token_total_liquidity": {
223
+ "token_address": "a",
224
+ "liquidity_in_usd": "liu",
225
+ "liquidity_in_native": "lin",
226
+ "pool_count": "pc",
227
+ "timestamp": "ts",
228
+ },
229
+ }
230
+
231
+
232
+ def get_field_mappings(method_name: str) -> Dict[str, str]:
233
+ """Get field mappings for a specific subscription method.
234
+
235
+ Args:
236
+ method_name: The subscription method name.
237
+
238
+ Returns:
239
+ A dictionary mapping long field names to short field names.
240
+ """
241
+ return CEL_FIELD_MAPPINGS.get(method_name, {})
242
+
243
+
244
+ def replace_filter_fields(filter_expr: str, method_name: str) -> str:
245
+ """Replace long field names with short field names in filter expressions.
246
+
247
+ Automatically adds meta. prefix if not present.
248
+
249
+ Args:
250
+ filter_expr: The filter expression to process.
251
+ method_name: The subscription method name.
252
+
253
+ Returns:
254
+ The processed filter expression with short field names.
255
+ """
256
+ if not filter_expr:
257
+ return filter_expr
258
+
259
+ field_mappings = get_field_mappings(method_name)
260
+ result = filter_expr
261
+
262
+ # Replace all long field names with short field names
263
+ for long_field, short_field in field_mappings.items():
264
+ # Pattern 1: fieldName (without meta. prefix)
265
+ pattern1 = rf"\b{re.escape(long_field)}\b"
266
+ # Pattern 2: meta.fieldName (with meta. prefix)
267
+ pattern2 = rf"\bmeta\.{re.escape(long_field)}\b"
268
+
269
+ result = re.sub(pattern1, f"meta.{short_field}", result)
270
+ result = re.sub(pattern2, f"meta.{short_field}", result)
271
+
272
+ return result
273
+
274
+
275
+ def get_available_fields(method_name: str) -> List[str]:
276
+ """Get available field names for a specific subscription method.
277
+
278
+ Args:
279
+ method_name: The subscription method name.
280
+
281
+ Returns:
282
+ A list of available field names.
283
+ """
284
+ return list(get_field_mappings(method_name).keys())
@@ -0,0 +1,415 @@
1
+ """Data models for the ChainStream WebSocket Stream API."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from enum import Enum
5
+ from typing import Optional
6
+
7
+
8
+ class TokenActivityType(str, Enum):
9
+ """Token activity type."""
10
+
11
+ SELL = "sell"
12
+ BUY = "buy"
13
+ ADD_LIQUIDITY = "add_liquidity"
14
+ REMOVE_LIQUIDITY = "remove_liquidity"
15
+
16
+
17
+ class ChannelType(str, Enum):
18
+ """Channel type for subscriptions."""
19
+
20
+ NEW = "new"
21
+ HOT = "trending"
22
+ US_STOCKS = "us_stocks"
23
+ COMPLETED = "completed"
24
+ GRADUATED = "graduated"
25
+
26
+
27
+ class MetricType(str, Enum):
28
+ """Metric type for measurements."""
29
+
30
+ LIQUIDITY_IN_USD = "liquidity_in_usd"
31
+ MIGRATED_RATIO = "migrated_ratio"
32
+
33
+
34
+ class RankingType(str, Enum):
35
+ """Ranking type for token rankings."""
36
+
37
+ NEW = "new"
38
+ HOT = "trending"
39
+ STOCKS = "stocks"
40
+ FINAL_STRETCH = "completed"
41
+ MIGRATED = "graduated"
42
+
43
+
44
+ class Dex(str, Enum):
45
+ """DEX (Decentralized Exchange) type."""
46
+
47
+ PUMP_FUN = "pump_fun"
48
+ RAYDIUM_LAUNCHPAD = "raydium_launchpad"
49
+ METEORA_DYNAMIC_BOUNDING_CURVE = "meteora_dynamic_bounding_curve"
50
+ BONK_FUN = "bonk_fun"
51
+ BOOP_FUN = "boop_fun"
52
+ MOONIT_FUN = "moonit_fun"
53
+
54
+
55
+ class Resolution(str, Enum):
56
+ """Candle resolution for time-based data."""
57
+
58
+ S1 = "1s"
59
+ S15 = "15s"
60
+ S30 = "30s"
61
+ M1 = "1m"
62
+ M5 = "5m"
63
+ M15 = "15m"
64
+ H1 = "1h"
65
+ H4 = "4h"
66
+ H12 = "12h"
67
+ D1 = "1d"
68
+
69
+
70
+ @dataclass
71
+ class TokenActivity:
72
+ """Token activity data."""
73
+
74
+ address: str
75
+ price_usd: str
76
+ amount: str
77
+ activity_type: TokenActivityType
78
+ tx_hash: str
79
+ timestamp: int
80
+
81
+
82
+ @dataclass
83
+ class TokenStat:
84
+ """Token statistics with multi-timeframe data."""
85
+
86
+ address: str
87
+ timestamp: int
88
+
89
+ # 1-minute data
90
+ buys_1m: Optional[int] = None
91
+ sells_1m: Optional[int] = None
92
+ buyers_1m: Optional[int] = None
93
+ sellers_1m: Optional[int] = None
94
+ buy_volume_in_usd_1m: Optional[str] = None
95
+ sell_volume_in_usd_1m: Optional[str] = None
96
+ price_1m: Optional[str] = None
97
+ open_in_usd_1m: Optional[str] = None
98
+ close_in_usd_1m: Optional[str] = None
99
+
100
+ # 5-minute data
101
+ buys_5m: Optional[int] = None
102
+ sells_5m: Optional[int] = None
103
+ buyers_5m: Optional[int] = None
104
+ sellers_5m: Optional[int] = None
105
+ buy_volume_in_usd_5m: Optional[str] = None
106
+ sell_volume_in_usd_5m: Optional[str] = None
107
+ price_5m: Optional[str] = None
108
+ open_in_usd_5m: Optional[str] = None
109
+ close_in_usd_5m: Optional[str] = None
110
+
111
+ # 15-minute data
112
+ buys_15m: Optional[int] = None
113
+ sells_15m: Optional[int] = None
114
+ buyers_15m: Optional[int] = None
115
+ sellers_15m: Optional[int] = None
116
+ buy_volume_in_usd_15m: Optional[str] = None
117
+ sell_volume_in_usd_15m: Optional[str] = None
118
+ price_15m: Optional[str] = None
119
+ open_in_usd_15m: Optional[str] = None
120
+ close_in_usd_15m: Optional[str] = None
121
+
122
+ # 30-minute data
123
+ buys_30m: Optional[int] = None
124
+ sells_30m: Optional[int] = None
125
+ buyers_30m: Optional[int] = None
126
+ sellers_30m: Optional[int] = None
127
+ buy_volume_in_usd_30m: Optional[str] = None
128
+ sell_volume_in_usd_30m: Optional[str] = None
129
+ price_30m: Optional[str] = None
130
+ open_in_usd_30m: Optional[str] = None
131
+ close_in_usd_30m: Optional[str] = None
132
+
133
+ # 1-hour data
134
+ buys_1h: Optional[int] = None
135
+ sells_1h: Optional[int] = None
136
+ buyers_1h: Optional[int] = None
137
+ sellers_1h: Optional[int] = None
138
+ buy_volume_in_usd_1h: Optional[str] = None
139
+ sell_volume_in_usd_1h: Optional[str] = None
140
+ price_1h: Optional[str] = None
141
+ open_in_usd_1h: Optional[str] = None
142
+ close_in_usd_1h: Optional[str] = None
143
+
144
+ # 4-hour data
145
+ buys_4h: Optional[int] = None
146
+ sells_4h: Optional[int] = None
147
+ buyers_4h: Optional[int] = None
148
+ sellers_4h: Optional[int] = None
149
+ buy_volume_in_usd_4h: Optional[str] = None
150
+ sell_volume_in_usd_4h: Optional[str] = None
151
+ price_4h: Optional[str] = None
152
+ open_in_usd_4h: Optional[str] = None
153
+ close_in_usd_4h: Optional[str] = None
154
+
155
+ # 24-hour data
156
+ buys_24h: Optional[int] = None
157
+ sells_24h: Optional[int] = None
158
+ buyers_24h: Optional[int] = None
159
+ sellers_24h: Optional[int] = None
160
+ buy_volume_in_usd_24h: Optional[str] = None
161
+ sell_volume_in_usd_24h: Optional[str] = None
162
+ price_24h: Optional[str] = None
163
+ open_in_usd_24h: Optional[str] = None
164
+ close_in_usd_24h: Optional[str] = None
165
+
166
+ # Current price
167
+ price: Optional[str] = None
168
+
169
+
170
+ @dataclass
171
+ class TokenHolder:
172
+ """Token holder information."""
173
+
174
+ token_address: str
175
+ timestamp: int
176
+ holders: Optional[int] = None
177
+ top100_amount: Optional[str] = None
178
+ top10_amount: Optional[str] = None
179
+ top100_holders: Optional[int] = None
180
+ top10_holders: Optional[int] = None
181
+ top100_ratio: Optional[str] = None
182
+ top10_ratio: Optional[str] = None
183
+ creators_holders: Optional[int] = None
184
+ creators_amount: Optional[str] = None
185
+ creators_ratio: Optional[str] = None
186
+
187
+
188
+ @dataclass
189
+ class WalletBalance:
190
+ """Wallet balance data."""
191
+
192
+ wallet_address: str
193
+ token_address: str
194
+ token_price_in_usd: str
195
+ balance: str
196
+ timestamp: int
197
+
198
+
199
+ @dataclass
200
+ class WalletPnl:
201
+ """Wallet profit and loss data."""
202
+
203
+ wallet_address: str
204
+ buys: int
205
+ buy_amount: str
206
+ buy_amount_in_usd: str
207
+ average_buy_price_in_usd: str
208
+ sell_amount: str
209
+ sell_amount_in_usd: str
210
+ sells: int
211
+ wins: int
212
+ win_ratio: str
213
+ pnl_in_usd: str
214
+ average_pnl_in_usd: str
215
+ pnl_ratio: str
216
+ profitable_days: int
217
+ losing_days: int
218
+ tokens: int
219
+ resolution: str
220
+
221
+
222
+ @dataclass
223
+ class DexProtocol:
224
+ """DEX protocol information."""
225
+
226
+ program_address: Optional[str] = None
227
+ protocol_family: Optional[str] = None
228
+ protocol_name: Optional[str] = None
229
+
230
+
231
+ @dataclass
232
+ class NewToken:
233
+ """New token data."""
234
+
235
+ token_address: str
236
+ name: str
237
+ symbol: str
238
+ created_at_ms: int
239
+ decimals: Optional[int] = None
240
+ launch_from: Optional[DexProtocol] = None
241
+
242
+
243
+ @dataclass
244
+ class TokenSupply:
245
+ """Token supply data."""
246
+
247
+ token_address: str
248
+ timestamp: int
249
+ supply: Optional[str] = None
250
+ market_cap_in_usd: Optional[str] = None
251
+
252
+
253
+ @dataclass
254
+ class DexPoolBalance:
255
+ """DEX pool balance data."""
256
+
257
+ pool_address: str
258
+ token_a_address: str
259
+ token_a_liquidity_in_usd: str
260
+ token_b_address: str
261
+ token_b_liquidity_in_usd: str
262
+
263
+
264
+ @dataclass
265
+ class TokenLiquidity:
266
+ """Token liquidity data."""
267
+
268
+ token_address: str
269
+ metric_type: MetricType
270
+ value: str
271
+ timestamp: int
272
+
273
+
274
+ @dataclass
275
+ class TokenMaxLiquidity:
276
+ """Token max liquidity data (max liquidity in a single pool)."""
277
+
278
+ token_address: str
279
+ pool_address: str
280
+ liquidity_in_usd: str
281
+ liquidity_in_native: str
282
+ timestamp: int
283
+
284
+
285
+ @dataclass
286
+ class TokenTotalLiquidity:
287
+ """Token total liquidity data (total liquidity across all pools)."""
288
+
289
+ token_address: str
290
+ liquidity_in_usd: str
291
+ liquidity_in_native: str
292
+ pool_count: int
293
+ timestamp: int
294
+
295
+
296
+ @dataclass
297
+ class TokenBondingCurve:
298
+ """Token bonding curve data."""
299
+
300
+ token_address: Optional[str] = None
301
+ progress_ratio: Optional[str] = None
302
+
303
+
304
+ @dataclass
305
+ class SocialMedia:
306
+ """Social media links."""
307
+
308
+ twitter: Optional[str] = None
309
+ telegram: Optional[str] = None
310
+ website: Optional[str] = None
311
+ tiktok: Optional[str] = None
312
+ discord: Optional[str] = None
313
+ facebook: Optional[str] = None
314
+ github: Optional[str] = None
315
+ instagram: Optional[str] = None
316
+ linkedin: Optional[str] = None
317
+ medium: Optional[str] = None
318
+ reddit: Optional[str] = None
319
+ youtube: Optional[str] = None
320
+ bitbucket: Optional[str] = None
321
+
322
+
323
+ @dataclass
324
+ class TokenMetadata:
325
+ """Token metadata."""
326
+
327
+ token_address: str
328
+ name: Optional[str] = None
329
+ decimals: Optional[int] = None
330
+ symbol: Optional[str] = None
331
+ image_url: Optional[str] = None
332
+ description: Optional[str] = None
333
+ social_media: Optional[SocialMedia] = None
334
+ created_at_ms: Optional[int] = None
335
+ launch_from: Optional[DexProtocol] = None
336
+ migrated_to: Optional[DexProtocol] = None
337
+
338
+
339
+ @dataclass
340
+ class TokenCandle:
341
+ """Token candlestick data."""
342
+
343
+ open: str
344
+ close: str
345
+ high: str
346
+ low: str
347
+ volume: str
348
+ resolution: str
349
+ time: int
350
+ number: int
351
+
352
+
353
+ @dataclass
354
+ class TradeActivity:
355
+ """Trade activity data."""
356
+
357
+ token_address: str
358
+ timestamp: int
359
+ kind: str
360
+ buy_amount: str
361
+ buy_amount_in_usd: str
362
+ buy_token_address: str
363
+ buy_token_name: str
364
+ buy_token_symbol: str
365
+ buy_wallet_address: str
366
+ sell_amount: str
367
+ sell_amount_in_usd: str
368
+ sell_token_address: str
369
+ sell_token_name: str
370
+ sell_token_symbol: str
371
+ sell_wallet_address: str
372
+ tx_hash: str
373
+
374
+
375
+ @dataclass
376
+ class WalletTokenPnl:
377
+ """Wallet token profit and loss data."""
378
+
379
+ wallet_address: str
380
+ token_address: str
381
+ token_price_in_usd: str
382
+ timestamp: int
383
+ open_time: int
384
+ last_time: int
385
+ close_time: int
386
+ buy_amount: str
387
+ buy_amount_in_usd: str
388
+ buy_count: int
389
+ buy_count_30d: int
390
+ buy_count_7d: int
391
+ sell_amount: str
392
+ sell_amount_in_usd: str
393
+ sell_count: int
394
+ sell_count_30d: int
395
+ sell_count_7d: int
396
+ held_duration_timestamp: int
397
+ average_buy_price_in_usd: str
398
+ average_sell_price_in_usd: str
399
+ unrealized_profit_in_usd: str
400
+ unrealized_profit_ratio: str
401
+ realized_profit_in_usd: str
402
+ realized_profit_ratio: str
403
+ total_realized_profit_in_usd: str
404
+ total_realized_profit_ratio: str
405
+
406
+
407
+ @dataclass
408
+ class RankingTokenList:
409
+ """Ranking token list data."""
410
+
411
+ metadata: Optional[TokenMetadata] = None
412
+ holder: Optional[TokenHolder] = None
413
+ supply: Optional[TokenSupply] = None
414
+ stat: Optional[TokenStat] = None
415
+ bonding_curve: Optional[TokenBondingCurve] = None