feat: update TVL calculation to include migrated ethereum and bnb chain#20003
feat: update TVL calculation to include migrated ethereum and bnb chain#20003gauthampharish-brine wants to merge 12 commits into
Conversation
…ontract-calls feat: update TVL calculation to include migrated ethereum and bnb chain
📝 WalkthroughWalkthroughMultipli TVL computation now caches the external aggregator payload, aggregates configured vault assets through on-chain calls, adds non-blacklisted v1 balances, and exports the ChangesMultipli TVL aggregation
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()
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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/multipli exports TVL: |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
projects/multipli/index.js
|
The adapter at projects/multipli exports TVL: |
|
The adapter at projects/multipli exports TVL: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
projects/multipli/index.js (1)
49-74: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAvoid coercing
undefinedto a string.When
rwaUSDis[api.chain]isundefined(e.g., forbscoravax), the template literal evaluates to"bsc:undefined". While this safely bypasses the equality checks in this specific context without causing bugs, coercingundefinedto a string inside a template literal is generally an anti-pattern.Consider conditionally defining
blacklistedto 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
📒 Files selected for processing (1)
projects/multipli/index.js
|
The adapter at projects/multipli 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 Please send a mail to metadata@defillama.com
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): 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