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: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

.codexrc
# dependencies
/node_modules

Expand Down Expand Up @@ -54,4 +54,4 @@ next-env.d.ts
CLAUDE.md
FULLAUTO_CONTEXT.md

.claude/settings.local.json
.claude/settings.local.json
32 changes: 32 additions & 0 deletions src/components/shared/estimated-value-tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { ReactNode } from 'react';
import { Tooltip } from '@/components/ui/tooltip';
import { TooltipContent } from '@/components/shared/tooltip-content';
import { cn } from '@/utils/components';

type EstimatedValueTooltipProps = {
children: ReactNode;
isEstimated: boolean;
detail?: string;
className?: string;
};

const DEFAULT_DETAIL = 'This USD value is estimated using a hardcoded price.';

export function EstimatedValueTooltip({ children, isEstimated, detail = DEFAULT_DETAIL, className }: EstimatedValueTooltipProps) {
if (!isEstimated) {
return <>{children}</>;
}

return (
<Tooltip
content={
<TooltipContent
title="Estimated value"
detail={detail}
/>
}
>
<span className={cn('cursor-help underline decoration-dotted underline-offset-2', className)}>{children}</span>
</Tooltip>
);
}
3 changes: 1 addition & 2 deletions src/data-sources/subgraph/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getSubgraphUrl } from '@/utils/subgraph-urls';
import { blacklistTokens, type ERC20Token, findToken, type UnknownERC20Token, TokenPeg } from '@/utils/tokens';
import { fetchMajorPrices, type MajorPrices } from '@/utils/majorPrices';
import type { Market, MarketWarning } from '@/utils/types';
import { SUBGRAPH_NO_PRICE, UNRECOGNIZED_COLLATERAL, UNRECOGNIZED_LOAN } from '@/utils/warnings';
import { UNRECOGNIZED_COLLATERAL, UNRECOGNIZED_LOAN } from '@/utils/warnings';
import { subgraphGraphqlFetcher } from './fetchers';

// Helper to safely parse BigDecimal/BigInt strings
Expand Down Expand Up @@ -104,7 +104,6 @@ const transformSubgraphMarketToMarket = (
if (knownCollateralAsset) {
collateralAssetPrice = getEstimateValue(knownCollateralAsset) ?? 0;
}
warnings.push(SUBGRAPH_NO_PRICE);
}

const supplyAssetsUsd = formatBalance(supplyAssets, loanAsset.decimals) * loanAssetPrice;
Expand Down
7 changes: 6 additions & 1 deletion src/features/markets/components/table/market-row-detail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Info } from '@/components/Info/info';
import { EstimatedValueTooltip } from '@/components/shared/estimated-value-tooltip';
import { OracleTypeInfo } from '@/features/markets/components/oracle';
import { useMarketWarnings } from '@/hooks/useMarketWarnings';
import { formatReadable } from '@/utils/balance';
Expand Down Expand Up @@ -30,7 +31,11 @@ export function ExpandedMarketDetail({ market }: { market: Market }) {
</div>
<div className="mb-1 flex items-start justify-between">
<p className="font-inter text-sm opacity-80">Available Liquidity</p>
<p className="text-right font-zen text-sm">{formatReadable(Number(market.state.liquidityAssetsUsd))}</p>
<p className="text-right font-zen text-sm">
<EstimatedValueTooltip isEstimated={!market.hasUSDPrice}>
{formatReadable(Number(market.state.liquidityAssetsUsd))}
</EstimatedValueTooltip>
</p>
</div>
<div className="mb-1 flex items-start justify-between">
<p className="font-inter text-sm opacity-80">Utilization Rate</p>
Expand Down
3 changes: 3 additions & 0 deletions src/features/markets/components/table/market-table-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export function MarketTableBody({ currentEntries, expandedRowId, setExpandedRowI
assets={item.state.supplyAssets}
decimals={item.loanAsset.decimals}
symbol={item.loanAsset.symbol}
isEstimated={!item.hasUSDPrice}
/>
)}
{columnVisibility.totalBorrow && (
Expand All @@ -191,6 +192,7 @@ export function MarketTableBody({ currentEntries, expandedRowId, setExpandedRowI
assets={item.state.borrowAssets}
decimals={item.loanAsset.decimals}
symbol={item.loanAsset.symbol}
isEstimated={!item.hasUSDPrice}
/>
)}
{columnVisibility.liquidity && (
Expand All @@ -200,6 +202,7 @@ export function MarketTableBody({ currentEntries, expandedRowId, setExpandedRowI
assets={item.state.liquidityAssets}
decimals={item.loanAsset.decimals}
symbol={item.loanAsset.symbol}
isEstimated={!item.hasUSDPrice}
/>
)}
{columnVisibility.supplyAPY && (
Expand Down
7 changes: 6 additions & 1 deletion src/features/markets/components/table/market-table-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ArrowDownIcon, ArrowUpIcon, ExternalLinkIcon } from '@radix-ui/react-icons';
import { TableHead, TableCell } from '@/components/ui/table';
import { TokenIcon } from '@/components/shared/token-icon';
import { EstimatedValueTooltip } from '@/components/shared/estimated-value-tooltip';
import { formatBalance, formatReadable } from '@/utils/balance';
import { getAssetURL } from '@/utils/external';
import type { SortColumn } from '../constants';
Expand Down Expand Up @@ -68,20 +69,24 @@ export function TDTotalSupplyOrBorrow({
assets,
decimals,
symbol,
isEstimated = false,
}: {
dataLabel: string;
assetsUSD: number;
assets: string;
decimals: number;
symbol: string;
isEstimated?: boolean;
}) {
return (
<TableCell
data-label={dataLabel}
className="z-50"
style={{ minWidth: '120px' }}
>
<p className="z-50">${`${formatReadable(Number(assetsUSD))} `} </p>
<p className="z-50">
<EstimatedValueTooltip isEstimated={isEstimated}>${formatReadable(Number(assetsUSD))}</EstimatedValueTooltip>
</p>
<p className="z-50 opacity-70">{`${formatReadable(formatBalance(assets, decimals))} ${symbol}`}</p>
</TableCell>
);
Expand Down
18 changes: 1 addition & 17 deletions src/utils/warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ export const SUBGRAPH_NO_ORACLE = {
__typename: 'OracleWarning_MonarchAttached',
};

// Most subgraph markets has no price data
export const SUBGRAPH_NO_PRICE = {
type: 'subgraph_no_price',
level: 'warning',
__typename: 'MarketWarning_SubgraphNoPrice',
};

export const subgraphDefaultWarnings: MarketWarning[] = [SUBGRAPH_NO_ORACLE];

export const UNRECOGNIZED_LOAN = {
Expand Down Expand Up @@ -90,15 +83,6 @@ const morphoOfficialWarnings: WarningWithDetail[] = [
},
];

const subgraphWarnings: WarningWithDetail[] = [
{
code: 'subgraph_no_price',
level: 'warning',
description: 'The USD value of the market is estimated with an offchain price source.',
category: WarningCategory.general,
},
];

const BAD_DEBT: WarningWithDetail = {
code: 'bad_debt_realized',
level: 'warning',
Expand Down Expand Up @@ -155,7 +139,7 @@ export const getMarketWarningsWithDetail = (market: Market, optionsOrWhitelist?:
const { considerWhitelist = false, oracleMetadataMap } = options;
const result = [];

const allDetails = [...morphoOfficialWarnings, ...subgraphWarnings];
const allDetails = [...morphoOfficialWarnings];

const whitelistedMarketData = considerWhitelist
? monarchWhitelistedMarkets.find((m) => m.id === market.uniqueKey.toLowerCase())
Expand Down