Separate Zest into versions - to combine under parent#zest in server repo#17988
Separate Zest into versions - to combine under parent#zest in server repo#179880xpeluche merged 3 commits intoDefiLlama:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds a new ZEST v2 adapter exporting Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 adapter at projects/zest exports TVL: |
|
The adapter at projects/zest-v2 exports TVL: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
projects/zest-v2/index.js (1)
18-30:tvl()owners are a manual copy ofV2_VAULTSvault addresses — derive them instead.All six vault addresses in the
tvl()owners list are identical toV2_VAULTS[*].vault. If a new vault is added toV2_VAULTSfor the borrowed calculation, thetvl()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.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
projects/zest/index.js (1)
37-38:api.addcalled unconditionally whenborrowsis'0'.For assets with no active borrows (or when
datais absent),borrowsfalls 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.
NOTE
Please enable "Allow edits by maintainers" while putting up the PR.
package-lock.jsonfile as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CIName (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
Updates