Closed Artemyin closed 9 months ago
Hey, Thanks for the contribution. I will like to add there is an abrupt stop of the script after a few minutes due to. Too many calls did you take this into consideration?
you catch httpx.HTTPStatusError: Client error '429 Too Many Requests' for url 'https://api.mainnet-beta.solana.com'
in get_tokens
?
The 429 issue you are running into is a RPC rate limit. Testnet has the following rate limits at the time of writing:
Maximum number of requests per 10 seconds per IP: 100 Maximum number of requests per 10 seconds per IP for a single RPC: 40 Maximum concurrent connections per IP: 40 Maximum connection rate per 10 seconds per IP: 40 Maximum amount of data per 30 second: 100 MB
gonna try to work around to omit this error
Your script was great point to start. I figured it out how solana API works thanks to you.
I did:
Diff
```diff - wallet_address = "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" + RaydiumLPV4 = "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" ... - search = "initialize2" + log_instruction = "initialize2" ... - def getTokens(...) + def get_tokens_info(...) ```
replaced standard websockets with SolanaWsClientProtocol from solana.rpc.websocket_api
... async with connect(WSS) as websocket: subscription_id = await subscribe_to_logs( websocket, RpcTransactionLogsFilterMentions(RaydiumLPV4), Finalized ) ...
lines 32-74
.logs_subscribe
, instead ofwebsocket.send(json.dumps(parametrs))
.process_messages
in list comprehension. That function is generator function, indeed (yield instead return). itsyield
signature value if its logs align with requiredlog_instruction
.process_messages
generator, so its more obvious entries points and place to future modificationsprint_table
functionThere is still bunch place for optimization. But at this point its become more consistent due to using one lib for all purpose. also its more easy for debugging and possible testing
P.S. script stops after finding first LP, remove
break
for infinite loop