Conversation
|
The adapter at projects/resolv exports TVL: |
|
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)
📝 WalkthroughWalkthroughThe Ethereum adapter gains a functional, timestamp-gated TVL routine that reads token total supplies, subtracts a post-hack minted amount, imports core asset addresses, and adds a methodology string; Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 docstrings
🧪 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 projects/resolv exports TVL: |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
projects/resolv/index.js (2)
14-19: Sequential awaits can be parallelized for better performance.The two
api.callinvocations on lines 14 and 19 are independent and could be executed concurrently usingPromise.all.Parallel fetch example
if (api.timestamp > 1774137600) { - api.add(ADDRESSES.ethereum.USDC, (await api.call({ target: tokens[0], abi: 'erc20:totalSupply' })) / 10 **12) - // Subtract 80M after hack - // https://etherscan.io/tx/0x41b6b9376d174165cbd54ba576c8f6675ff966f17609a7b80d27d8652db1f18f - // https://etherscan.io/tx/0xfe37f25efd67d0a4da4afe48509b258df48757b97810b28ce4c649658dc33743 - api.add(ADDRESSES.ethereum.USDC, -8e13) - api.add(tokens[1], await api.call({ target: tokens[1], abi: 'erc20:totalSupply' })) + const [usrSupply, rlpSupply] = await Promise.all([ + api.call({ target: tokens[0], abi: 'erc20:totalSupply' }), + api.call({ target: tokens[1], abi: 'erc20:totalSupply' }), + ]) + api.add(ADDRESSES.ethereum.USDC, BigInt(usrSupply) / BigInt(10 ** 12)) + // Subtract 80M after hack + // https://etherscan.io/tx/0x41b6b9376d174165cbd54ba576c8f6675ff966f17609a7b80d27d8652db1f18f + // https://etherscan.io/tx/0xfe37f25efd67d0a4da4afe48509b258df48757b97810b28ce4c649658dc33743 + api.add(ADDRESSES.ethereum.USDC, -8e13) + api.add(tokens[1], rlpSupply)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@projects/resolv/index.js` around lines 14 - 19, The two independent token supply fetches use sequential awaits (api.call for tokens[0] and tokens[1]); change them to run in parallel via Promise.all, await both results together, then call api.add for ADDRESSES.ethereum.USDC (divide result[0] by 10**12) and api.add(tokens[1], result[1]); keep the subsequent hard-coded subtraction api.add(ADDRESSES.ethereum.USDC, -8e13) in place and ensure you use the same symbols (api.call, api.add, tokens, ADDRESSES) when replacing the code.
13-14: Consider usingBigIntarithmetic to avoid potential precision loss.The division
/ 10 ** 12coerces the largetotalSupplyvalue to a JavaScriptNumber, which may lose precision for supplies exceedingNumber.MAX_SAFE_INTEGER(~9e15). USR with 18 decimals and ~114M supply approaches 1.14e26 in raw units.Also, the timestamp
1774137600would benefit from a comment indicating the target date.Suggested improvement
misrepresentedTokens: true, tvl: async (api) => { - if (api.timestamp > 1774137600) { - api.add(ADDRESSES.ethereum.USDC, (await api.call({ target: tokens[0], abi: 'erc20:totalSupply' })) / 10 **12) + // Nov 19, 2026 - apply hack adjustment after this date + if (api.timestamp > 1774137600) { + const usrSupply = await api.call({ target: tokens[0], abi: 'erc20:totalSupply' }) + api.add(ADDRESSES.ethereum.USDC, BigInt(usrSupply) / BigInt(10 ** 12))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@projects/resolv/index.js` around lines 13 - 14, The current expression in the api.add call coerces a big ERC20 totalSupply to a Number via `/ 10 ** 12`, risking precision loss; update the logic that reads (await api.call({ target: tokens[0], abi: 'erc20:totalSupply' })) / 10 **12 to use BigInt arithmetic (e.g., cast totalSupply to BigInt, divide by BigInt(10) ** BigInt(12) or scale appropriately) before passing to api.add so values remain exact, and ensure api.add accepts the BigInt (or convert to a safe string if required); also add a brief comment beside the literal timestamp 1774137600 indicating its human-readable date for clarity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@projects/resolv/index.js`:
- Around line 14-19: The two independent token supply fetches use sequential
awaits (api.call for tokens[0] and tokens[1]); change them to run in parallel
via Promise.all, await both results together, then call api.add for
ADDRESSES.ethereum.USDC (divide result[0] by 10**12) and api.add(tokens[1],
result[1]); keep the subsequent hard-coded subtraction
api.add(ADDRESSES.ethereum.USDC, -8e13) in place and ensure you use the same
symbols (api.call, api.add, tokens, ADDRESSES) when replacing the code.
- Around line 13-14: The current expression in the api.add call coerces a big
ERC20 totalSupply to a Number via `/ 10 ** 12`, risking precision loss; update
the logic that reads (await api.call({ target: tokens[0], abi:
'erc20:totalSupply' })) / 10 **12 to use BigInt arithmetic (e.g., cast
totalSupply to BigInt, divide by BigInt(10) ** BigInt(12) or scale
appropriately) before passing to api.add so values remain exact, and ensure
api.add accepts the BigInt (or convert to a safe string if required); also add a
brief comment beside the literal timestamp 1774137600 indicating its
human-readable date for clarity.
|
The adapter at projects/resolv exports TVL: |
Summary by CodeRabbit
Bug Fixes
Improvements
Documentation