-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Add zenrock DefiLlama TVL adapter #16860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
waynebruce0x
merged 12 commits into
DefiLlama:main
from
Peyton-Spencer:feature/zenrock-adapter
Nov 4, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cd6d26d
Add zenrock DefiLlama TVL adapter
Peyton-Spencer c0d15bc
Update methodology to reflect yield-bearing nature of zenBTC
Peyton-Spencer 6780600
feat(zenrock): replace API-based TVL with actual Bitcoin address queries
Peyton-Spencer 81434be
feat(zenrock): dynamically fetch change addresses from zenbtc params
Peyton-Spencer 0d22f67
Fix: Include both treasury and change addresses in Bitcoin TVL calcul…
Peyton-Spencer a7b4815
Refactor: Move zenrock address fetching to bitcoin-book fetchers helper
Peyton-Spencer ff3993d
feat: add zenZEC TVL (MVP, need to fetch zcash addresses)
Peyton-Spencer e30cefc
Refactor: Remove try-catch blocks and clean up unused code
Peyton-Spencer f6c2762
clean up unused code
Peyton-Spencer 5eb4e62
undo formatting change
Peyton-Spencer 9198df5
remove unused zenrockDCT
Peyton-Spencer c5b054b
change Bitcoin->assets
Peyton-Spencer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| const { sumTokens: sumBitcoinTokens } = require('../helper/chain/bitcoin'); | ||
| const { zenrock } = require('../helper/bitcoin-book/fetchers'); | ||
|
|
||
| /** | ||
| * Queries Bitcoin balances for all zrchain treasury and change addresses | ||
| * Returns balances object with Bitcoin TVL | ||
| */ | ||
| async function tvl() { | ||
| // Fetch all protocol addresses (treasury + change) from the bitcoin-book fetcher | ||
| const allAddresses = await zenrock(); | ||
|
|
||
| if (allAddresses.length === 0) { | ||
| return { bitcoin: '0' }; | ||
| } | ||
|
|
||
| // Use Bitcoin helper to sum balances for all addresses | ||
| const balances = {}; | ||
| await sumBitcoinTokens({ balances, owners: allAddresses }); | ||
|
|
||
| return balances; | ||
| } | ||
|
|
||
| /** | ||
| * Queries Zcash balances for all zrchain treasury and change addresses | ||
| * Returns balances object with Zcash TVL | ||
| * | ||
| * NOTE: Currently using supply-based approach as a test implementation. | ||
| * The address-based approach is commented out below for future use. | ||
| */ | ||
| async function zcashTvl() { | ||
| // Fetch custodied amount from DCT supply endpoint | ||
| const { get } = require('../helper/http'); | ||
| const { getConfig } = require('../helper/cache'); | ||
| const sdk = require('@defillama/sdk'); | ||
|
|
||
| const DCT_SUPPLY_API = 'https://api.diamond.zenrocklabs.io/dct/supply'; | ||
|
|
||
| const supplyData = await getConfig('zenrock/dct_supply', DCT_SUPPLY_API, { | ||
| fetcher: async () => { | ||
| const response = await get(DCT_SUPPLY_API); | ||
| return response; | ||
| } | ||
| }); | ||
|
|
||
| const balances = {}; | ||
|
|
||
| // Find ASSET_ZENZEC in supplies array | ||
| const zenZecSupply = supplyData.supplies?.find( | ||
| item => item.supply?.asset === 'ASSET_ZENZEC' | ||
| ); | ||
|
|
||
| if (zenZecSupply && zenZecSupply.supply?.custodied_amount) { | ||
| // custodied_amount is in Zatoshi (smallest unit, like satoshis for BTC) | ||
| // Convert to ZEC by dividing by 1e8 | ||
| const custodiedAmount = Number(zenZecSupply.supply.custodied_amount); | ||
| const custodiedZEC = custodiedAmount / 1e8; | ||
|
|
||
| sdk.util.sumSingleBalance(balances, 'zcash', custodiedZEC); | ||
| } | ||
|
|
||
| return balances; | ||
| } | ||
|
|
||
| module.exports = { | ||
| methodology: 'zrchain locks native assets through its decentralized MPC network. zenBTC, Zenrock\'s flagship product, is a yield-bearing wrapped Bitcoin issued on Solana and EVM chains. TVL represents the total Bitcoin locked in zrchain treasury addresses. All zenBTC is fully backed by native Bitcoin, with the price of zenBTC anticipated to increase as yield payments are made continuously.', | ||
| bitcoin: { | ||
| tvl, | ||
| }, | ||
| zcash: { | ||
| tvl: zcashTvl, | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.