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
9 changes: 9 additions & 0 deletions projects/virtus-protocol-cl/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { uniV3Export } = require("../helper/uniswapV3")

module.exports = uniV3Export({
base: {
factory: '0x0e5Ab24beBdA7e5Bb3961f7E9b3532a83aE86B48',
fromBlock: 42960000,
eventAbi: 'event PoolCreated(address indexed token0, address indexed token1, int24 indexed tickSpacing, address pool)',
Comment on lines +6 to +7
Copy link
Copy Markdown
Contributor

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:

#!/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}")
PY

Repository: DefiLlama/DefiLlama-Adapters

Length of output: 592


🏁 Script executed:

# First, find and read the adapter file
find . -path "*/virtus-protocol-cl/*" -type f | head -20

Repository: DefiLlama/DefiLlama-Adapters

Length of output: 110


🏁 Script executed:

# Search for the adapter file more broadly
fd -e "index.js" | grep -i virtus | head -5

Repository: DefiLlama/DefiLlama-Adapters

Length of output: 54


🏁 Script executed:

# List files in projects directory to understand structure
ls -la projects/ | head -30

Repository: DefiLlama/DefiLlama-Adapters

Length of output: 1834


🏁 Script executed:

cat -n projects/virtus-protocol-cl/index.js

Repository: 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 -80

Repository: 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 -20

Repository: DefiLlama/DefiLlama-Adapters

Length of output: 3565


🏁 Script executed:

# Search for Uniswap V3 adapters specifically
grep -r "uniV3Export\|uniswapV3" projects --include="*.js" -l | head -20

Repository: 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 -40

Repository: DefiLlama/DefiLlama-Adapters

Length of output: 3756


🏁 Script executed:

# Find and read the uniswapV3 helper
cat -n projects/helper/uniswapV3.js | head -150

Repository: 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")
EOF

Repository: DefiLlama/DefiLlama-Adapters

Length of output: 314


🏁 Script executed:

# Check if adapter is supposed to override topics
grep -A5 -B5 "virtus" projects/helper/uniswapV3.js

Repository: 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.

Suggested change
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).

},
})
9 changes: 9 additions & 0 deletions registries/uniswapV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2854,6 +2854,15 @@ const uniV2Configs = {
start: '2025-08-05',
qiev3: '0x8E23128a5511223bE6c0d64106e2D4508C08398C'
},
'virtus-protocol': {
base: '0x7F03ae4452192b0E280fB0d4f9c225DDa88C7623',
_options: {
abis: {
allPairsLength: 'uint256:allPoolsLength',
allPairs: 'function allPools(uint256) view returns (address)',
}
}
},
'forest-v1': {
bsc: {
factory: '0x9d5ef0f61a5e88d90fb231f84413b5fc43bf6a9e',
Expand Down
Loading