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.| State | What it means for you | Spreads | Trade directions |
|---|---|---|---|
| NORMAL | Full functionality. Standard spreads. Both trade directions available. | Standard | Both |
| PROTECT | Increased market risk detected. Spreads widen. Maximum transaction sizes are reduced. Both directions remain available. | Wider | Both |
| RESTRICT | Significant stress detected. Maximum spreads applied. Trading may be limited to one direction only — the direction that reduces pool imbalance. | Maximum | One direction only |
| HALT | Trading paused entirely. Existing in-flight swaps settle normally. New quote requests are rejected. | N/A | None |
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: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.
Position limit reduction
If conditions worsen, maximum transaction sizes are reduced. Smaller trades can still execute while the system manages its exposure more conservatively.
Direction restriction
Under RESTRICT state, trading may be limited to the single direction that reduces pool imbalance. The direction that worsens imbalance is blocked.
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: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.