Add LazyUSD yield adapter#2267
Conversation
LazyUSD is a delta-neutral yield vault on Ethereum that deploys USDC across lending protocols, DEXs, and derivatives platforms to generate sustainable yields while maintaining full USDC backing. The adapter calculates APY based on share price changes over a 7-day window, falling back to accumulated yield for new vaults.
- Use vault deploy block to calculate available history - Try 7-day window first, fall back to 1-day if vault is newer - Remove hardcoded daysLive that would become stale
- Corrected VAULT_DEPLOY_BLOCK from 21763550 to 24181000 (Jan 7, 2026) - Use ethers.js directly instead of SDK for more reliable ABI parsing - Calculate APY using 7-day window (falls back to 1-day for new vaults)
📝 WalkthroughWalkthroughA new adapter module is introduced at Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
|
Error while running lazyusd adapter: Test Suites: 1 failed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@src/adaptors/lazyusd/index.js`:
- Around line 33-35: The calculation for apyBase uses historicalSharePrice (from
await vault.sharePrice({ blockTag: historicalBlock })) without guarding against
zero, which can yield Infinity/NaN; before computing priceChange and apyBase,
check that historicalSharePrice is a positive non-zero number and if it's zero
or falsy either set apyBase to 0 (or skip the APY calculation) and optionally
log/mark the vault as uninitialized — update the block that assigns
historicalSharePrice, computes priceChange, and sets apyBase to perform this
validation and handle the zero-case safely.
- Around line 4-6: The VAULT_DEPLOY_BLOCK constant is incorrect (24181000 is
non-existent); locate the actual deployment block for the VAULT address
(0xd53B68fB4eb907c3c1E348CD7d7bEDE34f763805) by checking the contract creation
transaction on Etherscan or by querying the creation tx receipt via web3/ethers
to get its blockNumber, then update VAULT_DEPLOY_BLOCK to that integer value in
the file (ensure you modify the VAULT_DEPLOY_BLOCK constant alongside the
existing VAULT and USDC constants).
🧹 Nitpick comments (2)
src/adaptors/lazyusd/index.js (2)
1-1: Unused import:sdkis never used.The
@defillama/sdkimport is declared but not referenced anywhere in this file. Remove it to avoid confusion.Suggested fix
-const sdk = require('@defillama/sdk'); const { ethers } = require('ethers');
18-18:blocksPerDayis an approximation.The value 7200 assumes exactly 12-second block times. Post-merge Ethereum averages ~12.05s, which introduces minor drift over 7 days (~0.4%). This is acceptable for APY estimates but worth noting.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/adaptors/lazyusd/index.js
🔇 Additional comments (3)
src/adaptors/lazyusd/index.js (3)
8-11: LGTM!The human-readable ABI format is appropriate for ethers.js, and the function signatures match standard vault interfaces.
27-36: Edge case: vault less than 1 day old still returnsapyBase = 0.If the vault is less than 1 day old, the fallback on line 28 sets
historicalBlock = latestBlock - blocksPerDay, which may still be less thanVAULT_DEPLOY_BLOCK. The condition on line 32 will then be false, leavingapyBase = 0. This is likely acceptable behavior for new vaults, but worth confirming this is intentional.
50-54: LGTM!The export structure follows the standard DefiLlama yield adapter pattern with
timetravel,apy, andurlproperties.
|
Error while running lazyusd adapter: Test Suites: 1 failed, 1 total |
|
Error while running lazyusd adapter: Test Suites: 1 failed, 1 total |
- Remove fallback to 1-day calculation - Return 0 APY if vault is less than 7 days old - Add guard against division by zero - Cap APY at 100% to filter data outliers - Simpler, more predictable calculation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Error while running lazyusd adapter: Test Suites: 1 failed, 1 total |
|
Error while running lazyusd adapter: Test Suites: 1 failed, 1 total |
Following best practices from other vault-style adapters (Sandclock, Beraborrow), providing both metrics gives users better insight into yield stability. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Error while running lazyusd adapter: Test Suites: 1 failed, 1 total |
|
The lazy adapter exports pools: Test Suites: 1 passed, 1 total |
|
@sirmoremoney |
90873bf to
1eff626
Compare
|
The lazy adapter exports pools: Test Suites: 1 passed, 1 total |
|
Summary
Test output
Test plan
npm run test --adapter=lazyusd- all relevant tests passSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.