Skip to main content
Glama

TradingCalc MCP: Options, Forex, Risk Stats, Prediction Markets, On-Chain & Crypto Futures

Liquidation Safety

workflow.run_liquidation_safety
Read-only

Calculate the liquidation price for an isolated-margin futures position with one flat maintenance margin rate (mmr, which you supply from your exchange's tier), unless you use the tiered mode described below. The default is isolated: it does not model a cross account. To get a cross-account figure pass walletBalance, otherMaintenanceMargin and otherUnrealizedPnl (any of them switches to cross, with size required), plus tiers for tiered maintenance margin; there is no separate marginMode parameter. The flat model is generic, for linear and inverse alike, not any one exchange's engine. By default the maintenance margin is taken on the position value at the liquidation price (the form Bybit, KuCoin and Hyperliquid document); mmBase "entry" takes it on the entry value (the form MEXC documents); liqFeeRate adds a liquidation fee to the rate (KuCoin). Optional tiered mode, for tiered maintenance margin and shared (cross) collateral after the Binance USD-M help page (linear) and the Bybit inverse and Binance COIN-M definitions (inverse, size in USD contracts, tier bands, cum, wallet and other-position fields all in the base coin): pass size (required there) and tiers (upTo, mmr, optional cum), optionally walletBalance, otherMaintenanceMargin, otherUnrealizedPnl. In that mode mmr is used only when tiers are left out, mmBase "entry" and liqFeeRate are refused, the last tier is open-ended, and the tier used is the one that holds the notional at the liquidation price (our choice, exchanges do not publish theirs); tier rows are supplied by you, never fetched here (for the current tiers of an exchange by symbol use workflow.run_liquidation_live), and the result then also carries tier {index, mmr, cum}. Without those fields it is the flat model: no tiers and no shared collateral, so it can differ from an exchange's own figure. Edge cases: entryPrice and leverage above zero; mmr 0 to 0.2 (default 0.005); liqFeeRate 0 to 0.05 (default 0, refused in tiered mode); tiered mode needs size, 1 to 50 tiers ascending by upTo, mmr 0 to 0.5 never lower than the previous tier, only the last tier may leave out upTo, and a cum that disagrees with the tier rates is an error; walletBalance above zero, otherOpenMaintenanceMargin 0 or more. Not covered: auto-deleveraging, partial liquidation, mark price versus last price, funding paid while open, and the exchange own engine, which may differ. Use when user asks "where will I get liquidated?" or "how close is my liq price?" with a margin rate or tier table given; when the user names an exchange and a symbol and gives no tier table, use workflow.run_liquidation_live instead. Returns: liqPrice (the price). liqPrice is null when the position cannot be liquidated: an inverse short whose margin covers any price rise (at 1x or less with the default mmBase; with mmBase "entry" only a little below 1x), or whose price would be more than 1e9 times the entry. Check for null before doing arithmetic on it. When mmr plus liqFeeRate is at least 1/leverage the position is already at or below its maintenance margin at entry: liqPrice is the entry price and liquidatedAtEntry is true.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "side": "<side>",
      "entryPrice": "<entryPrice>",
      "leverage": "<leverage>"
    },
    "name": "workflow.run_liquidation_safety"
  }
}

Input Schema

NameRequiredDescriptionDefault
mmrNoMaintenance margin rate, default 0.005 (0.5%)
sideYesTrade direction: "long" or "short"
sizeNoPosition size: base units for linear, USD contracts for inverse. Needed for tiered mode (tiers, walletBalance and the other fields select it); ignored otherwise.
tiersNoTiered mode (needs size): 1 to 50 maintenance margin tiers ascending by upTo (notional cap in quote for linear, in base coin for inverse, above 0; the last band is open-ended: an upTo given on the last tier is accepted and ignored); mmr 0 to 0.5 and not decreasing. cum = maintenance amount (Binance cum, Bybit mmDeduction); derived from the rates when omitted.
mmBaseNoValue the maintenance margin is taken on: "liquidation" = position value at the liquidation price (default; Bybit, KuCoin, Hyperliquid), "entry" = entry value (MEXC). Refused in tiered mode.
leverageYesLeverage multiplier, e.g. 10 for 10x
entryPriceYesEntry price (positive)
liqFeeRateNoLiquidation fee as a fraction of position value, default 0, max 0.05; added to mmr (e.g. KuCoin 0.0006). Refused in tiered mode.
contractTypeNolinear = USDT-margined (default), inverse = coin-margined (e.g. Deribit/Bybit/MEXC BTC-settled perps). Tiers and shared collateral: both (inverse: size in USD, bands and balances in the base coin).
walletBalanceNoShared collateral (needs size): wallet balance backing the position. Default: the isolated initial margin, size x entry / leverage in quote for linear, size / entry / leverage in the base coin for inverse.
otherUnrealizedPnlNoShared collateral: unrealized PnL of other positions (default 0, may be negative).
otherMaintenanceMarginNoShared collateral (needs size): maintenance margin of other positions, 0 or more (default 0).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changed
    • changedInput schema / properties / contractType / description
      Previous value: -"linear = USDT-margined (default), inverse = coin-margined (e.g. Deribit/Bybit/MEXC BTC-settled perps)."New value: +"linear = USDT-margined (default), inverse = coin-margined (e.g. Deribit/Bybit/MEXC BTC-settled perps). Tiers and shared collateral: both (inverse: size in USD, bands and balances in the base coin)."
    • changedInput schema / properties / liqFeeRate / description
      Previous value: -"Liquidation fee as a fraction of position value, default 0, max 0.05; added to mmr (e.g. KuCoin 0.0006)."New value: +"Liquidation fee as a fraction of position value, default 0, max 0.05; added to mmr (e.g. KuCoin 0.0006). Refused in tiered mode."
    • changedInput schema / properties / mmBase / description
      Previous value: -"Value the maintenance margin is taken on: \"liquidation\" = position value at the liquidation price (default; Bybit, KuCoin, Hyperliquid), \"entry\" = entry value (MEXC)."New value: +"Value the maintenance margin is taken on: \"liquidation\" = position value at the liquidation price (default; Bybit, KuCoin, Hyperliquid), \"entry\" = entry value (MEXC). Refused in tiered mode."
    • addedInput schema / properties / otherMaintenanceMargin
      Added value: +{
      +  "description": "Shared collateral (needs size): maintenance margin of other positions, 0 or more (default 0).",
      +  "minimum": 0,
      +  "type": "number"
      +}
    • addedInput schema / properties / otherUnrealizedPnl
      Added value: +{
      +  "description": "Shared collateral: unrealized PnL of other positions (default 0, may be negative).",
      +  "type": "number"
      +}
    • addedInput schema / properties / size
      Added value: +{
      +  "description": "Position size: base units for linear, USD contracts for inverse. Needed for tiered mode (tiers, walletBalance and the other fields select it); ignored otherwise.",
      +  "type": "number"
      +}
    • addedInput schema / properties / tiers
      Added value: +{
      +  "description": "Tiered mode (needs size): 1 to 50 maintenance margin tiers ascending by upTo (notional cap in quote for linear, in base coin for inverse, above 0; the last band is open-ended: an upTo given on the last tier is accepted and ignored); mmr 0 to 0.5 and not decreasing. cum = maintenance amount (Binance cum, Bybit mmDeduction); derived from the rates when omitted.",
      +  "items": {
      +    "properties": {
      +      "cum": {
      +        "description": "Maintenance amount of this tier (Binance cum, Bybit mmDeduction; base coin for inverse); derived from the rates when omitted.",
      +        "minimum": 0,
      +        "type": "number"
      +      },
      +      "mmr": {
      +        "description": "Maintenance margin rate of this tier, as a fraction.",
      +        "maximum": 0.5,
      +        "minimum": 0,
      +        "type": "number"
      +      },
      +      "upTo": {
      +        "description": "Notional cap of this tier (quote currency for linear, base coin for inverse); omit on the last tier.",
      +        "exclusiveMinimum": 0,
      +        "type": "number"
      +      }
      +    },
      +    "required": [
      +      "mmr"
      +    ],
      +    "type": "object"
      +  },
      +  "maxItems": 50,
      +  "minItems": 1,
      +  "type": "array"
      +}
    • addedInput schema / properties / walletBalance
      Added value: +{
      +  "description": "Shared collateral (needs size): wallet balance backing the position. Default: the isolated initial margin, size x entry / leverage in quote for linear, size / entry / leverage in the base coin for inverse.",
      +  "exclusiveMinimum": 0,
      +  "type": "number"
      +}
  2. Changed2 schema fields changed
    • addedInput schema / properties / liqFeeRate
      Added value: +{
      +  "description": "Liquidation fee as a fraction of position value, default 0, max 0.05; added to mmr (e.g. KuCoin 0.0006).",
      +  "type": "number"
      +}
    • addedInput schema / properties / mmBase
      Added value: +{
      +  "description": "Value the maintenance margin is taken on: \"liquidation\" = position value at the liquidation price (default; Bybit, KuCoin, Hyperliquid), \"entry\" = entry value (MEXC).",
      +  "enum": [
      +    "liquidation",
      +    "entry"
      +  ],
      +  "type": "string"
      +}
  3. Changed1 schema field changed
    • addedInput schema / properties / side / description
      Added value: +"Trade direction: \"long\" or \"short\""
  4. Changed1 schema field changed
    • addedInput schema / properties / contractType
      Added value: +{
      +  "description": "linear = USDT-margined (default), inverse = coin-margined (e.g. Deribit/Bybit/MEXC BTC-settled perps).",
      +  "enum": [
      +    "linear",
      +    "inverse"
      +  ],
      +  "type": "string"
      +}
  5. Added

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnly, non-destructive, and closed-world behavior, and the description adds substantial context beyond that: default isolated model, how cross mode is selected, tiered-mode restrictions, mmBase exchange conventions, null liqPrice semantics, and liquidatedAtEntry behavior. It also lists what is not covered, such as ADL, partial liquidation, and mark-versus-last price.

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

Conciseness3/5

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

The description is front-loaded with the default model and alternative, and it has useful sections for edge cases, exclusions, and returns. However, it is extremely dense and long, with repeated schema-level detail and some run-on sentences that make it harder to parse than necessary.

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 12 parameters, no output schema, and complex flat/tiered/cross modes, the description is complete. It covers defaults, required interactions, edge cases, null return meaning, liquidatedAtEntry, and explicit modeling limitations.

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 schema already carries parameter meanings. The description still adds useful interaction semantics not obvious from individual fields: cross mode is selected by walletBalance/otherMaintenanceMargin/otherUnrealizedPnl rather than a marginMode parameter, tiered mode requires size, and mmBase and liqFeeRate are refused in tiered mode.

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 states a specific verb and resource: calculate the liquidation price for an isolated-margin futures position. It explicitly distinguishes flat mode from tiered mode and names workflow.run_liquidation_live as the alternative for live exchange tiers.

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

Usage Guidelines5/5

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

It gives explicit when-to-use guidance with user phrasings ("where will I get liquidated?", "how close is my liq price?") and a clear routing rule: use workflow.run_liquidation_live when the user names an exchange and symbol but supplies no tier table. It also explains when cross-account mode is triggered.

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.