Skip to main content
Glama

Calculate Health Factor

calculate_health_factor
Read-onlyIdempotent

Calculates a lending health factor from position inputs, with no wallet or on-chain lookup required. Give it collateral (one or more assets, each with its own liquidation threshold) and the debt, and it returns the health factor, the blended threshold, the collateral drop that would trigger liquidation, and the collateral value at which liquidation begins. Optionally simulates a collateral price drop and a change in the borrowed asset's price. Formula: HF = (Σ collateral value × liquidation threshold) ÷ debt. Works for Aave, Morpho, Spark, Kamino and any protocol using the standard formula. Use this when asked: "What is my health factor if I supply 5 ETH at 80% and borrow $6,500?", "How far can ETH fall before I get liquidated?", "What happens to my HF if I add collateral or repay?", "Work out the health factor for this position".

Input Schema

NameRequiredDescriptionDefault
debt_usdYesTotal borrowed value in USD. Zero means no debt, so no liquidation risk.
collateralYesCollateral legs. Pass one entry per supplied asset; each keeps its own liquidation threshold and the blended figure is derived.
debt_change_pctNoOptional: simulate the borrowed asset's price moving by this percentage. Positive grows the debt and pushes HF down (borrowing a volatile asset); 0 or omitted is stablecoin debt.
collateral_drop_pctNoOptional: simulate the collateral falling by this percentage, e.g. 30 for a 30% crash.

Output Schema

NameRequiredDescriptionDefault
debtUsdYesTotal debt used in the calculation
riskLevelYesRisk tier, or null when there is no debt
simulatedNoPresent only when a simulation was requested
healthFactorYesHealth factor, or null when there is no debt — with nothing borrowed there is no liquidation point
collateralValueUsdYesTotal collateral value across every leg
blendedThresholdPctYesWeighted liquidation threshold across all collateral legs
dropToLiquidationPctYesHow far the collateral can fall before the health factor reaches 1.0
riskAdjustedCollateralUsdYesCollateral value after each leg is discounted by its own liquidation threshold
liquidationAtCollateralValueUsdYesTotal collateral value at which liquidation begins, or null when there is no debt

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/idempotent/non-destructive, so the bar is lower, yet the description adds substantial context: the exact return contents (health factor, blended threshold, liquidation-trigger collateral drop, collateral value at liquidation), the formula, and the fact that no on-chain lookup occurs. This is well beyond what the annotations convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core purpose before the formula, supported protocols, and example queries, so an agent gets the essentials first. The four quoted example prompts are useful for intent matching but make the block noticeably long and slightly repetitive.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter computation tool with a full output schema and read-only annotations, the description covers purpose, inputs, formula, supported protocols, return fields, and usage triggers. Nothing an agent needs to invoke it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description earns extra credit by stating the formula HF = (Σ collateral value × liquidation threshold) ÷ debt, which clarifies how the collateral and debt parameters are actually combined. It also explains the optional collateral_drop_pct / debt_change_pct as what-if simulations. It stops short of adding format or edge-case detail beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The first sentence states a precise verb+resource ("Calculates a lending health factor from position inputs") and immediately scopes it against wallet-based siblings with "no wallet or on-chain lookup required." It also names the protocols covered (Aave, Morpho, Spark, Kamino), so an agent can distinguish it from simulate_liquidation and scan_wallet without reading the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly enumerates when to use the tool via four quoted example prompts, which directly map user intents to this tool. It does not, however, name the alternative to use instead of this one (e.g. simulate_liquidation) or state when-not conditions, so it falls short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.