Docs/Examples/Price Alerter

PriceAlerter

Monitor Chainlink price feeds and trigger alerts on threshold crossings.


Overview

PriceAlerter monitors a Chainlink price feed and emits alerts when the price crosses configured thresholds. Demonstrates AutoLoop for monitoring and notification patterns.

  • Base: AutoLoopCompatible
  • VRF: No
  • Gas: ~90,000 per tick
  • Use case: Price monitoring, automated trading signals, DeFi triggers

Key Concepts

  • Uses AutoLoopCompatible for pure automation
  • Integrates with Chainlink price feeds for real-time data
  • shouldProgressLoop() checks if the price has crossed a threshold since last check
  • progressLoop() emits an alert event and updates the stored price

Deploy

forge create examples/PriceAlerter.sol:PriceAlerter \
  --constructor-args $PRICE_FEED_ADDRESS $THRESHOLD \
  --rpc-url $RPC_URL \
  --private-key $PRIVATE_KEY

This example shows that AutoLoop isn't limited to games — it works for any contract that needs periodic automated execution.