Skip to content

feat: adapter alias#509

Merged
antoncoding merged 1 commit into
masterfrom
feat/adapter-alias
May 1, 2026
Merged

feat: adapter alias#509
antoncoding merged 1 commit into
masterfrom
feat/adapter-alias

Conversation

@antoncoding
Copy link
Copy Markdown
Owner

@antoncoding antoncoding commented May 1, 2026

Summary by CodeRabbit

  • New Features

    • Added support for vault adapter aliases to enable more flexible vault identification and improved labeling.
    • Introduced new address labeling functionality to enhance vault and adapter name resolution across the app.
  • Improvements

    • Optimized address lookup performance for faster vault and adapter identification.
    • Updated market charts to accurately display vault and adapter names for borrowers and suppliers.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monarch Ready Ready Preview, Comment May 1, 2026 8:10am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

The changes extend the vault address resolution system by adding support for vault adapter aliases. The VaultRegistryContext now fetches adapter alias data and exposes a getAddressLabel API that returns labels for both direct vaults and adapter-mapped addresses. Multiple chart components and hooks are updated to use this new API with chainId awareness.

Changes

Cohort / File(s) Summary
Vault Registry Core
src/contexts/VaultRegistryContext.tsx, src/data-sources/monarch-api/index.ts, src/data-sources/monarch-api/vaults.ts
Added vault adapter alias fetching with GraphQL query and transformation logic; new getAddressLabel API supporting both vaults and adapters; optimized address resolution using chainId-aware lookup maps; combined loading/error states from vaults and adapter-alias queries.
Query & Utility Hooks
src/hooks/queries/useVaultAdapterAliasesQuery.ts, src/hooks/useAddressLabel.ts
New query hook for adapter aliases with 10-minute stale/30-minute GC timings; updated useAddressLabel to use getAddressLabel API with chainId parameter and broader documentation scope.
Chart Components
src/features/market-detail/components/charts/borrowers-pie-chart.tsx, src/features/market-detail/components/charts/supplier-positions-chart.tsx, src/features/market-detail/components/charts/suppliers-pie-chart.tsx
Migrated display-name resolution from vault lookups to getAddressLabel with chainId support; added memoized useCallback for name resolution logic.

Sequence Diagram

sequenceDiagram
    participant Component as Chart Component
    participant Context as VaultRegistryContext
    participant MonarchAPI as Monarch API
    participant Cache as Computed Maps<br/>(chainId:address)

    Component->>Context: getAddressLabel(address, chainId)
    
    alt chainId provided
        Context->>Cache: lookup in precomputed map
        Cache-->>Context: AddressLabel or undefined
    else no chainId
        Context->>Cache: search across all addresses
        Cache-->>Context: AddressLabel or undefined
    end
    
    Context-->>Component: AddressLabel with displayName
    Component->>Component: render displayName or fallback
    
    Note over Context,MonarchAPI: On context load:
    Context->>MonarchAPI: fetchMonarchVaults()
    Context->>MonarchAPI: fetchMonarchVaultAdapterAliases()
    MonarchAPI-->>Context: vaults[], adapters[]
    Context->>Cache: build chainId:address lookup maps
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • fix: vault history #479: Adds Monarch adapter lookup functionality affecting the same adapter-resolution APIs and data sources.
  • fix: label #460: Modifies address-label resolution to be chain-aware, paralleling the chainId parameter added here.
  • feat: label vault #220: Introduced the original useAddressLabel hook and vault registry patterns that this PR extends.

Suggested labels

feature request, ui

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: adapter alias' accurately reflects the main change—adding adapter alias support to the vault registry and related components.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adapter-alias

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added feature request Specific feature ready to be implemented ui User interface labels May 1, 2026
Copy link
Copy Markdown

@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 `@src/data-sources/monarch-api/vaults.ts`:
- Around line 362-399: The catch in fetchMonarchVaultAdapterAliases currently
swallows failures by returning [] — instead log the error (keep the
console.warn) and then rethrow a normalized/typed error so callers (e.g., React
Query) can surface the failure; specifically, replace the "return []" in
fetchMonarchVaultAdapterAliases's catch with throwing a new application-level
error (wrapping the original error from monarchGraphqlFetcher) or rethrowing the
original after normalization, ensuring the thrown error includes context like
"Failed fetching Monarch adapter aliases" and the original error details.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4aa5f985-7ca5-473f-92fb-7ff9baed366a

📥 Commits

Reviewing files that changed from the base of the PR and between 7189039 and be77830.

📒 Files selected for processing (8)
  • src/contexts/VaultRegistryContext.tsx
  • src/data-sources/monarch-api/index.ts
  • src/data-sources/monarch-api/vaults.ts
  • src/features/market-detail/components/charts/borrowers-pie-chart.tsx
  • src/features/market-detail/components/charts/supplier-positions-chart.tsx
  • src/features/market-detail/components/charts/suppliers-pie-chart.tsx
  • src/hooks/queries/useVaultAdapterAliasesQuery.ts
  • src/hooks/useAddressLabel.ts

Comment on lines +362 to +399
export const fetchMonarchVaultAdapterAliases = async (): Promise<VaultAdapterAlias[]> => {
try {
const aliases: VaultAdapterAlias[] = [];
const seenKeys = new Set<string>();

for (let page = 0; page < MONARCH_ADAPTER_ALIAS_MAX_PAGES; page++) {
const response = await monarchGraphqlFetcher<MonarchAdapterAliasesResponse>(adapterAliasesQuery, {
adapterTypes: MORPHO_MARKET_ADAPTER_TYPES,
limit: MONARCH_ADAPTER_ALIAS_PAGE_SIZE,
offset: page * MONARCH_ADAPTER_ALIAS_PAGE_SIZE,
});

const records = response.data?.Adapter ?? [];
for (const record of records) {
const alias = transformAdapterAliasRecord(record);
if (!alias) {
continue;
}

const key = `${alias.chainId}:${alias.address}`;
if (seenKeys.has(key)) {
continue;
}

seenKeys.add(key);
aliases.push(alias);
}

if (records.length < MONARCH_ADAPTER_ALIAS_PAGE_SIZE) {
break;
}
}

return aliases;
} catch (error) {
console.warn('Error fetching Monarch vault adapter aliases:', error);
return [];
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don't hide Monarch alias fetch failures behind an empty list.

Returning [] from the catch block makes the alias source look healthy even when the query is broken, so consumers silently fall back to short addresses and the registry never sees an error. Let the request reject after logging so React Query can surface the failure.

Small fix
 } catch (error) {
   console.warn('Error fetching Monarch vault adapter aliases:', error);
-  return [];
+  throw error;
 }
As per coding guidelines, handle errors appropriately with try-catch blocks and normalize remote errors into typed app errors.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/data-sources/monarch-api/vaults.ts` around lines 362 - 399, The catch in
fetchMonarchVaultAdapterAliases currently swallows failures by returning [] —
instead log the error (keep the console.warn) and then rethrow a
normalized/typed error so callers (e.g., React Query) can surface the failure;
specifically, replace the "return []" in fetchMonarchVaultAdapterAliases's catch
with throwing a new application-level error (wrapping the original error from
monarchGraphqlFetcher) or rethrowing the original after normalization, ensuring
the thrown error includes context like "Failed fetching Monarch adapter aliases"
and the original error details.

@antoncoding antoncoding merged commit 55e08b1 into master May 1, 2026
4 checks passed
@antoncoding antoncoding deleted the feat/adapter-alias branch May 1, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Specific feature ready to be implemented ui User interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant