Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughA new module introduces Ethereum TVL and staking logic for the Phoenix Protocol. The implementation fetches ERC4626 vault share balances, converts them to underlying asset amounts through batched on-chain calls, and attributes the resolved values to their respective token addresses. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client/API
participant Chain as Ethereum Blockchain
participant Vault as ERC4626 Vault
participant Token as Token Contract
Client->>Chain: Batch call balanceOf(vault) on strategy
Chain-->>Client: Returns share balances
Client->>Vault: Batch call convertToAssets(shares)
Vault->>Chain: Fetch conversion logic
Chain-->>Vault: Return conversion data
Vault-->>Client: Returns asset amounts
Client->>Vault: Batch call asset() getter
Vault->>Chain: Fetch token address
Chain-->>Vault: Return token address
Vault-->>Client: Returns token address
Client->>Token: api.add(token, assets)
Token-->>Client: TVL attributed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 projects/phoenix-protocol exports TVL: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
projects/phoenix-protocol/index.js (1)
6-14: Refactor away from index-coupled parallel arrays.
strategies[i]andvaults[i]work now, but this pattern is brittle for future edits and can silently mispair contracts. Prefer explicit{ strategy, vault }tuples.♻️ Proposed refactor
-const strategies = [ - "0xE7aEC21BF6420FF483107adCB9360C4b31d69D78", // YieldStrategyDola - "0x8b4A75290A1C4935eC1dfd990374AC4BD4D33952", // YieldStrategyUSDC -]; - -const vaults = [ - "0x79eB84B5E30Ef2481c8f00fD0Aa7aAd6Ac0AA54d", // AutoDOLA - "0xa7569A44f348d3D70d8ad5889e50F78E33d80D35", // AutoUSDC -]; +const strategyVaultPairs = [ + { + strategy: "0xE7aEC21BF6420FF483107adCB9360C4b31d69D78", // YieldStrategyDola + vault: "0x79eB84B5E30Ef2481c8f00fD0Aa7aAd6Ac0AA54d", // AutoDOLA + }, + { + strategy: "0x8b4A75290A1C4935eC1dfd990374AC4BD4D33952", // YieldStrategyUSDC + vault: "0xa7569A44f348d3D70d8ad5889e50F78E33d80D35", // AutoUSDC + }, +]; async function tvl(api) { const shares = await api.multiCall({ abi: "erc20:balanceOf", - calls: vaults.map((vault, i) => ({ target: vault, params: strategies[i] })), + calls: strategyVaultPairs.map(({ vault, strategy }) => ({ target: vault, params: strategy })), }); const assets = await api.multiCall({ abi: "function convertToAssets(uint256) view returns (uint256)", - calls: vaults.map((vault, i) => ({ target: vault, params: shares[i] })), + calls: strategyVaultPairs.map(({ vault }, i) => ({ target: vault, params: shares[i] })), }); - const tokens = await api.multiCall({ abi: "address:asset", calls: vaults }); + const tokens = await api.multiCall({ + abi: "address:asset", + calls: strategyVaultPairs.map(({ vault }) => vault), + });Also applies to: 19-25
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@projects/phoenix-protocol/index.js` around lines 6 - 14, The code uses parallel arrays strategies and vaults which can mispair; replace both arrays with a single array of objects like [{ strategy: "0x...", vault: "0x..." }, ...] and update any code that iterates or indexes strategies[i]/vaults[i] to destructure each tuple (e.g., for (const {strategy, vault} of phoenixPairs) ...) so pairing is explicit; apply the same refactor to the other parallel arrays in this file (the second pair around the later block) and update referenced symbols (strategies, vaults) to the new collection name (e.g., phoenixPairs) and their usages (index-based accesses) accordingly.
🤖 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/phoenix-protocol/index.js`:
- Around line 6-14: The code uses parallel arrays strategies and vaults which
can mispair; replace both arrays with a single array of objects like [{
strategy: "0x...", vault: "0x..." }, ...] and update any code that iterates or
indexes strategies[i]/vaults[i] to destructure each tuple (e.g., for (const
{strategy, vault} of phoenixPairs) ...) so pairing is explicit; apply the same
refactor to the other parallel arrays in this file (the second pair around the
later block) and update referenced symbols (strategies, vaults) to the new
collection name (e.g., phoenixPairs) and their usages (index-based accesses)
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e4227f9c-b1ed-4697-a555-0eb0e7b97471
📒 Files selected for processing (1)
projects/phoenix-protocol/index.js
Phoenix Protocol
Adds a TVL adapter for Phoenix Protocol on Ethereum mainnet.
Methodology
YieldStrategy*contracts. The adapter reads each strategy's vault share balance and converts to underlying assets viaconvertToAssets, then attributes the value to the underlying asset token (priced normally by DefiLlama).0x3984eBC84d45a889dDAc595d13dc0aC2E54819F4), reported via the standardstakinghelper.Contracts
0xf3B5B661b92B75C71fA5Aba8Fd95D7514A9CD6050x3984eBC84d45a889dDAc595d13dc0aC2E54819F40xE7aEC21BF6420FF483107adCB9360C4b31d69D780x8b4A75290A1C4935eC1dfd990374AC4BD4D339520x79eB84B5E30Ef2481c8f00fD0Aa7aAd6Ac0AA54d0xa7569A44f348d3D70d8ad5889e50F78E33d80D35Checklist
Summary by CodeRabbit