Add Boar Finance APY adapter#2766
Conversation
|
Error while running boar-finance adapter: Test Suites: 1 failed, 1 total |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds Boar Finance BTC Vault Adapter
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
The boar-finance adapter exports pools: Test Suites: 1 passed, 1 total |
|
@RohanNero tagging you since you are in the loop merging DefiLlama/DefiLlama-Adapters#19794 some time ago |
| chain: utils.formatChain(CHAIN), | ||
| project: "boar-finance", | ||
| symbol: "BTC", | ||
| poolMeta: "veBTC — Boar managed", |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Just dbl checking this apy is net?
| tvlUsd, | ||
| apyBase, | ||
| underlyingTokens: [BTC], | ||
| rewardTokens: [BTC], |
There was a problem hiding this comment.
reward tokens can be removed
0xkr3p
left a comment
There was a problem hiding this comment.
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.)
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:
src/adaptors/boar-finance/index.jsthat replicates the dapp's APY calculation for the BTC vault on Mezo, including subgraph queries and on-chain reads.timetravel: falseand provides the Boar Finance dashboard URL.Summary by CodeRabbit