Skip to content

fix: auto set max rate#320

Merged
antoncoding merged 1 commit intomasterfrom
feat/rate
Jan 23, 2026
Merged

fix: auto set max rate#320
antoncoding merged 1 commit intomasterfrom
feat/rate

Conversation

@antoncoding
Copy link
Copy Markdown
Owner

@antoncoding antoncoding commented Jan 23, 2026

Summary by CodeRabbit

Release Notes

  • Chores
    • Enhanced vault initialization with automatic APY rate configuration during setup.
    • Internal code maintenance improvements.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jan 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
monarch Ready Ready Preview, Comment Jan 23, 2026 6:17am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

Adds a setMaxAPY transaction step to vault initialization with a fixed value, executed before allocator setup. Also renames an internal variable in the networks utility.

Changes

Cohort / File(s) Summary
Vault initialization
src/hooks/useVaultV2.ts
Inserts setMaxRate transaction call with hardcoded APY value (63419583967n) into the initialization sequence, placed unconditionally before existing allocator setup logic
Network utilities
src/utils/networks.ts
Renames internal variable from apiKey to _apiKey

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • antoncoding/monarch#276: Modifies vault initialization transaction sequencing in the same file, adding allocator and setup steps alongside market withdrawal logic

Suggested labels

feature request

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main change: adding a setMaxRate call to automatically set the maximum APY in the initialization sequence.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/rate

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 added the feature request Specific feature ready to be implemented label Jan 23, 2026
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

🤖 Fix all issues with AI agents
In `@src/hooks/useVaultV2.ts`:
- Around line 236-245: The setMaxRate call is missing the timelock submit step
and should follow the same submit+execute pattern used for
setIsAllocator/abdicate; after creating setMaxAPYTx via encodeFunctionData
(variable setMaxAPYTx) and before pushing it onto txs, create and push a
timelock submit transaction (e.g., submitTransaction/submit call that wraps
setMaxAPYTx as the data payload, often named submitTx or similar) so the
sequence mirrors the other operations, then ensure the corresponding execute
step will run the submitted transaction; update the code around
setMaxAPYTx/txs.push to add that submit wrapper.

Comment thread src/hooks/useVaultV2.ts
Comment on lines +236 to +245
// Step 6.2 As allocator, set max apy
const setMaxAPYTx = encodeFunctionData({
abi: vaultv2Abi,
functionName: 'setMaxRate',
args: [63419583967n], // max max rate = 200e16 / (86400 * 365) // 200% APR
});

txs.push(setMaxAPYTx);

// Step 6.3 (Optional). Set initial allocator if provided.
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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find the vaultv2Abi definition
find . -type f -name "*.ts" -o -name "*.tsx" | head -20
rg "vaultv2Abi" --type ts --type tsx -l

Repository: antoncoding/monarch

Length of output: 692


🏁 Script executed:

# Check the useVaultV2.ts file for context around setMaxRate and other operations
cat -n src/hooks/useVaultV2.ts | sed -n '200,300p'

Repository: antoncoding/monarch

Length of output: 4078


🏁 Script executed:

# Search for submit pattern in vault-related code
rg "functionName.*submit" --type ts --type tsx -A 2 -B 2

Repository: antoncoding/monarch

Length of output: 90


🏁 Script executed:

# Look for the vaultv2Abi definition to understand setMaxRate
rg "vaultv2Abi\s*=" --type ts --type tsx -A 10

Repository: antoncoding/monarch

Length of output: 90


🏁 Script executed:

# Search for vault contract definitions
rg "setMaxRate" --type ts -A 5 -B 5

Repository: antoncoding/monarch

Length of output: 32285


🏁 Script executed:

# Look for vaultv2Abi source
rg "export.*vaultv2Abi|vaultv2Abi.*=" --type ts -A 5

Repository: antoncoding/monarch

Length of output: 31610


🏁 Script executed:

# Find any contract files or ABI definitions
find . -type f \( -name "*vault*" -o -name "*abi*" \) | grep -E "\.(ts|tsx|json|sol)$" | head -20

Repository: antoncoding/monarch

Length of output: 1165


Add submit call for setMaxRate to match the timelock pattern used elsewhere.

All similar operations (setIsAllocator, abdicate) in this initialization sequence use the submit+execute pattern. setMaxRate currently skips the submit, which is inconsistent and likely incorrect.

Apply this pattern
      const setMaxAPYTx = encodeFunctionData({
        abi: vaultv2Abi,
        functionName: 'setMaxRate',
        args: [63419583967n], // max max rate = 200e16 / (86400 * 365) // 200% APR
      });

-      txs.push(setMaxAPYTx);
+      const submitSetMaxAPYTx = encodeFunctionData({
+        abi: vaultv2Abi,
+        functionName: 'submit',
+        args: [setMaxAPYTx],
+      });
+
+      txs.push(submitSetMaxAPYTx, setMaxAPYTx);
🤖 Prompt for AI Agents
In `@src/hooks/useVaultV2.ts` around lines 236 - 245, The setMaxRate call is
missing the timelock submit step and should follow the same submit+execute
pattern used for setIsAllocator/abdicate; after creating setMaxAPYTx via
encodeFunctionData (variable setMaxAPYTx) and before pushing it onto txs, create
and push a timelock submit transaction (e.g., submitTransaction/submit call that
wraps setMaxAPYTx as the data payload, often named submitTx or similar) so the
sequence mirrors the other operations, then ensure the corresponding execute
step will run the submitted transaction; update the code around
setMaxAPYTx/txs.push to add that submit wrapper.

@antoncoding antoncoding merged commit 2b2f26d into master Jan 23, 2026
4 checks passed
@antoncoding antoncoding deleted the feat/rate branch January 23, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Specific feature ready to be implemented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant