Skip to content

Point st0x fixed-spread and oracle-limit at 0trade v5 oracle - #52

Merged
Siddharth2207 merged 33 commits into
mainfrom
feat/0trade-oracle-fixed-spread-v4
Aug 10, 2026
Merged

Siddharth2207 merged 33 commits into
mainfrom
feat/0trade-oracle-fixed-spread-v4

Conversation

@Siddharth2207

@Siddharth2207 Siddharth2207 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrate st0x-fixed-spread and st0x-oracle-limit to the 0trade v5 oracle.

Strategies

  • src/st0x-fixed-spread-v5.rain (replaces v4)
  • src/st0x-oracle-limit-v5.rain (replaces v4)
  • Registry keys: st0x-fixed-spread-v5, st0x-oracle-limit-v5

Oracle wiring

  • oracle-url: https://oracle.t0trade.com/context/v5
  • oracle-signer: 0xdB665B5ef8Bd04Fd977bB3A64790eaa52749ACcc
  • oracle-schema-version: 5
  • Frame expiry: now() <= signed-context<0 8>() (oracle clamps expiry to session end)

Behaviour

  • Fixed-spread quotes at raw oracle baseline IO (no session multipliers / ERC4626 dividend branches)
  • Pair bind: signed input/output tokens must match the order IO
  • Hard-coded active-session guard (rth / premarket / afterhours) + session-window bounds
  • Min/max price safety bounds remain deployer-configurable
  • Removed deployer allowed-session field — no session picker; orders follow whatever active session the oracle is signing
  • Removed relative max-staleness — superseded by absolute frame expiry

Chore

  • Re-pin settings.yaml + root registry URLs (token-list → settings → registry)

Why

st0x.raindex-deploy 0trade manifests should consume these strategies from st0x.registry. With v5, freshness is an oracle-stamped deadline (≤ session end), so session/staleness UI choices are redundant.

Test plan

  • Rain loads via registry entries st0x-fixed-spread-v5 and st0x-oracle-limit-v5
  • Deploy UI shows min/max price only (no Market session / max-staleness fields)
  • Signed context comes from oracle.t0trade.com/context/v5 / signer 0xdB665B5e…
  • Schema version 5; trades revert after slot-8 expiry
  • Trades revert outside session window / on closed-session tags
  • Pair mismatch and out-of-band prices still revert

Summary by CodeRabbit

  • New Features

    • Added the fixed-spread v5 strategy with oracle-based pricing.
    • Added validation for signer authenticity, token pairs, active sessions, timestamps, expiry, and price safety limits.
    • Added configurable maximum data-staleness and minimum/maximum price controls.
    • Added Base deployment and market-session configuration.
  • Updates

    • Updated registry references and replaced the fixed-spread v4 entry with v5.
    • Updated the Base token list reference.

Use oracle.t0trade.com/context/v4 and signer 0xE2f3… so registry consumers of this strategy match 0trade deploys.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds the fixed-spread v5 strategy, updates v4 to use direct oracle pricing, refreshes registry entries, and pins a newer Base token-list commit.

Changes

Fixed-spread oracle migration

Layer / File(s) Summary
Add fixed-spread v5 strategy
src/st0x-fixed-spread-v5.rain
Defines Base deployment metadata, oracle bindings, token selection, session settings, price bounds, and validated oracle-price IO.
Replace v4 calculation with direct oracle pricing
src/st0x-fixed-spread-v4.rain
Replaces baseline, multiplier, and ERC4626 flows with direct signer, schema, token-pair, session, timestamp, freshness, and price-bound validation.
Refresh pinned resource references
registry, settings.yaml
Updates registry commit URLs, replaces the v4 registry entry with v5, removes the oracle-limit v4 entry, and updates the Base token-list commit.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant calculate_io
  participant SignedOracleContext
  participant OrderTokenPair
  calculate_io->>SignedOracleContext: Read signed oracle data
  calculate_io->>OrderTokenPair: Validate the signed token pair
  calculate_io->>SignedOracleContext: Validate session, timestamps, expiry, and price bounds
  SignedOracleContext-->>calculate_io: Return validated oracle price
  calculate_io-->>calculate_io: Set the oracle price as IO
Loading

Possibly related PRs

Suggested reviewers: findolor, alastairong1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the oracle migration and the affected strategies, matching the pull request’s stated objective.
Description check ✅ Passed The description directly addresses the strategy, oracle, registry, and configuration changes in the pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/0trade-oracle-fixed-spread-v4

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.

Siddharth2207 and others added 5 commits August 6, 2026 19:45
Point all st0x-fixed-spread-v4 scenarios at the correct t0trade oracle signer.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pin registry URLs to the 0trade oracle rain commit.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove session multipliers and ERC4626 dividends sell/buy paths so
the strategy quotes the v4 oracle price with guards only.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/st0x-fixed-spread-v4.rain`:
- Around line 144-160: Update the session guard around ensure so oracle-session
must first equal "rth", "premarket", or "afterhours"; only then accept
allowed-session "all" or an exact match with allowed-session. Preserve the
existing rejection message and ensure closed or other inactive sessions cannot
pass either branch.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 12424fa5-7386-4316-ae8e-2032b42eb903

📥 Commits

Reviewing files that changed from the base of the PR and between 9eca565 and 1ce0917.

📒 Files selected for processing (3)
  • registry
  • settings.yaml
  • src/st0x-fixed-spread-v4.rain

Comment thread src/st0x-fixed-spread-v4.rain Outdated
Siddharth2207 and others added 6 commits August 7, 2026 19:52
Closed or inactive sessions can no longer pass via exact match alone;
oracle-session must be rth, premarket, or afterhours first.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Reject signed oracle prices older than a deployer-configured age so
stale quotes cannot be reused for the rest of the session window.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/st0x-fixed-spread-v4.rain`:
- Around line 204-210: Update the validation around the existing “Oracle price
expired” check to first require oracle-publish-time to be less than or equal to
now(), then perform the saturating-sub freshness comparison. Ensure future
publish timestamps are rejected before the age calculation can clamp them to
zero.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0dc3f8d4-debc-4f7c-8f8d-8fcd0d9dcde2

📥 Commits

Reviewing files that changed from the base of the PR and between 1ce0917 and 863f353.

📒 Files selected for processing (3)
  • registry
  • settings.yaml
  • src/st0x-fixed-spread-v4.rain
🚧 Files skipped from review as they are similar to previous changes (2)
  • registry
  • settings.yaml

Comment thread src/st0x-fixed-spread-v4.rain Outdated
Siddharth2207 and others added 15 commits August 7, 2026 22:26
saturating-sub clamps future timestamps to zero age; require
publish-time <= now() first so those quotes cannot pass freshness.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
"Oracle publish time in the future" was 33 chars and caused
StringTooLong (0x30515bda) on deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Base interpreter lacks saturating-sub (UnknownWord 0xaedfba2f).
Future publish times are already rejected, so plain sub is safe.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Staleness via sub already rejects future timestamps.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Point both at oracle.t0trade.com/context/v5 with schema 5 and
frame expiry at signed-context slot 8. Drop max-staleness now that
expiry covers freshness; rename strategy files and registry keys.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@Siddharth2207 Siddharth2207 changed the title Point st0x-fixed-spread-v4 at 0trade oracle Point st0x fixed-spread and oracle-limit at 0trade v5 oracle Aug 7, 2026
Siddharth2207 and others added 6 commits August 8, 2026 01:01
Oracle clamps frame expiry to session end, so deployers do not
choose a session. Keep hard-coded active-session and window guards
plus slot-8 expiry.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Out of scope for this PR; fixed-spread v5 only.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@Siddharth2207
Siddharth2207 merged commit cc831c7 into main Aug 10, 2026
1 check passed
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