Skip to content

Separate Zest into versions - to combine under parent#zest in server repo#17988

Merged
0xpeluche merged 3 commits intoDefiLlama:mainfrom
y0s0n:main
Feb 23, 2026
Merged

Separate Zest into versions - to combine under parent#zest in server repo#17988
0xpeluche merged 3 commits intoDefiLlama:mainfrom
y0s0n:main

Conversation

@y0s0n
Copy link
Contributor

@y0s0n y0s0n commented Feb 10, 2026

NOTE

Please enable "Allow edits by maintainers" while putting up the PR.


  • If you would like to add a volume/fees/revenue adapter please submit the PR here.
  • If you would like to add a liquidations adapter, please refer to this readme document for details.
  1. Once your adapter has been merged, it takes time to show on the UI. If more than 24 hours have passed, please let us know in Discord.
  2. Sorry, We no longer accept fetch adapter for new projects, we prefer the tvl to computed from blockchain data, if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.
  3. Please fill the form below only if the PR is for listing a new protocol else it can be ignored/replaced with reason/details about the PR
  4. For updating listing info It is a different repo, you can find your listing in this file: https://github.com/DefiLlama/defillama-server/blob/master/defi/src/protocols/data2.ts, you can edit it there and put up a PR
  5. Do not edit/push package-lock.json file as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CI
  6. No need to go to our discord and announce that you've created a PR, we monitor all PRs and will review it asap

Name (to be shown on DefiLlama):
Twitter Link:
List of audit links if any:
Website Link:
Logo (High resolution, will be shown with rounded borders):
Current TVL:
Treasury Addresses (if the protocol has treasury)
Chain:
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)
Short Description (to be shown on DefiLlama):
Token address and ticker if any:
Category (full list at https://defillama.com/categories) *Please choose only one:
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
Implementation Details: Briefly describe how the oracle is integrated into your project:
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated):
Github org/user (Optional, if your code is open source, we can track activity):
Does this project have a referral program?

Summary by CodeRabbit

  • New Features

    • Added borrowed metric reporting for both ZEST and ZEST v2.
    • ZEST v2 now provides both total-value (TVL) and borrowed data.
  • Updates

    • Refined TVL coverage for ZEST by adjusting included pools/vaults.
    • Normalized numeric handling for reported token amounts.
    • Adjusted borrowing accounting to map wrapped STX to the base token for accurate totals.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Adds a new ZEST v2 adapter exporting stacks.tvl and stacks.borrowed; extends the existing ZEST v1 adapter with a borrowed(api) function, new imports, and asset constants. Both adapters now expose borrowed reporting alongside TVL.

Changes

Cohort / File(s) Summary
ZEST V2 Module
projects/zest-v2/index.js
New adapter module exposing stacks with tvl and borrowed. tvl delegates to sumTokens for predefined vault owners; borrowed iterates V2 vaults, reads vault assets/availability, computes borrowed amounts, and records positives via the provided api. Includes toBI helper for BigInt handling.
ZEST V1 Adapter
projects/zest/index.js
Added call import from stacks API and nullAddress mapping; introduced POOL_READ and V1_ASSETS; added borrowed(api) which queries pool read methods, maps wstx to nullAddress, computes borrows and calls api.add. Exports updated to include borrowed.
Manifest
package.json
Manifest updated alongside new adapter additions (lines reported).

Sequence Diagram(s)

sequenceDiagram
  participant Adapter as Adapter (zest / zest-v2)
  participant StacksRPC as Stacks RPC (call)
  participant Vault as Vault Contract(s)
  participant API as Adapter API (api.add)

  Adapter->>StacksRPC: request vault list / get assets / get-available-asset
  StacksRPC->>Vault: perform read-only contract call
  Vault-->>StacksRPC: return assets and available amounts
  StacksRPC-->>Adapter: deliver call results
  Adapter->>Adapter: compute borrowedAmt = asset - available (per token)
  Adapter->>API: api.add(tokenId, borrowedAmt) for positive amounts
  API-->>Adapter: acknowledge
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through vaults and read the stack,
Counting tokens, little and black,
V1 and V2, I tally with glee,
Borrowed bits and balances I see,
A joyful nibble — adapters clap back!

🚥 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 clearly describes the main change: separating Zest into versions (v1 and v2) for consolidation under a parent#zest structure in the server repo.
Description check ✅ Passed The description contains the template structure but all form fields are unfilled, as this PR is for refactoring existing code, not listing a new protocol, so the template fields can be ignored per the template's own guidance.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 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.

@llamabutler
Copy link

The adapter at projects/zest exports TVL:

stacks                    58.59 M

total                    58.59 M 

@llamabutler
Copy link

The adapter at projects/zest-v2 exports TVL:

stacks                    191.92 k

total                    191.92 k 

Copy link
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

🧹 Nitpick comments (1)
projects/zest-v2/index.js (1)

18-30: tvl() owners are a manual copy of V2_VAULTS vault addresses — derive them instead.

All six vault addresses in the tvl() owners list are identical to V2_VAULTS[*].vault. If a new vault is added to V2_VAULTS for the borrowed calculation, the tvl() owners list must be manually updated too, which is easy to miss.

♻️ Proposed refactor
 async function tvl() {
     return sumTokens({
-        owners: [
-            'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-vault-stx',
-            'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-vault-ststx',
-            'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-vault-ststxbtc',
-            'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-vault-sbtc',
-            'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-vault-usdc',
-            'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-vault-usdh',
-            'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-market-vault',
-        ],
+        owners: [
+            ...V2_VAULTS.map(({ vault }) => vault),
+            'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.v0-market-vault',
+        ],
     })
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@projects/zest-v2/index.js` around lines 18 - 30, The owners array in tvl() is
hardcoded duplicate addresses of V2_VAULTS[*].vault; change tvl() to derive
owners from the shared V2_VAULTS list (e.g., map V2_VAULTS to extract each
.vault) and pass that resulting array into sumTokens so adding/removing vaults
in V2_VAULTS automatically updates tvl(); update references inside the tvl()
function (and any related naming like V2_VAULTS) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@projects/zest/index.js`:
- Around line 30-38: The loop over V1_ASSETS calls the `get-reserve-data` via
`call` and then accesses `data['total-borrows-variable'].value` unsafely; update
the block around the `call` result (the anonymous async handler) to guard
against null/undefined `data` and missing `total-borrows-variable` (or use
optional chaining) and provide a safe default or skip adding to `api` when the
field is absent; keep references to `POOL_READ`, `get-reserve-data`, `tokenId`,
and `api.add` so the fix simply checks `data` and
`data['total-borrows-variable']` before using `.value` and uses 0 (or omits the
entry) when uninitialized.

---

Nitpick comments:
In `@projects/zest-v2/index.js`:
- Around line 18-30: The owners array in tvl() is hardcoded duplicate addresses
of V2_VAULTS[*].vault; change tvl() to derive owners from the shared V2_VAULTS
list (e.g., map V2_VAULTS to extract each .vault) and pass that resulting array
into sumTokens so adding/removing vaults in V2_VAULTS automatically updates
tvl(); update references inside the tvl() function (and any related naming like
V2_VAULTS) accordingly.

Copy link
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.

🧹 Nitpick comments (1)
projects/zest/index.js (1)

37-38: api.add called unconditionally when borrows is '0'.

For assets with no active borrows (or when data is absent), borrows falls back to '0' and a zero-value entry is still submitted for all 10 assets. This is a no-op but generates unnecessary calls. A simple guard keeps the output clean.

♻️ Proposed guard
-        const borrows = data?.['total-borrows-variable']?.value ?? '0'
-        api.add(tokenId, borrows)
+        const borrows = data?.['total-borrows-variable']?.value
+        if (borrows && borrows !== '0') api.add(tokenId, borrows)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@projects/zest/index.js` around lines 37 - 38, api.add is being called even
when borrows resolves to the string '0', causing unnecessary no-op submissions;
update the logic around the borrows variable (from
data?.['total-borrows-variable']?.value) to only call api.add(tokenId, borrows)
when borrows represents a non-zero value (e.g., borrows !== '0' or
Number(borrows) > 0) so that entries are skipped for absent data/zero borrows.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@projects/zest/index.js`:
- Around line 37-38: api.add is being called even when borrows resolves to the
string '0', causing unnecessary no-op submissions; update the logic around the
borrows variable (from data?.['total-borrows-variable']?.value) to only call
api.add(tokenId, borrows) when borrows represents a non-zero value (e.g.,
borrows !== '0' or Number(borrows) > 0) so that entries are skipped for absent
data/zero borrows.

@0xpeluche 0xpeluche merged commit 8c7c5a7 into DefiLlama:main Feb 23, 2026
2 checks passed
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