Skip to content

fix: enforce on-chain fallback 60s cap for new markets (H2)#85

Open
0x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/h2-onchain-fallback-bypass
Open

fix: enforce on-chain fallback 60s cap for new markets (H2)#85
0x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/h2-onchain-fallback-bypass

Conversation

@0x-SquidSol
Copy link
Copy Markdown
Contributor

Summary

  • The M-4 on-chain fallback had a 60s time cap to prevent pushing stale prices indefinitely
  • The guard lastExternal > 0 was bypassed for any market that never received an external price (DexScreener/Jupiter), because lastExternalPriceMs defaulted to 0
  • A manipulated on-chain authorityPriceE6 would be pushed forever for new/unlisted markets

Fix

Seed lastExternalPriceMs to Date.now() on first encounter of each market:

  • New markets get a 60s grace window from their first fallback attempt
  • After 60s with no external price, the oracle goes stale naturally (as M-4 intended)
  • Remove the lastExternal > 0 guard since lastExternal is now always a real timestamp
  • When an external price is eventually fetched, the clock resets normally

Test plan

  • All 133 existing tests pass
  • Fix is a 6-line change with clear semantics

🤖 Generated with Claude Code

The M-4 on-chain fallback time cap was guarded by `lastExternal > 0`,
which meant markets that never received an external price (new markets,
unlisted tokens) had no time limit — the stale on-chain price was
pushed indefinitely.

Seed `lastExternalPriceMs` to `Date.now()` on first encounter so:
- New markets get a 60s grace window from first fallback attempt
- After 60s with no external price, the oracle goes stale naturally
- The `lastExternal > 0` guard is no longer needed

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Warning

Rate limit exceeded

@0x-SquidSol has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 27 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 2 minutes and 27 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a347472-669e-45dd-8cdb-ba9a7c3634e7

📥 Commits

Reviewing files that changed from the base of the PR and between 63ad1a0 and 48930fd.

📒 Files selected for processing (1)
  • src/services/oracle.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant