Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-seo-audit-1777280932.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Stop Loss Orders
Stop Loss orders are oracle-based programmatic orders that automatically trigger when asset prices fall below a specified threshold, providing automated risk management through Chainlink-compatible price feeds.Core Mechanism
The system monitors price ratios between two tokens. When the calculated exchange rate reaches or falls below the strike price, the order becomes executable:Essential Data Structure
| Parameter | Description |
|---|---|
sellToken / buyToken | Token pair addresses |
sellAmount / buyAmount | Trade amounts based on order type |
sellTokenPriceOracle | Chainlink-compatible price oracle for sell token |
buyTokenPriceOracle | Chainlink-compatible price oracle for buy token |
strike | Exchange rate threshold (18 decimals) that activates execution |
validTo | Expiration timestamp |
maxTimeSinceLastOracleUpdate | Staleness limit for oracle data |
Critical Oracle Requirements
Both oracles must use identical quote currencies. Price feeds undergo validation checks for:- Positivity
- Freshness within the specified time window
- Decimal normalization to 18 decimals
Order Execution Flow
The contract performs sequential validation:- Confirms order hasn’t expired
- Retrieves current oracle prices
- Validates both prices exceed zero
- Checks oracle data freshness
- Normalizes prices to 18 decimals
- Compares current rate against strike
- Returns executable
GPv2Orderif all conditions pass
Practical Examples
- Protecting GNO positions at $200
- Selling up to 50 ETH with partial fills at $2000
- Cross-asset trading (WBTC for ETH at 15:1 ratio)