Skip to content

fix(term-structure): track StableERC4626ForCustomize vaults and fix Gnosis Safe TVL#18713

Open
tkspring-henry wants to merge 2 commits intoDefiLlama:mainfrom
tkspring-henry:fix/term-structure-4626-tvl
Open

fix(term-structure): track StableERC4626ForCustomize vaults and fix Gnosis Safe TVL#18713
tkspring-henry wants to merge 2 commits intoDefiLlama:mainfrom
tkspring-henry:fix/term-structure-4626-tvl

Conversation

@tkspring-henry
Copy link
Copy Markdown
Contributor

@tkspring-henry tkspring-henry commented Apr 10, 2026

Summary

  • Add new TermMax4626Factory (0x3Cc88...) on Ethereum (fromBlock 24790495)
  • Track StableERC4626ForCustomizeCreated event to capture customize vaults (e.g. XAUt vault)
  • Fix TVL calculation for vaults where thirdPool is a Gnosis Safe instead of an ERC20 token, by adding [underlying, thirdPool] fallback with permitFailure

Test plan

  • Verified XAUt ($19.87k) now appears in Ethereum TVL
  • Confirmed no double-counting with Morpho-backed vaults (e.g. gtUSDC)
  • Total Ethereum TVL: $23.95M (previously $23.93M)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Detects and tracks additional stable vaults created via factory events across supported chains.
  • Improvements

    • More accurate TVL calculation for stable vaults with two-phase token/owner aggregation.
    • Improved fallback handling for non-standard pool contracts to ensure assets are included in TVL.

…6 factory

- Track new TermMax4626Factory 0x3Cc88...on Ethereum (fromBlock 24790495)
- Add StableERC4626ForCustomizeCreated event to capture customize vaults (e.g. XAUt)
- Fix TVL for vaults where thirdPool is a Gnosis Safe (not ERC20) by adding
  [underlying, thirdPool] fallback with permitFailure

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

coderabbitai bot commented Apr 10, 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: 227af5c3-1f9e-4096-b907-aee7e498cad6

📥 Commits

Reviewing files that changed from the base of the PR and between d86f488 and 03b218a.

📒 Files selected for processing (1)
  • projects/term-structure/index.js

📝 Walkthrough

Walkthrough

Added event parsing for StableERC4626ForCustomizeCreated to discover additional stable ERC-4626 vaults from TermMax4626Factory; refactored TVL aggregation to maintain dedicated stable token/owner pairs and a fallback path when thirdPool is not ERC-20-like, invoking primary and fallback sumTokens2 calls.

Changes

Cohort / File(s) Summary
Stable ERC4626 Vault Discovery
projects/term-structure/index.js
Added StableERC4626ForCustomizeCreated event ABI and appended a new TermMax4626Factory entry (address + fromBlock) to the Ethereum scan list; extended vault discovery to include stableERC4626ForCustomize addresses from factory logs.
TVL Aggregation & Fallbacks
projects/term-structure/index.js
Split token/owner aggregation into stableTokensAndOwners and stableFallbackTokensAndOwners; added thirdPoolSupplies read with permitFailure: true to detect non-ERC20 thirdPool instances and route those to fallback pairs; runs primary and fallback sumTokens2 collections.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant API as API
    participant EthNode as Ethereum Node
    participant Factory as TermMax4626Factory (events)
    participant Vault as StableERC4626 Vaults
    participant TVL as sumTokens2

    rect rgba(0,128,0,0.5)
    API->>EthNode: fetch TermMax4626Factory logs (StableERC4626ForCustomizeCreated)
    EthNode-->>API: logs with stableERC4626ForCustomize addresses
    end

    rect rgba(0,0,255,0.5)
    API->>Vault: read underlying & thirdPool for each stable vault
    Vault-->>API: returns stableUnderlyings[], thirdPools[]
    end

    rect rgba(255,165,0,0.5)
    API->>EthNode: batch call thirdPool.totalSupply (permitFailure: true)
    EthNode-->>API: thirdPoolSupplies[] (some null if non-ERC20)
    end

    rect rgba(128,0,128,0.5)
    API->>TVL: call sumTokens2 with stableTokensAndOwners (primary)
    API->>TVL: call sumTokens2 with stableFallbackTokensAndOwners (fallback for null supplies)
    TVL-->>API: aggregated TVL
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through logs at break of day,
Found vaults that quietly hide away.
For pools that balk at ERC‑20 play,
I leave a fallback path to save the day.
🥕🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
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.
Description check ❓ Inconclusive The PR description provides a clear summary of changes with test results, but does not follow the repository's template format. While the description is informative, it does not follow the standardized template. Consider formatting with template sections for consistency with repository guidelines.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: tracking StableERC4626ForCustomize vaults and fixing Gnosis Safe TVL calculation.

✏️ 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.

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: 1

🤖 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/term-structure/index.js`:
- Around line 629-640: The current code always adds both [thirdPool, vault] and
the fallback [underlying, thirdPool], which double-counts when thirdPool is a
normal ERC20; instead, split the primary and fallback paths: build and sum the
primary tokensAndOwners array (push [stableUnderlyings[i], vault] and
[thirdPools[i], vault]) and call sumTokens2({ api, tokensAndOwners }) for that;
then probe each thirdPool for ERC20 compliance (e.g., try an ERC20 call such as
'erc20:decimals' or another small ERC20 ABI call using api.call/api.multiCall)
and only for those thirdPools where the ERC20 probe fails push
[stableUnderlyings[i], thirdPools[i]] into a separate fallback array and call
sumTokens2({ api, tokensAndOwners: fallbackArray, permitFailure: true }). Ensure
you reference stableERC4626For4626Vaults, stableUnderlyings, thirdPools,
stableTokensAndOwners, and sumTokens2 when making these changes.
🪄 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: 06cb0a53-2568-41be-9951-fdf097e93323

📥 Commits

Reviewing files that changed from the base of the PR and between ecb3b3e and d86f488.

📒 Files selected for processing (1)
  • projects/term-structure/index.js

…oid double counting

Use totalSupply probe to distinguish ERC20 thirdPools from Gnosis Safes,
so normal stable vaults don't run under permitFailure and fallback path
only applies to non-ERC20 thirdPools.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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