Skip to content

Add ZigChain TVL for DeFa , as DeFa is live on zigchain is well now #18706

Open
strugglingfrfr wants to merge 5 commits intoDefiLlama:mainfrom
strugglingfrfr:defa-stats-update
Open

Add ZigChain TVL for DeFa , as DeFa is live on zigchain is well now #18706
strugglingfrfr wants to merge 5 commits intoDefiLlama:mainfrom
strugglingfrfr:defa-stats-update

Conversation

@strugglingfrfr
Copy link
Copy Markdown
Contributor

@strugglingfrfr strugglingfrfr commented Apr 9, 2026

NOTE

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


  1. If you would like to add a volume/fees/revenue adapter please submit the PR here.

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

  3. 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.

  4. 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

  5. Please do not add new npm dependencies, do not edit/push pnpm-lock.yaml file 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

    • Added ZigChain TVL tracking.
    • Exposed Stellar TVL as a distinct tracked endpoint.
  • Improvements

    • Stellar TVL retrieval updated to use direct on-chain queries for more reliable results with added validation.
    • ZigChain TVL added with normalized and validated values.
    • Balances now include USD Coin in TVL calculations.
    • Marked certain tokens as misrepresented to improve accuracy.
  • Platform

    • Extended multi-chain TVL monitoring across Stellar and ZigChain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 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: 49000653-b255-494a-bc91-aa2c76eb88c3

📥 Commits

Reviewing files that changed from the base of the PR and between ffafbac and 4b074b4.

📒 Files selected for processing (1)
  • projects/defa/index.js

📝 Walkthrough

Walkthrough

Replace Axios/XDR simulation with Soroban callSoroban for Stellar TVL (scaled by 1e7); add ZigChain TVL via CosmWasm queryContract (scaled by 1e6). Update exports, methodology, and set misrepresentedTokens: true.

Changes

Cohort / File(s) Summary
Multi-chain TVL Integration
projects/defa/index.js
Removed Axios/XDR simulateTransaction flow; added stellarTvl(api) using callSoroban(STELLAR_CONTRACT, "get_active_tvl") (normalize /1e7, validate positive finite) and zigchainTvl(api) using queryContract for active_tvl (normalize /1e6, validate). Updated module.exports (added zigchain.tvl, replaced stellar.tvl binding), updated methodology, and set misrepresentedTokens: true.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped from RPC to chain and back,
Scaled numbers tidy, no more hack,
Soroban hummed, CosmWasm chimed,
Balances added, checks aligned,
A little rabbit’s patch — neatly packed.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description reproduces the repository template but leaves all new-listing fields blank without providing relevant information for this update. Add details about the changes made: explain that Stellar TVL was refactored to use Soroban directly and that ZigChain TVL support was added via CosmWasm contract queries.
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 (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly indicates the main change: adding ZigChain TVL support for DeFa, which aligns with the code changes that add zigchain TVL functionality.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

The adapter at projects/defa exports TVL:

stellar                   3.77 M
zigchain                  1.10 M

total                    4.87 M 

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

🤖 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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2f49f641-3564-4238-9b2c-381d3a2cd645

📥 Commits

Reviewing files that changed from the base of the PR and between 7f98555 and 1a30d39.

📒 Files selected for processing (1)
  • projects/defa/index.js

@llamabutler
Copy link
Copy Markdown

The adapter at projects/defa exports TVL:

stellar                   3.76 M
zigchain                  1.10 M

total                    4.87 M 

Copy link
Copy Markdown
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/defa/index.js (1)

44-65: Drop the stale tvl() helper while you’re here.

After switching the exports to stellarTvl / zigchainTvl, the old local helper is just dead code and still references removed getActiveTvl(). 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ce311f6-91be-40e4-a52a-5713cb82a6a9

📥 Commits

Reviewing files that changed from the base of the PR and between 1a30d39 and 41a555d.

📒 Files selected for processing (1)
  • projects/defa/index.js

@llamabutler
Copy link
Copy Markdown

The adapter at projects/defa exports TVL:

stellar                   3.77 M
zigchain                  1.10 M

total                    4.87 M 

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

🤖 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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa84033c-a00e-47b7-a5ba-da58619b44f0

📥 Commits

Reviewing files that changed from the base of the PR and between 41a555d and ffafbac.

📒 Files selected for processing (1)
  • projects/defa/index.js

@llamabutler
Copy link
Copy Markdown

The adapter at projects/defa exports TVL:

stellar                   3.77 M
zigchain                  1.10 M

total                    4.87 M 

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