Commit Graph

19 Commits

Author SHA1 Message Date
Alex Kuligowski 40ad32b8d0 feat(core): add RPC rate limiting and retry handling (#154)
* feat(core): add RPC rate limiting, retry logic, and 429 handling

Addresses #44 — users on free-tier RPC endpoints hit HTTP 429 errors
during buy transactions due to no rate limiting or retry handling.

- Add TokenBucketRateLimiter (new file: src/core/rpc_rate_limiter.py)
- Gate all RPC methods through rate limiter (both post_rpc and solana-py calls)
- Rewrite post_rpc() with retry loop, exponential backoff, jitter, and
  specific 429 detection with Retry-After header support
- Replace per-call aiohttp session with shared persistent session
- Wire node.max_rps from YAML bot config through to SolanaClient
- Fix cleanup manager and learning example to use SolanaClient abstraction
  instead of bypassing it via get_client()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(core): address CodeRabbitAI review feedback on rate limiting PR

Validate max_rps > 0 in TokenBucketRateLimiter to prevent ZeroDivisionError
and infinite loops with fractional values. Add asyncio.Lock to _get_session
to fix race condition, handle non-numeric Retry-After headers gracefully,
replace dead json.JSONDecodeError with aiohttp.ContentTypeError, and combine
burn+close into a single transaction in cleanup example.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: document RPC rate limiting feature in README

- Add section on built-in RPC rate limiting with token bucket algorithm
- Document configurable max RPS and automatic retry logic
- Update roadmap to mark "Configurable RPS" as completed
- Clarify benefits of rate limiting for provider compliance

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: use math.ceil for burst_size to handle fractional max_rps

- Replace int(max_rps) with math.ceil(max_rps) in burst_size calculation
- Prevents infinite loop when max_rps < 1.0 (e.g., 0.5 RPS would result in burst_size=0)
- Ensures burst_size is always at least 1 for valid fractional rates
- Addresses CodeRabbit feedback on rpc_rate_limiter.py:27

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(core): validate burst_size and fix table pipe consistency

Address remaining CodeRabbitAI review feedback: add burst_size
validation guard, fix TRY003 lint (use msg variable for ValueError),
break long line under 88 chars, and fix MD055 table pipe style in README.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(core): separate 429 retry budget from error retries in post_rpc

429 responses no longer count against max_retries — they use a dedicated
max_429_retries counter (default 10) so free-tier users hitting rate
limits won't exhaust retries prematurely. Also refresh the aiohttp
session inside the retry loop to avoid stale references after network
failures, and fix cleanup log message accuracy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Anton Sauchyk <antonsauchyk@gmail.com>
2026-02-17 10:02:11 +01:00
Anton Sauchyk 9d93d859a8 Reduce RPC delays when selling (#150)
* feat(trading): enhance sell execution with token amount and price parameters to reduce RPC delays

* feat(trading): add method to fetch actual token balance after transaction to improve accuracy

* feat(trading): update account data size limit and enhance price calculations
2025-11-23 12:02:29 +01:00
Anton Sauchyk b6928d1f5f feat(core): integrate account data size limit (#144)
* feat(core): integrate account data size limit in buyer and seller transaction

* refactor: format code for improved readability and consistency
2025-10-28 21:21:21 +01:00
smypmsa 9731b179cc feat(core): add configurable cu limits 2025-09-03 15:05:12 +00:00
smypmsa cb5c9ed1cd chore: pumpportal time based config example 2025-08-05 20:48:03 +00:00
smypmsa bf7fbaa8ab chore(core): update example for logs 2025-08-04 05:07:05 +00:00
smypmsa 9b6563cecc feat(core): add event idl parser 2025-08-02 19:19:20 +00:00
smypmsa bae03c3fab fix(core): block event processor account keys bytes 2025-08-02 16:41:23 +00:00
smypmsa 26c048c86a fix(core): platform listener check 2025-08-02 16:12:45 +00:00
smypmsa e7107751f5 fix(letsbonk): buy/sell instructions 2025-08-02 15:38:53 +00:00
smypmsa bb35101a8f wip(core): platform aware trading 2025-08-02 09:25:39 +00:00
Bukhtiiarov b74d8df0a9 chore: update generated protobuf files 2025-06-30 15:10:59 +03:00
smypmsa 984f43b757 fix: remove coderabbit syntax bugs 2025-06-15 20:12:54 +00:00
smypmsa 473b1bec70 feat: add simple tp and sl with price polling 2025-06-15 18:20:13 +00:00
smypmsa 185811d854 feat: add pump portal listener 2025-06-15 11:48:31 +00:00
smypmsa e41a5f4f4f feat(core): add support for creator fee update 2025-05-12 20:07:51 +00:00
smypmsa aa145dc018 feat: add geyser auth type, compare listeners for new tokens 2025-05-06 08:39:13 +00:00
smypmsa a36fab7352 fix: comments, minor fixes 2025-04-29 11:56:55 +00:00
smypmsa 40e4a4b130 feat: add support for multiple bots 2025-04-24 20:32:47 +00:00