Add ZigChain TVL for DeFa , as DeFa is live on zigchain is well now #18706
Add ZigChain TVL for DeFa , as DeFa is live on zigchain is well now #18706strugglingfrfr wants to merge 5 commits intoDefiLlama:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
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)
📝 WalkthroughWalkthroughReplace Axios/XDR simulation with Soroban Changes
Sequence Diagram(s)sequenceDiagram
participant Defa as Defa module
participant Soroban as Soroban RPC
participant StellarC as Stellar Contract
participant ZigRPC as ZigChain RPC
participant ZigC as ZigChain Contract
participant API as Adapter API
rect rgba(100,150,240,0.5)
Defa->>Soroban: callSoroban(STELLAR_CONTRACT, "get_active_tvl")
Soroban-->>StellarC: invoke get_active_tvl
StellarC-->>Soroban: active_tvl (raw)
Soroban-->>Defa: active_tvl (raw)
Defa->>Defa: convert & validate (/1e7)
Defa->>API: add "usd-coin" and return api.getBalances()
end
rect rgba(240,150,100,0.5)
Defa->>ZigRPC: queryContract(ZIGCHAIN_LOGGER, {active_tvl})
ZigRPC-->>ZigC: query active_tvl
ZigC-->>ZigRPC: active_tvl (raw)
ZigRPC-->>Defa: active_tvl (raw)
Defa->>Defa: convert & validate (/1e6)
Defa->>API: add "usd-coin" and return api.getBalances()
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 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/defa exports TVL: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/defa/index.js`:
- Around line 75-80: The adapter currently reports USD figures from logger
contracts for Stellar and ZigChain (see module.exports, methodology, stellar: {
tvl: stellarTvl }, zigchain: { tvl: zigchainTvl }) which map priced/synthetic
balances to USDC rather than reporting underlying token inventories; add
misrepresentedTokens: true to the exported object (alongside timetravel and
methodology) so consumers know the adapter reports priced/synthetic values
rather than actual token balances.
- Around line 23-27: The current code extracts TVL by slicing the last 16 bytes
of the XDR buffer (xdr) which ignores ScVal type metadata; instead parse the
ScVal structurally using the repository parser (use _parseScVal in
projects/helper/chain/stellar.js or Stellar SDK's scValToNative) on
Buffer.from(xdr, "base64"), handle Option/Int/Uint variants the parser returns,
and then convert the parsed numeric value to BigInt for the return; update the
block that reads the xdr variable so it calls the parser, checks for an Option
unwrap if needed, validates the resulting type is numeric, and returns BigInt of
that parsed numeric value rather than buffer.slice(-16).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
|
The adapter at projects/defa exports TVL: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
projects/defa/index.js (1)
44-65: Drop the staletvl()helper while you’re here.After switching the exports to
stellarTvl/zigchainTvl, the old local helper is just dead code and still references removedgetActiveTvl(). Keeping a broken path around makes future reuse/debugging harder.♻️ Proposed cleanup
-async function tvl(api) { - const activeTvl = await getActiveTvl(); - - if (activeTvl === 0n) throw new Error("TVL is zero"); - - const normalized = Number(activeTvl) / 1e7; - api.addCGToken("usd-coin", normalized); - - return api.getBalances(); - } - - module.exports = {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@projects/defa/index.js` around lines 44 - 65, Remove the stale tvl() helper and any references to the removed getActiveTvl() function: delete the async function tvl(api) block (which adds usd-coin and returns api.getBalances()) since exports now use stellarTvl and zigchainTvl; ensure module.exports only references stellarTvl and zigchainTvl and that no other code in this file refers to tvl or getActiveTvl so there are no dangling/broken calls.
🤖 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/defa/index.js`:
- Around line 44-65: Remove the stale tvl() helper and any references to the
removed getActiveTvl() function: delete the async function tvl(api) block (which
adds usd-coin and returns api.getBalances()) since exports now use stellarTvl
and zigchainTvl; ensure module.exports only references stellarTvl and
zigchainTvl and that no other code in this file refers to tvl or getActiveTvl so
there are no dangling/broken calls.
|
The adapter at projects/defa exports TVL: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/defa/index.js`:
- Line 25: Update the inline documentation comment that currently reads
"zigchian" to the correct spelling "zigchain" so the comment describing the
contract ("The contract returns active liquidity in DeFa zigchian contracts
denominated in USD") is corrected; locate the comment in projects/defa/index.js
(the top-level file comment) and replace the typo.
- Around line 13-20: The external TVL value returned to stellarTvl (from
callSoroban / get_active_tvl) is being coerced with Number(...) and passed to
api.addCGToken without validation; update stellarTvl to parse the result to a
numeric value (e.g., const parsed = Number(activeTvl) or parseFloat) and then
check Number.isFinite(parsed) (or !Number.isNaN(parsed) && isFinite(parsed))
before calling api.addCGToken, and if the value is not finite either throw a
descriptive error or skip adding the token so you don't introduce NaN into
balances; ensure the check references the activeTvl variable and the
api.addCGToken call so the fix is applied in stellarTvl.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
|
The adapter at projects/defa exports TVL: |
NOTE
Please enable "Allow edits by maintainers" while putting up the PR.
If you would like to add a
volume/fees/revenueadapter please submit the PR here.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.
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.
For updating listing info It is a different repo, you can find your listing in this file, you can edit it there and put up a PR
Please do not add new npm dependencies, do not edit/push
pnpm-lock.yamlfile as part of your changes(Needs to be filled only for new listings)
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
Improvements
Platform