Skip to content

wip on folio#28

Open
thedavidmeister wants to merge 117 commits intomainfrom
2025-04-22-folio
Open

wip on folio#28
thedavidmeister wants to merge 117 commits intomainfrom
2025-04-22-folio

Conversation

@thedavidmeister
Copy link
Copy Markdown
Contributor

@thedavidmeister thedavidmeister commented Apr 22, 2025

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • New Features

    • Folio rebalancer UI for Arbitrum2 and Base2: seven-token deposits/selectors, threshold & fee controls, and automated equal-weight portfolio rebalancing.
    • Fixed‑Spread and Pyth-based strategy variants with new Base2/Arbitrum2 deployments and GUI presets.
  • Chores

    • Registry entries unified to a single commit URL; platform settings expanded with Base2/Arbitrum2 endpoints, orderbooks, deployers, scenarios, and deployments.
    • Several strategy configs bumped/expanded to include Base2/Arbitrum2.
  • Documentation

    • Added Folio Rebalancer and Fixed‑Spread strategy docs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 22, 2025

Walkthrough

Adds a new Folio rebalancer config and docs; expands networks with arbitrum2 and base2 across multiple strategies and settings; and updates the registry to reference a unified commit URL (63f12dd).

Changes

Cohort / File(s) Change Summary
Folio config
src/folio.rain
New v2 configuration introducing arbitrum2/base2 networks, metaboards, subgraphs, orderbooks, deployers, per-network orders (7 inputs / 7 outputs), scenarios, deployments, GUI metadata (deposits, threshold/fee, token selectors) and embedded raindex-subparser script implementing IO calculation (#calculate-io) with placeholder handlers.
Folio docs
src/folio.md
New documentation "Folio Rebalancer" describing equal-weight portfolio rebalancing.
Registry mappings
registry
Updated multiple strategy entries to point at unified commit URL https://raw.githubusercontent.com/rainlanguage/rain.strategies/63f12dd1901ef7bbaf1efc46cc46227f830d50ab/src/...; added folio and fixed-spread entries referencing that commit.
Auction DCA
src/auction-dca.rain
v2 bump and additions for arbitrum2/base2: networks, metaboards, subgraphs, orderbooks, deployers, orders, scenarios (including pyth variants), deployments, rails, and GUI expansions for pyth flows.
Fixed-limit / Fixed-spread / Docs / Canary / Dynamic-spread / Grid
src/fixed-limit.rain, src/fixed-spread.rain, src/fixed-spread.md, src/canary.rain, src/dynamic-spread.rain, src/grid.rain
Version bumps (v1→v2 where applicable), metaboard/subgraph endpoint updates, additions of base2 entries in several strategy configs; new fixed-spread strategy and docs added.
Settings / networks
settings.yaml
Added base2 network/subgraph/metaboard entries; updated metaboard/subgraph endpoints for arbitrum/arbitrum2/base; added/updated orderbooks and deployers for base2 and arbitrum2 with adjusted addresses.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User
    participant GUI
    participant FolioScript as Folio
    participant Vaults
    participant Orderbook

    User ->> GUI: set deposits, threshold, fee, tokens
    GUI ->> FolioScript: trigger rebalance (params)
    FolioScript ->> Vaults: read input-vault-before(), output-vault-before()
    Note right of FolioScript #e6f7ff: compute base-io → corrected-io → feed-io → amount → io-ratio
    FolioScript ->> FolioScript: ensure nonzero balances
    alt rebalance required
        FolioScript ->> Orderbook: submit add-order(s) with io-ratio & amount
        Orderbook ->> Vaults: execute transfers
    end
    Vaults -->> GUI: updated balances
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • hardyjosh
  • findolor

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The PR title "wip on folio" is vague and uses a non-descriptive term ("wip") that does not convey meaningful information about the actual changes. While "folio" is indeed a real part of the changeset (a new portfolio rebalancer strategy is added), the title significantly understates the scope of the PR, which also includes addition of a complete new fixed-spread strategy, updates to multiple existing strategies (auction-dca, canary, dynamic-spread, fixed-limit, grid), registry updates, and settings modifications. A teammate scanning commit history would not understand the full extent of these changes from this vague title. Consider updating the title to be more descriptive and comprehensive, such as "Add folio portfolio rebalancer and fixed-spread strategy, update existing strategies and registry" or a similar formulation that captures the main changes. This will help teammates quickly understand the scope of the PR when reviewing history.
✅ 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 changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2025-04-22-folio

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bd30b3 and 051593d.

📒 Files selected for processing (2)
  • registry (1 hunks)
  • src/fixed-spread.rain (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-26T15:31:37.916Z
Learnt from: 0xgleb
PR: rainlanguage/rain.strategies#45
File: registry:0-0
Timestamp: 2025-07-26T15:31:37.916Z
Learning: In the rain.strategies repository, the registry file uses full commit SHAs to pin strategy URLs as the current established pattern, rather than using tags or branches, as confirmed by project maintainer 0xgleb.

Applied to files:

  • registry
🔇 Additional comments (3)
src/fixed-spread.rain (3)

135-137: Confirm “buy shares” semantics vs configured deposits/labels.

This variant is titled “buy shares” but:

  • deposits specify output (Line 136), which implies selling output.
  • field texts say “to sell” (Lines 172–177).

If the intent is to accumulate output (buy shares), deposits should likely be input, field copy should say “buy”, and IO bounds may need to reference input-side decreases. Otherwise, keep deposits as output and rename the variant to avoid implying a buy-side flow.

I can prep a patch either way once you confirm the intended side.

Also applies to: 171-177


100-107: Sanity-check Pyth feed IDs (hex prefixes differ).

Most presets start with 0x92…, but:

  • GME uses 0x91… (Line 103 and 161),
  • BRK-B uses 0x93… (Line 165).

Please confirm these are the correct canonical Pyth price feed IDs for Base. If not, replace with the proper 32-byte identifiers.

Also applies to: 160-169


46-47: Verify subparser addresses for Base mainnet.

Ensure raindex-subparser and subparser-0 addresses are deployed on Base (chain-id 8453) and correspond to the expected words used by using-words-from.

Also applies to: 54-55


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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🔭 Outside diff range comments (1)
src/folio.rain (1)

71-86: 🛠️ Refactor suggestion

Add comprehensive documentation for the rebalancing logic.

The script implements portfolio rebalancing logic but lacks detailed documentation explaining:

  • How the rebalancing algorithm works
  • What the expected outcomes are
  • How frequently it should run
  • Edge cases and how they're handled

Consider adding comments that explain the mathematical formulas and their purpose.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ace299b and 406704f.

📒 Files selected for processing (1)
  • src/folio.rain (1 hunks)

Comment thread src/folio.rain Outdated
Comment thread src/folio.rain Outdated
Comment thread src/folio.rain Outdated
Comment thread src/folio.rain
Comment thread src/folio.rain Outdated
Comment thread src/folio.rain
Comment thread src/folio.rain Outdated
Comment thread src/folio.rain Outdated
Comment thread src/folio.rain
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa4e99a and 5560b42.

📒 Files selected for processing (1)
  • src/folio.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
src/folio.md

1-1: First line in a file should be a top-level heading
null

(MD041, first-line-heading, first-line-h1)


1-1: Files should end with a single newline character
null

(MD047, single-trailing-newline)

Comment thread src/folio.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5560b42 and 25f2d92.

📒 Files selected for processing (1)
  • registry (1 hunks)
🔇 Additional comments (1)
registry (1)

1-5:

Details

✅ Verification successful

Verify updated commit hash for existing strategies.

Please confirm that the new commit hash 406704fba73edc8f724c66c69b32944cfb619959 is correct for all referenced strategy files and that each URL resolves successfully.


🏁 Script executed:

#!/bin/bash
# Verify that each raw.githubusercontent URL in the registry returns HTTP 200
urls=$(grep -Eo 'https://raw.githubusercontent.com/rainlanguage/rain.strategies/[0-9a-f]+/src/[A-Za-z0-9_.-]+\.rain' registry)
for url in $urls; do
  status=$(curl -s -o /dev/null -w "%{http_code}" "$url")
  if [ "$status" != "200" ]; then
    echo "$url returned HTTP $status"
    exit 1
  else
    echo "$url"
  fi
done
echo "All strategy URLs are valid."

Length of output: 238


🏁 Script executed:

#!/bin/bash
# Locate the registry file by searching for a known snippet
registry_file=$(rg -l '^fixed-limit https://raw.githubusercontent.com' -n)
if [ -z "$registry_file" ]; then
  echo "❌ Could not find a file containing the registry entries."
  exit 1
else
  echo "✅ Registry file found at: $registry_file"
fi

# Verify that each raw.githubusercontent URL in the registry returns HTTP 200
urls=$(grep -Eo 'https://raw.githubusercontent.com/rainlanguage/rain.strategies/[0-9a-f]+/src/[A-Za-z0-9_.-]+\.rain' "$registry_file")
for url in $urls; do
  status=$(curl -s -o /dev/null -w "%{http_code}" "$url")
  if [ "$status" != "200" ]; then
    echo "$url returned HTTP $status"
    exit 1
  else
    echo "$url"
  fi
done
echo "All strategy URLs are valid."

Length of output: 3984


Commit hash verified and URLs validated

All strategy entries in registry use commit 406704fba73edc8f724c66c69b32944cfb619959 and each raw.githubusercontent.com URL returns HTTP 200. No further action required.

Comment thread registry Outdated
thedavidmeister and others added 5 commits April 23, 2025 16:40
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/folio.md (1)

1-4: 🧹 Nitpick (assertive)

Expand documentation with usage and configuration guidance.

Right now the file contains only a brief tagline. It would be helpful to introduce sections such as:

  • Motivation: Why use the Folio strategy?
  • Configuration: Link to and describe key parameters in src/folio.rain.
  • Usage Example: CLI or code snippets showing how to run the rebalancer.
  • Integration Notes: Where this strategy sits in the registry and any prerequisites (e.g., Arbitrum network setup).

Adding these will turn this into a more user-friendly guide.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba9cad4 and 88442ad.

📒 Files selected for processing (1)
  • src/folio.md (1 hunks)
🔇 Additional comments (1)
src/folio.md (1)

1-1: Top-level heading is correctly added.

The document now begins with an H1 heading (# Folio Rebalancer), satisfying markdown lint requirements (MD041).

Comment thread src/folio.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (8)
src/folio.rain (8)

1-1: Consider using versioned tags instead of commit hashes.

Using a specific commit hash (8898591f3bcaa21dc91dc3b8584330fc405eadfa) ensures reproducibility but makes it harder to track which version is being used. Consider using named version tags if available.


5-5: Consider using a dedicated RPC provider for production.

The RPC endpoint https://1rpc.io/arb is a public endpoint that may have rate limits or reliability issues. For a production application, consider using a dedicated or private RPC provider.


14-14: Replace the placeholder subgraph URL with an actual production URL.

The URL https://example.com/subgraph appears to be a placeholder and should be updated with the actual subgraph endpoint for Arbitrum before deployment.


28-32: Replace token placeholders with actual token addresses or identifiers.

The tokens are currently defined as generic placeholders (token1 and token2). For production deployment, these should be replaced with actual token addresses, symbols, or identifiers specific to Arbitrum.


75-77: Add default value for the spread parameter.

While threshold has a default value of 0.05 defined in the GUI section, there's no default value specified for the spread parameter. Consider adding a default value to ensure the script works as expected without explicit configuration.


6-7: 🧹 Nitpick (assertive)

Remove redundant network ID definition.

Both chainId and network-id are set to the same value (42161). This is redundant and might cause confusion. Consider keeping only one of these properties.

    chain-id: 42161
-    network-id: 42161

58-62: 🧹 Nitpick (assertive)

Add data validation for user inputs in the GUI.

The threshold field lacks input validation constraints. Consider adding min/max values and validation rules to prevent users from entering invalid values.

        - binding: threshold
          name: Threshold
          description: The threshold for rebalancing the portfolio.
          type: number
          default: 0.05
+         min: 0.01
+         max: 0.99
+         step: 0.01

81-81: 🛠️ Refactor suggestion

Add additional protection against small output vault balances.

While the current check ensures non-zero balances, division by very small output vault balances could still result in extremely large ratios. Consider adding a minimum threshold for the output vault balance.

-:ensure(every(input-vault-balance() output-vault-balance()) "zero balance"),
+:ensure(every(input-vault-balance() output-vault-balance()) "zero balance")
+ ensure(gt(output-vault-balance() 0.000001) "output balance too small"),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88442ad and c1d18e7.

📒 Files selected for processing (2)
  • registry (1 hunks)
  • src/folio.rain (1 hunks)
🔇 Additional comments (2)
src/folio.rain (1)

87-88: Implement the handle-io function.

The #handle-io function is defined but empty. Consider implementing this function to handle the calculated io-ratio or provide documentation explaining why it's intentionally left empty.

Is this function intentionally left empty for future implementation, or should it be implementing specific functionality based on the calculated io-ratio?

registry (1)

1-6:

Details

✅ Verification successful

Verify the integrity of the commit hash reference.

All strategy entries now point to the same commit hash. Please ensure this commit contains all the necessary files including the new folio.rain file.

Run the following to verify the existence of all strategy files at the referenced commit:


🏁 Script executed:

#!/bin/bash
# Verify all strategy files exist at the referenced commit

COMMIT="da14edc80baf42eb79c9686453f3dca6c46e7d37"
REPO="rainlanguage/rain.strategies"
FILES=("src/fixed-limit.rain" "src/auction-dca.rain" "src/grid.rain" "src/dynamic-spread.rain" "src/canary.rain" "src/folio.rain")

for file in "${FILES[@]}"; do
  echo "Checking $file..."
  curl -s -o /dev/null -w "%{http_code}" "https://raw.githubusercontent.com/$REPO/$COMMIT/$file"
done

Length of output: 1806


Commit hash da14edc verified – all strategy files are present

All six scripts (fixed-limit.rain, auction-dca.rain, grid.rain, dynamic-spread.rain, canary.rain, folio.rain) return HTTP 200 at this commit. No further action needed.

Comment thread src/folio.rain
using-words-from raindex-subparser
:ensure(every(input-vault-balance() output-vault-balance()) "zero balance"),
base-io: div(input-vault-balance() output-vault-balance()),
corrected-io: div(base-io sub(1 threshold)),
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Apr 28, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Prevent potential division by zero.

The calculation div(base-io sub(1 threshold)) could result in division by zero if threshold equals 1. Consider adding validation to ensure threshold is always less than 1.

-corrected-io: div(base-io sub(1 threshold)),
+corrected-io: div(base-io ensure(lt(threshold 1) "threshold must be less than 1" sub(1 threshold))),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
corrected-io: div(base-io sub(1 threshold)),
-corrected-io: div(base-io sub(1 threshold)),
+corrected-io: div(base-io ensure(lt(threshold 1) "threshold must be less than 1" sub(1 threshold))),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

threshold is compile time so will always error or not at all

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@thedavidmeister You're absolutely right! Since the threshold is determined at compile time, any division by zero scenario would be caught during compilation rather than at runtime. My suggested runtime validation is unnecessary in this case. Thank you for the clarification.

  (\   /)
 ( ._.)
o_(")(")

thinking


✏️ Learnings added
Learnt from: thedavidmeister
PR: rainlanguage/rain.strategies#28
File: src/folio.rain:119-119
Timestamp: 2025-07-03T09:46:28.843Z
Learning: In Rain language configuration files, binding values like `threshold` are compile-time constants, so validation errors (such as division by zero) are caught during compilation rather than requiring runtime checks.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: Siddharth2207
PR: rainlanguage/rain.strategies#42
File: src/fixed-limit.rain:19-23
Timestamp: 2025-06-19T03:59:46.063Z
Learning: In rain.strategies configuration files, `arbitrum2` is an intentional alias for the Arbitrum network (same chain-id 42161) but with updated contract addresses. It serves as a deployment target for newer contract versions while maintaining the existing `arbitrum` configuration during transition periods.

Learnt from: findolor
PR: rainlanguage/rain.strategies#29
File: settings.yaml:1-35
Timestamp: 2025-04-30T06:32:49.466Z
Learning: In the Rain Strategies project, the `matchain` network referenced in `orderbooks` and `deployers` sections of the configuration YAML doesn't require an explicit definition in the `networks` section.

Comment thread registry Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (7)
src/folio.rain (7)

1-1: 🧹 Nitpick (assertive)

Consider using versioned tags instead of commit hashes.

Using a specific commit hash (8898591f3bcaa21dc91dc3b8584330fc405eadfa) ensures reproducibility but makes it harder to track which version is being used. Consider using named version tags if available.


5-8: 🛠️ Refactor suggestion

Consider using a dedicated RPC provider and removing redundant network IDs.

Two issues to address:

  1. The RPC endpoint https://1rpc.io/arb is a public endpoint that may have rate limits or reliability issues.
  2. Both chainId and network-id are set to 42161, which is redundant.
  arbitrum:
-   rpc: https://1rpc.io/arb
+   rpc: [YOUR_DEDICATED_RPC_PROVIDER_URL]
    chain-id: 42161
-   network-id: 42161
    currency: ETH

14-14: ⚠️ Potential issue

Replace the placeholder subgraph URL with an actual production URL.

The URL https://example.com/subgraph appears to be a placeholder and should be updated with the actual subgraph endpoint for Arbitrum before deployment.


28-38: ⚠️ Potential issue

Replace token placeholders with actual token addresses or identifiers.

The tokens are currently defined as generic placeholders (token1 through token5). For production deployment, these should be replaced with actual token addresses, symbols, or identifiers specific to Arbitrum.


64-68: 🛠️ Refactor suggestion

Add data validation for user inputs in the GUI.

The GUI configuration lacks input validation constraints for the threshold field. Consider adding min/max values and validation rules to prevent users from entering invalid values.

      - binding: threshold
        name: Threshold
        description: The threshold for rebalancing the portfolio. E.g. 0.05 = 5%
        type: number
        default: 0.05
+       min: 0.01
+       max: 0.99
+       step: 0.01

98-98: 🛠️ Refactor suggestion

Add default value for the spread parameter.

While threshold has a default value of 0.05 defined in the GUI section, there's no default value specified for the spread parameter. Consider adding a default value to ensure the script works as expected without explicit configuration.


102-104: ⚠️ Potential issue

Prevent potential division by zero and add protection against small balances.

Two issues to address:

  1. Division by zero if output vault balance is zero (already checked by the ensure function)
  2. Division by zero if threshold equals 1 in the corrected-io calculation
:ensure(every(input-vault-before() output-vault-before()) "zero balance"),
-base-io: div(input-vault-before() output-vault-before()),
-corrected-io: div(base-io sub(1 threshold)),
+base-io: div(input-vault-before() ensure(gt(output-vault-before() 0.000001) "output balance too small" output-vault-before())),
+corrected-io: div(base-io ensure(lt(threshold 1) "threshold must be less than 1" sub(1 threshold))),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1d18e7 and 5a93c49.

📒 Files selected for processing (2)
  • registry (1 hunks)
  • src/folio.rain (1 hunks)
🔇 Additional comments (1)
registry (1)

1-6: Update confirmed for all strategy references.

All strategy entries now point to the latest commit hash (9e24aef), and the new "folio" strategy has been properly added to the registry. This ensures consistency across all strategies.

Comment thread src/folio.rain
Comment on lines +69 to +73
- binding: fee
name: Fee
description: The fee for rebalancing the portfolio. E.g. 0.003 = 0.3%
type: number
default: 0.003
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add validation constraints for the fee parameter.

Similar to the threshold field, the fee field should have validation constraints to prevent users from entering invalid values.

      - binding: fee
        name: Fee
        description: The fee for rebalancing the portfolio. E.g. 0.003 = 0.3%
        type: number
        default: 0.003
+       min: 0
+       max: 0.1
+       step: 0.001
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- binding: fee
name: Fee
description: The fee for rebalancing the portfolio. E.g. 0.003 = 0.3%
type: number
default: 0.003
- binding: fee
name: Fee
description: The fee for rebalancing the portfolio. E.g. 0.003 = 0.3%
type: number
default: 0.003
min: 0
max: 0.1
step: 0.001
🤖 Prompt for AI Agents
In src/folio.rain around lines 69 to 73, the fee parameter lacks validation
constraints. Add validation rules similar to the threshold field to ensure the
fee value is within an acceptable range, such as a minimum of 0 and a maximum of
1, to prevent invalid inputs.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 85afe72 and ecb2643.

📒 Files selected for processing (2)
  • registry (1 hunks)
  • src/folio.rain (1 hunks)
🔇 Additional comments (1)
registry (1)

1-6: LGTM! Consistent commit hash update and new strategy addition.

All strategy entries have been consistently updated to the new commit hash, and the new "folio" strategy is properly formatted and follows the established pattern.

Comment thread src/folio.rain
#threshold !The threshold for rebalancing the portfolio.
#fee !The fee for rebalancing the portfolio.

#spread !The spread for the portfolio on return of threshold.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Define the spread parameter or remove the comment.

The #spread parameter is declared with a comment but is never used in the calculation logic. Either:

  1. Remove this line if it's not needed, or
  2. Implement its usage in the calculation logic

This could cause confusion about the expected parameters.

🤖 Prompt for AI Agents
In src/folio.rain at line 113, the #spread parameter is declared but not used
anywhere in the calculation logic. To fix this, either remove the #spread
declaration if it is unnecessary, or update the calculation logic to incorporate
the spread parameter appropriately so that it affects the portfolio return
threshold as intended.

Comment thread src/folio.rain
Comment thread src/folio.rain
Comment on lines +106 to +108
---

#raindex-subparser !The subparser to use.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Add comprehensive documentation for the embedded script.

The script section lacks documentation explaining:

  1. The purpose and flow of the calculation logic
  2. How the parameters interact with each other
  3. Expected input/output behavior
  4. Integration with the handler functions

Consider adding detailed comments:

 ---
 
+# Portfolio Rebalancing Script
+# Calculates input-output ratios for maintaining equal token distribution
+# Uses threshold to determine when rebalancing is needed and fee for transaction costs
+
 #raindex-subparser !The subparser to use.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
---
#raindex-subparser !The subparser to use.
---
# Portfolio Rebalancing Script
# Calculates input-output ratios for maintaining equal token distribution
# Uses threshold to determine when rebalancing is needed and fee for transaction costs
#raindex-subparser !The subparser to use.
🤖 Prompt for AI Agents
In src/folio.rain around lines 106 to 108, the embedded script lacks
comprehensive documentation. Add detailed comments explaining the purpose and
flow of the calculation logic, how the parameters interact, the expected input
and output behavior, and how the script integrates with the handler functions.
This will improve code clarity and maintainability.

Comment thread src/folio.rain
Comment on lines +56 to +59
gui:
name: Folio
description: Maintains an equal distribution of assets in a portfolio.
short-description: Rebalances a portfolio to maintain equal distribution of assets.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Enhance strategy description for better user understanding.

The current description is quite generic. Consider providing more specific information about:

  1. What "equal distribution" means (equal value? equal token count?)
  2. How often rebalancing occurs
  3. What triggers a rebalancing action
-name: Folio
-description: Maintains an equal distribution of assets in a portfolio.
-short-description: Rebalances a portfolio to maintain equal distribution of assets.
+name: Folio
+description: Automatically rebalances a multi-token portfolio to maintain equal value distribution across all assets when any token deviates beyond the configured threshold.
+short-description: Multi-token portfolio rebalancer with configurable threshold-based triggers.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
gui:
name: Folio
description: Maintains an equal distribution of assets in a portfolio.
short-description: Rebalances a portfolio to maintain equal distribution of assets.
gui:
name: Folio
description: Automatically rebalances a multi-token portfolio to maintain equal value distribution across all assets when any token deviates beyond the configured threshold.
short-description: Multi-token portfolio rebalancer with configurable threshold-based triggers.
🤖 Prompt for AI Agents
In src/folio.rain around lines 56 to 59, the strategy description is too generic
and lacks clarity. Update the gui description and short-description fields to
specify that "equal distribution" refers to equal value allocation of assets,
mention the frequency of rebalancing (e.g., daily, weekly), and describe what
triggers the rebalancing (e.g., threshold deviation or time interval). This will
provide users with a clearer understanding of the strategy's behavior.

Comment thread src/folio.rain
Comment on lines +115 to +122
#calculate-io
using-words-from raindex-subparser
:ensure(every(input-vault-before() output-vault-before()) "zero balance"),
base-io: div(input-vault-before() output-vault-before()),
corrected-io: div(base-io sub(1 threshold)),
feed-io: mul(corrected-io add(1 fee)),
amount: mul(output-vault-before() threshold),
io-ratio: feed-io;
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Jun 4, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add boundary validation for the calculation logic.

The calculation logic has several potential edge cases that could cause issues:

  1. The every() function on line 117 only checks for zero balances, but very small balances could still cause precision issues
  2. The logic assumes input-vault-before() and output-vault-before() return arrays of the same length for the 7 tokens
  3. No validation that threshold and fee are positive values

Consider adding these validations:

 #calculate-io
 using-words-from raindex-subparser
-:ensure(every(input-vault-before() output-vault-before()) "zero balance"),
+:ensure(every(input-vault-before() output-vault-before()) "zero balance")
+ ensure(every(gt(input-vault-before() 0.000001) gt(output-vault-before() 0.000001)) "balance too small")
+ ensure(and(gt(threshold 0) lt(threshold 1)) "threshold must be between 0 and 1")
+ ensure(gt(fee 0) "fee must be positive"),

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/folio.rain around lines 115 to 122, add boundary validations to the
calculation logic by first ensuring that input-vault-before() and
output-vault-before() arrays have the same length to avoid mismatches, then
check that all balances are not only zero but also above a small positive
threshold to prevent precision issues, and finally validate that threshold and
fee variables are positive values before proceeding with calculations. Implement
these checks early in the code to prevent invalid data from affecting the
computation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

zero balance check is to prevent trades while user is depositing and withdrawing from vaults

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@thedavidmeister Thanks for the clarification! That makes perfect sense - the zero balance check serves as a safety mechanism to prevent race conditions during vault operations. I understand now that it's not just about preventing division by zero, but about ensuring trades don't execute while users are actively managing their vault positions.

This is a much more sophisticated approach than I initially recognized, as it protects against potential timing issues that could occur in a multi-user environment.


✏️ Learnings added
Learnt from: thedavidmeister
PR: rainlanguage/rain.strategies#28
File: src/folio.rain:115-122
Timestamp: 2025-07-03T09:47:14.877Z
Learning: In Rain language folio strategy, the zero balance check using `every(input-vault-before() output-vault-before())` is specifically implemented to prevent trades from executing while users are depositing or withdrawing from vaults, serving as a safety mechanism against race conditions during vault operations.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: Siddharth2207
PR: rainlanguage/rain.strategies#42
File: src/fixed-limit.rain:19-23
Timestamp: 2025-06-19T03:59:46.063Z
Learning: In rain.strategies configuration files, `arbitrum2` is an intentional alias for the Arbitrum network (same chain-id 42161) but with updated contract addresses. It serves as a deployment target for newer contract versions while maintaining the existing `arbitrum` configuration during transition periods.

Learnt from: thedavidmeister
PR: rainlanguage/rain.strategies#28
File: src/folio.rain:119-119
Timestamp: 2025-07-03T09:46:28.843Z
Learning: In Rain language configuration files, binding values like `threshold` are compile-time constants, so validation errors (such as division by zero) are caught during compilation rather than requiring runtime checks.

Learnt from: findolor
PR: rainlanguage/rain.strategies#29
File: settings.yaml:1-35
Timestamp: 2025-04-30T06:32:49.466Z
Learning: In the Rain Strategies project, the `matchain` network referenced in `orderbooks` and `deployers` sections of the configuration YAML doesn't require an explicit definition in the `networks` section.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

♻️ Duplicate comments (1)
registry (1)

1-7: Alphabetical sorting still not applied.

The registry entries remain unsorted, which was previously flagged. The current order is:

  • fixed-limit, auction-dca, grid, dynamic-spread, canary, folio, fixed-spread

The alphabetical order should be:

  • auction-dca, canary, dynamic-spread, fixed-limit, fixed-spread, folio, grid

Maintaining alphabetical order minimizes diff churn when adding new strategies.

Apply this diff to sort alphabetically:

-fixed-limit https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/fixed-limit.rain
 auction-dca https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/auction-dca.rain
-grid https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/grid.rain
+canary https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/canary.rain
 dynamic-spread https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/dynamic-spread.rain
-canary https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/canary.rain
-folio https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/folio.rain
+fixed-limit https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/fixed-limit.rain
 fixed-spread https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/fixed-spread.rain
+folio https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/folio.rain
+grid https://raw.githubusercontent.com/rainlanguage/rain.strategies/b6ba0085f716587d3f95adacdcbbcfae18c109c4/src/grid.rain
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b79e5c and d01a3f8.

📒 Files selected for processing (3)
  • registry (1 hunks)
  • src/fixed-spread.md (1 hunks)
  • src/fixed-spread.rain (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-26T15:31:37.916Z
Learnt from: 0xgleb
PR: rainlanguage/rain.strategies#45
File: registry:0-0
Timestamp: 2025-07-26T15:31:37.916Z
Learning: In the rain.strategies repository, the registry file uses full commit SHAs to pin strategy URLs as the current established pattern, rather than using tags or branches, as confirmed by project maintainer 0xgleb.

Applied to files:

  • registry
🔇 Additional comments (3)
src/fixed-spread.rain (1)

4-11: Well-structured configuration and implementation.

The following sections are correctly implemented:

  • Network configuration with proper RPC, chain-id, and network-id for Base
  • Valid metaboard, orderbook, and deployer addresses
  • Properly structured orders, scenarios, and deployments
  • Comprehensive GUI configuration with equity price feed presets covering major stocks (GOOG, AMZN, AAPL, MSFT, TSLA, NVDA, META, GME, MSTR, BRK-B, SPLG, IAU)
  • Sound inline subparser logic for pyth-price baselines and IO calculations with proper min/max trade amount validation

Also applies to: 17-30, 44-78, 92-145, 150-202, 205-238

src/fixed-spread.md (1)

1-1: Clear and concise strategy documentation.

The documentation accurately describes the fixed-spread strategy's core behavior and value proposition.

registry (1)

1-7: Unified commit reference applied consistently.

All registry entries now reference the unified commit b6ba0085f716587d3f95adacdcbbcfae18c109c4, which aligns with the established pattern of using full commit SHAs for version pinning.

Based on learnings.

Comment thread src/fixed-spread.rain
Comment on lines +13 to +14
subgraphs:
base2: https://example.com/subgraph
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Replace placeholder subgraph URL with valid endpoint.

The subgraph URL https://example.com/subgraph is a placeholder and will cause runtime failures when the strategy attempts to query blockchain data.

Please provide the correct Base subgraph endpoint URL for this network.

🤖 Prompt for AI Agents
In src/fixed-spread.rain around lines 13-14, the subgraph entry uses a
placeholder URL (https://example.com/subgraph) which will fail at runtime;
replace that value with the network's actual Base subgraph endpoint (for example
theGraph style endpoint such as
https://api.thegraph.com/subgraphs/name/<OWNER>/<SUBGRAPH> or the project's
published Base subgraph URL), i.e. update the base2 value to the correct,
reachable Base subgraph HTTP endpoint for this network.

Comment thread src/fixed-spread.rain Outdated
Comment thread src/fixed-spread.rain
Comment thread src/fixed-spread.rain
description: Select the token you want to purchase
base-pyth-inv:
name: Base pyth buy shares
description: Deploy an fixed-spread trategy on Base using Pyth price feeds to buy shares.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typo in deployment description.

"trategy" should be "strategy".

Apply this diff:

-      description: Deploy an fixed-spread trategy on Base using Pyth price feeds to buy shares.
+      description: Deploy a fixed-spread strategy on Base using Pyth price feeds to buy shares.

Note: Also fixed the article from "an" to "a" since "fixed-spread" starts with a consonant sound.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: Deploy an fixed-spread trategy on Base using Pyth price feeds to buy shares.
description: Deploy a fixed-spread strategy on Base using Pyth price feeds to buy shares.
🤖 Prompt for AI Agents
In src/fixed-spread.rain around line 147, the deployment description contains
typos: "an fixed-spread trategy on Base using Pyth price feeds to buy shares."
Change "trategy" to "strategy" and update the article "an" to "a" so the line
reads with correct spelling and grammar (e.g., "Deploy a fixed-spread strategy
on Base using Pyth price feeds to buy shares.").

Comment thread src/fixed-spread.rain Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (5)
registry (1)

1-7: Keep registry entries alphabetically sorted to minimize diff churn.

The entries are not in alphabetical order. Sorting them alphabetically will reduce noisy diffs when strategies are added or modified.

Current order: fixed-limit, auction-dca, grid, dynamic-spread, canary, folio, fixed-spread

Alphabetical order should be: auction-dca, canary, dynamic-spread, fixed-limit, fixed-spread, folio, grid

src/fixed-spread.rain (4)

13-14: Replace placeholder subgraph URL with valid endpoint.

The subgraph URL https://example.com/subgraph is a placeholder and will cause runtime failures when the strategy attempts to query blockchain data.

Based on past review comments, this issue was previously flagged but remains unaddressed.


70-70: Update documentation URL to match unified commit hash in registry.

The description URL references commit e25bc4876b5ffb8bb28097b0ca66de291c75ff56, but the registry uses 67e52ee2265954617613e12d474e31101fd0986e. This inconsistency could lead to users seeing outdated or mismatched documentation.

Apply this diff to align with the registry commit:

-  description: https://raw.githubusercontent.com/rainlanguage/rain.strategies/e25bc4876b5ffb8bb28097b0ca66de291c75ff56/src/fixed-spread.md
+  description: https://raw.githubusercontent.com/rainlanguage/rain.strategies/67e52ee2265954617613e12d474e31101fd0986e/src/fixed-spread.md

Note: This was previously flagged and marked as addressed, but the issue persists in the current code.


134-134: Fix typo and grammar in deployment description.

"trategy" should be "strategy", and "an" should be "a" before the consonant sound.

Apply this diff:

-      description: Deploy an fixed-spread trategy on Base using Pyth price feeds to buy shares.
+      description: Deploy a fixed-spread strategy on Base using Pyth price feeds to buy shares.

178-182: Fix binding name to match expected identifier.

The binding name multiplier is inconsistent with:

  • The base-pyth deployment which uses baseline-multiplier (line 120)
  • The comment definition at line 205: #baseline-multiplier
  • The calculate-io logic at line 218 which references baseline-multiplier

This will cause binding resolution to fail when deploying base-pyth-inv.

Apply this diff:

-        - binding: multiplier
+        - binding: baseline-multiplier
           name: Benchmark price multiplier
           description: |
             The multiplier to be applied to the benchmark when calculating the price the strategy will offer at
           default: 1.001
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bfb219 and cd18998.

📒 Files selected for processing (2)
  • registry (1 hunks)
  • src/fixed-spread.rain (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-26T15:31:37.916Z
Learnt from: 0xgleb
PR: rainlanguage/rain.strategies#45
File: registry:0-0
Timestamp: 2025-07-26T15:31:37.916Z
Learning: In the rain.strategies repository, the registry file uses full commit SHAs to pin strategy URLs as the current established pattern, rather than using tags or branches, as confirmed by project maintainer 0xgleb.

Applied to files:

  • registry

Comment thread src/fixed-spread.rain
deployments:
base-pyth:
name: Base pyth sell shares
description: Deploy an fixed-spread strategy on Base using Pyth price feeds to sell shares.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix grammar: use "a" instead of "an" before consonant sound.

The article "an" should be "a" before "fixed-spread" which starts with a consonant sound.

Apply this diff:

-      description: Deploy an fixed-spread strategy on Base using Pyth price feeds to sell shares.
+      description: Deploy a fixed-spread strategy on Base using Pyth price feeds to sell shares.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: Deploy an fixed-spread strategy on Base using Pyth price feeds to sell shares.
description: Deploy a fixed-spread strategy on Base using Pyth price feeds to sell shares.
🤖 Prompt for AI Agents
In src/fixed-spread.rain around line 76, the description currently reads "Deploy
an fixed-spread strategy..." — change the article "an" to "a" so it reads
"Deploy a fixed-spread strategy on Base using Pyth price feeds to sell shares."
Save the file.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (4)
registry (1)

1-7: Sort entries alphabetically to reduce diff churn.

Reorder by strategy name (stable convention in prior reviews).

-fixed-limit https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/fixed-limit.rain
-auction-dca https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/auction-dca.rain
-grid https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/grid.rain
-dynamic-spread https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/dynamic-spread.rain
-canary https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/canary.rain
-folio https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/folio.rain
-fixed-spread https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/fixed-spread.rain
+auction-dca   https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/auction-dca.rain
+canary        https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/canary.rain
+dynamic-spread https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/dynamic-spread.rain
+fixed-limit   https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/fixed-limit.rain
+fixed-spread  https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/fixed-spread.rain
+folio         https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/folio.rain
+grid          https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/grid.rain
src/fixed-spread.rain (3)

13-15: Replace placeholder subgraph URL.

base2 subgraph points to https://example.com/subgraph, which will fail at runtime. Provide the actual subgraph endpoint.


76-76: Grammar/typo fixes in deployment descriptions.

Use “a” (not “an”) and fix “trategy” → “strategy”.

-      description: Deploy an fixed-spread strategy on Base using Pyth price feeds to sell shares.
+      description: Deploy a fixed-spread strategy on Base using Pyth price feeds to sell shares.-      description: Deploy an fixed-spread trategy on Base using Pyth price feeds to buy shares.
+      description: Deploy a fixed-spread strategy on Base using Pyth price feeds to buy shares.

Also applies to: 134-134


70-70: Align docs URL to the unified commit used in registry.

Update e25bc4… to cb19f88… to avoid drift.

-  description: https://raw.githubusercontent.com/rainlanguage/rain.strategies/e25bc4876b5ffb8bb28097b0ca66de291c75ff56/src/fixed-spread.md
+  description: https://raw.githubusercontent.com/rainlanguage/rain.strategies/cb19f88bc7b484026bab9ac7f7f616de09d0e09a/src/fixed-spread.md
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a2679b and 1f00b4d.

📒 Files selected for processing (2)
  • registry (1 hunks)
  • src/fixed-spread.rain (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-26T15:31:37.916Z
Learnt from: 0xgleb
PR: rainlanguage/rain.strategies#45
File: registry:0-0
Timestamp: 2025-07-26T15:31:37.916Z
Learning: In the rain.strategies repository, the registry file uses full commit SHAs to pin strategy URLs as the current established pattern, rather than using tags or branches, as confirmed by project maintainer 0xgleb.

Applied to files:

  • registry
🔇 Additional comments (5)
registry (1)

1-7: Commit pinning to a unified SHA looks good.

URLs consistently pin to cb19f88…, matching the repository’s pattern of pinning to full commit SHAs. Based on learnings

src/fixed-spread.rain (4)

18-18: Endpoint sanity check.

Confirm the Goldsky metaboard URL ending with “/gn” is correct and reachable for base2.


41-57: Naming consistency: bindings present but minimal.

Looks consistent with calculate-io expecting baseline-fn and baseline-multiplier. After fixing quoting, ensure GUI-provided bindings flow into deployments.


1-223: File under review is clean; broader repo requires verification.

The grep search found no stale "arbitrum" identifiers in src/fixed-spread.rain itself—it contains only base2 configuration.

However, the repo-wide search reveals numerous "arbitrum" entries across other files (settings.yaml, src/fixed-limit.rain, src/dynamic-spread.rain, src/canary.rain, src/auction-dca.rain). Many of these files show both "arbitrum" and "arbitrum2" as parallel configurations rather than straightforward renames. For example, src/auction-dca.rain maintains separate deployments for "arbitrum" and "arbitrum2" with distinct orderbooks and scenarios.

Verify whether these coexisting entries represent intentional dual-chain support or stale identifiers requiring cleanup.


102-111: Verify Pyth Base price feed IDs against official source.

Web search could not retrieve the canonical hex price feed IDs for these 12 equities on Base. Manually verify the hex values—particularly the flagged 0x9145 prefix for GME/USD and IAU/USD versus 0x9245 for others—against the official Pyth price feed ID registry or Base's Pyth integration documentation.

Comment thread src/fixed-spread.rain
bindings:
raindex-subparser: 0xb05BC61963B6bEBAe9C2FEd827de600E99FB83fD
subparser-0: 0x2fbBe5715c3b40aD455992dD75129e7e0733ec7a
baseline-fn: '''pyth-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.

⚠️ Potential issue | 🔴 Critical

Fix malformed quoting for baseline-fn.

Triple-leading quote breaks parsing; use a single‑quoted symbol.

-      baseline-fn: '''pyth-price-baseline'
+      baseline-fn: "'pyth-price-baseline'"-      baseline-fn: '''pyth-price-baseline-inv'
+      baseline-fn: "'pyth-price-baseline-inv'"

Also applies to: 56-56

🤖 Prompt for AI Agents
In src/fixed-spread.rain around lines 48 and 56, the baseline-fn value is
incorrectly quoted with triple-leading quotes (e.g. '''pyth-price-baseline')
which breaks parsing; replace the malformed quoting with a single-quoted symbol
(e.g. 'pyth-price-baseline') so the value is a proper single-quoted symbol
literal in both locations. Ensure you remove the extra leading quotes and keep
consistent single-quote style for baseline-fn at both line ranges.

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.

3 participants