The ChainlinkTriggerFactory deploys triggers that use Chainlink oracles for price data. The triggers compare a "truth" price with a "tracking" price. If the price delta exceeds a specified tolerance during a check, the trigger state becomes TRIGGERED, and any related protection markets pay out.
There are two types of Chainlink triggers that the factory can deploy:
Dual-oracle triggers: compare the price feeds of two Chainlink oracles.
Peg-protection triggers: compare the price feed of a Chainlink oracle with a fixed price, or "peg".
Here is a searchable list of available Chainlink oracle addresses, aka "Data Feeds".
Determine Trigger Parameters
The parameters required to deploy a dual-oracle trigger a peg-protection trigger:
structTriggerMetadata {// The name that should be used for safety modules that use the trigger.string name;// A human-readable description of the trigger.string description;// The URI of a logo image to represent the trigger.string logoURI;// Extra metadata for the trigger.string extraData;}/// @notice Call this function to deploy a ChainlinkTrigger./// @param _truthOracle The address of the desired truthOracle for the trigger./// @param _trackingOracle The address of the desired trackingOracle for the trigger./// @param _priceTolerance The priceTolerance that the deployed trigger will/// have. See ChainlinkTrigger.priceTolerance() for more information./// @param _truthFrequencyTolerance The frequency tolerance that the deployed trigger will/// have for the truth oracle. See ChainlinkTrigger.truthFrequencyTolerance() for more information./// @param _trackingFrequencyTolerance The frequency tolerance that the deployed trigger will/// have for the tracking oracle. See ChainlinkTrigger.trackingFrequencyTolerance() for more information./// @param _metadata See TriggerMetadata for more info.functiondeployTrigger(AggregatorV3Interface_truthOracle,AggregatorV3Interface_trackingOracle,uint256_priceTolerance,uint256_truthFrequencyTolerance,uint256_trackingFrequencyTolerance,TriggerMetadatamemory_metadata) publicreturns (IChainlinkTrigger_trigger);/// @notice Call this function to deploy a ChainlinkTrigger with a/// FixedPriceAggregator as its truthOracle. This is useful if you were/// configuring a safety module in which you wanted to track whether or not a stablecoin/// asset had become depegged./// @param _price The fixed price, or peg, with which to compare the trackingOracle price./// @param _decimals The number of decimals of the fixed price. This should/// match the number of decimals used by the desired _trackingOracle./// @param _trackingOracle The address of the desired trackingOracle for the trigger./// @param _priceTolerance The priceTolerance that the deployed trigger will/// have. See ChainlinkTrigger.priceTolerance() for more information./// @param _frequencyTolerance The frequency tolerance that the deployed trigger will/// have for the tracking oracle. See ChainlinkTrigger.trackingFrequencyTolerance() for more information./// @param _metadata See TriggerMetadata for more info.functiondeployTrigger(int256_price,uint8_decimals,AggregatorV3Interface_trackingOracle,uint256_priceTolerance,uint256_frequencyTolerance,TriggerMetadatamemory_metadata) publicreturns (IChainlinkTrigger_trigger)
Decimals must match:
For a dual-oracle trigger, both oracles must use the same number of decimals.
For a peg-protection trigger, the tracking oracle must return prices with the same number of decimals specified for the peg.
If the truthOracle returns a price of 0, the trigger will treat the priceTolerance as exceeded, regardless of the trackingOracle price.
Deploy Trigger
For instance, to deploy a dual-oracle trigger comparing the mainnet ETH/USD price to the mainnet stETH/USD price and entering a TRIGGERED state when the price deviates by more than 10%, use:
factory.deployTrigger(AggregatorV3Interface(0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419),// ETH/USDAggregatorV3Interface(0xcfe54b5cd566ab89272946f602d76ea879cab4a8),// stETH/USD0.1e4,// A >10% price deviation will cause the trigger to be triggerable.600,// Truth price must have published within the last 10 minutes to be valid.600,// Tracking price must have published within the last 10 minutes to be valid.TriggerMetadata("name","description","logoURI","extraData"));
To deploy a peg-protection trigger comparing the mainnet USDT/USD price to a fixed $1 peg, entering a TRIGGERED state if the price differs by more than 1%, use:
factory.deployTrigger(1e8,// Fixed price of $1, denominated in 8 decimals.8,// 8 decimal places will be used for the peg, matching the oracle.AggregatorV3Interface(0x3e7d1eab13ad0104d2750b8863b489d65364e32d),// USDT/USD oracle0.01e4,// A 1% price tolerance.3600,// Price data may be at most 1 hour old.TriggerMetadata("name","category","description","logoURI"));
If an existing trigger has the desired configuration, a new trigger will not be deployed, and the existing trigger's address will be returned.