Skip to content

Update Lagoon vaults Incentives computation#2625

Open
GuiDupont wants to merge 10 commits into
DefiLlama:masterfrom
hopperlabsxyz:master
Open

Update Lagoon vaults Incentives computation#2625
GuiDupont wants to merge 10 commits into
DefiLlama:masterfrom
hopperlabsxyz:master

Conversation

@GuiDupont
Copy link
Copy Markdown
Contributor

@GuiDupont GuiDupont commented Apr 24, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Refined APY calculations with improved separation between base APY and reward components
    • Enhanced tracking of incentive and airdrop rewards for more accurate pool performance metrics

p22z and others added 3 commits February 27, 2026 15:36
Sum incentives[].apr + airdrops[].apr directly instead of deriving
apyReward from (linearNetApr - linearNetAprWithoutExtraYields), which
also includes native yield. DefiLlama's apyReward should represent
reward incentives only, not yield intrinsic to the underlying asset.
…eld-from-reward

fix(lagoon): split apyBase/apyReward and exclude native yield
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 524d4bf8-c306-4841-8332-708dadc22543

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
📝 Walkthrough

Walkthrough

The Lagoon adapter's GraphQL query now extracts additional APR data for incentives and airdrops. The mapping logic reassigns apyBase to linearNetAprWithoutExtraYields and introduces a new apyReward field calculated as the combined APR from both incentive and airdrop sources.

Changes

Cohort / File(s) Summary
Lagoon Adapter APY Calculation
src/adaptors/lagoon/index.js
Modified GraphQL query to fetch incentive and airdrop APR components. Reassigned apyBase to linearNetAprWithoutExtraYields and added apyReward calculation as the sum of incentive and airdrop APRs with null-coalescing for missing values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hopping through yields with careful intent,
We gather the rewards that come and are sent—
Incentives and airdrops, both counted with care,
Sweet APRs combined in the Lagoon's fair air! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update Lagoon vaults Incentives computation' accurately describes the main change: updating how incentive APR components are retrieved and computed for Lagoon vaults in the GraphQL query and pool mapping.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions
Copy link
Copy Markdown

Error while running lagoon adapter:

Test Suites: 1 failed, 1 total
Tests: 33 failed, 361 passed, 394 total
Snapshots: 0 total
Time: 0.474 s
Ran all test suites.

Nb of pools: 65
 

Sample pools:
┌─────────┬──────────────────────────────────────────────────────────────┬────────────┬──────────┬──────────────────┬──────────────────────┬───────────┬────────────────────┬──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────┐
│ (index) │ pool                                                         │ chain      │ project  │ symbol           │ apyBase              │ apyReward │ tvlUsd             │ underlyingTokens                                 │ url                                                                             │
├─────────┼──────────────────────────────────────────────────────────────┼────────────┼──────────┼──────────────────┼──────────────────────┼───────────┼────────────────────┼──────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
│ 0       │ 'lagoon-0x936facdf10c8c36294e7b9d28345255539d81bc7-ethereum' │ 'ethereum' │ 'lagoon' │ 'rock.rETH'      │ -0.42537360109200417 │ null      │ 23033280.191840246 │ [ '0xae78736cd615f374d3085123a210448e74fc6393' ] │ 'https://app.lagoon.finance/vault/1/0x936facdf10c8c36294e7b9d28345255539d81bc7' │
│ 1       │ 'lagoon-0xb09f761cb13baca8ec087ac476647361b6314f98-ethereum' │ 'ethereum' │ 'lagoon' │ 'T9cbBTC'        │ 2.591694966238953    │ null      │ 13766928.51580365  │ [ '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf' ] │ 'https://app.lagoon.finance/vault/1/0xb09f761cb13baca8ec087ac476647361b6314f98' │
│ 2       │ 'lagoon-0xd548f6ed03e718843124ed29ffd0ed9ae81e6dc5-ethereum' │ 'ethereum' │ 'lagoon' │ 'tHEMIBTC'       │ null                 │ null      │ 8592046.176436739  │ [ '0x06ea695b91700071b161a434fed42d1dcbad9f00' ] │ 'https://app.lagoon.finance/vault/1/0xd548f6ed03e718843124ed29ffd0ed9ae81e6dc5' │
│ 3       │ 'lagoon-0xce0b790ae0d8cf91e01f3fb69025e14569b574f3-ethereum' │ 'ethereum' │ 'lagoon' │ 'tulipaUSDC'     │ 7.496581823539153    │ null      │ 7698517.369498979  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0xce0b790ae0d8cf91e01f3fb69025e14569b574f3' │
│ 4       │ 'lagoon-0x7a12d4b719f5aa479ecd60defed909fb2a37e428-ethereum' │ 'ethereum' │ 'lagoon' │ 'rock.loopedETH' │ -0.7147264749154681  │ null      │ 6139263.415925077  │ [ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ] │ 'https://app.lagoon.finance/vault/1/0x7a12d4b719f5aa479ecd60defed909fb2a37e428' │
│ 5       │ 'lagoon-0x07ed467acd4ffd13023046968b0859781cb90d9b-ethereum' │ 'ethereum' │ 'lagoon' │ '9SETH'          │ null                 │ null      │ 6084813.397644397  │ [ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ] │ 'https://app.lagoon.finance/vault/1/0x07ed467acd4ffd13023046968b0859781cb90d9b' │
│ 6       │ 'lagoon-0x2a676c2744421b4fae65ce86b47adacb620047d4-ethereum' │ 'ethereum' │ 'lagoon' │ 'ghemiBTC'       │ 1.0624342670150557   │ null      │ 3961870.710705514  │ [ '0x06ea695b91700071b161a434fed42d1dcbad9f00' ] │ 'https://app.lagoon.finance/vault/1/0x2a676c2744421b4fae65ce86b47adacb620047d4' │
│ 7       │ 'lagoon-0x03d1ec0d01b659b89a87eabb56e4af5cb6e14bfc-ethereum' │ 'ethereum' │ 'lagoon' │ '9SUSDC'         │ 2.2999716885599595   │ null      │ 3753147.5400233925 │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0x03d1ec0d01b659b89a87eabb56e4af5cb6e14bfc' │
│ 8       │ 'lagoon-0x3c63f3ce75dc83735745cf4e86b63414d95ee355-ethereum' │ 'ethereum' │ 'lagoon' │ 'DAMMeth'        │ null                 │ null      │ 3433625.5267844624 │ [ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ] │ 'https://app.lagoon.finance/vault/1/0x3c63f3ce75dc83735745cf4e86b63414d95ee355' │
│ 9       │ 'lagoon-0xdae854d0896ad2fee335689a3f7b4a95fd1a3e46-ethereum' │ 'ethereum' │ 'lagoon' │ 'gamiUSDC'       │ 3.7091036744879093   │ null      │ 2691283.70112338   │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0xdae854d0896ad2fee335689a3f7b4a95fd1a3e46' │
└─────────┴──────────────────────────────────────────────────────────────┴────────────┴──────────┴──────────────────┴──────────────────────┴───────────┴────────────────────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/adaptors/lagoon/index.js`:
- Around line 74-81: Guard against null/missing lists from vault.state.weeklyApr
by making sumApr tolerant of null: change the helper sumApr so it accepts a
possibly-null input (e.g., const sumApr = (items = []) => items.reduce(...)) or
explicitly default incentives/airdrops to [] when calling sumApr; keep the
existing apyReward logic (sumApr(incentives) + sumApr(airdrops) || null) so a
zero total still yields null. Update the symbols: sumApr, incentives, airdrops,
apyReward, and vault.state.weeklyApr accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7597a5a2-a27a-49e5-b8d9-4646edd87629

📥 Commits

Reviewing files that changed from the base of the PR and between 635c06a and 00935e8.

📒 Files selected for processing (1)
  • src/adaptors/lagoon/index.js

Comment thread src/adaptors/lagoon/index.js Outdated
@GuiDupont GuiDupont closed this Apr 24, 2026
@GuiDupont GuiDupont reopened this Apr 24, 2026
@github-actions
Copy link
Copy Markdown

Error while running lagoon adapter:

Test Suites: 1 failed, 1 total
Tests: 33 failed, 361 passed, 394 total
Snapshots: 0 total
Time: 0.461 s
Ran all test suites.

Nb of pools: 65
 

Sample pools:
┌─────────┬──────────────────────────────────────────────────────────────┬────────────┬──────────┬──────────────────┬──────────────────────┬───────────┬────────────────────┬──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────┐
│ (index) │ pool                                                         │ chain      │ project  │ symbol           │ apyBase              │ apyReward │ tvlUsd             │ underlyingTokens                                 │ url                                                                             │
├─────────┼──────────────────────────────────────────────────────────────┼────────────┼──────────┼──────────────────┼──────────────────────┼───────────┼────────────────────┼──────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
│ 0       │ 'lagoon-0x936facdf10c8c36294e7b9d28345255539d81bc7-ethereum' │ 'ethereum' │ 'lagoon' │ 'rock.rETH'      │ -0.42537360109200417 │ null      │ 23033280.191840246 │ [ '0xae78736cd615f374d3085123a210448e74fc6393' ] │ 'https://app.lagoon.finance/vault/1/0x936facdf10c8c36294e7b9d28345255539d81bc7' │
│ 1       │ 'lagoon-0xb09f761cb13baca8ec087ac476647361b6314f98-ethereum' │ 'ethereum' │ 'lagoon' │ 'T9cbBTC'        │ 2.591694966238953    │ null      │ 13766928.51580365  │ [ '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf' ] │ 'https://app.lagoon.finance/vault/1/0xb09f761cb13baca8ec087ac476647361b6314f98' │
│ 2       │ 'lagoon-0xd548f6ed03e718843124ed29ffd0ed9ae81e6dc5-ethereum' │ 'ethereum' │ 'lagoon' │ 'tHEMIBTC'       │ null                 │ null      │ 8592046.176436739  │ [ '0x06ea695b91700071b161a434fed42d1dcbad9f00' ] │ 'https://app.lagoon.finance/vault/1/0xd548f6ed03e718843124ed29ffd0ed9ae81e6dc5' │
│ 3       │ 'lagoon-0xce0b790ae0d8cf91e01f3fb69025e14569b574f3-ethereum' │ 'ethereum' │ 'lagoon' │ 'tulipaUSDC'     │ 7.496581823539153    │ null      │ 7698517.369498979  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0xce0b790ae0d8cf91e01f3fb69025e14569b574f3' │
│ 4       │ 'lagoon-0x7a12d4b719f5aa479ecd60defed909fb2a37e428-ethereum' │ 'ethereum' │ 'lagoon' │ 'rock.loopedETH' │ -0.7147264749154681  │ null      │ 6139263.415925077  │ [ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ] │ 'https://app.lagoon.finance/vault/1/0x7a12d4b719f5aa479ecd60defed909fb2a37e428' │
│ 5       │ 'lagoon-0x07ed467acd4ffd13023046968b0859781cb90d9b-ethereum' │ 'ethereum' │ 'lagoon' │ '9SETH'          │ null                 │ null      │ 6084813.397644397  │ [ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ] │ 'https://app.lagoon.finance/vault/1/0x07ed467acd4ffd13023046968b0859781cb90d9b' │
│ 6       │ 'lagoon-0x2a676c2744421b4fae65ce86b47adacb620047d4-ethereum' │ 'ethereum' │ 'lagoon' │ 'ghemiBTC'       │ 1.0624342670150557   │ null      │ 3961870.710705514  │ [ '0x06ea695b91700071b161a434fed42d1dcbad9f00' ] │ 'https://app.lagoon.finance/vault/1/0x2a676c2744421b4fae65ce86b47adacb620047d4' │
│ 7       │ 'lagoon-0x03d1ec0d01b659b89a87eabb56e4af5cb6e14bfc-ethereum' │ 'ethereum' │ 'lagoon' │ '9SUSDC'         │ 2.2999716885599595   │ null      │ 3753147.5400233925 │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0x03d1ec0d01b659b89a87eabb56e4af5cb6e14bfc' │
│ 8       │ 'lagoon-0x3c63f3ce75dc83735745cf4e86b63414d95ee355-ethereum' │ 'ethereum' │ 'lagoon' │ 'DAMMeth'        │ null                 │ null      │ 3433625.5267844624 │ [ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ] │ 'https://app.lagoon.finance/vault/1/0x3c63f3ce75dc83735745cf4e86b63414d95ee355' │
│ 9       │ 'lagoon-0xdae854d0896ad2fee335689a3f7b4a95fd1a3e46-ethereum' │ 'ethereum' │ 'lagoon' │ 'gamiUSDC'       │ 3.7091036744879093   │ null      │ 2691283.70112338   │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0xdae854d0896ad2fee335689a3f7b4a95fd1a3e46' │
└─────────┴──────────────────────────────────────────────────────────────┴────────────┴──────────┴──────────────────┴──────────────────────┴───────────┴────────────────────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@GuiDupont GuiDupont closed this Apr 24, 2026
@GuiDupont GuiDupont reopened this Apr 24, 2026
@github-actions
Copy link
Copy Markdown

The lagoon adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 196 passed, 196 total
Snapshots: 0 total
Time: 0.343 s
Ran all test suites.

Nb of pools: 32
 

Sample pools:
┌─────────┬──────────────────────────────────────────────────────────────┬────────────┬──────────┬──────────────────┬──────────────────────┬───────────┬────────────────────┬──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────┐
│ (index) │ pool                                                         │ chain      │ project  │ symbol           │ apyBase              │ apyReward │ tvlUsd             │ underlyingTokens                                 │ url                                                                             │
├─────────┼──────────────────────────────────────────────────────────────┼────────────┼──────────┼──────────────────┼──────────────────────┼───────────┼────────────────────┼──────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
│ 0       │ 'lagoon-0x936facdf10c8c36294e7b9d28345255539d81bc7-ethereum' │ 'ethereum' │ 'lagoon' │ 'rock.rETH'      │ -0.42537360109200417 │ 0         │ 23033280.191840246 │ [ '0xae78736cd615f374d3085123a210448e74fc6393' ] │ 'https://app.lagoon.finance/vault/1/0x936facdf10c8c36294e7b9d28345255539d81bc7' │
│ 1       │ 'lagoon-0xb09f761cb13baca8ec087ac476647361b6314f98-ethereum' │ 'ethereum' │ 'lagoon' │ 'T9cbBTC'        │ 2.591694966238953    │ 0         │ 13766928.51580365  │ [ '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf' ] │ 'https://app.lagoon.finance/vault/1/0xb09f761cb13baca8ec087ac476647361b6314f98' │
│ 2       │ 'lagoon-0xce0b790ae0d8cf91e01f3fb69025e14569b574f3-ethereum' │ 'ethereum' │ 'lagoon' │ 'tulipaUSDC'     │ 7.496581823539153    │ 0         │ 7698517.369498979  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0xce0b790ae0d8cf91e01f3fb69025e14569b574f3' │
│ 3       │ 'lagoon-0x7a12d4b719f5aa479ecd60defed909fb2a37e428-ethereum' │ 'ethereum' │ 'lagoon' │ 'rock.loopedETH' │ -0.7147264749154681  │ 0         │ 6139263.415925077  │ [ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ] │ 'https://app.lagoon.finance/vault/1/0x7a12d4b719f5aa479ecd60defed909fb2a37e428' │
│ 4       │ 'lagoon-0x2a676c2744421b4fae65ce86b47adacb620047d4-ethereum' │ 'ethereum' │ 'lagoon' │ 'ghemiBTC'       │ 1.0624342670150557   │ 0         │ 3941717.681702444  │ [ '0x06ea695b91700071b161a434fed42d1dcbad9f00' ] │ 'https://app.lagoon.finance/vault/1/0x2a676c2744421b4fae65ce86b47adacb620047d4' │
│ 5       │ 'lagoon-0x03d1ec0d01b659b89a87eabb56e4af5cb6e14bfc-ethereum' │ 'ethereum' │ 'lagoon' │ '9SUSDC'         │ 2.2999716885599595   │ 0         │ 3753147.5400233925 │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0x03d1ec0d01b659b89a87eabb56e4af5cb6e14bfc' │
│ 6       │ 'lagoon-0xdae854d0896ad2fee335689a3f7b4a95fd1a3e46-ethereum' │ 'ethereum' │ 'lagoon' │ 'gamiUSDC'       │ 3.7091036744879093   │ 0         │ 2691283.70112338   │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'https://app.lagoon.finance/vault/1/0xdae854d0896ad2fee335689a3f7b4a95fd1a3e46' │
│ 7       │ 'lagoon-0xbb211be8664128e30c6adcd5998eca9592be272f-ethereum' │ 'ethereum' │ 'lagoon' │ 'ammVWETH'       │ -85.49830907669956   │ 0         │ 1746694.987799683  │ [ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ] │ 'https://app.lagoon.finance/vault/1/0xbb211be8664128e30c6adcd5998eca9592be272f' │
│ 8       │ 'lagoon-0x8245fd9ae99a482dfe76576dd4298f799c041d61-ethereum' │ 'ethereum' │ 'lagoon' │ 'uUSCC++'        │ 0.014856351341981293 │ 0         │ 1407682.36090643   │ [ '0x35d8949372d46b7a3d5a56006ae77b215fc69bc0' ] │ 'https://app.lagoon.finance/vault/1/0x8245fd9ae99a482dfe76576dd4298f799c041d61' │
│ 9       │ 'lagoon-0x414070fb9e64fd69160d75da57e75ba11f9f605a-ethereum' │ 'ethereum' │ 'lagoon' │ 'gamiWBTC'       │ 1.7216956802561905   │ 0         │ 1400362.763101729  │ [ '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599' ] │ 'https://app.lagoon.finance/vault/1/0x414070fb9e64fd69160d75da57e75ba11f9f605a' │
└─────────┴──────────────────────────────────────────────────────────────┴────────────┴──────────┴──────────────────┴──────────────────────┴───────────┴────────────────────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Copy link
Copy Markdown
Contributor

@0xkr3p 0xkr3p left a comment

Choose a reason for hiding this comment

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

hey @GuiDupont, thanks for the PR, just a comment to resolve and pls remove package-lock.json file from PR

apyBase: vault.state.weeklyApr.linearNetAprWithoutExtraYields,
apyBase,
apyReward,
tvlUsd: vault.state.totalAssetsUsd || 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pls add rewardTokens field

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.

3 participants