feat: DIA fixed-spread v3 strategy with session gating - #33
feat: DIA fixed-spread v3 strategy with session gating#33Siddharth2207 wants to merge 9 commits into
Conversation
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>
|
Warning Review limit reached
Next review available in: 18 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe registry is updated to replace v2 strategy entries with v3 variants and adds DIA Fixed-Spread v3 Strategy
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
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>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
strategy/st0x-dia-fixed-spread-v3.rain (1)
313-315: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the unused
dia-price-baseline-invhelper.st0x-dia-baseline-inv-v3already callsdia-price-baselineand appliesinv()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
📒 Files selected for processing (2)
strategy/registrystrategy/st0x-dia-fixed-spread-v3.rain
| _: call<'st0x-session-guard-v3>(), | ||
|
|
||
| dia-baseline: call<'dia-price-baseline'>(), |
There was a problem hiding this comment.
🎯 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:
- 1: https://github.com/rainprotocol/specs/blob/main/rainlang.md
- 2: https://github.com/rainprotocol/rainlang
- 3: https://hackmd.io/BuuicWzpT3SIGk6DUaho6g
- 4: https://github.com/rainprotocol/specs/blob/main/dotrain.md
- 5: https://github.com/nikeedev/rain-lang/blob/main/language_syntax.md
- 6: https://scizzorz.github.io/rain/
- 7: https://github.com/scizzorz/rain
🏁 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:
- 1: https://hackmd.io/BuuicWzpT3SIGk6DUaho6g
- 2: https://docs.rainlang.xyz/learning-rainlang-in-60-minutes/rainlang-in-30-minutes.svelte
- 3: https://github.com/rainprotocol/specs/blob/main/dotrain.md
🌐 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 200Repository: 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.rainRepository: 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.rainRepository: 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>()`.
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>
Summary
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 feedsbase-st0x-dia-v3) and buy (base-st0x-dia-inv-v3) deployments withallowed-session,dia-id,baseline-multiplier,oracle-price-timeout, and min/max price safety guardsstrategy/registry(also includes the v3 registry pin migration fromchore/bump-registry-v3)Test plan
base-st0x-dia-v3andbase-st0x-dia-inv-v3via Raindex order builderMade with Cursor
Summary by CodeRabbit
New Features
Bug Fixes