Skip to content

Feat/nexus-mutual fee & revenue#5047

Merged
treeoflife2 merged 7 commits intoDefiLlama:masterfrom
0x4r45h:feat/nexus-mutual-fee-revenue
Dec 19, 2025
Merged

Feat/nexus-mutual fee & revenue#5047
treeoflife2 merged 7 commits intoDefiLlama:masterfrom
0x4r45h:feat/nexus-mutual-fee-revenue

Conversation

@0x4r45h
Copy link
Contributor

@0x4r45h 0x4r45h commented Dec 12, 2025

closes #4816
This is an insurance protocol. Members who want to buy insurance pay premiums to the protocol (fees). If an incident happens, claims are paid out from these collected premiums. I'm not sure where to show payouts data.

At first, I thought to deduct claims from premiums and show the remaining amount as revenue. But this approach seems naive , and on some days revenue could become negative if claims are high.

@llamabutler
Copy link

The nexus-mutual.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees nexus-mutual.ts

🦙 Running NEXUS-MUTUAL.TS adapter 🦙
---------------------------------------------------
Start Date:	Thu, 11 Dec 2025 15:59:13 GMT
End Date:	Fri, 12 Dec 2025 15:59:13 GMT
---------------------------------------------------

------ ERROR ------
Error: Request failed with status code 401
    at _queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:219:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
Request failed with status code 401

Copy link
Member

@g1nt0ki g1nt0ki left a comment

Choose a reason for hiding this comment

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

hi @0x4r45h

  • Can you instead use on chain data
  • payouts can be treated as negative fees since we are treating the yield as fees
  • I think there is some confusion, capital pool is where LPs deposit funds? if so, we treat the premium sent to them as supply side revenue, revenue = what goes to the stakers & team, and holder revenue is what goes to the stakers, protocol revenue is what goes to the team

@llamabutler
Copy link

The nexus-mutual.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees nexus-mutual.ts

🦙 Running NEXUS-MUTUAL.TS adapter 🦙
---------------------------------------------------
Start Date:	Sun, 14 Dec 2025 16:34:06 GMT
End Date:	Mon, 15 Dec 2025 16:34:06 GMT
---------------------------------------------------

------ ERROR ------
Error: Request failed with status code 401
    at _queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:219:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
Request failed with status code 401

@0x4r45h
Copy link
Contributor Author

0x4r45h commented Dec 15, 2025

hi @0x4r45h

  • Can you instead use on chain data
  • payouts can be treated as negative fees since we are treating the yield as fees
  • I think there is some confusion, capital pool is where LPs deposit funds? if so, we treat the premium sent to them as supply side revenue, revenue = what goes to the stakers & team, and holder revenue is what goes to the stakers, protocol revenue is what goes to the team

Hey @g1nt0ki, thanks for your review.

  1. First I tried to use on-chain data, but the CoverBought event has a productId. To find the exact amount paid for that productId, a lot of joins and historical calculations are needed to get the amount at the time the tx was executed. That is why I switched to Dune queries.

  2. is it acceptable to have negative values in dailyFees and revenues on some days?

  3. This one is a bit tricky for me.

  • The capital pool is not a simple liquidity pool. it holds everything paid to the protocol, including cover fees and the assets paid to buy NXM.
  • The NXM token is backed by the capital pool – it can be minted and redeemed against this pool.
  • There are also staking pools, each of them sells covers for a variety of protocols. NXM holders can choose to stake on these pools to open cover capacity for new covers to be sold.

When someone buys a cover:
A. 50% of the paid fees goes to the capital pool.
B. The remaining 50% is minted as NXM and rewarded to stakers of the pool that sold the cover (not to be confused with the capital pool).

Now I can see this from two perspectives:

  • A = HoldersRevenue: it benefits all NXM holders because their token value goes up.
  • B = SupplySideRevenue: because those stakers made it possible for this cover to be sold (they are somehow like liquidity providers on a DEX).

OR

  • A = SupplySideRevenue: considering the capital pool as a liquidity pool, so everyone holding NXM is somehow providing liquidity for the protocol.
  • B = HoldersRevenue: although this is paid only to stakers of a specific pool, still count it towards Holders revenue.

Which one is better, or do you have any better suggestions?

@0x4r45h 0x4r45h marked this pull request as ready for review December 15, 2025 19:10
@0x4r45h 0x4r45h requested a review from g1nt0ki December 15, 2025 19:10
@g1nt0ki
Copy link
Member

g1nt0ki commented Dec 17, 2025

1, hmm, can you keep it as v1, this way, we run it only once a day
2. yes, need to set the flag: allowNegativeValue with a comment explaining why it can be negative
3. I would say, fee going to capital pool would be holder revenue (as it is used to buy NXM which is good for everyone), and the part that goes to the stakers as supply side revenue

@llamabutler
Copy link

The nexus-mutual.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees nexus-mutual.ts

🦙 Running NEXUS-MUTUAL.TS adapter 🦙
---------------------------------------------------
Start Date:	Tue, 16 Dec 2025 00:00:00 GMT
End Date:	Wed, 17 Dec 2025 00:00:00 GMT
---------------------------------------------------

------ ERROR ------
Error: Request failed with status code 401
    at _queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:219:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
Request failed with status code 401

@treeoflife2 treeoflife2 self-assigned this Dec 17, 2025
add COALESCE to handle nulls
remove unused selected columns
@llamabutler
Copy link

The nexus-mutual.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees nexus-mutual.ts

🦙 Running NEXUS-MUTUAL.TS adapter 🦙
---------------------------------------------------
Start Date:	Wed, 17 Dec 2025 00:00:00 GMT
End Date:	Thu, 18 Dec 2025 00:00:00 GMT
---------------------------------------------------

------ ERROR ------
Error: Request failed with status code 401
    at _queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:219:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
Request failed with status code 401

@0x4r45h 0x4r45h requested a review from treeoflife2 December 18, 2025 14:43
@treeoflife2 treeoflife2 merged commit 18a3f1d into DefiLlama:master Dec 19, 2025
1 of 2 checks passed
@llamabutler
Copy link

The nexus-mutual.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees nexus-mutual.ts

🦙 Running NEXUS-MUTUAL.TS adapter 🦙
---------------------------------------------------
Start Date:	Thu, 18 Dec 2025 00:00:00 GMT
End Date:	Fri, 19 Dec 2025 00:00:00 GMT
---------------------------------------------------

------ ERROR ------
Error: Request failed with status code 401
    at _queryDune (/home/runner/work/dimension-adapters/dimension-adapters/helpers/dune.ts:219:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
Request failed with status code 401

RohanNero pushed a commit to RohanNero/dimension-adapters that referenced this pull request Mar 13, 2026
* nexus-mutual fee and revenue

* fix indents

* add paid claims to nexus-mutual

* optimize the query

* change adapter to v1

* combine queries into a single one
add COALESCE to handle nulls
remove unused selected columns

* refactor

---------

Co-authored-by: treeoflife2 <[email protected]>
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.

Track Nexus Mutual Fee/Revenue

4 participants