Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/hooks/useVaultV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,16 @@ export function useVaultV2({

txs.push(submitSetSelfAllocatorTx, setSelfAllocatorTx);

// Step 6.2 (Optional). Set initial allocator if provided.
// 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.
Comment on lines +236 to +245
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.

if (allocator && allocator !== zeroAddress) {
const setAllocatorTx = encodeFunctionData({
abi: vaultv2Abi,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { AgentMetadata } from './types';
const alchemyKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY;
const rpcPriority = process.env.NEXT_PUBLIC_RPC_PRIORITY;

const apiKey = process.env.NEXT_PUBLIC_THEGRAPH_API_KEY;
const _apiKey = process.env.NEXT_PUBLIC_THEGRAPH_API_KEY;

/**
* Helper function to get RPC URL with fallback logic. Priority behavior:
Expand Down