Conversation
📝 WalkthroughWalkthroughTwo new integrations added to support the Virtus Protocol: a Uniswap V3-style module configuration for the protocol's concentrated liquidity component, and a Uniswap V2-style registry entry with factory address and ABI definitions for the base protocol. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
The adapter at virtus-protocol exports TVL: |
|
The adapter at projects/virtus-protocol-cl exports TVL: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@projects/virtus-protocol-cl/index.js`:
- Around line 6-7: The PoolCreated event ABI in this adapter is incorrect and
missing the uint24 fee and has wrong parameter order; update the eventAbi string
(the one currently set to 'event PoolCreated(address indexed token0, address
indexed token1, int24 indexed tickSpacing, address pool)') to match the
canonical Uniswap V3 signature from projects/helper/uniswapV3.js:
'PoolCreated(address indexed token0, address indexed token1, uint24 indexed fee,
int24 tickSpacing, address pool)' so the decoder can parse logs correctly (do
not change the topics logic).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3a29b07b-371c-483f-a19e-5caaff7f2af9
📒 Files selected for processing (2)
projects/virtus-protocol-cl/index.jsregistries/uniswapV2.js
| fromBlock: 42960000, | ||
| eventAbi: 'event PoolCreated(address indexed token0, address indexed token1, int24 indexed tickSpacing, address pool)', |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify which PoolCreated signature actually emits logs for the target factory on Base RPC.
python - <<'PY'
import json, requests, subprocess, sys
try:
from eth_utils import keccak
except Exception:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "eth-utils"])
from eth_utils import keccak
rpc = "https://mainnet.base.org"
factory = "0x0e5Ab24beBdA7e5Bb3961f7E9b3532a83aE86B48"
from_block = 42960000
def rpc_call(method, params):
r = requests.post(rpc, json={"jsonrpc":"2.0","id":1,"method":method,"params":params}, timeout=30)
r.raise_for_status()
return r.json()["result"]
latest = int(rpc_call("eth_blockNumber", []), 16)
signatures = {
"current_in_file": "PoolCreated(address,address,int24,address)",
"uniswap_v3_canonical": "PoolCreated(address,address,uint24,int24,address)",
}
for name, sig in signatures.items():
topic0 = "0x" + keccak(text=sig).hex()
logs = rpc_call("eth_getLogs", [{
"address": factory,
"fromBlock": hex(from_block),
"toBlock": hex(latest),
"topics": [topic0]
}])
print(f"{name}: {len(logs)} logs, topic0={topic0}")
PYRepository: DefiLlama/DefiLlama-Adapters
Length of output: 592
🏁 Script executed:
# First, find and read the adapter file
find . -path "*/virtus-protocol-cl/*" -type f | head -20Repository: DefiLlama/DefiLlama-Adapters
Length of output: 110
🏁 Script executed:
# Search for the adapter file more broadly
fd -e "index.js" | grep -i virtus | head -5Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# List files in projects directory to understand structure
ls -la projects/ | head -30Repository: DefiLlama/DefiLlama-Adapters
Length of output: 1834
🏁 Script executed:
cat -n projects/virtus-protocol-cl/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 465
🏁 Script executed:
# Check the uniswapV3 helper to understand what event signature is expected
cat -n helper/uniswapV3.js | head -80Repository: DefiLlama/DefiLlama-Adapters
Length of output: 123
🏁 Script executed:
# Find other Uniswap V3 adapters to compare event ABI patterns
grep -r "PoolCreated" projects --include="*.js" | head -20Repository: DefiLlama/DefiLlama-Adapters
Length of output: 3565
🏁 Script executed:
# Search for Uniswap V3 adapters specifically
grep -r "uniV3Export\|uniswapV3" projects --include="*.js" -l | head -20Repository: DefiLlama/DefiLlama-Adapters
Length of output: 628
🏁 Script executed:
# Look for other adapters on Base chain
grep -r "base.*factory\|factory.*base" projects --include="*.js" -B2 -A2 | head -40Repository: DefiLlama/DefiLlama-Adapters
Length of output: 3756
🏁 Script executed:
# Find and read the uniswapV3 helper
cat -n projects/helper/uniswapV3.js | head -150Repository: DefiLlama/DefiLlama-Adapters
Length of output: 3627
🏁 Script executed:
# Verify the topic hash for the correct signature
python3 << 'EOF'
from hashlib import sha256
# Canonical Uniswap V3 signature
canonical = "PoolCreated(address,address,uint24,int24,address)"
# Current virtus signature (wrong)
current = "PoolCreated(address,address,int24,address)"
def keccak256(s):
# Simple approximation - using sha256 for demonstration
import hashlib
return hashlib.sha256(s.encode()).hexdigest()
# Actually compute Keccak256 (need to import)
try:
from Crypto.Hash import keccak
k = keccak.new(digest_bits=256)
k.update(canonical.encode())
canonical_hash = k.hexdigest()
k2 = keccak.new(digest_bits=256)
k2.update(current.encode())
current_hash = k2.hexdigest()
print(f"Canonical signature: {canonical}")
print(f"Canonical topic: 0x{canonical_hash}")
print()
print(f"Current signature: {current}")
print(f"Current topic: 0x{current_hash}")
print()
print(f"Topics match: {canonical_hash == current_hash}")
except ImportError:
print("Note: Crypto library not available, but we can verify via helper file")
print(f"Helper specifies topic: 0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118")
print("This matches the canonical Uniswap V3 signature, not the current virtus signature")
EOFRepository: DefiLlama/DefiLlama-Adapters
Length of output: 314
🏁 Script executed:
# Check if adapter is supposed to override topics
grep -A5 -B5 "virtus" projects/helper/uniswapV3.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 54
Fix PoolCreated event ABI to match Uniswap V3 canonical signature.
The current ABI is missing the uint24 indexed fee parameter and has incorrect parameter ordering. The helper's canonical Uniswap V3 signature (projects/helper/uniswapV3.js:6) is PoolCreated(address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool). Since the adapter overrides eventAbi but not topics, it uses the correct topic hash but fails to decode events with the wrong ABI, resulting in zero TVL.
🔧 Proposed fix
module.exports = uniV3Export({
base: {
factory: '0x0e5Ab24beBdA7e5Bb3961f7E9b3532a83aE86B48',
fromBlock: 42960000,
- eventAbi: 'event PoolCreated(address indexed token0, address indexed token1, int24 indexed tickSpacing, address pool)',
+ eventAbi: 'event PoolCreated(address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool)',
},
})📝 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.
| fromBlock: 42960000, | |
| eventAbi: 'event PoolCreated(address indexed token0, address indexed token1, int24 indexed tickSpacing, address pool)', | |
| module.exports = uniV3Export({ | |
| base: { | |
| factory: '0x0e5Ab24beBdA7e5Bb3961f7E9b3532a83aE86B48', | |
| fromBlock: 42960000, | |
| eventAbi: 'event PoolCreated(address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool)', | |
| }, | |
| }) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@projects/virtus-protocol-cl/index.js` around lines 6 - 7, The PoolCreated
event ABI in this adapter is incorrect and missing the uint24 fee and has wrong
parameter order; update the eventAbi string (the one currently set to 'event
PoolCreated(address indexed token0, address indexed token1, int24 indexed
tickSpacing, address pool)') to match the canonical Uniswap V3 signature from
projects/helper/uniswapV3.js: 'PoolCreated(address indexed token0, address
indexed token1, uint24 indexed fee, int24 tickSpacing, address pool)' so the
decoder can parse logs correctly (do not change the topics logic).
Summary by CodeRabbit