Conversation
📝 WalkthroughWalkthroughNew Aptos TVL adapter module added at Changes
Sequence DiagramsequenceDiagram
participant TVL as TVL Calculator
participant OnChain as Aptos On-Chain
participant Indexer as Aptos Labs Indexer
TVL->>OnChain: call get_total_safes()
OnChain-->>TVL: safe count
TVL->>OnChain: call get_safes_range_info()
OnChain-->>TVL: safe list/details
TVL->>Indexer: query current_fungible_asset_balances (batched safe owners)
Indexer-->>TVL: fungible balances per safe
TVL->>OnChain: coin::balance<AptosCoin> per safe (concurrent)
OnChain-->>TVL: native APT balances
TVL->>OnChain: MOAR::pool::get_all_pools()
OnChain-->>TVL: pool list
TVL->>OnChain: MOAR::lens::get_lp_shares_and_deposited_amount(safe,pool) (concurrent)
OnChain-->>TVL: deposited amounts
TVL->>TVL: normalize & aggregate amounts
TVL->>TVL: api.add(token, amount) per asset
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 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/yield-ai 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/yield-ai/index.js`:
- Around line 424-429: The adapter exports currently omit the doublecounted
flag, causing higher-level aggregates to double-count Moar (already tracked
separately); update the exported object (module.exports) to include
doublecounted: true alongside timetravel and aptos (i.e., add the property
"doublecounted: true" within the module.exports object where timetravel, aptos,
and methodology are defined) so the adapter is marked as double-counted.
- Around line 352-365: The concurrent PromisePool call using
PromisePool.withConcurrency(...).for(safeAddresses).process(...) currently
ignores the returned result so any errors from function_view are swallowed;
update the call in projects/yield-ai/index.js to await the PromisePool.process()
return value, inspect the returned result.errors array (from the PromisePool
API) and handle non-empty errors by logging them (or rethrowing) so failures are
surfaced and stop/mark the run as partial; reference the
PromisePool.withConcurrency/.for/.process invocation and the async worker that
calls function_view/COIN_BALANCE_FN to locate where to capture and handle
result.errors.
🪄 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: eb2ef651-6e93-4163-ab37-f395103d1e7f
📒 Files selected for processing (1)
projects/yield-ai/index.js
|
The adapter at projects/yield-ai exports TVL: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
projects/yield-ai/index.js (1)
110-122: Minor edge case: scientific notation strings return incorrect values.If
vis a string like"1e10", the function returns"1"instead of"10000000000". While Aptos chain responses typically return raw integer strings making this unlikely in practice, consider handling this case for defensive robustness.♻️ Optional fix to handle scientific notation
function toIntegerString(v) { if (v == null) return null; if (typeof v === "bigint") return v.toString(); if (typeof v === "number") { if (!Number.isFinite(v)) return null; return BigInt(Math.trunc(v)).toString(); } const s = String(v).trim(); if (!s) return null; + // Handle scientific notation strings like "1e10" + if (/^-?\d+(\.\d+)?[eE][+-]?\d+$/.test(s)) { + const num = Number(s); + if (Number.isFinite(num)) return BigInt(Math.trunc(num)).toString(); + return null; + } const intPart = s.split(".")[0].split("e")[0].split("E")[0]; if (!/^-?\d+$/.test(intPart)) return null; return intPart; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@projects/yield-ai/index.js` around lines 110 - 122, The toIntegerString function mishandles numeric strings in scientific notation (e.g. "1e10"); update toIntegerString to detect when the trimmed input string s contains "e" or "E", parse it with Number(s) (ensure it's finite), convert to an integer via Math.trunc, then return BigInt(thatNumber).toString() (preserving sign); if that conversion fails or loses precision, fall back to the existing intPart validation logic using intPart and the /^\-?\d+$/ test. Locate this logic inside toIntegerString where s and intPart are defined.
🤖 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/yield-ai/index.js`:
- Around line 110-122: The toIntegerString function mishandles numeric strings
in scientific notation (e.g. "1e10"); update toIntegerString to detect when the
trimmed input string s contains "e" or "E", parse it with Number(s) (ensure it's
finite), convert to an integer via Math.trunc, then return
BigInt(thatNumber).toString() (preserving sign); if that conversion fails or
loses precision, fall back to the existing intPart validation logic using
intPart and the /^\-?\d+$/ test. Locate this logic inside toIntegerString where
s and intPart are defined.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c3a5bc1a-461b-4c7f-8788-83aa965efd36
📒 Files selected for processing (1)
projects/yield-ai/index.js
|
Implemented the requested changes: added doublecounted: true (Moar overlap) and now capture PromisePool.process() results for APT + Moar calls and throw if result.errors is non-empty to surface RPC/view failures. node test.js projects/yield-ai/index.js passes. |
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):
Yield AI
Twitter Link:
https://x.com/yieldai_app
List of audit links if any:
N/A
Website Link:
https://yieldai.app/
Logo (High resolution, will be shown with rounded borders):
PR to DefiLlama/icons: yield-ai.png (pending/merged). Temporary logo path for listing: https://icons.llama.fi/yield-ai.png
Current TVL:
~$700–$1.5k on Aptos at time of testing (varies with on-chain balances).
Treasury Addresses (if the protocol has treasury)
N/A
Chain:
Aptos
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed):
N/A
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed):
N/A
Short Description (to be shown on DefiLlama):
Yield AI is a DeFi dashboard for Aptos that integrates 10+ protocols and an AI Agent in one interface. Track balances and positions, compare APRs, and deposit, withdraw, swap, and claim rewards gaslessly — all to maximize your yield.
Token address and ticker if any:
N/A
Category (full list at https://defillama.com/categories) *Please choose only one:
AI Agents
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
N/A
Implementation Details: Briefly describe how the oracle is integrated into your project:
N/A
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
N/A
forkedFrom (Does your project originate from another project):
N/A
methodology (what is being counted as tvl, how is tvl being calculated):
TVL counts (1) fungible-asset balances held on Yield AI vault safe object addresses on Aptos (Aptos Labs indexer current_fungible_asset_balances, owner = safe), (2) native APT held in each safe’s CoinStore via 0x1::coin::balance<0x1::aptos_coin::AptosCoin> (native APT FA rows are skipped to avoid double counting), and (3) Moar Market supply positions attributed to each safe via 0xa3af...::pool::get_all_pools (paused pools excluded) and per (pool index, safe) 0xa3af...::lens::get_lp_shares_and_deposited_amount, adding the deposited underlying amount (response index 1) using each pool’s underlying_asset metadata (APT pool uses 0xa). Safes are enumerated using on-chain vault views get_total_safes / get_safes_range_info; only entries with exists == true are included (paused safes are included). Note: Moar is also listed separately on DefiLlama; maintainers may want to confirm how this overlap should be presented to avoid double counting in aggregate views.
No protocol backend/API is used; TVL is computed from Aptos on-chain views + Aptos Labs Indexer GraphQL for fungible balances.
Github org/user (Optional, if your code is open source, we can track activity):
N/A
Does this project have a referral program?
N/A
Summary by CodeRabbit