Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ When touching transaction and position flows, validation MUST include all releva
35. **Monarch proxy boundary integrity**: server-side Monarch proxy routes must use server-only API key env vars and bounded `AbortController` timeouts on upstream fetches. Do not let Monarch GraphQL or metrics calls hang indefinitely, and do not reference `NEXT_PUBLIC_*` secrets in server authorization headers.
36. **Vault fallback and adapter-sentinel integrity**: treat `zeroAddress` as “no adapter” in all vault routing and transaction-critical paths, canonicalize vault query/cache identity by lowercase address plus chain, and when Monarch metadata is unavailable fail closed or return explicit unknown state instead of synthesizing empty vault data or assuming missing allocators/caps from absent indexed fields.
37. **Vault setup-state derivation integrity**: only infer “adapter missing”, “needs initialization”, or auto-advance setup states from resolved adapter/vault queries, never from undefined/loading/error values. When Monarch returns both active adapter addresses and adapter detail rows, merge the union by canonical address instead of letting one source replace the other.
38. **Morpho vault query schema integrity**: shared Morpho vault metadata/rate queries must only request fields confirmed on the live `Vault`/`VaultState` schema. Do not add speculative top-level fields to the registry query, and do not swallow schema errors in a way that turns the global vault registry into an empty success state.


### REQUIRED: Regression Rule Capture
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/account-identity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function AccountIdentity({
const [mounted, setMounted] = useState(false);
const toast = useStyledToast();
const { toggleAddressBookmark, isAddressBookmarked } = usePortfolioBookmarks();
const { vaultName, shortAddress } = useAddressLabel(address);
const { vaultName, shortAddress } = useAddressLabel(address, chainId);
const { data: ensName } = useEnsName({
address: address as `0x${string}`,
chainId: 1,
Expand Down
9 changes: 5 additions & 4 deletions src/data-sources/morpho-api/vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type ApiVault = {
id: number;
};
name: string;
avgApy?: number | null;
state: {
apy?: number | null;
totalAssets: string;
};
asset: {
Expand All @@ -49,7 +49,7 @@ type AllVaultsApiResponse = {
type VaultApysApiResponse = {
data?: {
vaults?: {
items?: Pick<ApiVault, 'address' | 'avgApy' | 'chain'>[];
items?: Pick<ApiVault, 'address' | 'chain' | 'state'>[];
};
Comment thread
antoncoding marked this conversation as resolved.
};
errors?: { message: string }[];
Expand Down Expand Up @@ -131,13 +131,14 @@ export const fetchMorphoVaultApys = async (vaults: VaultAddressByNetwork[]): Pro

for (const vault of items) {
const key = getVaultApyKey(vault.address, vault.chain.id);
if (vault.avgApy === null || vault.avgApy === undefined) {
const apy = vault.state.apy;
if (apy === null || apy === undefined) {
continue;
}
if (!requestedKeys.has(key)) {
continue;
}
apys.set(key, vault.avgApy);
apys.set(key, apy);
}

return apys;
Expand Down
5 changes: 3 additions & 2 deletions src/graphql/vault-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const allVaultsQuery = `
id
}
name
avgApy
state {
totalAssets
}
Expand All @@ -29,10 +28,12 @@ export const vaultApysQuery = `
vaults(first: $first, where: $where) {
items {
address
avgApy
chain {
id
}
state {
apy
}
}
}
}
Expand Down