Skip to content

feat(napier): fix LP APY split and add volume enrichment#2445

Merged
0xkr3p merged 1 commit intoDefiLlama:masterfrom
napierfi:feat/napier-apy-volume-fix
Mar 25, 2026
Merged

feat(napier): fix LP APY split and add volume enrichment#2445
0xkr3p merged 1 commit intoDefiLlama:masterfrom
napierfi:feat/napier-apy-volume-fix

Conversation

@amrrobb
Copy link
Copy Markdown
Contributor

@amrrobb amrrobb commented Mar 4, 2026

Summary

Linear: NAP-2375 — DefiLlama Dashboard Enhancement

  • Fix LP apyBase: Use poolApy - poolTargetRewardsApy instead of poolBaseApy (swap fees only → full LP APY including rehypothecation yield)
  • Fix LP apyReward: Use poolTargetRewardsApy (pool-weighted) instead of underlyingRewardsApy (unweighted)
  • Fix LP rewardTokens: Use poolTargetRewards (pool-weighted reward tokens for LP) instead of underlyingRewards
  • Add volumeUsd1d: Enrichment field from napier-api pre-computed daily volume

Context

poolApy is the canonical total LP APY from napier-api, composed of:
poolBaseApy + poolPtImpliedApy + poolTargetUnderlyingApy + poolTargetRewardsApy + rehypo APYs

The previous adapter used poolBaseApy for apyBase (swap fees only) and underlyingRewardsApy for apyReward (full underlying, not pool-weighted). This misreported LP yields — apyBase was too low and apyReward was unweighted by pool share.

After contract modification, rehypothecation yield is now reflected in poolApy and correctly categorized as part of LP returns, increasing the reported fee/yield statistics captured by Napier Protocol.

PT entry remains unchanged — underlyingRewardsApy and underlyingRewards are correct for PT.

Test plan

  • Tested against staging API with Ethereum + Arbitrum markets
  • Verified 130+ pools returned with correct APY values and volume data
  • All values pass keepFinite filter

- Fix LP apyBase: use poolApy - poolTargetRewardsApy (was poolBaseApy, swap fees only)
- Fix LP apyReward: use poolTargetRewardsApy (pool-weighted, was unweighted underlyingRewardsApy)
- Fix LP rewardTokens: use poolTargetRewards (pool-weighted) instead of underlyingRewards
- Add volumeUsd1d to LP entries from napier-api volumeInUsd
- PT entry unchanged (underlyingRewardsApy and underlyingRewards remain correct for PT)
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Modified LP APY calculation in the Napier adaptor to compute apyBase as poolApy minus poolTargetRewardsApy, set apyReward to poolTargetRewardsApy, source rewardTokens from poolTargetRewards instead of underlyingRewards, and add volumeUsd1d metric to the LP APY object.

Changes

Cohort / File(s) Summary
Napier LP APY Calculation
src/adaptors/napier/index.js
Modified LP APY computation: apyBase now calculated as poolApy minus poolTargetRewardsApy, apyReward set to poolTargetRewardsApy (both defaulting to 0 if missing), rewardTokens sourced from poolTargetRewards instead of underlyingRewards, and volumeUsd1d metric added to LP APY object. PT APY structure unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 With whiskers twitching, calculations bright,
APY metrics hop into the light,
Pool rewards now weighted just right,
Volume tallied, data takes flight! 🌙✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(napier): fix LP APY split and add volume enrichment' accurately describes the main changes: fixing LP APY calculations and adding volume data enrichment.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@amrrobb amrrobb changed the title Fix Napier LP APY split and add volume feat(napier): fix LP APY split and add volume enrichment Mar 5, 2026
@amrrobb amrrobb marked this pull request as draft March 5, 2026 07:12
@amrrobb
Copy link
Copy Markdown
Contributor Author

amrrobb commented Mar 5, 2026

Linear: NAP-2375 — DefiLlama Dashboard Enhancement

Related PRs:

This PR: Fixes LP APY calculation to use poolApy which includes rehypothecation yield. This is where rehypo yield is properly reflected — in LP APY, not in the fees adapter. See NAP-2375 comment for the reasoning on why rehypo should not be categorized as fees.

Also adds volumeUsd1d enrichment field for LP entries.

Draft until all adapters are ready to go live together.

@amrrobb amrrobb marked this pull request as ready for review March 19, 2026 07:13
@0xkr3p
Copy link
Copy Markdown
Contributor

0xkr3p commented Mar 24, 2026

Hi @amrrobb,

Thanks for the PR, I tested the PR, the TVL / APY values are extremely low inconsistent, some even negative. Are you able to check this please?

Here are the test results:

Nb of pools: 16
 

Sample pools: [
  {
    pool: '0xe556af29d16ae64011906b580303d92bebed06fd-hyperliquid',
    chain: 'Hyperliquid L1',
    project: 'napier',
    symbol: 'WPUSDT',
    tvlUsd: 47.697039448628345,
    apyBase: -36.57634753455756,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0x2fc5b62a4e0c2491cdc83cfea5c8fa82462dca7b',
      '0xd8d54b633877986f33971540ccd2b385d0e0e93f'
    ],
    volumeUsd1d: 0,
    poolMeta: 'LP Pool | Maturity Sun May 10 2026',
    url: 'https://app.napier.finance/user/pool/999/0x2fc5b62a4e0c2491cdc83cfea5c8fa82462dca7b/zap/add'
  },
  {
    pool: '0x2fc5b62a4e0c2491cdc83cfea5c8fa82462dca7b-hyperliquid',
    chain: 'Hyperliquid L1',
    project: 'napier',
    symbol: 'WPUSDT',
    tvlUsd: 24.676916617687013,
    apyBase: -73.1869550177765,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0xd8d54b633877986f33971540ccd2b385d0e0e93f' ],
    poolMeta: 'Principal Token | Maturity Sun May 10 2026',
    url: 'https://app.napier.finance/user/mint/999/0x2fc5b62a4e0c2491cdc83cfea5c8fa82462dca7b/mint'
  },
  {
    pool: '0xa9b276a2f69aee6bb4daad366c5d05633d386204-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'SUSDE',
    tvlUsd: 1.1783832239142285,
    apyBase: 4.375750233804493,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0xd7361c1832c53ce0c8c05b2733f86e3317120eb3',
      '0x9d39a5de30e57443bff2a8307a4256c8797a3497'
    ],
    volumeUsd1d: 0.0013463029557250156,
    poolMeta: 'LP Pool | Maturity Sat Mar 20 2027',
    url: 'https://app.napier.finance/user/pool/1/0xd7361c1832c53ce0c8c05b2733f86e3317120eb3/zap/add'
  },
  {
    pool: '0xd7361c1832c53ce0c8c05b2733f86e3317120eb3-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'SUSDE',
    tvlUsd: 0.18017946320569975,
    apyBase: 9.783328309911377,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0x9d39a5de30e57443bff2a8307a4256c8797a3497' ],
    poolMeta: 'Principal Token | Maturity Sat Mar 20 2027',
    url: 'https://app.napier.finance/user/mint/1/0xd7361c1832c53ce0c8c05b2733f86e3317120eb3/mint'
  },
  {
    pool: '0xcb01432b5c44b4729dcd1f839966706402f2c3c3-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'WSTUSR',
    tvlUsd: 0.11179755054368884,
    apyBase: 2.3305234830658876,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0x3b6a510e2cd4dd270cee007c4942fe969817992c',
      '0x1202f5c7b4b9e47a1a484e8b270be34dbbc75055'
    ],
    volumeUsd1d: 0,
    poolMeta: 'LP Pool | Maturity Sat Mar 20 2027',
    url: 'https://app.napier.finance/user/pool/1/0x3b6a510e2cd4dd270cee007c4942fe969817992c/zap/add'
  },
  {
    pool: '0x3b6a510e2cd4dd270cee007c4942fe969817992c-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'WSTUSR',
    tvlUsd: 0.01666234478533374,
    apyBase: 9.999999999999998,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0x1202f5c7b4b9e47a1a484e8b270be34dbbc75055' ],
    poolMeta: 'Principal Token | Maturity Sat Mar 20 2027',
    url: 'https://app.napier.finance/user/mint/1/0x3b6a510e2cd4dd270cee007c4942fe969817992c/mint'
  },
  {
    pool: '0x5bb084cf0d4eaae76ba1fba71dcda7db2c968395-arbitrum',
    chain: 'Arbitrum',
    project: 'napier',
    symbol: 'YOG-USDC',
    tvlUsd: 0,
    apyBase: 0,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0xd115b9dcfa9b702254f5512b691e6571cc713f6a',
      '0x87deae530841a9671326c9d5b9f91bdb11f3162c'
    ],
    volumeUsd1d: 0,
    poolMeta: 'LP Pool | Maturity Fri Nov 13 2026',
    url: 'https://app.napier.finance/user/pool/42161/0xd115b9dcfa9b702254f5512b691e6571cc713f6a/zap/add'
  },
  {
    pool: '0xd115b9dcfa9b702254f5512b691e6571cc713f6a-arbitrum',
    chain: 'Arbitrum',
    project: 'napier',
    symbol: 'YOG-USDC',
    tvlUsd: 0,
    apyBase: 0,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0x87deae530841a9671326c9d5b9f91bdb11f3162c' ],
    poolMeta: 'Principal Token | Maturity Fri Nov 13 2026',
    url: 'https://app.napier.finance/user/mint/42161/0xd115b9dcfa9b702254f5512b691e6571cc713f6a/mint'
  },
  {
    pool: '0x47377d8f5ee83835fd6747f7071cc39dc8ea8a83-arbitrum',
    chain: 'Arbitrum',
    project: 'napier',
    symbol: 'FUSDC',
    tvlUsd: 0,
    apyBase: -100,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0xd14018ca65f6f3043c42641f5301cbeada34ab60',
      '0x1a996cb54bb95462040408c06122d45d6cdb6096'
    ],
    volumeUsd1d: 0,
    poolMeta: 'LP Pool | Maturity Wed Jun 17 2026',
    url: 'https://app.napier.finance/user/pool/42161/0xd14018ca65f6f3043c42641f5301cbeada34ab60/zap/add'
  },
  {
    pool: '0xd14018ca65f6f3043c42641f5301cbeada34ab60-arbitrum',
    chain: 'Arbitrum',
    project: 'napier',
    symbol: 'FUSDC',
    tvlUsd: 0,
    apyBase: 0,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0x1a996cb54bb95462040408c06122d45d6cdb6096' ],
    poolMeta: 'Principal Token | Maturity Wed Jun 17 2026',
    url: 'https://app.napier.finance/user/mint/42161/0xd14018ca65f6f3043c42641f5301cbeada34ab60/mint'
  }
]
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@amrrobb
Copy link
Copy Markdown
Contributor Author

amrrobb commented Mar 25, 2026

Thanks for testing @0xkr3p! Fixed both issues:

  1. Negative APYs — Clamped apyBase to Math.max(0, ...) for both LP and PT pools. The negatives were coming from low-liquidity pools where the pool pricing was unfavorable.

  2. $0 TVL / test markets — Added a filter to exclude markets with zero TVL (totalTvlInUsdFmt > 0). This removes the empty Arbitrum test markets.

Updated test output:

Pools: 6
  Hyperliquid L1 | WPUSDT  | tvl: $47.68   | apyBase: 0.00%  | LP Pool
  Hyperliquid L1 | WPUSDT  | tvl: $24.67   | apyBase: 0.00%  | Principal Token
  Ethereum       | SUSDE   | tvl: $1.18    | apyBase: 4.38%  | LP Pool
  Ethereum       | SUSDE   | tvl: $0.18    | apyBase: 9.78%  | Principal Token
  Ethereum       | WSTUSR  | tvl: $0.11    | apyBase: 2.28%  | LP Pool
  Ethereum       | WSTUSR  | tvl: $0.02    | apyBase: 10.00% | Principal Token

Negative APYs: 0
$0 TVL pools: 0

Note: TVL is still low (< $10k threshold) on these pools as they're newly deployed. TVL will increase as liquidity is added.

@0xkr3p 0xkr3p merged commit 40fdef5 into DefiLlama:master Mar 25, 2026
2 checks passed
@amrrobb
Copy link
Copy Markdown
Contributor Author

amrrobb commented Mar 30, 2026

@0xkr3p Quick question — the adapter is merged but the "Yields" tab isn't showing on our protocol page (https://defillama.com/protocol/napier). We noticed all our pools are currently below the $10k TVL threshold.

Will the Yields tab appear automatically once at least one pool crosses $10k, or is there something else needed on our end?

Thanks!

@amrrobb
Copy link
Copy Markdown
Contributor Author

amrrobb commented Mar 30, 2026

@0xkr3p Following up — we checked and we do have markets above the $10k TVL threshold. For example, our "cp0x LRT Conservative Vault" on Ethereum has ~$146k TVL.

However, Napier still returns empty from the yields API (https://yields.llama.fi/pools) and the "Yields" tab doesn't appear on https://defillama.com/protocol/napier.

Could you help check if there's an issue with the adapter not picking up these markets, or if something else is preventing them from showing?

Thanks!

@0xkr3p
Copy link
Copy Markdown
Contributor

0xkr3p commented Mar 31, 2026

@0xkr3p Following up — we checked and we do have markets above the $10k TVL threshold. For example, our "cp0x LRT Conservative Vault" on Ethereum has ~$146k TVL.

However, Napier still returns empty from the yields API (https://yields.llama.fi/pools) and the "Yields" tab doesn't appear on https://defillama.com/protocol/napier.

Could you help check if there's an issue with the adapter not picking up these markets, or if something else is preventing them from showing?

Thanks!

Hey @amrrobb, will take a look later today, thanks for raising

@0xkr3p
Copy link
Copy Markdown
Contributor

0xkr3p commented Mar 31, 2026

hey @amrrobb, the test results for the napier adapter still show a maximum of $48 TVL, this why no pools are being displayed

Sample pools: [
  {
    pool: '0xe556af29d16ae64011906b580303d92bebed06fd-hyperliquid',
    chain: 'Hyperliquid L1',
    project: 'napier',
    symbol: 'WPUSDT',
    tvlUsd: 48.17537139649564,
    apyBase: -40.203684663951734,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0x2fc5b62a4e0c2491cdc83cfea5c8fa82462dca7b',
      '0xd8d54b633877986f33971540ccd2b385d0e0e93f'
    ],
    volumeUsd1d: 0,
    poolMeta: 'LP Pool | Maturity Sun May 10 2026',
    url: 'https://app.napier.finance/user/pool/999/0x2fc5b62a4e0c2491cdc83cfea5c8fa82462dca7b/zap/add'
  },
  {
    pool: '0x2fc5b62a4e0c2491cdc83cfea5c8fa82462dca7b-hyperliquid',
    chain: 'Hyperliquid L1',
    project: 'napier',
    symbol: 'WPUSDT',
    tvlUsd: 24.92439020786256,
    apyBase: -80.4495428396209,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0xd8d54b633877986f33971540ccd2b385d0e0e93f' ],
    poolMeta: 'Principal Token | Maturity Sun May 10 2026',
    url: 'https://app.napier.finance/user/mint/999/0x2fc5b62a4e0c2491cdc83cfea5c8fa82462dca7b/mint'
  },
  {
    pool: '0x3ac81d432b5c5a16aefdbfa34b2507e99170548f-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'WSTETH',
    tvlUsd: 3.1725289827354475,
    apyBase: 3.427970607642646,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0xdd093572dbb381df081b475b31e6b20c0cbd3109',
      '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0'
    ],
    volumeUsd1d: 0,
    poolMeta: 'LP Pool | Maturity Sat Mar 27 2027',
    url: 'https://app.napier.finance/user/pool/1/0xdd093572dbb381df081b475b31e6b20c0cbd3109/zap/add'
  },
  {
    pool: '0xdd093572dbb381df081b475b31e6b20c0cbd3109-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'WSTETH',
    tvlUsd: 2.310652719545755,
    apyBase: 9.55699968214057,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0' ],
    poolMeta: 'Principal Token | Maturity Sat Mar 27 2027',
    url: 'https://app.napier.finance/user/mint/1/0xdd093572dbb381df081b475b31e6b20c0cbd3109/mint'
  },
  {
    pool: '0x2ad67705337e2ff40063876479be86a22c917b7a-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'WSTUSR',
    tvlUsd: 0.7860274233443765,
    apyBase: 4.029651525460223,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0x1202f5c7b4b9e47a1a484e8b270be34dbbc75055' ],
    poolMeta: 'Principal Token | Maturity Wed Mar 31 2027',
    url: 'https://app.napier.finance/user/mint/1/0x2ad67705337e2ff40063876479be86a22c917b7a/mint'
  },
  {
    pool: '0x2a2587b1e17e9217d66b13d40361426d22e1f674-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'APYUSD',
    tvlUsd: 0.013284498216015543,
    apyBase: 8.492768726922078,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0x624baa90470e54cdbfd4b7237bf0e9862abd8a36',
      '0x38eeb52f0771140d10c4e9a9a72349a329fe8a6a'
    ],
    volumeUsd1d: 0,
    poolMeta: 'LP Pool | Maturity Sat Mar 27 2027',
    url: 'https://app.napier.finance/user/pool/1/0x624baa90470e54cdbfd4b7237bf0e9862abd8a36/zap/add'
  },
  {
    pool: '0x54cda6acee7c66d603aa3962916f505622957b1c-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'WSTUSR',
    tvlUsd: 0.01089553147542694,
    apyBase: 0.4556876358740553,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0x2ad67705337e2ff40063876479be86a22c917b7a',
      '0x1202f5c7b4b9e47a1a484e8b270be34dbbc75055'
    ],
    volumeUsd1d: 0,
    poolMeta: 'LP Pool | Maturity Wed Mar 31 2027',
    url: 'https://app.napier.finance/user/pool/1/0x2ad67705337e2ff40063876479be86a22c917b7a/zap/add'
  },
  {
    pool: '0x624baa90470e54cdbfd4b7237bf0e9862abd8a36-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'APYUSD',
    tvlUsd: 0.0019801566162916313,
    apyBase: 9.99999999999998,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0x38eeb52f0771140d10c4e9a9a72349a329fe8a6a' ],
    poolMeta: 'Principal Token | Maturity Sat Mar 27 2027',
    url: 'https://app.napier.finance/user/mint/1/0x624baa90470e54cdbfd4b7237bf0e9862abd8a36/mint'
  },
  {
    pool: '0x3b2e094de40a9ce85b39ff7769442e73bca60ca0-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'APXUSD',
    tvlUsd: 0.000996792482417978,
    apyBase: 35.231961968128196,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [
      '0xfe9642faeaca42f823a7c024afa0ea91e26d9459',
      '0x98a878b1cd98131b271883b390f68d2c90674665'
    ],
    volumeUsd1d: 0.00000830576119401,
    poolMeta: 'LP Pool | Maturity Sat Mar 27 2027',
    url: 'https://app.napier.finance/user/pool/1/0xfe9642faeaca42f823a7c024afa0ea91e26d9459/zap/add'
  },
  {
    pool: '0xfe9642faeaca42f823a7c024afa0ea91e26d9459-ethereum',
    chain: 'Ethereum',
    project: 'napier',
    symbol: 'APXUSD',
    tvlUsd: 0.00014848332433248414,
    apyBase: 8.322907589672674,
    apyReward: 0,
    rewardTokens: [],
    underlyingTokens: [ '0x98a878b1cd98131b271883b390f68d2c90674665' ],
    poolMeta: 'Principal Token | Maturity Sat Mar 27 2027',
    url: 'https://app.napier.finance/user/mint/1/0xfe9642faeaca42f823a7c024afa0ea91e26d9459/mint'
  }
]
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

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