How does it work?
By hooking the swap function of your trading contract into the Rules Engine with a policy that tracks price movements over time and automatically pauses trading when price changes exceed predefined limits within a specific timeframe.Let’s break that down further.
The circuit breaker monitors price changes over a 5-minute window (300 seconds). If the price drops by more than 10 units within this timeframe, trading is automatically paused for 15 minutes (900 seconds). This gives the market time to stabilize before resuming normal operations. The system uses trackers to store:- LastPrice: The price at the start of the current monitoring window
- LastTimestamp: When the current monitoring window began
- LockedUntil: When trading will be allowed to resume
- Market protection: Prevent extreme volatility from destabilizing your token
- Investor confidence: Show that your protocol has built-in safeguards
- Manipulation prevention: Stop coordinated attacks or pump-and-dump schemes
- Regulatory compliance: Demonstrate responsible trading mechanisms
Implementation
This policy requires integration with a trading contract that provides price data. You’ll need to:- Set the price drop threshold (10 units in this example)
- Set the monitoring window (5 minutes = 300 seconds)
- Set the pause duration (15 minutes = 900 seconds)
- Ensure your trading contract exposes the current spot price
- Replace the swap function signature with your actual trading function
This policy assumes you have the ability to customize contracts that control a trading pool for
your token. If you’re looking for a liquidity solution that enables this, reach
out so we can talk more!
Policy JSON
The rule conditions in the above example are split across multiple lines for readability. For
valid JSON you must remove those line returns.