Skip to main content
Protect your token from extreme volatility and manipulation by automatically pausing trading when price movements exceed safe thresholds. This policy monitors price changes and temporarily halts trading to prevent market disruption and protect investors.

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
This is particularly useful for:
  • 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:
  1. Set the price drop threshold (10 units in this example)
  2. Set the monitoring window (5 minutes = 300 seconds)
  3. Set the pause duration (15 minutes = 900 seconds)
  4. Ensure your trading contract exposes the current spot price
  5. 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

{
  "Name": "Price Change Circuit Breaker Policy",
  "Description": "A set of rules to pause trading for 15 min if price change exceeds given threshold",
  "PolicyType": "open",
  "CallingFunctions": [
    {
      "Name": "Swap",
      "FunctionSignature": "swap(address _tokenIn, uint256 _amountIn, uint256 _minOut, address _recipient, uint256 _expires)",
      "EncodedValues": "address _tokenIn, uint256 _amountIn, uint256 _minOut, address _recipient, uint256 _expires, uint256 spotPrice"
    }
  ],
  "Trackers": [
    {
      "Name": "LockedUntil",
      "Type": "uint256",
      "InitialValue": "17609747490"
    },
    {
      "Name": "LastPrice",
      "Type": "uint256",
      "InitialValue": "50"
    },
    {
      "Name": "LastTimestamp",
      "Type": "uint256",
      "InitialValue": "1760974749"
    }
  ],
  "MappedTrackers": [],
  "ForeignCalls": [],
  "Rules": [
    {
      "Name": "Trading Paused Checker",
      "Description": "Determines if trading has been paused due to price change over duration limits",
      "Condition": "GV:BLOCK_TIMESTAMP < TR:LockedUntil",
      "PositiveEffects": ["revert(\"Trading is paused due to price fluctuation\")"],
      "NegativeEffects": [],
      "CallingFunction": "Swap"
    },
    {
      "Name": "Time Elapsed Checker",
      "Description": "Determines if duration window is met to reset trackers",
      "Condition": "(GV:BLOCK_TIMESTAMP > TR:LockedUntil
                        AND (GV:BLOCK_TIMESTAMP - TR:LastTimestamp > 300)
                    )",
      "PositiveEffects": ["TRU:LastPrice = spotPrice", "TRU:LastTimestamp = GV:BLOCK_TIMESTAMP"],
      "NegativeEffects": [],
      "CallingFunction": "Swap"
    },
    {
      "Name": "Pause Trading Condition",
      "Description": "If price change exceeds limit within timeframe, set locking tracker",
      "Condition": "(GV:BLOCK_TIMESTAMP > TR:LockedUntil
                        AND (GV:BLOCK_TIMESTAMP - TR:LastTimestamp < 300)
                        AND (TR:LastPrice - spotPrice > 10)
                    )",
      "PositiveEffects": ["TRU:LockedUntil = (GV:BLOCK_TIMESTAMP + 900)", "TRU:LastPrice = spotPrice", "TRU:LastTimestamp = (GV:BLOCK_TIMESTAMP + 900)"],
      "NegativeEffects": [],
      "CallingFunction": "Swap"
    }
  ]
}
The rule conditions in the above example are split across multiple lines for readability. For valid JSON you must remove those line returns.
I