Skip to content

[fix] CallPut - correct fees and revenue accounting - #8771

Draft
ayggdrasil wants to merge 1 commit into
DefiLlama:masterfrom
ayggdrasil:codex/fix-callput-fees-revenue
Draft

[fix] CallPut - correct fees and revenue accounting#8771
ayggdrasil wants to merge 1 commit into
DefiLlama:masterfrom
ayggdrasil:codex/fix-callput-fees-revenue

Conversation

@ayggdrasil

Copy link
Copy Markdown

Summary

  • Define Fees as options Trade Fee + Risk Premium.
  • Define Revenue and Protocol Revenue as Trade Fee only.
  • Attribute Risk Premium to Supply-side Revenue for OLP liquidity providers.
  • Remove liquidity/swap fees, rebate reclassification, and FeeDistributor allocation from this adapter because they are outside CallPut's confirmed Fees/Revenue definitions.

Why

The current adapter reports identical Fees and Revenue and does not include Risk Premium. In the original CallPut submission (#8667), Risk Premium handling was removed in commit 13439bee because it was treated as option premium. The contracts record it separately from option premium:

  • CollectPositionFees.feeUsd is the Trade Fee.
  • NotifyPendingAmount.pendingUsd with priceType = 1 (RP) is the Risk Premium.
  • priceType = 0 (MP) is ignored.

The adapter now reads each vault's vaultUtils address, filters the RP events, and applies:

Fees              = Trade Fee + Risk Premium
Revenue           = Trade Fee
Protocol Revenue  = Trade Fee
Supply-side       = Risk Premium

This preserves the accounting invariant Fees = Revenue + Supply-side Revenue.

Period totals and backfill request

The matching 7d and 30d figures were caused by missing historical indexed days after the adapter first went live, rather than by the event timestamp boundaries. Historical onchain checks found positive activity beyond both the 24h and 7d windows.

Please backfill CallPut from the adapter start date, 2026-01-30, after this change is merged. Once backfilled, 24h, 7d, and 30d will aggregate their actual distinct date ranges.

Validation

  • npm run ts-check -- --pretty false
  • Unit test verifies Trade Fee/RP classification and the accounting invariant.
  • Official adapter harness and direct daily checks on Base:
UTC day Trade Fee Risk Premium Expected Fees Expected Revenue
2026-08-13 $205.4296 $84.8026 $290.2322 $205.4296
2026-08-12 $276.8254 $66.8100 $343.6354 $276.8254
2026-08-07 $497 $247 $744 $497
2026-07-30 $217 $76 $293 $217

Previous PR: #8667

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 93d1836f-ca16-4444-8ecc-d885b94f2235

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

The callput adapter exports:

====== TOTAL DAILY AGGREGATED (sum of slots per chain) ======

BASE 👇
End timestamp: 1786708799 (2026-08-14T11:59:59.000Z)
Daily fees: 268.68
Daily revenue: 229.83
Daily protocol revenue: 229.83
Daily supply side revenue: 40.36




FEES BREAKDOWN 👇

label                          | Daily fees         | Daily supply side revenue | Daily revenue     
---                            | ---                | ---                       | ---               
Options Trade Fees             | 229.82770000000002 |                           |                   
Risk Premium                   | 40.3595            |                           |                   
Risk Premium To OLPs           |                    | 40.3595                   |                   
Options Trade Fees To Protocol |                    |                           | 229.82770000000002

@bheluga bheluga self-assigned this Aug 15, 2026

@bheluga bheluga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayggdrasil thanks for the PR
The reason we are against considering premium as fees is that, LP's take risk selling the options.
And you count only premiums earned by them and not their losses, leading to inflated fees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants