Skip to content

fixed spread#7

Merged
hardyjosh merged 23 commits into
ST0x-Technology:mainfrom
Siddharth2207:2026-04-16-fixed-spread
Apr 17, 2026
Merged

fixed spread#7
hardyjosh merged 23 commits into
ST0x-Technology:mainfrom
Siddharth2207:2026-04-16-fixed-spread

Conversation

@Siddharth2207

@Siddharth2207 Siddharth2207 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

FIxed spread strategy for st0x

Summary by CodeRabbit

  • New Features

    • Added "St0x fixed spread limit" strategy: oracle-backed fixed-spread trading for the base orderbook, with GUI exposure and configurable baseline multiplier, min/max price bounds, max staleness, and selectable buy/sell token roles. Includes runtime safeguards for oracle signature, timestamp freshness, and price bounds.
  • Chores

    • Updated registry mappings to reference the latest upstream strategy versions.

@coderabbitai

coderabbitai Bot commented Apr 16, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cebdf543-1301-4c1e-a6b7-731392c7247f

📥 Commits

Reviewing files that changed from the base of the PR and between eb52673 and 2606b67.

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

📝 Walkthrough

Walkthrough

Registry entries for two existing strategy files were updated to a new upstream commit (bde82a0...) and a new registry mapping st0x-fixed-spread was added. A new Rain strategy strategy/st0x-fixed-spread.rain (v5) was introduced implementing an oracle-backed fixed-spread baseline with signer/schema/time/price safety checks and GUI deployment metadata.

Changes

Cohort / File(s) Summary
Registry
strategy/registry
Updated upstream commit references for settings.yaml and st0x-oracle-limit.rain to bde82a0...; added new mapping st0x-fixed-spreadstrategy/st0x-fixed-spread.rain at the same commit. (Lines: +3 / -2)
New Strategy
strategy/st0x-fixed-spread.rain
Added new Rain strategy (v5) defining base order, scenario st0x-oracle-baseline-base, baseline #st0x-oracle-baseline that validates signed oracle context (signer, schema), enforces publish-time/staleness and price bounds (>0, min/max), computes IO using baseline-multiplier, exposes GUI deployment base-st0x, and includes no-op IO/add-order handlers. (Lines: +189)

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant GUI as "GUI / Deployment"
  participant Strategy as "st0x-fixed-spread.rain"
  participant Oracle as "Signed Context Oracle"
  participant Orderbook as "RAINDEX Orderbook"

  GUI->>Strategy: deploy scenario with params (baseline-multiplier, min/max-price, max-staleness, input/output)
  Strategy->>Oracle: fetch signed-context (schema v1) -> request price, publish_time, signer
  Oracle-->>Strategy: signed context (oracle-price, publish-time, signer, schema)
  Strategy->>Strategy: verify signer, schema, publish_time ≤ now, age ≤ max-staleness
  Strategy->>Strategy: assert oracle-price > 0 and min-price < oracle-price < max-price
  Strategy->>Strategy: compute IO = oracle-price * baseline-multiplier
  Strategy->>Orderbook: provide IO (offer-amount, io price) for `base` order
  Orderbook-->>GUI: reflect orderbook quoting / deployment status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped the registry, found a fixed-spread tune,
Signed context hummed under a silver moon.
Multipliers dance, checks keep the pace,
Orders set sail with a trusted oracle's grace.
Hooray — carrots for safe market space!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fixed spread' is vague and overly generic, lacking specificity about whether this adds, modifies, or updates the feature, and does not convey the full scope of changes including registry updates. Consider a more descriptive title such as 'Add st0x-fixed-spread strategy and update registry' or 'Implement fixed spread limit strategy with oracle backing' to better convey the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@strategy/st0x-fixed-spread.rain`:
- Line 50: Update the user-facing description strings that contain
grammar/spelling errors: replace "Deploy an fixed-spread strategy on Base using
St0x price feeds to sell shares." (the line with the description: key) with the
correct phrasing such as "Deploy a fixed-spread strategy on Base using St0x
price feeds to sell shares." and make the same correction for the second
occurrence around the description at the other location (the second description:
key near line 104).
- Around line 121-135: The UI tunable "oracle-price-timeout" is defined but
never referenced by the strategy; remove the dead field by deleting the binding
block for "oracle-price-timeout" (the block starting with "binding:
oracle-price-timeout" / "name: Oracle Price Timeout") from the Rainlang config
so user input is not exposed as a no-op, or alternatively add usage of the
variable (e.g., reference oracle-price-timeout in the strategy logic where
oracle freshness is validated) if you intend to honor the timeout.
- Around line 21-30: The code is recursively calling call<'baseline-fn'>()
(which resolves back to the same function) causing infinite recursion; replace
those call<'baseline-fn'>() invocations with the already-bound baseline variable
(bound via call<'st0x-oracle-baseline'>()) so the function uses the computed
baseline value instead of re-invoking baseline-fn; update occurrences where
baseline-fn is invoked (look for call<'baseline-fn'>() in the body of
st0x-oracle-baseline and related code) to reference baseline.
🪄 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: 5d359360-f46f-4f69-ac8a-c4e5f2845536

📥 Commits

Reviewing files that changed from the base of the PR and between 2af911e and 7994eb0.

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

Comment thread strategy/st0x-fixed-spread.rain Outdated
Comment thread strategy/st0x-fixed-spread.rain Outdated
Comment thread strategy/st0x-fixed-spread.rain Outdated
@Siddharth2207 Siddharth2207 changed the title 2026 04 16 fixed spread fixed spread Apr 16, 2026

@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.

♻️ Duplicate comments (2)
strategy/st0x-fixed-spread.rain (2)

249-255: ⚠️ Potential issue | 🔴 Critical

Replace self-recursive call<'baseline-fn>() with baseline variable.

This is an infinite recursion bug. When baseline-fn is bound to 'st0x-feed-price':

  1. #calculate-io calls call<'baseline-fn>() → resolves to call<'st0x-feed-price>()
  2. #st0x-feed-price computes baseline but then calls call<'baseline-fn>() again
  3. This resolves back to call<'st0x-feed-price>() → infinite loop

The baseline variable is already correctly bound to the oracle price. Use it instead of recursively calling the same function.

🐛 Proposed fix
 `#st0x-feed-price`
   baseline: call<'st0x-oracle-baseline>()
-  _: mul(call<'baseline-fn>() baseline-multiplier);
+  _: mul(baseline baseline-multiplier);
 
 `#st0x-feed-price-inv`
   baseline: call<'st0x-oracle-baseline>()
-  _: inv(mul(call<'baseline-fn>() baseline-multiplier));
+  _: inv(mul(baseline baseline-multiplier));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@strategy/st0x-fixed-spread.rain` around lines 249 - 255, The two rule blocks
`#st0x-feed-price` and `#st0x-feed-price-inv` currently call call<'baseline-fn>()
causing self-recursion when baseline-fn is bound to 'st0x-feed-price'; replace
those recursive call<'baseline-fn>() uses with the already-bound baseline
variable (i.e., use baseline where call<'baseline-fn>() appears in both mul(...)
and inv(mul(...)) expressions) so the oracle price variable is reused instead of
re-invoking the same rule.

50-50: ⚠️ Potential issue | 🟡 Minor

Fix user-facing description typos.

Line 50: "an fixed-spread" should be "a fixed-spread".
Line 104: "an fixed-spread trategy" should be "a fixed-spread strategy" (two typos).

✏️ Proposed fix
-      description: Deploy an fixed-spread strategy on Base using St0x price feeds to sell shares.
+      description: Deploy a fixed-spread strategy on Base using St0x price feeds to sell shares.

At line 104:

-      description: Deploy an fixed-spread trategy on Base using St0x price feeds to buy shares.
+      description: Deploy a fixed-spread strategy on Base using St0x price feeds to buy shares.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@strategy/st0x-fixed-spread.rain` at line 50, Fix the user-facing typos in the
strategy description fields: change "an fixed-spread" to "a fixed-spread" in the
description key (the line starting with description:) and correct the second
occurrence "an fixed-spread trategy" to "a fixed-spread strategy" wherever that
string appears (search for the phrase "fixed-spread" to locate both places).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@strategy/st0x-fixed-spread.rain`:
- Around line 249-255: The two rule blocks `#st0x-feed-price` and
`#st0x-feed-price-inv` currently call call<'baseline-fn>() causing self-recursion
when baseline-fn is bound to 'st0x-feed-price'; replace those recursive
call<'baseline-fn>() uses with the already-bound baseline variable (i.e., use
baseline where call<'baseline-fn>() appears in both mul(...) and inv(mul(...))
expressions) so the oracle price variable is reused instead of re-invoking the
same rule.
- Line 50: Fix the user-facing typos in the strategy description fields: change
"an fixed-spread" to "a fixed-spread" in the description key (the line starting
with description:) and correct the second occurrence "an fixed-spread trategy"
to "a fixed-spread strategy" wherever that string appears (search for the phrase
"fixed-spread" to locate both places).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28e468d2-0637-4b38-9ae4-f884a09f6f15

📥 Commits

Reviewing files that changed from the base of the PR and between 7994eb0 and eb52673.

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

@hardyjosh hardyjosh merged commit aa7ac8a into ST0x-Technology:main Apr 17, 2026
3 checks 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.

2 participants