Skip to content

feat: DIA fixed-spread v3 strategy with session gating - #33

Open
Siddharth2207 wants to merge 9 commits into
mainfrom
feat/st0x-dia-fixed-spread-v3
Open

feat: DIA fixed-spread v3 strategy with session gating#33
Siddharth2207 wants to merge 9 commits into
mainfrom
feat/st0x-dia-fixed-spread-v3

Conversation

@Siddharth2207

@Siddharth2207 Siddharth2207 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add st0x-dia-fixed-spread-v3.rain, a hybrid fixed-spread strategy that gates quotes on v3 st0x oracle session context while sourcing benchmark prices from on-chain DIA feeds
  • Includes sell (base-st0x-dia-v3) and buy (base-st0x-dia-inv-v3) deployments with allowed-session, dia-id, baseline-multiplier, oracle-price-timeout, and min/max price safety guards
  • Register the new strategy in strategy/registry (also includes the v3 registry pin migration from chore/bump-registry-v3)

Test plan

  • Compose base-st0x-dia-v3 and base-st0x-dia-inv-v3 via Raindex order builder
  • Verify session guards revert outside allowed market sessions
  • Verify DIA price is used for IO ratio (not signed-context price slot)
  • Bump registry commit pins after merge

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Added a new strategy configuration option for DIA-based fixed spread trading.
    • Introduced updated strategy versions and refreshed registry links to the latest published sources.
  • Bug Fixes

    • Improved oracle/session validation to better ensure trades use trusted, current market data.
    • Added safety limits so pricing stays within configured minimum and maximum bounds.

Siddharth2207 and others added 2 commits June 22, 2026 18:37
Point registry at 84160af and register v3 strategies after #30 renamed
st0x-oracle-limit-v2 / st0x-fixed-spread-v2 to their v3 counterparts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Combine v3 st0x oracle session guards with on-chain DIA price feeds for
sell and buy fixed-spread deployments, and register the new strategy.

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

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Siddharth2207, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4f0834b4-cb19-49d7-8a58-f520d9821417

📥 Commits

Reviewing files that changed from the base of the PR and between bc5ce74 and e998451.

📒 Files selected for processing (2)
  • strategy/registry
  • strategy/st0x-dia-fixed-spread-v3.rain
📝 Walkthrough

Walkthrough

The registry is updated to replace v2 strategy entries with v3 variants and adds st0x-dia-fixed-spread-v3, pointing to a new commit hash. A new Rain strategy file st0x-dia-fixed-spread-v3.rain is introduced with session guard logic, DIA price baseline computation (normal and inverted), and IO calculation.

DIA Fixed-Spread v3 Strategy

Layer / File(s) Summary
Registry update to v3 entries
strategy/registry
Replaces *-v2 entries with st0x-oracle-limit-v3, st0x-fixed-spread-v3, adds st0x-dia-fixed-spread-v3, and updates all raw.githubusercontent.com commit URLs including settings.yaml.
Strategy scenarios and builder config
strategy/st0x-dia-fixed-spread-v3.rain (lines 1–241)
Defines strategy version 6, token wiring, two scenarios (st0x-dia-baseline-v3 and st0x-dia-baseline-inv-v3), two Base deployments, and all UI/config fields: allowed-session, dia-id, baseline-multiplier, oracle-price-timeout, min-price, max-price, and token selection.
Session guard and DIA price baseline logic
strategy/st0x-dia-fixed-spread-v3.rain (lines 255–370)
Implements st0x-session-guard-v3 validating oracle signer, schema version, session compatibility (including "all" sentinel), and time window; then computes normal and inverted DIA baselines with non-zero and [min-price, max-price] safety checks.
IO calculation and no-op handlers
strategy/st0x-dia-fixed-spread-v3.rain (lines 371–380)
Sets offer-amount to max-positive-value(), computes io as baseline-fn * baseline-multiplier, and defines handle-io and handle-add-order as empty.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • hardyjosh

🐇 A new DIA feed hops into view,
With session guards and baselines true,
v3 arrives with safety checks neat,
Min, max, and timeouts complete—
The registry now points the way! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a DIA fixed-spread v3 strategy with session gating.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/st0x-dia-fixed-spread-v3

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.

Point registry at bc5ce74 so raw.githubusercontent.com URLs resolve
to the commit that adds st0x-dia-fixed-spread-v3.

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: 2

🧹 Nitpick comments (1)
strategy/st0x-dia-fixed-spread-v3.rain (1)

313-315: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the unused dia-price-baseline-inv helper. st0x-dia-baseline-inv-v3 already calls dia-price-baseline and applies inv() after the bounds checks, so this definition is never used and only adds confusion.

🤖 Prompt for 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.

In `@strategy/st0x-dia-fixed-spread-v3.rain` around lines 313 - 315, Remove the
unused dia-price-baseline-inv helper from the strategy; st0x-dia-baseline-inv-v3
already computes dia-price-baseline and applies inv() after its bounds checks,
so this definition should be deleted to avoid confusion. Locate the helper by
its dia-price-baseline-inv symbol in the strategy file and ensure no remaining
references depend on it.
🤖 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 `@strategy/registry`:
- Around line 1-6: The `strategy/registry` entry for `st0x-dia-fixed-spread-v3`
is broken because its pinned `.rain` URL is unreachable; update that registry
mapping to point to the correct existing strategy artifact, and verify the other
entries like `st0x-fixed-spread-v3` and `st0x-oracle-limit-v3` still reference
valid raw URLs.

In `@strategy/st0x-dia-fixed-spread-v3.rain`:
- Around line 318-320: The `call<'dia-price-baseline'>()` reference has an extra
trailing quote and should match the other `call<...>` entries in this block.
Update the `dia-baseline` entry in the strategy config so it uses the same
`call<'name>()` pattern as `call<'st0x-session-guard-v3>()` and
`call<'baseline-fn>()`, specifically `call<'dia-price-baseline>()`.

---

Nitpick comments:
In `@strategy/st0x-dia-fixed-spread-v3.rain`:
- Around line 313-315: Remove the unused dia-price-baseline-inv helper from the
strategy; st0x-dia-baseline-inv-v3 already computes dia-price-baseline and
applies inv() after its bounds checks, so this definition should be deleted to
avoid confusion. Locate the helper by its dia-price-baseline-inv symbol in the
strategy file and ensure no remaining references depend on it.
🪄 Autofix (Beta)

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

Run ID: 391611e7-803d-419a-b947-ef8c38f47771

📥 Commits

Reviewing files that changed from the base of the PR and between 3af431d and bc5ce74.

📒 Files selected for processing (2)
  • strategy/registry
  • strategy/st0x-dia-fixed-spread-v3.rain

Comment thread strategy/registry Outdated
Comment thread strategy/st0x-dia-fixed-spread-v3.rain Outdated
Comment on lines +318 to +320
_: call<'st0x-session-guard-v3>(),

dia-baseline: call<'dia-price-baseline'>(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect how call<...> source references are written across existing strategies
rg -nP "call<'[^)]*?>" strategy/ -g '*.rain'

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 802


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the surrounding source and look for language docs or parser rules
sed -n '300,360p' strategy/st0x-dia-fixed-spread-v3.rain
printf '\n---\n'
rg -n "call<'|call<\" -g '*.rain' -g '*.md' -g '*.ts' -g '*.js' -g '*.rs' .

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 1557


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the surrounding source and look for language docs or parser rules
sed -n '300,360p' strategy/st0x-dia-fixed-spread-v3.rain
printf '\n---\n'
rg -n "call<'|call<\"" -g '*.rain' -g '*.md' -g '*.ts' -g '*.js' -g '*.rs' .

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 2141


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the surrounding source and look for Rain syntax references in the repo
sed -n '310,356p' strategy/st0x-dia-fixed-spread-v3.rain
printf '\n---\n'
rg -n "call<'|source|baseline-fn|st0x-session-guard-v3|dia-price-baseline" .

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 50391


🌐 Web query:

Rain language call<...> source reference syntax quoted identifier

💡 Result:

The term "Rain language" most prominently refers to the Rainlang programming language used for onchain logic and smart contract development [1][2]. The syntax for calls and source referencing in this context is as follows: Call Syntax In Rainlang, words represent compiled Solidity functions [1]. A call is performed by using the word name as a prefix, followed by parentheses containing optional inputs [1][3]. - Transaction-time inputs are provided within parentheses: word(input1 input2) [3]. - Parse-time inputs, when required, are provided within angle brackets <> before the parentheses: word(transaction-time-args) [3]. - The special call word is used to execute fragments or other bindings, often using quoted identifiers to reference them [4]. Quoted Identifier Syntax The single quote (') is used to quote names [4]. This operator acts similarly to quoting in Lisp or Clojure, referencing the name itself rather than the value it names [4]. - Quoted identifiers are used to reference binding names, which allows for features like renaming or calculating indexes for call-like words [4]. - Example: call<'add-five 1>(5) demonstrates using a quoted identifier 'add-five to reference a specific binding fragment within a call [4]. Note: Multiple projects use the name "Rain" [5][6]. The information above specifically pertains to the Rainlang/dotrain ecosystem (rainprotocol) [1][4][2]. Other languages named "Rain" exist but follow different syntactical conventions [6][7].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find any syntax examples or grammar rules that define call<...>
fd -a -t f . .
printf '\n---\n'
rg -n "call<'.*'>\\(|call<'.*'\\(|call<" . --glob '!**/node_modules/**'

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 2076


🌐 Web query:

Rainlang source reference call<'name>() syntax quote source identifier

💡 Result:

In Rainlang, the call syntax allows sources to invoke other sources within the same file as if they were words [1][2]. While the standard call operation uses a source index (e.g., call<1>(...)), the syntax call<'name>(...) utilizes a quoted source identifier to reference a named fragment [3]. Key details regarding this syntax include: - Quoted Identifiers: The single quote (') character is used to quote names, enabling the use of human-readable labels for fragments instead of relying solely on numeric source indices [3]. - Tooling Transformation: This syntax is a feature often used in.rain files; tooling is responsible for processing these quoted fragments by including them as callable sources and substituting the quoted names with the corresponding source index in the final compiled artifact [3]. - Usage Example: #add-five i:, _: add(i 5) #main /* calls the named fragment 'add-five' */ _: call<'add-five 1>(5) In this example, the tool replaces 'add-five' with the actual source index assigned during compilation [3].

Citations:


🌐 Web query:

site:github.com rainlang call<' source reference

💡 Result:

In Rainlang, the call syntax call<'name>(...) is used within dotrain files to invoke a named fragment of logic [1]. The call operator serves as a mechanism to reuse defined expressions within a document [1]. When using this syntax: 1. name refers to a label defined elsewhere in the dotrain document (prefixed by #) which serves as the source fragment to be called [1]. 2. The values provided inside the parentheses, such as (5) in call<'add-five>(5), are passed as arguments to that fragment [1]. 3. Tooling (such as the Rain language server) processes these calls by identifying the referenced fragment, calculating necessary indices for the compiled artifact, and substituting the human-readable name with the corresponding source index [1]. This mechanism allows for modularizing Rainlang scripts, enabling developers to define reusable logic in fragments and invoke them by name throughout their main expressions [1].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Look for the source name and any syntax or grammar references around call<...>
rg -n "dia-price-baseline|st0x-session-guard-v3|call<'" . --glob '!**/node_modules/**'

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 1018


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find grammar/docs files that could define Rain source-call syntax
git ls-files | rg '(^|/)(README|docs?|grammar|parser|syntax|rain).*'
printf '\n---\n'
git ls-files | rg '\.(md|txt|rain|pegjs|ne|yml|yaml|json|ts|js)$' | head -n 200

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 480


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect Rainlang usage notes in the repo README and surrounding strategy syntax
rg -n -A3 -B3 "call<'|dotrain|Rainlang|quoted" README.md strategy/st0x-dia-fixed-spread-v3.rain strategy/st0x-fixed-spread-v3.rain strategy/st0x-fixed-spread.rain

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 3153


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -A3 -B3 "call<'|dotrain|Rainlang|quoted" README.md strategy/st0x-dia-fixed-spread-v3.rain strategy/st0x-fixed-spread-v3.rain strategy/st0x-fixed-spread.rain

Repository: ST0x-Technology/st0x-oracle-server

Length of output: 3153


Fix the trailing quote in call<'dia-price-baseline'>() Match the other call<...> references here (call<'st0x-session-guard-v3>(), call<'baseline-fn>()) by using call<'dia-price-baseline>().

🤖 Prompt for 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.

In `@strategy/st0x-dia-fixed-spread-v3.rain` around lines 318 - 320, The
`call<'dia-price-baseline'>()` reference has an extra trailing quote and should
match the other `call<...>` entries in this block. Update the `dia-baseline`
entry in the strategy config so it uses the same `call<'name>()` pattern as
`call<'st0x-session-guard-v3>()` and `call<'baseline-fn>()`, specifically
`call<'dia-price-baseline>()`.

Siddharth2207 and others added 6 commits June 30, 2026 16:07
Nested call<'dia-price-baseline'>() fails Rainlang parsing because
dia-price is a built-in word; fetch the benchmark inline instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
Point registry at 49bb288 so raw.githubusercontent.com URLs resolve
to the commit with the inline dia-price fix.

Co-authored-by: Cursor <cursoragent@cursor.com>
Nested call<'st0x-session-guard-v3'>() caused BadOpOutputsLength at
deploy time; flatten into each baseline entry point like st0x-fixed-spread-v3.

Co-authored-by: Cursor <cursoragent@cursor.com>
Point registry at e2254b2 so raw.githubusercontent.com URLs resolve to the
commit with inlined session guards.

Co-authored-by: Cursor <cursoragent@cursor.com>
dia-price returns two values; use `dia-baseline _:` like the DIA
reference strategy to avoid BadOpOutputsLength at deploy time.

Co-authored-by: Cursor <cursoragent@cursor.com>
Point registry at f093441.

Co-authored-by: Cursor <cursoragent@cursor.com>
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