Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughIntroduces a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 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 |
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/term-structure/index.js`:
- Around line 325-326: The blacklist membership checks for MARKET_BLACKLIST and
VAULT_BLACKLIST are case-sensitive, so normalize addresses before comparing:
when filtering marketV2Addresses (the .filter using MARKET_BLACKLIST[api.chain])
and where VAULT_BLACKLIST is used (the filter at/near the VAULT handling),
convert the parsed/returned addr to a consistent case (e.g., addr.toLowerCase())
before calling .includes, or ensure the blacklist entries are normalized too;
update the filter predicates that reference MARKET_BLACKLIST and VAULT_BLACKLIST
to compare normalized forms and guard against undefined blacklist entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b0656d57-4c4a-4fe3-b043-d0f6e73a1e35
📒 Files selected for processing (1)
projects/term-structure/index.js
| .concat(marketV2Addresses) | ||
| .filter(addr => !MARKET_BLACKLIST[api.chain]?.includes(addr)); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether log helpers normalize addresses (which would make current includes() checks fragile).
set -euo pipefail
echo "== Locate getLogs helper =="
fd -i "getLogs.js"
echo
echo "== Inspect helper implementation for normalization =="
sed -n '1,260p' helper/cache/getLogs.js
echo
echo "== Search for lowercase/checksum normalization in log helpers =="
rg -n -C2 "toLowerCase|checksum|lowercase|onlyArgs|map\\(" helper/cache/getLogs.js
echo
echo "== Confirm current blacklist matching callsites in adapter =="
rg -n -C2 "MARKET_BLACKLIST|includes\\(|filter\\(" projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 271
🏁 Script executed:
# Find the correct path to getLogs helper
git ls-files | grep -i getlogs
# Also check the term-structure adapter structure
ls -la projects/term-structure/Repository: DefiLlama/DefiLlama-Adapters
Length of output: 286
🏁 Script executed:
# Search for getLogs usage in the term-structure adapter
rg -n "getLogs|getLogs2" projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 474
🏁 Script executed:
# Inspect how addresses come from getLogs and what the adapter does with them
rg -n -B5 -A5 "getLogs|getTokens|decodeEventLog" projects/term-structure/index.js | head -100Repository: DefiLlama/DefiLlama-Adapters
Length of output: 3888
🏁 Script executed:
# Inspect the getLogs helper for address normalization
cat -n projects/helper/cache/getLogs.js | head -150Repository: DefiLlama/DefiLlama-Adapters
Length of output: 6083
🏁 Script executed:
# Search specifically for toLowerCase or address normalization in getLogs
rg -n "toLowerCase|checksum|normalize|address" projects/helper/cache/getLogs.js | head -50Repository: DefiLlama/DefiLlama-Adapters
Length of output: 478
🏁 Script executed:
# Check what addresses are returned from the getLogs calls and how they're used
rg -n -A3 "getTermMaxMarketAddresses\|getTermMaxMarketV2Addresses" projects/term-structure/index.js | head -50Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Look at the actual MARKET_BLACKLIST definition and surrounding code
rg -n -B2 -A10 "MARKET_BLACKLIST" projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 1706
🏁 Script executed:
# Check if there's any address normalization in the adapter itself
rg -n "toLowerCase|checksum" projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Verify what ethers Interface.parseLog does with addresses by checking if there are any comments or documentation in the code
head -300 projects/term-structure/index.js | tail -100Repository: DefiLlama/DefiLlama-Adapters
Length of output: 2654
🏁 Script executed:
# Search for similar blacklist patterns in other adapters
rg -n "BLACKLIST.*includes|filter.*BLACKLIST" --type js projects/ | head -20Repository: DefiLlama/DefiLlama-Adapters
Length of output: 864
🏁 Script executed:
# Check if ethers.js in this repo has any address normalization utilities or if addresses are documented
rg -n "ethers\..*Address|getAddress|parseLog" projects/helper/ | head -30Repository: DefiLlama/DefiLlama-Adapters
Length of output: 1929
🏁 Script executed:
# Verify what the actual logs look like by checking the event definitions
rg -n "CreateMarket\|MarketCreated" projects/term-structure/index.js -A 2Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Check if there are any comments or code indicating address format expectations
rg -n -B5 "lowercase|checksum|format" projects/term-structure/index.js | head -40Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Check if ethers.js is used elsewhere in term-structure for clues about address format
rg -n "ethers\|Interface\|parseLog" projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Look for the event ABI definitions in term-structure to understand the field types
rg -n "EVENTS\." projects/term-structure/index.js -A 3 | head -60Repository: DefiLlama/DefiLlama-Adapters
Length of output: 1551
🏁 Script executed:
# Check what ethers.js version is used and its default behavior
cat package.json | rg -A 5 "ethers"Repository: DefiLlama/DefiLlama-Adapters
Length of output: 232
🏁 Script executed:
# Find where EVENTS is defined in term-structure
rg -n "const EVENTS\|= {" projects/term-structure/index.js | head -20Repository: DefiLlama/DefiLlama-Adapters
Length of output: 169
🏁 Script executed:
# Get the EVENTS definition
sed -n '150,280p' projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 3250
🏁 Script executed:
# Find EVENTS definition more carefully
rg -n "const EVENTS" projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 91
🏁 Script executed:
# Get the EVENTS object definition
sed -n '11,150p' projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 5588
🏁 Script executed:
# Check what ethers.js v6 returns from parseLog for addresses
# by looking for any documentation or examples in the repo
rg -n "parseLog\|getAddress" projects/ -A 2 -B 2 | head -50Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Verify if there are any real-world issues with the blacklist checks
# by checking if there are any bug reports or TODOs
rg -n "TODO|FIXME|BUG|blacklist" projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Double-check: does getLogs2 behave differently than getLogs?
sed -n '160,250p' projects/helper/cache/getLogs.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 2667
🏁 Script executed:
# Extract all blacklist addresses and check their format
rg -n "0x[a-fA-F0-9]+" projects/term-structure/index.js | grep -E "BLACKLIST|0x[a-f][a-f0-9]*[A-F]|0x[A-F][a-f0-9]*[A-F]" | head -40Repository: DefiLlama/DefiLlama-Adapters
Length of output: 1549
🏁 Script executed:
# More precise check: look at the actual blacklist values
sed -n '270,285p' projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 611
🏁 Script executed:
# And check VAULT_BLACKLIST too
sed -n '253,270p' projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 513
🏁 Script executed:
# Check if there are any recent changes or issues related to address casing
git log --oneline -20 projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 113
🏁 Script executed:
# Verify if ethers.js has any address normalization in the contract decode process
# by checking how addresses are handled elsewhere in the codebase
rg -n "\.toLowerCase()" projects/ -B 2 -A 2 | grep -A 2 -B 2 "address\|Address" | head -60Repository: DefiLlama/DefiLlama-Adapters
Length of output: 3960
🏁 Script executed:
# Check if the same pattern of using .includes() for address matching exists elsewhere
rg -n "\.includes.*0x|includes.*address" projects/ --type js | head -20Repository: DefiLlama/DefiLlama-Adapters
Length of output: 2556
🏁 Script executed:
# Check the event definitions more carefully - are the addresses indexed or not?
sed -n '32,50p' projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 1829
🏁 Script executed:
# Search for how ethers.js handles address normalization in similar projects
# by checking imports and usage patterns
rg -n "import.*ethers\|require.*ethers" projects/ -A 3 | head -30Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Final verification: check if there's any test or example showing what format addresses come back in
rg -n "market.*=.*0x|collateral.*=.*0x" projects/term-structure/ -B 2 -A 2Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Extract all blacklist addresses and check their exact casing
rg -n "0x[a-fA-F0-9]{40}" projects/term-structure/index.js | grep -A 1 -B 1 "BLACKLIST"Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Get exact blacklist contents with casing preserved
sed -n '253,281p' projects/term-structure/index.jsRepository: DefiLlama/DefiLlama-Adapters
Length of output: 852
🏁 Script executed:
# Final verification: check ethers.js v6 default behavior documentation
# by looking for any ethers usage in tests or examples
find projects/ -name "*.test.js" -o -name "*.spec.js" 2>/dev/null | head -5Repository: DefiLlama/DefiLlama-Adapters
Length of output: 54
🏁 Script executed:
# Check if there are any comments about address casing in the codebase
rg -n "checksum|EIP-55|case.*sensitive" projects/ -i | head -20Repository: DefiLlama/DefiLlama-Adapters
Length of output: 1987
Normalize addresses before blacklist checks.
At line 326 and line 549, the blacklist comparison is case-sensitive. Additionally, line 416 has the same issue with VAULT_BLACKLIST. Since ethers.Interface.parseLog() returns checksummed addresses and the ethereum entry in VAULT_BLACKLIST is lowercase (0x5c16d84e998c661d9f6c7cc23e1144e4b7f39759), excluded vaults/markets will not be filtered correctly, causing TVL/borrowed amounts to include blacklisted positions.
Normalize addresses before comparison:
Proposed fix
const MARKET_BLACKLIST = {
bsquared: [
"0x39256Ad46B721F47d48D1e0918a986cAc0c210ed", // B2BTC/uBTC
"0xe7d99048B6A292CBda8c7C3c0D38eBdaB3999870", // WBTC/uBTC
"0x5022B6563f6bc9f0D47F407ba32B64e1f438213a", // uBTC/WBTC
],
};
+const MARKET_BLACKLIST_SET = Object.fromEntries(
+ Object.entries(MARKET_BLACKLIST).map(([chain, addrs]) => [
+ chain,
+ new Set(addrs.map((a) => a.toLowerCase())),
+ ])
+);
+
+const VAULT_BLACKLIST_SET = Object.fromEntries(
+ Object.entries(VAULT_BLACKLIST).map(([chain, addrs]) => [
+ chain,
+ new Set(addrs.map((a) => a.toLowerCase())),
+ ])
+);
+
+function isBlacklistedMarket(chain, addr) {
+ return MARKET_BLACKLIST_SET[chain]?.has(addr.toLowerCase());
+}
+
+function isBlacklistedVault(chain, addr) {
+ return VAULT_BLACKLIST_SET[chain]?.has(addr.toLowerCase());
+}
+
async function getTermMaxMarketOwnerTokens(api) {
const [marketV1Addresses, marketV2Addresses] = await Promise.all([
getTermMaxMarketAddresses(api),
getTermMaxMarketV2Addresses(api),
]);
const marketAddresses = []
.concat(marketV1Addresses)
.concat(marketV2Addresses)
- .filter(addr => !MARKET_BLACKLIST[api.chain]?.includes(addr));
+ .filter(addr => !isBlacklistedMarket(api.chain, addr));
...
}
async function getTermMaxV2MarketBorrowed(api) {
- const marketAddresses = (await getTermMaxMarketV2Addresses(api)).filter(addr => !MARKET_BLACKLIST[api.chain]?.includes(addr));
+ const marketAddresses = (await getTermMaxMarketV2Addresses(api))
+ .filter(addr => !isBlacklistedMarket(api.chain, addr));
...
}
async function getTermMaxVaultTvl(api) {
...
- .filter((address) => !VAULT_BLACKLIST[api.chain]?.includes(address));
+ .filter((address) => !isBlacklistedVault(api.chain, address));
...
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@projects/term-structure/index.js` around lines 325 - 326, The blacklist
membership checks for MARKET_BLACKLIST and VAULT_BLACKLIST are case-sensitive,
so normalize addresses before comparing: when filtering marketV2Addresses (the
.filter using MARKET_BLACKLIST[api.chain]) and where VAULT_BLACKLIST is used
(the filter at/near the VAULT handling), convert the parsed/returned addr to a
consistent case (e.g., addr.toLowerCase()) before calling .includes, or ensure
the blacklist entries are normalized too; update the filter predicates that
reference MARKET_BLACKLIST and VAULT_BLACKLIST to compare normalized forms and
guard against undefined blacklist entries.
|
The adapter at projects/term-structure exports TVL: |
Summary by CodeRabbit
Bug Fixes
Documentation