FIX guard against vault share price rebase in curator fee calculations#6332
FIX guard against vault share price rebase in curator fee calculations#6332SissonJ wants to merge 1 commit intoDefiLlama:masterfrom
Conversation
Summary by CodeRabbitRelease Notes
WalkthroughThe computation of Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ❌ 6❌ Failed checks (4 warnings, 2 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
helpers/curators/index.ts (2)
22-40: 🧹 Nitpick | 🔵 TrivialAdd JSDoc comments for exported functions and interfaces.
The exported entities
CuratorConfig,getEulerVaultFee, andgetCuratorExportlack JSDoc documentation. As per coding guidelines, public functions in helper files should include JSDoc comments to document purpose, parameters, return types, and important behavior (such as the rebase handling introduced in this PR).📝 Example JSDoc structure
+/** + * Configuration for curator vault fee tracking + * `@property` methodology - Optional methodology description for the adapter + * `@property` breakdownFees - Whether to break down fees by source (Morpho/Euler) + * `@property` vaults - Vault addresses and owners by chain + */ export interface CuratorConfig { methodology?: any; breakdownFees?: boolean;+/** + * Calculate fees for Euler vaults + * `@param` options - Fetch options with API and time range + * `@param` balances - Balances object to accumulate fees, revenue, and supply-side revenue + * `@param` vaults - Array of Euler vault addresses + * `@param` breakdownFees - Whether to label fees by source + * `@remarks` When vault share price rebases (rateAfter <= rateBefore), growth rate is set to 0 + */ export async function getEulerVaultFee(options: FetchOptions, balances: Balances, vaults: Array<string>, breakdownFees?: boolean) {+/** + * Generate a fees adapter for curator vaults + * `@param` curatorConfig - Configuration specifying vaults and owners per chain + * `@returns` SimpleAdapter configured to track curator fees across Morpho and Euler vaults + * `@remarks` Handles vault share price rebases by clamping negative growth to zero + */ export function getCuratorExport(curatorConfig: CuratorConfig): SimpleAdapter {As per coding guidelines: "Include JSDoc comments for public functions in helper files"
Also applies to: 244-244, 336-336
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@helpers/curators/index.ts` around lines 22 - 40, The CuratorConfig interface and exported functions getEulerVaultFee and getCuratorExport are missing JSDoc; add JSDoc comments above each exported symbol (CuratorConfig, getEulerVaultFee, getCuratorExport) describing their purpose, parameters/types (e.g., explain vaults shape, start type, morpho/euler arrays), return values, and any important behavior such as rebase handling/assumptions or optional fields (breakdownFees, vault owner arrays). Ensure the comments include parameter descriptions and return type information and mention edge cases (e.g., how rebase is handled) so consumers and tooling (TS/IDE) get clear documentation.
403-403: 🧹 Nitpick | 🔵 TrivialUpdate the comment at line 403 to reflect the actual behavior after growthRate clamping.
The review comment correctly identifies that
growthRateis now clamped to0n(lines 218, 255, 303), which ensures all fee calculations from vault yields are non-negative. The original comment "we allow negative fees for vaults because vaults can make yields or make loss too" no longer accurately describes the behavior—losses now result in zero fees, not negative fees.Consider either:
- Removing the flag if curator-based adapters don't have independent negative fee sources
- Updating the comment to reflect the new clamping logic: "we allow negative fees from secondary revenue sources that dependent adapters may include (e.g., asset liquidation costs, rewards that exceed base yields)"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@helpers/curators/index.ts` at line 403, The comment on allowNegativeValue should be updated to reflect that growthRate is clamped to 0n (see growthRate clamp occurrences at lines where growthRate is set) so vault yields cannot produce negative fees; change the comment on the allowNegativeValue flag to either remove it if curator-based adapters truly have no other negative-fee sources, or revise it to explain that negative fees are only allowed for secondary/independent revenue sources (e.g., asset liquidation costs or reward accounting) and not from growthRate-derived vault yields which are clamped to zero.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@helpers/curators/index.ts`:
- Around line 22-40: The CuratorConfig interface and exported functions
getEulerVaultFee and getCuratorExport are missing JSDoc; add JSDoc comments
above each exported symbol (CuratorConfig, getEulerVaultFee, getCuratorExport)
describing their purpose, parameters/types (e.g., explain vaults shape, start
type, morpho/euler arrays), return values, and any important behavior such as
rebase handling/assumptions or optional fields (breakdownFees, vault owner
arrays). Ensure the comments include parameter descriptions and return type
information and mention edge cases (e.g., how rebase is handled) so consumers
and tooling (TS/IDE) get clear documentation.
- Line 403: The comment on allowNegativeValue should be updated to reflect that
growthRate is clamped to 0n (see growthRate clamp occurrences at lines where
growthRate is set) so vault yields cannot produce negative fees; change the
comment on the allowNegativeValue flag to either remove it if curator-based
adapters truly have no other negative-fee sources, or revise it to explain that
negative fees are only allowed for secondary/independent revenue sources (e.g.,
asset liquidation costs or reward accounting) and not from growthRate-derived
vault yields which are clamped to zero.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1e7a188b-bf85-40ba-ad60-7f68930581fd
📒 Files selected for processing (1)
helpers/curators/index.ts
|
Instead of setting growthRate to 0 when a share price rebase is detected, we could develop a function that queries more granular data for the vault and calculates the growthRate before the share price rebase and after, retaining the data quality in the affected bucket |
|
hi @SissonJ we want to track negative impact on vault. When the price shares were reduced, that incurred loss for depositors |
Summary
getMorphoVaultFee,getEulerVaultFee, andgetMorphoVaultV2Feewhere a vaultshare price rebase (i.e.
rateAfter < rateBefore) would cause false negative fee reportingrateAfter <= rateBefore, the growth rate is now set to0n— reporting zero fees ispreferable to reporting a false negative
Root cause
When a Morpho/Euler vault undergoes a share price rebase,
rateAftercan be less thanrateBefore.The original subtraction
rateAfter - rateBeforeresults in incorrect fee reports with an adjustment. Under normal vault operation, share price constantly goes up, so this case was left uncheckedTest plan
pnpm test fees gauntlet 2026-04-01and confirm no negative values