Skip to content

Add Boar Finance APY adapter#2766

Open
kpyszkowski wants to merge 3 commits into
DefiLlama:masterfrom
boar-network:boar-finance-apy
Open

Add Boar Finance APY adapter#2766
kpyszkowski wants to merge 3 commits into
DefiLlama:masterfrom
boar-network:boar-finance-apy

Conversation

@kpyszkowski

@kpyszkowski kpyszkowski commented Jun 30, 2026

Copy link
Copy Markdown

This pull request introduces a new yield adapter for Boar Finance's BTC vault on Mezo. The adapter closely mirrors the dapp's APY calculation logic, fetching recent compound events from a subgraph, estimating the relevant block, and reading on-chain data to compute the APY and TVL for the vault.

New Boar Finance BTC vault adapter:

  • Implements a yield adapter in src/adaptors/boar-finance/index.js that replicates the dapp's APY calculation for the BTC vault on Mezo, including subgraph queries and on-chain reads.
  • Defines all relevant contract addresses, ABIs, and constants for accurate data fetching and APY computation.
  • Exports the adapter with timetravel: false and provides the Boar Finance dashboard URL.

Summary by CodeRabbit

  • New Features
    • Added support for a new BTC yield pool on Mezo, including APY and TVL reporting.
    • Enabled historical rate estimation so the pool’s performance can be tracked over time.
    • Improved pricing integration to display the pool’s value in USD.

@github-actions

Copy link
Copy Markdown

Error while running boar-finance adapter:

Test Suites: 1 failed, 1 total
Tests: 1 failed, 11 passed, 12 total
Snapshots: 0 total
Time: 0.138 s
Ran all test suites.

Nb of pools: 1
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────┬────────┬────────────────┬────────┬────────────────────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┬──────────────────────────────────────────────────┬──────────────────────────────────┐
│ (index) │ pool                                                       │ chain  │ project        │ symbol │ poolMeta               │ tvlUsd             │ apyBase            │ underlyingTokens                                 │ rewardTokens                                     │ url                              │
├─────────┼────────────────────────────────────────────────────────────┼────────┼────────────────┼────────┼────────────────────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┼──────────────────────────────────────────────────┼──────────────────────────────────┤
│ 0       │ '0x3d4b1b884a7a1e59fe8589a3296ec8f8cbb6f279-boar-btc-mezo' │ 'Mezo' │ 'boar-finance' │ 'BTC'  │ 'veBTC — Boar managed' │ 1033844.9275209429 │ 15.966273389898888 │ [ '0x7b7C000000000000000000000000000000000000' ] │ [ '0x7b7C000000000000000000000000000000000000' ] │ 'https://boar.finance/dashboard' │
└─────────┴────────────────────────────────────────────────────────────┴────────┴────────────────┴────────┴────────────────────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┴──────────────────────────────────────────────────┴──────────────────────────────────┘

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca597263-28d9-4bde-8d58-e8aba7c98f98

📥 Commits

Reviewing files that changed from the base of the PR and between c4c41d0 and 62135ed.

📒 Files selected for processing (1)
  • src/adaptors/boar-finance/index.ts

📝 Walkthrough

Walkthrough

Adds src/adaptors/boar-finance/index.ts, a new yield adapter for the Boar Finance BTC vault on Mezo. It defines ABIs, constants, and helpers to query a Goldsky subgraph for the latest compound event, estimate the corresponding historical block, read on-chain locked amount and yield-per-epoch, compute APY and TVL, and export the adapter.

Boar Finance BTC Vault Adapter

Layer / File(s) Summary
Constants, ABIs, and block-estimation helpers
src/adaptors/boar-finance/index.ts
Defines LOCKED_ABI, YIELD_PER_EPOCH_ABI, chain/address/epoch constants, and helper functions to convert a timestamp to an epoch-start boundary and estimate the corresponding historical block number.
getApy implementation and module export
src/adaptors/boar-finance/index.ts
Queries the Goldsky subgraph for the latest compounds event, reads locked and yieldPerEpoch on-chain, fetches BTC price, computes apyBase and tvlUsd, and exports the adapter with protocolId, timetravel, apy, and url.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐗 A boar dug through the blockchain dirt,
Found BTC locked beneath the turf.
Each epoch yields a compounded treat,
APY computed, oh so neat.
The rabbit checks the math and grins —
Another vault where DeFi wins! 🐇

🚥 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 clearly and concisely describes the main change: adding a Boar Finance APY adapter.
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.
✨ 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.

@github-actions

Copy link
Copy Markdown

The boar-finance adapter exports pools:

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

Nb of pools: 1
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────┬────────┬────────────────┬────────┬────────────────────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┬──────────────────────────────────────────────────┬──────────────────────────────────┐
│ (index) │ pool                                                       │ chain  │ project        │ symbol │ poolMeta               │ tvlUsd             │ apyBase            │ underlyingTokens                                 │ rewardTokens                                     │ url                              │
├─────────┼────────────────────────────────────────────────────────────┼────────┼────────────────┼────────┼────────────────────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┼──────────────────────────────────────────────────┼──────────────────────────────────┤
│ 0       │ '0x3d4b1b884a7a1e59fe8589a3296ec8f8cbb6f279-boar-btc-mezo' │ 'Mezo' │ 'boar-finance' │ 'BTC'  │ 'veBTC — Boar managed' │ 1033844.9275209429 │ 15.966273389898888 │ [ '0x7b7C000000000000000000000000000000000000' ] │ [ '0x7b7C000000000000000000000000000000000000' ] │ 'https://boar.finance/dashboard' │
└─────────┴────────────────────────────────────────────────────────────┴────────┴────────────────┴────────┴────────────────────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┴──────────────────────────────────────────────────┴──────────────────────────────────┘

@kpyszkowski

Copy link
Copy Markdown
Author

@RohanNero tagging you since you are in the loop merging DefiLlama/DefiLlama-Adapters#19794 some time ago
can you merge this one as well? 🙏🏼

chain: utils.formatChain(CHAIN),
project: "boar-finance",
symbol: "BTC",
poolMeta: "veBTC — Boar managed",

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 rename to 28d unstake lock

// Step 5: mirrors computeEpochApy + weeklyRateToApy
const rateBP = (yieldAmount * APY_PRECISION) / lockedAmount;
const rate = Number(rateBP) / Number(APY_PRECISION);
const apyBase = ((1 + rate) ** EPOCHS_PER_YEAR - 1) * 100;

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.

Just dbl checking this apy is net?

tvlUsd,
apyBase,
underlyingTokens: [BTC],
rewardTokens: [BTC],

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.

reward tokens can be removed

@0xkr3p 0xkr3p left a comment

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.

hi @kpyszkowski, thanks for the PR. A few things to resolve before we can merge. I've left some comments on the PR. Can you also take a look at using the lookup block from the sdk instead of hardcoding estimations. Here is some code which could help:

 The lines involved:
  - 57–59 — hardcoded constants MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_TIMESTAMP,
  MAINNET_AVG_BLOCK_TIME
  - 88–91 — the estimateBlockAtEpochStart() function
  - 114 — const epochStartBlock = estimateBlockAtEpochStart(epochStart);
  - 117–132 — the Promise.all (only reads locked at the epoch-start block)
  - 145 — const tvlUsd = (Number(lockedAmount) / 1e18) * btcPrice; ← uses the epoch-start amount for
  TVL

  Change 1 — line 114 (block from API, not estimate):
  // before
  const epochStartBlock = estimateBlockAtEpochStart(epochStart);
  // after
  const { block: epochStartBlock } = await sdk.api.util.lookupBlock(epochStart, { chain: CHAIN });
  …then delete the now-unused estimateBlockAtEpochStart (88–91) and the three constants (57–59).

  Change 2 — TVL from current locked, not epoch-start. Add a second (latest-block) locked read to
  the Promise.all (117–132) and use it only for TVL; keep the epoch-start read purely as the APY
  denominator:
  const [lockedRes, currentLockedRes, yieldRes, priceData] = await Promise.all([
    sdk.api.abi.call({ target: VE_BTC, abi: LOCKED_ABI, params: [MANAGED_TOKEN_ID], chain: CHAIN,
  block: epochStartBlock }), // epoch-start → APY denominator
    sdk.api.abi.call({ target: VE_BTC, abi: LOCKED_ABI, params: [MANAGED_TOKEN_ID], chain: CHAIN }),
                           // current → TVL
    sdk.api.abi.call({ target: BOAR_BTC_RELAY, abi: YIELD_PER_EPOCH_ABI, params: [epochStart],
  chain: CHAIN }),
    utils.getPrices([BTC], CHAIN),
  ]);
  Then at line 145:
  // before
  const tvlUsd = (Number(lockedAmount) / 1e18) * btcPrice;
  // after
  const currentLocked = BigInt((currentLockedRes.output as LockedTuple).amount);
  const tvlUsd = (Number(currentLocked) / 1e18) * btcPrice;
  (lockedAmount at line 134 stays as-is — it's the correct epoch-start denominator for the rate at
  line 140.)

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