From 52e4f75eec31eb8915c4a2bc63777ca4781bb381 Mon Sep 17 00:00:00 2001 From: starksama <257340800+starksama@users.noreply.github.com> Date: Sat, 31 Jan 2026 19:14:38 +0800 Subject: [PATCH] feat(markets): add daily APY columns (24h supply/borrow) Add dailySupplyApy and dailyBorrowApy fields following the exact pattern from PR #355 (weekly/monthly APY). Changes: - GraphQL: add dailySupplyApy, dailyBorrowApy to state query - Types: add nullable daily APY fields to Market.state - Column visibility: add 24h Supply APY and 24h Borrow APY columns (off by default) - Sort: add DailySupplyAPY and DailyBorrowAPY sort columns - Table: add sortable headers and cells with null handling - Subgraph fallback: return null for daily APY (not supported) --- src/data-sources/subgraph/market.ts | 4 +++- .../markets/components/column-visibility.ts | 8 +++++++ src/features/markets/components/constants.ts | 10 ++++---- .../components/table/market-table-body.tsx | 24 +++++++++++++++++++ .../components/table/markets-table.tsx | 18 ++++++++++++++ src/graphql/morpho-api-queries.ts | 4 ++++ src/hooks/useFilteredMarkets.ts | 2 ++ src/utils/types.ts | 4 +++- 8 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/data-sources/subgraph/market.ts b/src/data-sources/subgraph/market.ts index 1f51e129..6cd56eac 100644 --- a/src/data-sources/subgraph/market.ts +++ b/src/data-sources/subgraph/market.ts @@ -188,7 +188,9 @@ const transformSubgraphMarketToMarket = ( timestamp, apyAtTarget: 0, rateAtTarget: '0', - // Subgraph doesn't support weekly/monthly APY - return null + // Subgraph doesn't support daily/weekly/monthly APY - return null + dailySupplyApy: null, + dailyBorrowApy: null, weeklySupplyApy: null, weeklyBorrowApy: null, monthlySupplyApy: null, diff --git a/src/features/markets/components/column-visibility.ts b/src/features/markets/components/column-visibility.ts index d6cf8aed..51200f35 100644 --- a/src/features/markets/components/column-visibility.ts +++ b/src/features/markets/components/column-visibility.ts @@ -9,6 +9,8 @@ export type ColumnVisibility = { rateAtTarget: boolean; trustedBy: boolean; utilizationRate: boolean; + dailySupplyAPY: boolean; + dailyBorrowAPY: boolean; weeklySupplyAPY: boolean; weeklyBorrowAPY: boolean; monthlySupplyAPY: boolean; @@ -24,6 +26,8 @@ export const DEFAULT_COLUMN_VISIBILITY: ColumnVisibility = { rateAtTarget: false, trustedBy: false, utilizationRate: false, + dailySupplyAPY: false, + dailyBorrowAPY: false, weeklySupplyAPY: false, weeklyBorrowAPY: false, monthlySupplyAPY: false, @@ -39,6 +43,8 @@ export const COLUMN_LABELS: Record = { rateAtTarget: 'Target Rate', trustedBy: 'Trusted By', utilizationRate: 'Utilization', + dailySupplyAPY: '24h Supply APY', + dailyBorrowAPY: '24h Borrow APY', weeklySupplyAPY: '7d Supply APY', weeklyBorrowAPY: '7d Borrow APY', monthlySupplyAPY: '30d Supply APY', @@ -54,6 +60,8 @@ export const COLUMN_DESCRIPTIONS: Record = { rateAtTarget: 'Interest rate at target utilization', trustedBy: 'Highlights your trusted vaults that currently supply this market', utilizationRate: 'Percentage of supplied assets currently borrowed', + dailySupplyAPY: '24-hour average supply APY', + dailyBorrowAPY: '24-hour average borrow APY', weeklySupplyAPY: '7-day average supply APY', weeklyBorrowAPY: '7-day average borrow APY', monthlySupplyAPY: '30-day average supply APY', diff --git a/src/features/markets/components/constants.ts b/src/features/markets/components/constants.ts index d8f40472..c325ae33 100644 --- a/src/features/markets/components/constants.ts +++ b/src/features/markets/components/constants.ts @@ -12,10 +12,12 @@ export enum SortColumn { TrustedBy = 11, UtilizationRate = 12, Trend = 13, - WeeklySupplyAPY = 14, - WeeklyBorrowAPY = 15, - MonthlySupplyAPY = 16, - MonthlyBorrowAPY = 17, + DailySupplyAPY = 14, + DailyBorrowAPY = 15, + WeeklySupplyAPY = 16, + WeeklyBorrowAPY = 17, + MonthlySupplyAPY = 18, + MonthlyBorrowAPY = 19, } // Gas cost to simplify tx flow: do not need to estimate gas for transactions diff --git a/src/features/markets/components/table/market-table-body.tsx b/src/features/markets/components/table/market-table-body.tsx index 9f683f3b..8d79e8fa 100644 --- a/src/features/markets/components/table/market-table-body.tsx +++ b/src/features/markets/components/table/market-table-body.tsx @@ -45,6 +45,8 @@ export function MarketTableBody({ currentEntries, expandedRowId, setExpandedRowI (columnVisibility.rateAtTarget ? 1 : 0) + (columnVisibility.trustedBy ? 1 : 0) + (columnVisibility.utilizationRate ? 1 : 0) + + (columnVisibility.dailySupplyAPY ? 1 : 0) + + (columnVisibility.dailyBorrowAPY ? 1 : 0) + (columnVisibility.weeklySupplyAPY ? 1 : 0) + (columnVisibility.weeklyBorrowAPY ? 1 : 0) + (columnVisibility.monthlySupplyAPY ? 1 : 0) + @@ -233,6 +235,28 @@ export function MarketTableBody({ currentEntries, expandedRowId, setExpandedRowI

{`${(item.state.utilization * 100).toFixed(2)}%`}

)} + {columnVisibility.dailySupplyAPY && ( + +

+ {item.state.dailySupplyApy != null ? : '—'} +

+
+ )} + {columnVisibility.dailyBorrowAPY && ( + +

+ {item.state.dailyBorrowApy != null ? : '—'} +

+
+ )} {columnVisibility.weeklySupplyAPY && ( )} + {columnVisibility.dailySupplyAPY && ( + + )} + {columnVisibility.dailyBorrowAPY && ( + + )} {columnVisibility.weeklySupplyAPY && ( { [SortColumn.TrustedBy]: '', [SortColumn.UtilizationRate]: 'state.utilization', [SortColumn.Trend]: '', // Trend is a filter mode, not a sort + [SortColumn.DailySupplyAPY]: 'state.dailySupplyApy', + [SortColumn.DailyBorrowAPY]: 'state.dailyBorrowApy', [SortColumn.WeeklySupplyAPY]: 'state.weeklySupplyApy', [SortColumn.WeeklyBorrowAPY]: 'state.weeklyBorrowApy', [SortColumn.MonthlySupplyAPY]: 'state.monthlySupplyApy', diff --git a/src/utils/types.ts b/src/utils/types.ts index fd3654a9..de641581 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -322,7 +322,9 @@ export type Market = { apyAtTarget: number; rateAtTarget: string; - // Weekly and monthly APY averages (may be null for new markets or backup subgraph) + // Daily, weekly and monthly APY averages (may be null for new markets or backup subgraph) + dailySupplyApy: number | null; + dailyBorrowApy: number | null; weeklySupplyApy: number | null; weeklyBorrowApy: number | null; monthlySupplyApy: number | null;