Alerts
An alert sends a message to Slack, Telegram or email when something happens on your contracts, or when a condition starts and again when it clears.
| Type | Sends | Example |
|---|---|---|
| Activity alert | A message each time something happens | A swap over $100k |
| Condition alert | One message when a condition starts, and one when it clears | Available liquidity below $1M |
Activity alerts
An activity alert starts from the moment it is made. It can follow:
- An event — Emitted by a contract, by every contract in a group, or by every watched contract: a swap, a deposit, a market created.
- A metric — Each new record of an activity metric that meets a condition, or each change in a state metric, such as a treasury balance moving.
- A table’s rows — A row opening or finishing: a loan opened, a withdrawal claimed.
- A group’s members — A contract joining or leaving a group, such as a new market from a factory.
An alert on an event can send only the emissions you want, by their fields or by values read from the contract: only swaps over $100k. You write the message, with formulas in braces over what happened:
{name(sender())} swapped {value} on {name(emitter())}On an event, matches in the same block arrive as one message. A message links to its transaction, or for several matches to the block, on the chain’s explorer, and to the alert in the app.
Condition alerts
A condition alert can watch for:
| Trigger | Alerts when | Example |
|---|---|---|
| Metric threshold | A metric crosses a line or another metric, moves against an earlier reading, or runs above its usual level | Available liquidity below $1M; hourly fees above three times their usual hour |
| Gone quiet | A contract emits none of an event for a stretch | No deposits for six hours |
| Failing calls | A contract’s transactions fail, by how many failed and what share | More than half of a router’s transactions failing over an hour |
| Overdue | Something opened is not answered in time, optionally matched on a shared field such as a request id | A withdrawal requested and not claimed within three days |
| Row threshold | An open row of a table breaks a rule on a column read from the contract | A loan’s health factor below 1.1 |
| Column of a group | A contract in a group breaks a rule on one of the group’s columns | A vault holding less than $1M |
| User activity | A user in a group of users meets a rule you write | An LP withdrawing half of what it held. See Alerts on users |
A row threshold, a column of a group and an alert on users judge each row, contract or user on its own: each alerts and clears by itself, and new ones are judged as they appear. A column of a group sends to every destination in the workspace. Gone quiet, failing calls and overdue on a group cover the contracts in it when the alert is made.
Rules on a metric
| Rule | Alerts when |
|---|---|
value < 25000 | The value is below a line (> for above) |
value > {Vault reserves} * 1.05 | It is more than 5% above another state metric, named in braces |
value < ago(24h) * 0.8 | It is down more than 20% on a day ago, up to 90 days back |
value < previous * 0.99 | It falls more than 1% from one reading to the next. Sends each time, with no all-clear |
total(1h) > 5000000 | An activity metric’s total over the last hour is above a line |
total(1h) > before(1h) * 1.1 | That total is up more than 10% on the hour before |
total(1h) > 3 * usual(1h, 7d) | That total is more than three times its usual hour over the last 7 days |
value rules are for a state metric on one contract or wallet; a metric over a group or a table takes a line, such as value > 50000. total() rules are for an activity metric, over windows from 5 minutes to 7 days. A row threshold or a column of a group is written the same way: value < 1.1.
Messages
The first message leads with the alert’s level, Critical: or Warning:, and the all-clear with Recovered::
Critical: ETH buffer has fallen below 25,000 ETH (now 24,810 ETH)
Recovered: ETH buffer is back above 25,000 ETH · critical for 2h 10mNothing is sent in between, however long the condition holds, and an alert needs no reply. A condition that starts again within 10 minutes of the last message waits until those 10 minutes are up, and is not sent if it has cleared by then.
In the app
The Alerts page in the contract.dev app lists every alert. Open one to see what it watches, where it sends and every message it sent, kept whether or not it had a destination. From there, Pause, Resume or Delete it. A row threshold or a column of a group opens its table or group instead; Delete it from the list.
| Status | Meaning |
|---|---|
| Active | Running |
| Paused | Sends nothing until resumed |
| Alerting | Its condition holds now |
| No data | No reading fresh enough to judge, so it cannot alert |
| Not enough history | An alert on users that cannot judge any of its users yet |
Ask your agent
Alerts are created and changed by your coding agent, the Slack/Telegram assistant or the CLI. Describe what you want to hear about; your agent picks the type, writes the rule and sets where it sends. See Agent Integration.
Message #trades whenever a swap over $100k goes through one of our pools.Alert us if any market's available liquidity falls below $1M.Tell us on Telegram if a withdrawal request goes unclaimed for three days.Lower the Treasury low alert to 20,000 ETH.From the CLI
contract-dev alert create "Treasury low" --on metric:"Treasury ETH" --when "value < 25000" --to "#risk"
contract-dev alert create "stETH quiet" --on steth --silence --each Transfer --for 24h
contract-dev alert update "Treasury low" --when "value < 20000"An alert’s rule, message, destinations and name change in place, on the same alert (a row threshold or a column of a group cannot be renamed). What an alert is on is set when it is made: to move it, delete it and make it again.
See alert for every flag.
Destinations
Alerts and reports send to Slack, Telegram and email. Connect them under Settings → Message destinations in the contract.dev app, or Slack and Telegram with channel add.
- Slack — Select Connect Slack workspace once. Then name a channel, such as
#alerts, when you set up an alert or report. A private channel needs the bot invited first:/invite @contract.dev. - Telegram — Select Direct message for a chat with the bot, or Connect Telegram group, then press Start in Telegram.
- Email — Select Add email and enter an address.
A destination can be shared by any number of alerts and reports, and each can send to several. Test sends a test message. An alert or report with no destination still runs, and everything it sends is kept on its page in the app.