Skip to content

add zest-v2 adapter#2464

Merged
0xkr3p merged 3 commits intoDefiLlama:masterfrom
0xkr3p:feat/add-zest-v2
Mar 9, 2026
Merged

add zest-v2 adapter#2464
0xkr3p merged 3 commits intoDefiLlama:masterfrom
0xkr3p:feat/add-zest-v2

Conversation

@0xkr3p
Copy link
Contributor

@0xkr3p 0xkr3p commented Mar 9, 2026

Summary by CodeRabbit

  • New Features
    • Added support for Zest v2 on Stacks so users can view Zest pools.
    • Displays pool TVL in USD using live price data.
    • Shows supply and borrow APYs for each pool.
    • Lists underlying assets and provides a market link for each pool.
    • Resilient fetching: problematic pools are skipped without impacting others.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ea64068-ecc1-4f9c-93f0-a88f5c3265ad

📥 Commits

Reviewing files that changed from the base of the PR and between 1a41446 and be25788.

📒 Files selected for processing (1)
  • src/adaptors/zest-v2/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/adaptors/zest-v2/index.js

📝 Walkthrough

Walkthrough

Adds a new Zest v2 adapter for Stacks that enumerates static pools, fetches external prices, computes TVL in USD, reads on‑chain supply/borrow APYs and total assets from deployer/vault contracts, and returns standardized pool objects; errors are handled per‑pool and for the overall process.

Changes

Cohort / File(s) Summary
Zest v2 Adapter Implementation
src/adaptors/zest-v2/index.js
New adapter module. Adds static pool list and price key mapping, fetches prices via CoinGecko/llama.fi, computes pool TVL, reads on‑chain APY and asset totals from deployer and vault contracts, assembles standardized pool objects, logs/skips per‑pool errors, wraps with top‑level error handling, and exports { timetravel: false, apy: getZestV2Pools, url }.

Sequence Diagram

sequenceDiagram
    participant Client as Client
    participant Adapter as Zest v2 Adapter
    participant PriceAPI as Price Data Service (CoinGecko/llama.fi)
    participant Chain as Stacks Mainnet (Deployer & Vaults)
    participant Result as Formatted Result

    Client->>Adapter: getZestV2Pools()
    Adapter->>PriceAPI: Fetch prices for asset keys
    PriceAPI-->>Adapter: Return price data
    Adapter->>Adapter: Select prices & compute TVL (per pool)
    
    loop for each pool
        Adapter->>Chain: Read deployer contract (supply/borrow APYs)
        Chain-->>Adapter: APY responses
        Adapter->>Chain: Read vault contract (total assets)
        Chain-->>Adapter: Asset totals
        Adapter->>Adapter: Build standardized pool object
    end

    Adapter->>Result: Aggregate pool objects
    Result-->>Client: Return pools array
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Tweedled whisk, I hop and cheer,
New pools arrive—prices clear,
On‑chain calls and TVL in view,
APYs counted, one by one too,
Hooray for Zest v2! 🌿

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add zest-v2 adapter' directly and clearly summarizes the main change: introducing a new Zest v2 adapter for the codebase.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@llamatester
Copy link

The zest-v2 adapter exports pools:

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

Nb of pools: 6
 

Sample pools:
┌─────────┬──────────────────────────────────────────────────────────────────────┬──────────┬───────────┬────────────┬────────────────────┬─────────┬───────────────┬─────────────────────────────────────────────────────────────────────┬────────────────────────────────────────────┐
│ (index) │ pool                                                                 │ chain    │ project   │ symbol     │ tvlUsd             │ apyBase │ apyBaseBorrow │ underlyingTokens                                                    │ url                                        │
├─────────┼──────────────────────────────────────────────────────────────────────┼──────────┼───────────┼────────────┼────────────────────┼─────────┼───────────────┼─────────────────────────────────────────────────────────────────────┼────────────────────────────────────────────┤
│ 0       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-sbtc-stacks'     │ 'Stacks' │ 'zest-v2' │ 'sBTC'     │ 38796790.09675166  │ 0       │ 3.86          │ [ 'stacks:SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token' ]   │ 'https://app.zestprotocol.com/market/main' │
│ 1       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-usdc-stacks'     │ 'Stacks' │ 'zest-v2' │ 'USDC'     │ 12014039.278761558 │ 0.07    │ 0.69          │ [ 'stacks:SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx' ]        │ 'https://app.zestprotocol.com/market/main' │
│ 2       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-usdh-stacks'     │ 'Stacks' │ 'zest-v2' │ 'USDH'     │ 4999429.022606846  │ 0       │ 0.15          │ [ 'stacks:SPN5AKG35QZSK2M8GAMR4AFX45659RJHDW353HSG.usdh-token-v1' ] │ 'https://app.zestprotocol.com/market/main' │
│ 3       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-ststxbtc-stacks' │ 'Stacks' │ 'zest-v2' │ 'stSTXbtc' │ 1085602.799570013  │ 0       │ 0             │ [ 'coingecko:blockstack' ]                                          │ 'https://app.zestprotocol.com/market/main' │
│ 4       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-ststx-stacks'    │ 'Stacks' │ 'zest-v2' │ 'stSTX'    │ 550765.2841685776  │ 0.18    │ 1.84          │ [ 'stacks:SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token' ]   │ 'https://app.zestprotocol.com/market/main' │
│ 5       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-stx-stacks'      │ 'Stacks' │ 'zest-v2' │ 'STX'      │ 16899.929136192342 │ 1.37    │ 3.67          │ [ 'coingecko:blockstack' ]                                          │ 'https://app.zestprotocol.com/market/main' │
└─────────┴──────────────────────────────────────────────────────────────────────┴──────────┴───────────┴────────────┴────────────────────┴─────────┴───────────────┴─────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────┘

@llamatester
Copy link

The zest-v2 adapter exports pools:

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

Nb of pools: 6
 

Sample pools:
┌─────────┬──────────────────────────────────────────────────────────────────────┬──────────┬───────────┬────────────┬────────────────────┬─────────┬───────────────┬──────────────────────────────────────────────────────────────────┬────────────────────────────────────────────┐
│ (index) │ pool                                                                 │ chain    │ project   │ symbol     │ tvlUsd             │ apyBase │ apyBaseBorrow │ underlyingTokens                                                 │ url                                        │
├─────────┼──────────────────────────────────────────────────────────────────────┼──────────┼───────────┼────────────┼────────────────────┼─────────┼───────────────┼──────────────────────────────────────────────────────────────────┼────────────────────────────────────────────┤
│ 0       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-sbtc-stacks'     │ 'Stacks' │ 'zest-v2' │ 'sBTC'     │ 38796790.09675166  │ 0       │ 3.86          │ [ 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token' ]       │ 'https://app.zestprotocol.com/market/main' │
│ 1       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-usdc-stacks'     │ 'Stacks' │ 'zest-v2' │ 'USDC'     │ 12014029.293535812 │ 0.07    │ 0.69          │ [ 'SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx' ]            │ 'https://app.zestprotocol.com/market/main' │
│ 2       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-usdh-stacks'     │ 'Stacks' │ 'zest-v2' │ 'USDH'     │ 4999429.02273612   │ 0       │ 0.15          │ [ 'SPN5AKG35QZSK2M8GAMR4AFX45659RJHDW353HSG.usdh-token-v1' ]     │ 'https://app.zestprotocol.com/market/main' │
│ 3       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-ststxbtc-stacks' │ 'Stacks' │ 'zest-v2' │ 'stSTXbtc' │ 1085602.799570013  │ 0       │ 0             │ [ 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststxbtc-token-v2' ] │ 'https://app.zestprotocol.com/market/main' │
│ 4       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-ststx-stacks'    │ 'Stacks' │ 'zest-v2' │ 'stSTX'    │ 550765.2849156036  │ 0.18    │ 1.84          │ [ 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token' ]       │ 'https://app.zestprotocol.com/market/main' │
│ 5       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-stx-stacks'      │ 'Stacks' │ 'zest-v2' │ 'STX'      │ 16899.929300342897 │ 1.37    │ 3.67          │ [ 'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.wstx' ]             │ 'https://app.zestprotocol.com/market/main' │
└─────────┴──────────────────────────────────────────────────────────────────────┴──────────┴───────────┴────────────┴────────────────────┴─────────┴───────────────┴──────────────────────────────────────────────────────────────────┴────────────────────────────────────────────┘

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: 2

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

76-88: Prefer the shared price utility over an inline llama client.

This reimplements price fetching/selection logic that already exists in src/adaptors/utils.js:334-363, so fallback and key-shaping behavior can drift independently over time.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/adaptors/zest-v2/index.js` around lines 76 - 88, Replace the local inline
price client by removing the functions fetchPrices and getPrice and instead
import and use the shared price utility exported from the adaptors utils module
(the existing shared price-fetch/selection helpers) to obtain current prices and
pick a matching key; update callers in this file to call the shared utility (use
the util's price-fetch function to get the prices object and the util's
selection function to choose the first available key/price), and remove the
duplicate logic so fallback and key-shaping behavior is centralized.
🤖 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/zest-v2/index.js`:
- Around line 164-166: The catch block inside getZestV2Pools currently logs the
error and returns [], which masks adapter-wide failures as an empty dataset;
change it to propagate the failure instead of returning an empty array by
removing the "return []" and rethrowing (or throwing a new Error with contextual
message) after logging so upstream can handle/retry the error; ensure you
reference getZestV2Pools in src/adaptors/zest-v2/index.js when making the
change.
- Around line 76-80: fetchPrices uses axios.get without a timeout which can hang
the adapter; update fetchPrices to pass a timeout option to axios.get (e.g.,
axios.get(url, { timeout: <ms> })) so the request fails fast, and handle the
error path (catch) to avoid blocking pool emission. Make changes in the
fetchPrices function where keys, url, and axios.get are used so the request
includes a timeout value and errors are handled appropriately.

---

Nitpick comments:
In `@src/adaptors/zest-v2/index.js`:
- Around line 76-88: Replace the local inline price client by removing the
functions fetchPrices and getPrice and instead import and use the shared price
utility exported from the adaptors utils module (the existing shared
price-fetch/selection helpers) to obtain current prices and pick a matching key;
update callers in this file to call the shared utility (use the util's
price-fetch function to get the prices object and the util's selection function
to choose the first available key/price), and remove the duplicate logic so
fallback and key-shaping behavior is centralized.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b9e417d5-c851-4494-aff5-55e11e104273

📥 Commits

Reviewing files that changed from the base of the PR and between 7eb5949 and 1a41446.

📒 Files selected for processing (1)
  • src/adaptors/zest-v2/index.js

Comment on lines +76 to +80
async function fetchPrices() {
const keys = [...new Set(POOLS.flatMap((p) => p.priceKeys))].join(',');
const url = `https://coins.llama.fi/prices/current/${keys}`;
const { data } = await axios.get(url);
return data.coins;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the actual code in the file
cat -n src/adaptors/zest-v2/index.js | head -100

Repository: DefiLlama/yield-server

Length of output: 3469


🏁 Script executed:

# Check if there's any error handling around the axios call
rg -A 10 -B 5 "fetchPrices" src/adaptors/zest-v2/index.js

Repository: DefiLlama/yield-server

Length of output: 906


🏁 Script executed:

# Look for how fetchPrices is called and if there's any wrapper error handling
rg "fetchPrices\(\)" src/adaptors/zest-v2/index.js

Repository: DefiLlama/yield-server

Length of output: 136


🌐 Web query:

axios default timeout behavior javascript library

💡 Result:

  • Axios’ default timeout is 0, which means no timeout (it will wait indefinitely unless something else aborts the request). [1][2]
  • timeout is milliseconds before Axios aborts the request (when set to a positive number). [1]
  • You can set it per request (axios.get(url, { timeout: 5000 })), globally (axios.defaults.timeout = 5000), or per instance (instance.defaults.timeout = 5000). [1][2]
  • For cases where a request may “hang” due to connection issues, Axios recommends combining timeout with cancellation (e.g., AbortController / AbortSignal.timeout(...)). [3]

Sources:
[1] Axios docs – Request Config (timeout: 1000, // default is 0 (no timeout)) (axios-http.com)
[2] Axios docs – Config defaults (notes default timeout is 0) (axios.rest)
[3] Axios docs – Cancellation (timeout vs cancellation, AbortSignal.timeout) (axios-http.com)

Citations:


Add a timeout to the price request.

axios.get() defaults to no timeout, so a hung llama.fi call will block the entire adapter indefinitely before any pools are emitted.

🛠️ Proposed fix
 async function fetchPrices() {
   const keys = [...new Set(POOLS.flatMap((p) => p.priceKeys))].join(',');
   const url = `https://coins.llama.fi/prices/current/${keys}`;
-  const { data } = await axios.get(url);
+  const { data } = await axios.get(url, { timeout: 10_000 });
   return data.coins;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/adaptors/zest-v2/index.js` around lines 76 - 80, fetchPrices uses
axios.get without a timeout which can hang the adapter; update fetchPrices to
pass a timeout option to axios.get (e.g., axios.get(url, { timeout: <ms> })) so
the request fails fast, and handle the error path (catch) to avoid blocking pool
emission. Make changes in the fetchPrices function where keys, url, and
axios.get are used so the request includes a timeout value and errors are
handled appropriately.

Comment on lines +164 to +166
} catch (error) {
console.log(`Error in getZestV2Pools: ${error.message}`);
return [];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don't mask adapter-wide failures as “zero pools”.

Returning [] here turns a transient upstream/RPC failure into a valid empty dataset, which can temporarily drop all Zest v2 markets from downstream consumers.

🛠️ Proposed fix
   } catch (error) {
-    console.log(`Error in getZestV2Pools: ${error.message}`);
-    return [];
+    console.error(`Error in getZestV2Pools: ${error.message}`);
+    throw error;
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (error) {
console.log(`Error in getZestV2Pools: ${error.message}`);
return [];
} catch (error) {
console.error(`Error in getZestV2Pools: ${error.message}`);
throw error;
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/adaptors/zest-v2/index.js` around lines 164 - 166, The catch block inside
getZestV2Pools currently logs the error and returns [], which masks adapter-wide
failures as an empty dataset; change it to propagate the failure instead of
returning an empty array by removing the "return []" and rethrowing (or throwing
a new Error with contextual message) after logging so upstream can handle/retry
the error; ensure you reference getZestV2Pools in src/adaptors/zest-v2/index.js
when making the change.

@llamatester
Copy link

The zest-v2 adapter exports pools:

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

Nb of pools: 6
 

Sample pools:
┌─────────┬──────────────────────────────────────────────────────────────────────┬──────────┬───────────┬────────────┬────────────────────┬─────────┬───────────────┬──────────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────┬────────────────────────────────────────────┐
│ (index) │ pool                                                                 │ chain    │ project   │ symbol     │ tvlUsd             │ apyBase │ apyBaseBorrow │ underlyingTokens                                                 │ token                                                        │ url                                        │
├─────────┼──────────────────────────────────────────────────────────────────────┼──────────┼───────────┼────────────┼────────────────────┼─────────┼───────────────┼──────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────┤
│ 0       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-sbtc-stacks'     │ 'Stacks' │ 'zest-v2' │ 'sBTC'     │ 39656224.33156425  │ 0       │ 3.86          │ [ 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token' ]       │ 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token'       │ 'https://app.zestprotocol.com/market/main' │
│ 1       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-usdc-stacks'     │ 'Stacks' │ 'zest-v2' │ 'USDC'     │ 12007360.420044322 │ 0.07    │ 0.69          │ [ 'SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx' ]            │ 'SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx'            │ 'https://app.zestprotocol.com/market/main' │
│ 2       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-usdh-stacks'     │ 'Stacks' │ 'zest-v2' │ 'USDH'     │ 4988958.992036849  │ 0       │ 0.16          │ [ 'SPN5AKG35QZSK2M8GAMR4AFX45659RJHDW353HSG.usdh-token-v1' ]     │ 'SPN5AKG35QZSK2M8GAMR4AFX45659RJHDW353HSG.usdh-token-v1'     │ 'https://app.zestprotocol.com/market/main' │
│ 3       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-ststxbtc-stacks' │ 'Stacks' │ 'zest-v2' │ 'stSTXbtc' │ 1100525.989305442  │ 0       │ 0             │ [ 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststxbtc-token-v2' ] │ 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststxbtc-token-v2' │ 'https://app.zestprotocol.com/market/main' │
│ 4       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-ststx-stacks'    │ 'Stacks' │ 'zest-v2' │ 'stSTX'    │ 548596.6929518925  │ 0.18    │ 1.84          │ [ 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token' ]       │ 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token'       │ 'https://app.zestprotocol.com/market/main' │
│ 5       │ 'sp1a27kfy4xerqccrcarcyd1cc5n7m6688bsyadj7.v0-vault-stx-stacks'      │ 'Stacks' │ 'zest-v2' │ 'STX'      │ 17132.348658197432 │ 1.37    │ 3.67          │ [ 'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.wstx' ]             │ 'SP1A27KFY4XERQCCRCARCYD1CC5N7M6688BSYADJ7.wstx'             │ 'https://app.zestprotocol.com/market/main' │
└─────────┴──────────────────────────────────────────────────────────────────────┴──────────┴───────────┴────────────┴────────────────────┴─────────┴───────────────┴──────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────┴────────────────────────────────────────────┘

@0xkr3p 0xkr3p merged commit 512b347 into DefiLlama:master Mar 9, 2026
2 checks passed
@0xkr3p 0xkr3p deleted the feat/add-zest-v2 branch March 9, 2026 15:04
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