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
4 changes: 3 additions & 1 deletion src/data-sources/subgraph/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/features/markets/components/column-visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export type ColumnVisibility = {
rateAtTarget: boolean;
trustedBy: boolean;
utilizationRate: boolean;
dailySupplyAPY: boolean;
dailyBorrowAPY: boolean;
weeklySupplyAPY: boolean;
weeklyBorrowAPY: boolean;
monthlySupplyAPY: boolean;
Expand All @@ -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,
Expand All @@ -39,6 +43,8 @@ export const COLUMN_LABELS: Record<keyof ColumnVisibility, string> = {
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',
Expand All @@ -54,6 +60,8 @@ export const COLUMN_DESCRIPTIONS: Record<keyof ColumnVisibility, string> = {
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',
Expand Down
10 changes: 6 additions & 4 deletions src/features/markets/components/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Comment on lines +15 to +20
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

🧩 Analysis chain

🏁 Script executed:

rg -n --type=ts --type=tsx '\bSortColumn\b' -A 2 -B 2 | head -100

Repository: antoncoding/monarch

Length of output: 90


🏁 Script executed:

rg -n --type=ts --type=tsx '(localStorage|sessionStorage|URLSearchParams|query.*sort|sort.*query)' -A 2 -B 2

Repository: antoncoding/monarch

Length of output: 90


🏁 Script executed:

fd -e ts -e tsx | xargs grep -l "SortColumn" | head -20

Repository: antoncoding/monarch

Length of output: 351


🏁 Script executed:

cat -n src/stores/useMarketPreferences.ts

Repository: antoncoding/monarch

Length of output: 11807


🏁 Script executed:

cat -n src/features/markets/components/table/markets-table.tsx | head -150

Repository: antoncoding/monarch

Length of output: 6928


🏁 Script executed:

rg -n 'SortColumn' src/features/markets/components/table/market-table-utils.tsx -A 3 -B 1

Repository: antoncoding/monarch

Length of output: 392


🏁 Script executed:

cat -n src/features/markets/components/constants.ts | head -50

Repository: antoncoding/monarch

Length of output: 1429


🏁 Script executed:

git log --oneline -20 src/stores/useMarketPreferences.ts

Repository: antoncoding/monarch

Length of output: 127


🏁 Script executed:

git log --oneline -20 src/features/markets/components/constants.ts

Repository: antoncoding/monarch

Length of output: 127


🏁 Script executed:

rg -n 'sortColumn' src/hooks/useFilteredMarkets.ts -A 5 -B 5

Repository: antoncoding/monarch

Length of output: 1123


🏁 Script executed:

rg -n 'SortColumn\.' --type ts -C 2 | grep -E "(localStorage|persist|migrate)" -A 3 -B 3

Repository: antoncoding/monarch

Length of output: 312


Add migration for shifted SortColumn numeric values.

The enum shifts break persisted sort preferences in localStorage. Users with saved sortColumn: 16 (previously WeeklySupplyAPY) will now load as the new WeeklyBorrowAPY at position 16. The store has a migrate function but only handles customTagConfigsortColumn numeric shifts are not handled. Either keep existing enum IDs stable (append new Daily entries at the end), or bump the store version to 3 and add a migration that remaps old enum numbers to the correct new values.

🤖 Prompt for AI Agents
In `@src/features/markets/components/constants.ts` around lines 15 - 20, Bump the
store version to 3 and add a migration in the existing migrate function to remap
persisted numeric sortColumn values to the current enum IDs instead of relying
on the raw numbers; specifically, detect old values (e.g. the previous 14–19
set) in state.sortColumn and replace them with the current enum members
(DailySupplyAPY, DailyBorrowAPY, WeeklySupplyAPY, WeeklyBorrowAPY,
MonthlySupplyAPY, MonthlyBorrowAPY) from constants.ts so saved preferences point
to the correct column, and keep the existing customTagConfig migration logic
intact.

}

// Gas cost to simplify tx flow: do not need to estimate gas for transactions
Expand Down
24 changes: 24 additions & 0 deletions src/features/markets/components/table/market-table-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down Expand Up @@ -233,6 +235,28 @@ export function MarketTableBody({ currentEntries, expandedRowId, setExpandedRowI
<p className="text-sm">{`${(item.state.utilization * 100).toFixed(2)}%`}</p>
</TableCell>
)}
{columnVisibility.dailySupplyAPY && (
<TableCell
data-label="24h Supply"
className="z-50 text-center"
style={{ minWidth: '85px', paddingLeft: 3, paddingRight: 3 }}
>
<p className="text-sm">
{item.state.dailySupplyApy != null ? <RateFormatted value={item.state.dailySupplyApy} /> : '—'}
</p>
</TableCell>
)}
{columnVisibility.dailyBorrowAPY && (
<TableCell
data-label="24h Borrow"
className="z-50 text-center"
style={{ minWidth: '85px', paddingLeft: 3, paddingRight: 3 }}
>
<p className="text-sm">
{item.state.dailyBorrowApy != null ? <RateFormatted value={item.state.dailyBorrowApy} /> : '—'}
</p>
</TableCell>
)}
{columnVisibility.weeklySupplyAPY && (
<TableCell
data-label="7d Supply"
Expand Down
18 changes: 18 additions & 0 deletions src/features/markets/components/table/markets-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,24 @@ function MarketsTable({ currentPage, setCurrentPage, className, tableClassName,
targetColumn={SortColumn.UtilizationRate}
/>
)}
{columnVisibility.dailySupplyAPY && (
<HTSortable
label="24h Supply"
sortColumn={sortColumn}
titleOnclick={titleOnclick}
sortDirection={sortDirection}
targetColumn={SortColumn.DailySupplyAPY}
/>
)}
{columnVisibility.dailyBorrowAPY && (
<HTSortable
label="24h Borrow"
sortColumn={sortColumn}
titleOnclick={titleOnclick}
sortDirection={sortDirection}
targetColumn={SortColumn.DailyBorrowAPY}
/>
)}
{columnVisibility.weeklySupplyAPY && (
<HTSortable
label="7d Supply"
Expand Down
4 changes: 4 additions & 0 deletions src/graphql/morpho-api-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ state {
timestamp
apyAtTarget
rateAtTarget
dailySupplyApy
dailyBorrowApy
weeklySupplyApy
weeklyBorrowApy
monthlySupplyApy
Expand Down Expand Up @@ -220,6 +222,8 @@ export const marketsQuery = `
timestamp
apyAtTarget
rateAtTarget
dailySupplyApy
dailyBorrowApy
weeklySupplyApy
weeklyBorrowApy
monthlySupplyApy
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useFilteredMarkets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export const useFilteredMarkets = (): Market[] => {
[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',
Expand Down
4 changes: 3 additions & 1 deletion src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down