fix: cache oracle keypair, remove dead replay code, fix pnlPct (L1+L2+L7)#97
fix: cache oracle keypair, remove dead replay code, fix pnlPct (L1+L2+L7)#970x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
Conversation
…y (L1+L2+L7) L1: OracleService called loadKeypair() on every pushPrice() invocation, re-parsing the keypair from env/disk each cycle. Now cached as a class field at construction, matching CrankService/LiquidationService/AdlService. L2: recentSignatures Maps in CrankService and LiquidationService were written to but never read — no .has() or .get() calls existed. The "BC1: Signature replay protection" was dead code. Removed the Maps, TTL constants, .set() calls, and cleanup loops from both services. Solana's runtime already prevents signature replay at the protocol level. L7: ADL pnlPct display divided by 1_000_000 then appended %, showing 30% as "0.3000%". Now divides by 10_000 (= 1M/100) to correctly display as "30.00%". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThis PR modifies four service files to streamline transaction handling and logging: adjusts ADL PnL percentage formatting, removes in-memory signature replay-protection maps from crank and liquidation services, and refactors oracle service to initialize keypair once at construction rather than per-call. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Three low-severity cleanups:
L1 — Oracle keypair not cached:
loadKeypair()called on everypushPrice()invocation, re-parsing from env/disk each cycleprivate readonly _keypairat construction, matching all other servicesL2 — Dead signature replay tracking:
recentSignaturesMaps in CrankService and LiquidationService were written to but never read.has()or.get()calls existed — the "BC1: Signature replay protection" was dead code.set()calls, and cleanup loops from both servicesL7 — ADL pnlPct display off by 100x:
%, showing 30% as "0.3000%"Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Style
Refactor