Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ratiofx.com/llms.txt

Use this file to discover all available pages before exploring further.

Risk Management

Ratio’s risk management system runs continuously, monitoring oracle health, pool inventory, market volatility, and overall system exposure. When conditions deteriorate, the system responds automatically — widening spreads, reducing position limits, or pausing trading entirely. This protects both LP capital and your execution quality without requiring manual intervention on either side.

System states

The risk system operates across four states. Your integration should be prepared to handle each one.
StateWhat it means for youSpreadsTrade directions
NORMALFull functionality. Standard spreads. Both trade directions available.StandardBoth
PROTECTIncreased market risk detected. Spreads widen. Maximum transaction sizes are reduced. Both directions remain available.WiderBoth
RESTRICTSignificant stress detected. Maximum spreads applied. Trading may be limited to one direction only — the direction that reduces pool imbalance.MaximumOne direction only
HALTTrading paused entirely. Existing in-flight swaps settle normally. New quote requests are rejected.N/ANone
State transitions happen automatically and instantly. There is no manual intervention step, and no delay between detecting a risk event and responding to it.

Circuit breaker triggers

The system evaluates four signals continuously. Any signal exceeding its threshold can trigger a state transition: Oracle health — Are price feeds fresh and consistent? If oracle data becomes stale or independent sources diverge significantly, the circuit breaker activates. The system will not execute a trade at an unreliable price. Market volatility — How much has the exchange rate moved in recent minutes? Elevated short-term volatility widens the volatility component of the spread and, if severe enough, triggers a state upgrade. Pool inventory — Are pool balances within acceptable ranges? Significant imbalance — where one pool is depleted relative to its target — triggers the inventory component of the spread and, at extreme levels, can restrict or halt the affected corridor. System exposure — Is the protocol’s overall risk position sustainable? Aggregate exposure across all active quotes and pools is monitored continuously.

How the system responds

Rather than a binary on/off switch, Ratio’s risk system provides a graduated response that keeps the platform serving you for as long as safely possible:
1

Spread widening

The first response to elevated risk is automatic spread widening. The volatility, liquidity, and inventory components adjust in real time. You continue to receive firm quotes; they are simply priced to reflect current conditions.
2

Position limit reduction

If conditions worsen, maximum transaction sizes are reduced. Smaller trades can still execute while the system manages its exposure more conservatively.
3

Direction restriction

Under RESTRICT state, trading may be limited to the single direction that reduces pool imbalance. The direction that worsens imbalance is blocked.
4

Full halt (HALT)

If conditions become severe, trading pauses entirely. The operations team is notified for manual review. Recovery is automatic once all risk signals clear.

Handling system states in your integration

You should poll or subscribe to the system state endpoint and adjust your user experience accordingly. Do not present a generic error to your users during a trading halt — use the state information to display a meaningful message. Checking the current state:
GET /v1/system/state
The response includes the current state for each corridor, any active restrictions, and an estimated time to recovery where available. Handling the DIRECTION_BLOCKED error: If you attempt to execute a swap in the restricted direction during a RESTRICT state, you will receive a DIRECTION_BLOCKED error. Your integration should catch this error and — if appropriate for your use case — inform the user that the direction is temporarily unavailable rather than retrying automatically. Quote responses include system state: Every quote response includes the current system state for the corridor. You can use this to surface proactive warnings in your UI before the user attempts to execute.
Do not retry a DIRECTION_BLOCKED error automatically. The restriction is intentional and will persist until pool balance is restored. Retrying will not succeed and may cause unnecessary friction for your users.

Recovery

When conditions improve, the system recovers automatically. All risk signals must clear before the system returns to NORMAL. If some signals clear but others remain elevated, the system moves to an intermediate state rather than full restoration. This conservative approach prevents the system from oscillating during volatile periods. Recovery from a HALT state requires manual review by the operations team in addition to automatic signal clearing. If you are in a HALT state and conditions appear to have normalised, contact Ratio support for an estimated recovery time.

Inventory rebalancing

When pool imbalance reaches configurable thresholds, the Liquidity Hub coordinates external rebalancing with market makers and OTC partners to restore target pool levels. Once rebalancing is complete and pool inventory returns to normal ranges, the inventory risk signal clears and the system transitions back toward NORMAL state. The inventory spread component adjusts continuously throughout this process — automatically making the rebalancing-friendly direction cheaper, which attracts natural offsetting flow from your users and other partners in addition to the active rebalancing operations.