Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Uniswap v2 price alert

Template: community/uniswap-v2-price-alert ยท category: monitoring ยท risk: monitor_only ยท community

Watches a Uniswap v2 pair's Sync event โ€” emitted on every reserve change โ€” and notifies a telegram channel when the reserve-derived spot price leaves a band. No signer, no relayer, no transactions.

Community template: it lives under templates/community/ in the rflow repo (not in the binary) and is fetched SHA-pinned and hash-verified at install time. The package ships NO ABI blob โ€” the manifest declares the pair interface against the curated builtin uniswap-v2-pair standard, and the install materializes abis/pair.json from it after verifying the Sync(uint112,uint112) topic0.

When to use it

  • alert on a spot-price breakout for a token that lives on a v2 pool
  • watch a long-tail pair no oracle covers
  • a template for your own first community submission (see templates/community/SUBMITTING.md)

Generate it

# a full project (fetched from the registry, hash-verified, then gated)
rflow new --template community/uniswap-v2-price-alert
 
# or add the workflow to an existing project
rflow add workflow community/uniswap-v2-price-alert
 
# browse the community index first
rflow templates ls --community

Non-interactive (CI/agents):

rflow new --template community/uniswap-v2-price-alert --yes --output ./v2 \
  --answer price_low=1000 --answer price_high=5000

Inputs

keytypedefault
project_namestringuniswap-v2-price-alert
network / chain_id / rpc_env / rpc_urlnetwork / chain_id / env_var / stringethereum / 1 / ETH_RPC / a public RPC
pair_name / pair_addresscontract / addressPair / zero placeholder (replace!)
token0_decimals / token1_decimalsint18 / 6
price_low / price_highdecimal1000 / 5000
channelstringops
tg_bot_token_env / tg_chat_id_envenv_varTG_BOT_TOKEN / TG_CHAT_ID

Price is reserve1 * 10^token0_decimals / reserve0 (token1 per 1 whole token0), computed with mul_div. It assumes a non-empty pool.

Required env vars

DATABASE_URL, the RPC env var (default ETH_RPC), and the telegram credentials (default TG_BOT_TOKEN / TG_CHAT_ID) โ€” all in the generated .env.example.

Safety notes

Monitor-only: no signer: and no relayers:, so the relayer engine never boots. The install records the registry, commit and per-file sha256s in .rflow/template-lock.yaml, and the workflow ends in on_failure: dead_letter.

Run it locally

docker compose up -d     # postgres on localhost:5448
# fill .env, set the pair address + decimals + band
rflow validate
rflow start

Common modifications

  • flip token0/token1 if the price reads inverted for your pair
  • widen the band, or add a second pair as another workflow
  • pair with the WETH wrap monitor on the same book