> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paystream.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Safety Mechanisms

> How we protect your capital: pre-entry gates, entry safety, margin tiers, venue outage handling, and monitoring.

## What Are Safety Mechanisms?

Safety mechanisms are the checks and protocols that sit between your capital and everything that can go wrong. Delta-neutral funding sounds simple: you're hedged, you collect funding. In practice, things break. We assume the worst and build layers that guard at every phase. We'd rather skip a trade or exit early than hope and hold.

We check every trade before it opens, make sure both legs fill before calling it open, watch margin continuously and act before the edge, handle exchange outages, and keep a kill switch separate from the trading engine so it can stop everything even if the engine hangs. The [auto-close pipeline](/strategies/auto-close) is live. Several other layers are designed and being rolled out. We've tested every guard against 7 historical crashes. For the exit side, see [Auto-close](/strategies/auto-close).

Below we spell out each risk we guard against and how we handle it.

***

## The Problems We Guard Against (and How)

### Bad Entry: Taking a Trade That Doesn't Pay

**The problem.** You open a position when funding looks good, but it flips negative an hour later. Or the spread is too tight and fees eat your edge. Or the trade is so crowded that ADL risk is sky-high. You're in before you know it's a bad idea.

**How we protect.** We run pre-entry gates before opening any position. If any gate fails, we skip. Missing a trade is better than entering a bad one.

| Gate                           | What It Checks                            | Pass Condition                                                                                   |
| :----------------------------- | :---------------------------------------- | :----------------------------------------------------------------------------------------------- |
| **Funding profitability**      | Is the funding diff worth it?             | Current diff above the recent historical range; funding positive for multiple intervals in a row |
| **Trade profitability**        | Does the spread allow profit after costs? | Net entry cost within acceptable range; break-even under 48h                                     |
| **Cross-market spread**        | Is spread wide enough for execution?      | Current spread above its recent average                                                          |
| **Open interest crowding**     | Is the trade too crowded?                 | OI not in the top percentile of its range                                                        |
| **Volatility circuit breaker** | Has price moved too much lately?          | Recent move within normal bounds                                                                 |
| **Basis Z-score**              | Is perp premium overstretched?            | Not too far above fair value                                                                     |
| **Liquidation buffer**         | Enough margin cushion after entry?        | Sufficient buffer relative to recent volatility                                                  |
| **Insurance fund**             | Is the exchange's safety net healthy?     | Insurance balance above its recent average                                                       |
| **ADL level**                  | How close are we to ADL risk?             | ADL indicator in the safe range                                                                  |
| **Oracle freshness**           | Is the price feed up to date?             | Within the freshness threshold for each venue                                                    |
| **Order book depth**           | Can we exit if we need to?                | Enough liquidity on both sides to absorb the position                                            |
| **Leverage**                   | Hard cap on leverage                      | Conservative limit, stricter for smaller assets                                                  |

Before every entry we also run a quick stress simulation. What if price drops sharply in an hour? What if funding flips negative for two days? What if ADL closes our profitable leg? If any scenario looks unacceptable, we don't enter.

### Half-Open Positions: One Leg Fills, the Other Fails

**The problem.** You're running two legs, long on one venue and short on another. Leg 1 fills. Leg 2 fails. You're now directional and exposed. One bad move and you're liquidated.

**How we protect.** For same-chain pairs, both legs go in a single atomic transaction. Both open or neither opens.

For cross-venue pairs, if the second leg fails we immediately close the first. If that rollback works, nothing is left open and we notify you. If it fails, we flag it for manual review and alert you immediately. You're never left half-open without explicit notification.

We also verify every fill. If what came back is short of what we requested, we retry the remainder or close the partial. If the two legs are mismatched after execution, we rebalance or close both.

### Margin Creep: Drifting Toward Liquidation Without Warning

**The problem.** Margin drops slowly, then suddenly. By the time you notice, you're one move from liquidation.

**How we protect.** We act in tiers so there's time to react before things get critical.

| Tier              | Margin Ratio | What We Do                                                                   |
| :---------------- | :----------- | :--------------------------------------------------------------------------- |
| **1 – Healthy**   | > 300%       | Monitor only; no action                                                      |
| **2 – Warning**   | 200–300%     | Alert; stop new entries; tighten take-profit                                 |
| **3 – Danger**    | 150–200%     | Reduce position; add collateral if needed; cancel all orders                 |
| **4 – Emergency** | under 150%   | Close everything. See [Auto-close](/strategies/auto-close) for how and when. |

### Venue Outage: One Exchange Goes Down While You're Exposed

**The problem.** One of your leg venues goes offline. You can't see your position, can't close it, can't hedge. Lighter was down 4.5 hours during the October 2025 crash. dYdX was offline for 8 hours.

**How we protect.** We watch both venues continuously. If one goes unreachable, we block new entries and alert you. If it stays down, we hedge on a third venue if we have the capital, or reduce the open leg to limit exposure. When the venue comes back, we re-verify your position before resuming normal monitoring and close any temporary hedge we placed.

### Engine Hang or Runaway: The Bot Stops Responding or Goes Rogue

**The problem.** The trading engine hangs, crashes, or starts behaving unexpectedly. You need something outside the main loop that can stop everything.

**How we protect.** The kill switch runs in a completely separate process. The engine checks the kill flag before every order; if it's set, everything stops. We can kill per-strategy, per-venue, or globally. If the engine stops responding on its own, it self-kills and alerts. Auto triggers include drawdown crossing a threshold, any API down for too long, margin too low, or delta too far from neutral.

### Optional: Extra Layers We're Building

Exchange-side stops place a stop-loss directly on the exchange, surviving even a full bot crash. Graduated confidence scores each pre-entry gate and scales position size by the result rather than a hard pass or fail. Graceful degradation steps down from full trading to exit-only to emergency close. On startup we run in read-only mode for a few minutes before allowing any new trades.

### How We Watch: Monitoring Infrastructure

All safety checks run continuously. Multiple positions are checked at the same time. For each position the priority order is: liquidation proximity first, then delta drift and ADL, then funding rate inversion. Funding data is collected from all supported venues regularly. Prices are pulled from multiple sources with automatic fallback.

### Validating Against History: Stress Testing

Every safeguard is tested against seven historical black swan events. Each simulation uses real historical prices, real funding rate shifts per venue, actual exchange downtime windows, and realistic slippage and execution delays. Every guard is confirmed to trigger before liquidation under each scenario.

**USDC depeg / SVB collapse (March 2023).** Collateral devalues 13%, funding rate volatility. Tests collateral health detection, funding flip guard.

**Curve/CRV exploit cascade (July 2023).** DeFi contagion, -30% crash, extreme negative funding. Tests cascade velocity detection, funding flip guard.

**Bitcoin ETF sell-the-news (January 2024).** BTC -14%, funding inversion, long liquidation cascades. Tests liquidation proximity, funding flip guard.

**Hyperliquid JELLY short squeeze (March 2025).** 429% pump, exchange force-settles positions. Tests position-gone detection, venue counterparty risk.

**October 2025 "The Big One."** $19.13B liquidated in 24 hours, BTC -14.5%, SOL -40%, venue outages, ADL activated across all major exchanges, $3.21B liquidated in a single 60-second window. Tests all safety mechanisms simultaneously.

**December 2024 flash crash.** BTC drops 7% rapidly, \$400M+ liquidations. Tests cascade velocity, liquidation proximity.

**POPCAT manipulation (2025).** Memecoin market manipulation, exchange bad debt. Tests position-gone detection, venue-specific risk.

For how these fit with [Overview](/strategies/overview), [Perp to perp](/strategies/perp-to-perp), and [Spot to perp](/strategies/spot-to-perp), use the links to jump between pages.
