Skip to content

feat: update TVL calculation to include migrated ethereum and bnb chain#20003

Open
gauthampharish-brine wants to merge 12 commits into
DefiLlama:mainfrom
gauthampharish-brine:main
Open

feat: update TVL calculation to include migrated ethereum and bnb chain#20003
gauthampharish-brine wants to merge 12 commits into
DefiLlama:mainfrom
gauthampharish-brine:main

Conversation

@gauthampharish-brine

@gauthampharish-brine gauthampharish-brine commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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 Please send a mail to metadata@defillama.com

  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): Multipli.fi
Twitter Link:
List of audit links if any:
Website Link:https://app.multipli.fi/
Logo (High resolution, will be shown with rounded borders):
Current TVL: 55.26 Million
Treasury Addresses (if the protocol has treasury)
Chain: Ethereum ,Bsc ,Monad,Avalanche
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
    • Expanded TVL coverage to include the Pharos chain.
    • Added vault-based TVL aggregation to improve completeness and accuracy.
  • Bug Fixes
    • Updated token blacklist handling and normalized address casing to ensure exclusions are applied consistently.
    • Improved TVL consolidation by merging vault results with externally sourced balances (for supported v1 chains) while avoiding duplicate counting.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Multipli TVL computation now caches the external aggregator payload, aggregates configured vault assets through on-chain calls, adds non-blacklisted v1 balances, and exports the pharos chain.

Changes

Multipli TVL aggregation

Layer / File(s) Summary
TVL source configuration
projects/multipli/index.js
Blacklist mappings, vault contract lists, and the v1 API chain list are updated.
Cached payload loading
projects/multipli/index.js
A lazy helper fetches, caches, and reuses the external aggregator payload, resetting the cache on errors.
Balance aggregation and chain wiring
projects/multipli/index.js
TVL queries configured vaults, adds non-blacklisted vault and v1 payload balances, returns adapter balances, and exports pharos.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant tvl
  participant api
  participant VaultContracts
  participant getApiPayload
  tvl->>api: multiCall vault assets and totalAssets
  api->>VaultContracts: query configured vaults
  VaultContracts-->>api: return vault data
  tvl->>api: add non-blacklisted vault balances
  tvl->>getApiPayload: request v1 payload balances
  getApiPayload-->>tvl: return cached payload
  tvl->>api: add non-blacklisted v1 balances
  api-->>tvl: return getBalances()
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The template is only partially filled; many required new-listing fields such as Twitter, logo, category, methodology, and documentation are still blank. Fill in the missing new-listing sections, especially Twitter, logo, short description, category, methodology, oracle/docs, and token details.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main change: updating Multipli's TVL calculation for migrated Ethereum and BNB Chain assets.
✨ 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.

@github-actions

Copy link
Copy Markdown

The adapter at projects/multipli exports TVL:

ethereum                  52.93 M
bsc                       2.31 M
avax                      13.36 k
monad                     6.13 k
base                      0.00
arbitrum                  0.00
pharos                    0.00

total                    55.26 M 

@gauthampharish-brine gauthampharish-brine marked this pull request as draft July 13, 2026 05:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@projects/multipli/index.js`:
- Around line 35-39: Update getApiPayload so a rejected API request clears the
shared apiPayload variable before propagating the error, allowing subsequent
calls to retry while preserving the existing promise reuse for successful or
pending requests.
🪄 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: db07130d-aa15-40b4-8d10-32943f7414fa

📥 Commits

Reviewing files that changed from the base of the PR and between ecc5f22 and 96de56c.

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

Comment thread projects/multipli/index.js
@gauthampharish-brine gauthampharish-brine marked this pull request as ready for review July 13, 2026 06:19
@github-actions

Copy link
Copy Markdown

The adapter at projects/multipli exports TVL:

ethereum                  52.93 M
bsc                       2.31 M
avax                      13.36 k
monad                     6.13 k
base                      0.00
arbitrum                  0.00
pharos                    0.00

total                    55.26 M 

@gauthampharish-brine gauthampharish-brine marked this pull request as draft July 14, 2026 07:41
@github-actions

Copy link
Copy Markdown

The adapter at projects/multipli exports TVL:

ethereum                  59.15 M
bsc                       3.52 M
avax                      13.37 k
monad                     9.69 k
base                      0.00
arbitrum                  0.00
pharos                    0.00

total                    62.69 M 

@gauthampharish-brine gauthampharish-brine marked this pull request as ready for review July 14, 2026 12:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

49-74: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Avoid coercing undefined to a string.

When rwaUSDis[api.chain] is undefined (e.g., for bsc or avax), the template literal evaluates to "bsc:undefined". While this safely bypasses the equality checks in this specific context without causing bugs, coercing undefined to a string inside a template literal is generally an anti-pattern.

Consider conditionally defining blacklisted to improve clarity.

🛠️ Proposed refactor
 const tvl = async (api) => {
-  const blacklisted = `${api.chain}:${rwaUSDis[api.chain]}`.toLowerCase()
+  const rwaAddress = rwaUSDis[api.chain]
+  const blacklisted = rwaAddress ? `${api.chain}:${rwaAddress}`.toLowerCase() : null
 
   // v2: on-chain vault balances
   const chainVaults = vaults[api.chain] ?? []
   if (chainVaults.length) {
     const [assets, totalAssets] = await Promise.all([
       api.multiCall({ abi: 'address:asset', calls: chainVaults }),
       api.multiCall({ abi: 'uint256:totalAssets', calls: chainVaults }),
     ])
     assets.forEach((asset, i) => {
-      if (`${api.chain}:${asset.toLowerCase()}` === blacklisted) return
+      if (blacklisted && `${api.chain}:${asset.toLowerCase()}` === blacklisted) return
       api.add(asset, totalAssets[i])
     })
   }
 
   // v1: API payload, only counted on chains where v1 users remain
   if (v1Chains.has(api.chain)) {
     const balances = (await getApiPayload())[api.chain] ?? {}
     Object.entries(balances).forEach(([key, balance]) => {
       if (key.toLowerCase() !== blacklisted) api.addBalances({ [key]: balance })
     })
   }
 
   return api.getBalances()
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/multipli/index.js` around lines 49 - 74, Update the blacklisted
value initialization in tvl so it is only defined when rwaUSDis[api.chain]
exists, avoiding template-literal coercion of undefined. Preserve the existing
case-insensitive blacklist comparisons by conditionally constructing the
chain/address string and handling chains without a configured blacklist as
having no match.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@projects/multipli/index.js`:
- Around line 49-74: Update the blacklisted value initialization in tvl so it is
only defined when rwaUSDis[api.chain] exists, avoiding template-literal coercion
of undefined. Preserve the existing case-insensitive blacklist comparisons by
conditionally constructing the chain/address string and handling chains without
a configured blacklist as having no match.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f8777850-bcc9-4812-94b6-2eb0a48cc174

📥 Commits

Reviewing files that changed from the base of the PR and between 0131d0e and 0e047d7.

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

@github-actions

Copy link
Copy Markdown

The adapter at projects/multipli exports TVL:

ethereum                  59.28 M
bsc                       3.54 M
avax                      13.38 k
monad                     9.69 k
base                      0.00
arbitrum                  0.00
pharos                    0.00

total                    62.84 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.

1 participant