Skip to content

feat(jobs): daily reclaim_rent sweep for zero-balance user banks#827

Merged
raymondjacobson merged 2 commits into
mainfrom
rj/reclaim-rent-job
May 19, 2026
Merged

feat(jobs): daily reclaim_rent sweep for zero-balance user banks#827
raymondjacobson merged 2 commits into
mainfrom
rj/reclaim-rent-job

Conversation

@raymondjacobson
Copy link
Copy Markdown
Member

@raymondjacobson raymondjacobson commented May 19, 2026

Summary

  • Adds a ReclaimRentJob to the solana-indexer that runs every 24h, closing zero-balance claimable token accounts created in the last 7 days for AUDIO and USDC and returning the rent to the signing fee payer.
  • Reuses the existing solanaRpcProviders, solanaFeePayerKeys, and writeDbUrl configuration via cfg.SolanaConfig / database.DbPool.
  • Mirrors the cmd/reclaim_rent logic (DB candidate query → on-chain re-verify of zero balance → batched 15 closes per tx) but uses the existing spl.TransactionSender for confirmation and multi-RPC broadcast.

Notes

  • No eager startup run. Unlike the other indexer jobs, this one moves real SOL on mainnet, so I deliberately omitted go reclaimRentJob.Run(...) — first fire is 24h after deploy. Add it if you want it to run on every deployment.
  • Skips gracefully when solanaRpcProviders or solanaFeePayerKeys are empty (dev/local).
  • 7-day filter uses sol_token_account_balances.created_at (when the indexer first saw the account), since sol_claimable_accounts has no created-at column. The 7d window with a 24h cadence provides 6 days of overlap so nothing is missed.
  • Rent destination = the fee payer that signs the tx (matches the cmd's default behavior).

Test plan

  • CI build + vet pass
  • Confirm the fee payer wallets accrue SOL after the first prod run (each closed account returns ~0.00204 SOL)
  • Watch indexer logs for processBatch failed errors after first run

🤖 Generated with Claude Code

Adds a ReclaimRentJob to the solana-indexer that, every 24h, closes
zero-balance claimable token accounts created in the last 7 days for
AUDIO and USDC, returning the rent lamports to the signing fee payer.
The 7-day lookback with a 24h cadence provides overlap to ensure no
eligible accounts are missed.

Reuses the existing solanaRpcProviders, solanaFeePayerKeys, and writeDbUrl
configuration via cfg.SolanaConfig and database.DbPool. Skips gracefully
when RPC or fee payers are not configured (dev/test). Each batch closes
up to 15 accounts per transaction via the existing spl.TransactionSender.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@rickyrombo rickyrombo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This would likely never run until the weekend, as we average at least 1 deploy every 24 hours

@raymondjacobson
Copy link
Copy Markdown
Member Author

Note: This would likely never run until the weekend, as we average at least 1 deploy every 24 hours

Yea, ill make it a real cron instead

Replaces the 24h-after-deploy ticker with a daily scheduler that fires
at noon Pacific. Recomputes "next noon LA" each iteration so DST
transitions don't drift the schedule. Embeds time/tzdata since the
runtime image is Alpine, which doesn't ship IANA tzdata by default.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@raymondjacobson raymondjacobson merged commit 5f02074 into main May 19, 2026
5 checks passed
@raymondjacobson raymondjacobson deleted the rj/reclaim-rent-job branch May 19, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants