Skip to main content
Glama

Perp Liquidation Gate

perp_gate
Read-onlyIdempotent

Deterministic perpetual-futures risk. Given a position (entry, size, margin/leverage, maint-margin/maxLeverage), returns the exact liquidation price, the % adverse move to liquidation, effective leverage, and (if a funding rate is given) the funding drag. Pass a Hyperliquid symbol (e.g. BTC) to auto-fill live mark price, funding, and max leverage. Includes a self-check proving the liquidation invariant. Call this BEFORE opening or sizing any leveraged perp position — an agent that knows its true liquidation distance does not get surprise-liquidated.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sideNolong | short (buy | sell are accepted synonyms, as is -1 for short); default long
sizeNoposition size in base units (or pass notional)
venueNolive-data venue (default hyperliquid). The maths is venue-agnostic — for any other venue omit this and pass maxLeverage/markPrice/fundingRateHourly yourself.
marginNoisolated margin posted (or pass leverage)
symbolNoperp symbol (e.g. BTC) — auto-fills live markPrice, fundingRateHourly, and the margin source (Hyperliquid notional tiers or dYdX maintenance rate); also defaults entryPrice to the live mark
leverageNoposition leverage (alternative to margin)
notionalNoposition notional in quote/USD
markPriceNocurrent mark; distance-to-liq measured from here
entryPriceNodefaults to live mark if a symbol is given
maxLeverageNovenue max leverage for the asset
horizonHoursNohorizon for the funding-drag estimate, in hours
maintMarginRateNoe.g. 0.0125; or pass maxLeverage (mmr = 0.5/maxLeverage)
fundingRateHourlyNohourly funding rate (Hyperliquid funds hourly)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okNofalse when the engine rejected the input
modelNomodel assumptions used
proofNoVerifiability envelope: echoed inputs, engine codeHash, contentHash of this exact result, self-checks, EIP-712 signature (EAS-ready). Re-run the open engine on `inputs` to reproduce the result byte-for-byte.
checksNoGround-truth self-checks; the result is untrustworthy if any fails.
fundingNofunding drag over the horizon (when a funding rate is given)
marginTierNovenue margin tier the notional falls into
liquidationPriceNoexact price at which the position liquidates
effectiveLeverageNonotional / margin actually run
initialMarginRatePctNoinitial margin rate applied (%)
moveToLiquidationPctNoadverse % move (from mark) that triggers liquidation
maintenanceMarginRatePctNomaintenance margin rate applied (%)

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already indicate readOnlyHint=true, idempotentHint=true, and destructiveHint=false. Description adds value by noting the self-check, deterministic nature, and live data dependency, enhancing transparency without contradiction.

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

Conciseness5/5

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

Single paragraph of ~100 words, front-loaded with key outputs and usage direction. Every sentence serves a purpose—no redundancy or filler.

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?

Given 13 parameters with no required ones, the description fully covers usage modes (live vs manual), venue agnosticism, and includes a self-check. The output schema exists, but description still summarizes key outputs.

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

Parameters5/5

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

All 13 parameters have descriptions in the schema (100% coverage). The description goes beyond by explaining parameter groups and relationships (e.g., symbol auto-fills markPrice, funding, maxLeverage; margin vs leverage alternatives; venue-agnostic math).

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 description clearly states it computes perpetual-futures risk metrics (liquidation price, adverse move, effective leverage, funding drag) and explicitly distinguishes itself as a pre-trade risk check for perp positions, differentiating from sibling tools like options_risk or portfolio_gate.

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?

Provides explicit guidance: 'Call this BEFORE opening or sizing any leveraged perp position' and explains how to use live data (pass symbol) or manual values. Does not explicitly list when not to use, but context is clear.

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.

TDQS

A4.6/5.0
Disambiguation5/5

Each tool addresses a distinct risk domain (event volatility, execution verification, LP risk, options, perps, portfolio, attestation, sizing, treasury) with no overlap; descriptions are precise and differentiate clearly.

Naming Consistency5/5

All tool names follow a consistent snake_case pattern combining a domain prefix with a verb or metaphor (e.g., _risk, _gate, _verify), making them predictable and easy to parse.

Tool Count5/5

The 9 tools cover a broad range of DeFi risk computations without being excessive; each tool serves a clear, non-redundant purpose within the server's scope.

Completeness5/5

The tool set provides comprehensive coverage for a risk analysis server: event risk, execution quality, LP risk, options and perps greeks, portfolio stress, attestation, sizing, and treasury risk; no obvious gaps for the intended domain.

Resources