Skip to content
Open
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: 4 additions & 0 deletions frontend/src/views/dashboard.screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export async function loadDashboardData(addr: string): Promise<DashboardData> {
equityUsd: agg.equityUsd,
netApy: agg.netApy,
accountHealth: agg.poolHF,
collateralUsd: agg.collateralUsd,
debtUsd: agg.debtUsd,
effLeverage: agg.effLeverage,
liqDays: agg.liqDays,
});
} catch (e) {
console.warn(`Dashboard: pool ${pool.name} load failed`, e);
Expand Down
22 changes: 20 additions & 2 deletions frontend/src/views/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export interface PoolAccount {
*/
accountHealth: number;
hasNew?: boolean;
// Extended pool-level aggregates from aggregatePoolAccount (PoolAccountSummary).
collateralUsd?: number; // total collateral in USD across all assets in this pool
debtUsd?: number; // total debt in USD across all assets in this pool
effLeverage?: number; // collateralUsd / equityUsd — effective pool-wide leverage
liqDays?: number | null; // estimated days until liquidation at current rates; null = n/a, Infinity = never
}

export interface VaultHolding {
Expand Down Expand Up @@ -146,7 +151,18 @@ function legRow(lg: Leg, last: boolean): HTMLElement {
]);
}

// ── Cards ───────────────────────────────────────────────────────────────────
// ── PositionPanel (pool card) ────────────────────────────────────────────────
/**
* Renders a single pool account as a PositionPanel card.
*
* Data wiring (all from aggregatePoolAccount — no mocks):
* accountHealth → agg.poolHF (Σ collateral×cFactor ÷ Σ debt/lFactor)
* liqDays → agg.liqDays (ln(poolHF) / spread × 365)
* effLeverage → agg.effLeverage (collateralUsd / equityUsd)
* collateralUsd → agg.collateralUsd
* debtUsd → agg.debtUsd
* legs (table) → agg.rows mapped via legsFromRows
*/
function poolCard(acc: PoolAccount, onManage: () => void, onAddLeg: () => void): HTMLElement {
const cross = acc.legs.length > 1;

Expand Down Expand Up @@ -179,7 +195,9 @@ function poolCard(acc: PoolAccount, onManage: () => void, onAddLeg: () => void):
"Pool-wide: total collateral value ÷ total debt across every leg in this pool. Liquidation is account-wide — it triggers when this drops below 1.0.",
),
]),
]);
liqRow,
crossNote,
];

if (cross) {
card.append(
Expand Down