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 API
The Stop Loss feature enables automated trading when token prices fall below specified thresholds. It relies on Chainlink-compatible price oracles to monitor token prices and trigger the order when conditions are satisfied.Key Parameters
| Parameter | Description |
|---|---|
sellToken / buyToken | Token pair addresses |
sellAmount / buyAmount | Trade amounts |
sellTokenPriceOracle | Chainlink-compatible oracle for sell token |
buyTokenPriceOracle | Chainlink-compatible oracle for buy token |
strike | Exchange rate threshold (18 decimals) |
validTo | Order expiration timestamp |
maxTimeSinceLastOracleUpdate | Oracle staleness limit |
Execution Logic
ThegetTradeableOrder function validates conditions in sequence:
- Confirms the order hasn’t expired
- Retrieves current prices from both oracles
- Verifies prices are positive and recently updated
- Normalizes both to 18 decimals
- Calculates the exchange rate and compares against strike
- Returns the executable order if conditions are met
Failure Scenarios
- Orders fail permanently with
OrderNotValidif expired or oracle prices are invalid - They revert with
PollTryNextBlock(signaling retry on next block) when prices are stale or the strike hasn’t been reached yet