Add phoenix-protocol (phUSD staking)#2682
Conversation
Single-pool adapter for the Phoenix Protocol phUSD staking contract on Ethereum. Computes USDC reward APY from rewardBalance/depletionDuration and reads the phUSD-emission APY directly from the contract's desiredAPYBps target. Prices phUSD via the Balancer V3 phUSD/sUSDS pool and the sUSDS ERC4626 conversion to USDS. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR introduces a new Phoenix Protocol adapter for the yield-server repository. It adds an APY calculation module that fetches phUSD staking TVL and reward rates, derives phUSD pricing from Balancer V3 pool reserves, and computes dual-component yields (USDC-based reward emission and phUSD-based APY from protocol settings). ChangesPhoenix Protocol Staking Adapter
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 phoenix-protocol adapter exports pools: Test Suites: 1 passed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/adaptors/phoenix-protocol/index.js (1)
51-59: ⚖️ Poor tradeoffConsider BigInt arithmetic for precision.
Converting balances to
Number(lines 51-52) may lose precision for very large pool balances. JavaScriptNumberhas ~15-17 significant decimal digits, which could introduce small rounding errors for 18-decimal tokens with large supplies. For typical pool sizes this is acceptable, but using BigInt arithmetic would be more robust.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/adaptors/phoenix-protocol/index.js` around lines 51 - 59, The code currently converts balances and sharesToAssets to Number which can lose precision; instead parse balances (balances[idxSusds], balances[idxPhusd]) and sharesToAssets as BigInt, perform fixed-point arithmetic using a chosen SCALE (e.g., BigInt(1e18)) to preserve 18-decimal precision: compute phUsdPriceInSUsds = (sUsdsBalance * SCALE) / phUsdBalance and compute usdsPerSUsds = (sharesToAssets * SCALE) / BigInt(1e18) (or equivalently keep shares scaled), then multiply and rescale to produce the final result; update the expressions that reference sUsdsBalance, phUsdBalance, sharesToAssets, phUsdPriceInSUsds, and usdsPerSUsds to use BigInt arithmetic and convert the final value to Number or string only at the return boundary.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/adaptors/phoenix-protocol/index.js`:
- Around line 37-38: The calls to callView using getPoolTokensAbi and
getCurrentLiveBalancesAbi pass BALANCER_POOL as a bare value; update these
invocations so the third argument is an array containing BALANCER_POOL (e.g.,
callView(BALANCER_VAULT, getPoolTokensAbi, [BALANCER_POOL]) and similarly for
getCurrentLiveBalancesAbi) to match the ABI parameter format used elsewhere and
avoid SDK runtime errors.
---
Nitpick comments:
In `@src/adaptors/phoenix-protocol/index.js`:
- Around line 51-59: The code currently converts balances and sharesToAssets to
Number which can lose precision; instead parse balances (balances[idxSusds],
balances[idxPhusd]) and sharesToAssets as BigInt, perform fixed-point arithmetic
using a chosen SCALE (e.g., BigInt(1e18)) to preserve 18-decimal precision:
compute phUsdPriceInSUsds = (sUsdsBalance * SCALE) / phUsdBalance and compute
usdsPerSUsds = (sharesToAssets * SCALE) / BigInt(1e18) (or equivalently keep
shares scaled), then multiply and rescale to produce the final result; update
the expressions that reference sUsdsBalance, phUsdBalance, sharesToAssets,
phUsdPriceInSUsds, and usdsPerSUsds to use BigInt arithmetic and convert the
final value to Number or string only at the return boundary.
🪄 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: 8c4801dc-2662-4d40-9e9d-072218b0caac
📒 Files selected for processing (2)
src/adaptors/phoenix-protocol/README.mdsrc/adaptors/phoenix-protocol/index.js
Match the form already used by the convertToAssets call in the same function. The SDK accepts both bare and array forms, but mixing them is noisy. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The phoenix-protocol adapter exports pools: Test Suites: 1 passed, 1 total |
Summary
Adds a yield adapter for the Phoenix Protocol phUSD staking contract on Ethereum mainnet, exposing a single pool searchable as
phUSD.Pool
0x3984eBC84d45a889dDAc595d13dc0aC2E54819F4(phUSD staking)phUSDphoenix-protocolStakers deposit phUSD and receive two emission-based rewards.
APY methodology
rewardBalance / depletionDurationis annualized and divided by USD TVL.desiredAPYBpstarget. Computed directly asdesiredAPYBps / 100(currently0; will activate when governance enables it).apyRewardis the sum of the two;apyBaseisnull(the staking action itself produces no organic yield).Pricing
phUSD is priced from the Balancer V3 phUSD/sUSDS 50/50 weighted pool:
getPoolTokens+getCurrentLiveBalances(both tokens 18-dec, no rate provider).phUsdPriceInSUsds = sUsdsBalance / phUsdBalance.convertToAssets(1e18)live exchange rate.$1.Falls back to
$1peg with a warning if any of the on-chain reads fail.USDC is hardcoded to
$1.Test plan
npm run test --adapter=phoenix-protocol— 11/11 passing.symbol === 'phUSD', sane TVL (~$11.5k at time of writing).🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation