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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export function getHealthFactorColor(
}
}

/** Above this value, the health factor is effectively unbounded. Callers that show
* a high-HF label (e.g. the Overview row) use this; numeric before/after deltas
* intentionally do not, to preserve the magnitude of the change. */
export const HEALTH_FACTOR_HEALTHY_THRESHOLD = 50;

export function formatHealthFactor(healthFactor: number | null): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invariant from the revision cycle — label substitution lives at the call site, never inside this formatter — is now documented above (L28-30), but nothing in CI guards it. A future tidy-up that pushes the > HEALTH_FACTOR_HEALTHY_THRESHOLD check back into formatHealthFactor would silently regress all three Greptile findings (action deltas would show Healthy → Healthy, repay preview would flip back to the Healthy vs - asymmetry, etc.).

A single test pins it:

// services/vault/src/applications/aave/utils/__tests__/healthFactorDisplay.test.ts
it("returns the raw number for high HF (delta callers depend on this)", () => {
  expect(formatHealthFactor(100)).toBe("100.00");
  expect(formatHealthFactor(50)).toBe("50.00");
});

No test file exists for this module today, so this would also seed the right home for future formatter tests.

if (healthFactor === null) {
return "-";
Expand Down
1 change: 1 addition & 0 deletions services/vault/src/applications/aave/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type {
// Display utilities (frontend-only, not in SDK)
export {
HEALTH_FACTOR_COLORS,
HEALTH_FACTOR_HEALTHY_THRESHOLD,
formatHealthFactor,
getHealthFactorColor,
} from "./healthFactorDisplay";
Expand Down
6 changes: 5 additions & 1 deletion services/vault/src/components/simple/OverviewSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import {
formatHealthFactor,
getHealthFactorColor,
HEALTH_FACTOR_HEALTHY_THRESHOLD,
type HealthFactorStatus,
} from "@/applications/aave/utils";
import { HealthFactorGauge, HeartIcon } from "@/components/shared";
Expand Down Expand Up @@ -37,7 +38,10 @@ export function OverviewSection({
return <DisconnectedOverview />;
}

const healthFactorFormatted = formatHealthFactor(healthFactor);
const healthFactorFormatted =
healthFactor !== null && healthFactor > HEALTH_FACTOR_HEALTHY_THRESHOLD
? COPY.overview.healthFactorHealthy
: formatHealthFactor(healthFactor);
const healthFactorColor = getHealthFactorColor(healthFactorStatus);
const showHealthFactor = healthFactor !== null;

Expand Down
1 change: 1 addition & 0 deletions services/vault/src/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ export const COPY = {
overview: {
heading: "Overview",
healthFactorLabel: "Health factor",
healthFactorHealthy: "Healthy",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR introduces the canonical key for the "Healthy" string — but STATUS_LABELS.safe in services/vault/src/components/shared/utils/healthFactorGauge.ts:10 still has "Healthy" inlined, and the gauge renders directly above this label in OverviewSection (same user, same screen). Not this PR's bug — it pre-dates — but this is the moment a canonical key exists, so worth pointing the gauge at it too. Otherwise a future copy change (e.g. "Healthy" → "Strong") silently de-syncs the two surfaces.

ltvLabel: "Current LTV",
totalCollateralValueLabel: "Total Collateral Value",
amountToRepayLabel: "Amount to repay",
Expand Down
Loading