Notify
Reports and alerts: everything the workspace sends, and the destinations it sends to. See Notifications.
Requires contract-dev login. A notification is named by its id or, when exactly one matches, its name.
notify
List every report and alert: type, name, when it sends, status, when it last sent, and id. notify list reads the same.
contract-dev notify [list] [--type report|alert] [--status <status>]| Flag | Description |
|---|---|
--type report|alert | Only reports, or only alerts. |
--status <status> | Only the notifications in this status, as the list prints it. |
Where each one sends is in notify show.
notify add report
A table of figures on a schedule.
contract-dev notify add report ["<name>"] [--template daily|weekly] [--row <line>]… [--table "<table>[ | …]"]…
--columns 24h[,7d,30d] [--compare] [--at <hour>] [--on <weekday>] [--tz <zone>]
[--every <interval>] [--only-when "<expr>"] [--scope <scope>] [--to <dest>]…| Flag | Description |
|---|---|
--template daily|weekly | Start from a template: its name, schedule and lines. Daily: active wallets, transactions, reverted share, volume in and out. Weekly adds alerts opened. |
--row <line> | A line of the table, in order; repeat for more. Replaces the template’s lines. See Lines. |
--add-row <line> | A line after the template’s. |
--table "<table> | …" | A table of rows under the lines, up to 3. See Tables in a report. |
--columns <w>,<w>… | The windows every line prints: 24h, 24h,7d,30d, 1h. A minute at the least. Required with --row. |
--compare | Add the change against the window before. |
--at <hour> | Daily at this hour, 0–23. Default 9. |
--on <weekday> | Weekly, on this day, at --at. |
--tz <zone> | The clock --at reads, as an IANA zone: Europe/London. Default: the machine’s. |
--every <interval> | Every interval instead, on the UTC clock: 1m, 10m, 1h, 6h, 1d. A minute to 7 days. |
--only-when "<expr>" | Send only when this holds, over the lines by label: "{Breached markets} > 0". |
--scope <scope> | What the lines add up over: workspace (default), tag:<group> or one watched contract. |
--to <dest> | Destinations by id, label or kind, from channels; repeat or comma-separate. Optional. |
Name the report, or start from --template.
contract-dev notify add report --template daily --to "#analytics"
contract-dev notify add report "Morning" --row transactions --row metric:"Treasury ETH" --columns 24h,7d --at 9
contract-dev notify add report "Hourly swaps" --every 1h --row eventCount:Swap --columns 1h --to telegram
contract-dev notify add report "Weekly risk" --on monday --row metric:"Breached markets" --columns 7d \
--only-when "{Breached markets} > 0" --to "#risk"Created report "Morning" (cmh5repo0001morning00aa).
First table queued: it shows on the report's page within a minute, then the report runs on schedule.Without a destination, the report still runs on schedule and every run shows on its page in the app.
Lines
--row | Line |
|---|---|
activeWallets | Wallets that sent a transaction. |
transactions | Transactions. |
revertedShare | The share of transactions that reverted. |
volumeInUsd · volumeOutUsd | Dollar volume in and out. |
alertsOpened | Alerts opened. |
eventCount:<Event> | Emissions of one event. |
metric:"<name>" | Any metric, state or activity. |
"metric:<name>=<clauses>" | A metric made for this report, in the clauses of metric define: "metric:Supply=on steth; call totalSupply()". It stays off the Metrics page and is deleted with the report. |
"formula:<Label>=<expr>[; call <name>=<call>]…" | An expression over reads. |
<line>@<scope> | A default line with its own scope, such as transactions@tag:pools. |
Tables in a report
--table "<table> | sort <col> | top <n> | days <n> | where <expr> | columns a,b"The table by name or id, then its clauses, each after a |. "<name>=<clauses>" makes a table for this report alone, deleted with it.
contract-dev notify add report "Big swaps" --table "Swaps | sort {Amount} | top 5 | days 1" --to "#trades"notify add alert
A message on one of two triggers: when something happens, or when a condition is met.
When something happens
A message for each match, from now on. A block’s matches arrive in one message. Nothing is sent for what happened before the alert was made.
contract-dev notify add alert ["<name>"] --on <contract> --event <Name> --message "<text>" [--when "<condition>"]
[--value "<expr>"] [--read <name>=<call>]… [--to <dest>]…| Flag | Description |
|---|---|
--on <contract> | The watched contract, by name or address. |
--group <group> | Instead of --on: every contract in the group. |
--event <Name> | The event that triggers it. |
--message "<text>" | The message, with {…} over the event’s fields and reads: "{name(sender())} swapped {value}". |
--when "<condition>" | Only the matches where this holds: "value >= 100000". |
--value "<expr>" | What each emission is worth: "usd(abs(amount0), t0)". |
--read <name>=<call> | A view of the emitting contract the value needs, named: --read t0=token0(). |
--to <dest> | Destinations; repeat or comma-separate. Optional. |
Instead of --event, an alert can follow:
| Flag | Sends when |
|---|---|
--on-value "<metric>" | A metric changes. |
--on-row "<table>[:opened|finished|both]" | A table’s row opens or finishes. |
--on-member "<group>[:joined|left|both]" | A contract joins or leaves a group. |
--metric "<metric>" | An activity metric records a match. |
contract-dev notify add alert "Large swaps" --group "Uniswap pools" --event Swap --read t0=token0() --read t1=token1() \
--value "max(usd(abs(amount0), t0), usd(abs(amount1), t1))" --when "value >= 100000" \
--message "{name(sender())} swapped {value} on {name(emitter())}" --to "#trades"
contract-dev notify add alert "New markets" --on-member "Wildcat markets" --message "{name(contract)} joined"When a condition is met
A message when the condition starts, and a recovery message when it clears.
contract-dev notify add alert ["<name>"] --on metric:"<metric>" --when "<formula>" [--remind] [--to <dest>]… [--max-age <sec>]| Flag | Description |
|---|---|
--on metric:"<metric>" | Any metric, state or activity, by name or id. --on "metric:<name>=<clauses>" defines one for this alert, off the Metrics page. |
--when "<formula>" | The rule, naming the metric as value. Required. |
--remind | Re-send every hour while the condition holds, until it clears or is acknowledged. Off by default: one message, then the recovery message. |
--max-age <sec> | A reading older than this is not judged on. At least 30. |
--to <dest> | Destinations; repeat or comma-separate. Optional. |
--when | Alerts when |
|---|---|
"value < 25000" | It falls below a line (> for above). |
"value > {Vault reserves} * 1.05" | It crosses another metric, named in braces. |
"value < previous * 0.99" | It falls more than 1% from the reading before. |
"value < ago(24h) * 0.8" | It is down more than 20% on a day ago. |
An alert on a condition has one line: a second line is a second alert.
contract-dev notify add alert "Treasury low" --on metric:"Treasury ETH" --when "value < 25000" --remind --to telegram
contract-dev notify add alert "Supply low" --on "metric:Supply=on steth; call totalSupply()" --when "value < 9000000"A contract goes quiet
contract-dev notify add alert ["<name>"] --on <contract> --silence --event <Name> [--for 24h] [--remind]
contract-dev notify add alert "stETH quiet" --on steth --silence --event Transfer --for 24hNo emission of the event for the window. --for is a minute to 30 days: 90m, 24h, 3d. Default 24h.
Its transactions fail
contract-dev notify add alert ["<name>"] --on <contract> --failures [--rows "<where>"] [--by <column>] [--when "<rule>"] [--for 1h]| Flag | Description |
|---|---|
--rows "<where>" | Which transactions count, such as swaps alone. |
--by <column> | Judge each value of a column on its own. |
--when "<rule>" | A rule over failed, total and share in the window: "failed >= 5 and share > 0.5". |
--for <window> | The window. Default 1h. |
Something is left unanswered
contract-dev notify add alert ["<name>"] --on <contract> --overdue --event <Open> --answer <Close>… [--match <field>]… --for 3d
contract-dev notify add alert "Withdrawal unclaimed" --on "Withdrawal Queue" --overdue --event WithdrawalRequested \
--answer WithdrawalClaimed --match requestId --for 7dAn open event not followed by an answer within --for. --match pairs each open with its own answer on the fields they share (requestId, or requestId=_requestId when the names differ). Without it, any answer closes the oldest open.
A row of a table
contract-dev notify add alert "<name>" --on table:"<table>" --column "<label>" --when "value < 1.1" [--to <dest>]…
contract-dev notify add alert "Loan at risk" --on table:"Loans" --column "Health factor" --when "value < 1.1"The rule on every open row of a state table, on a read column. Each row alerts and clears on its own. A row gets the rule when it opens and loses it when it finishes. Every row’s alert sends where the rule does. --remind is not taken.
Created row threshold "Loan at risk" (cmh5moni0007loan0000aa) on Loans: Health factor below 1.1.
14 open rows carry it now; each row opened from now gets it, each row finished loses it.
No destination yet: its alerts show in the app until one is set (notify set <name> --to <dest>).notify lists a row threshold as one line, however many rows carry it.
notify show <name>
Its settings and its history: a report’s runs, or an alert’s messages. A row threshold lists its rows, each with its status.
contract-dev notify show "Morning"notify set <name>
Change a notification with the flags it was made with. It keeps its history.
contract-dev notify set <name> [--when …] [--message …] [--row …] [--columns …] [--to <dest>…] [--remind | --no-remind] …| Flag | Description |
|---|---|
--to <dest>… | Replace the destinations. On a row threshold, every row’s alert follows, and --to none sends nowhere. |
--remind · --no-remind | Turn hourly reminders on or off. |
--add-row <line> · --remove-row <label> | A report: add or remove one line. |
--no-tables | A report: drop its tables. |
--always | A report: drop its --only-when. |
contract-dev notify set "Morning" --add-row volumeInUsd
contract-dev notify set "Loan at risk" --to "#risk"
contract-dev notify set "Treasury low" --no-remindnotify run <name>
Run a report now, off its schedule. notify send reads the same. Its destinations get it within a minute; without one, the table is on the report’s page in the app. An alert cannot be run.
contract-dev notify run "Morning"notify ack <name>
Acknowledge a reminding alert: reminders stop, and the recovery message still comes when it clears.
contract-dev notify ack "Treasury low"Acknowledged "Treasury low" — reminders stop; you'll still hear when it clears.Each alert that opened is also listed, and acknowledged by id, with alerts.
Rename, pause, resume, delete
contract-dev notify rename <name> "<new name>"
contract-dev notify pause <name> # send nothing until resumed
contract-dev notify resume <name>
contract-dev notify delete <name>… # one or several, with their historydelete resolves every name before deleting anything, so a typo deletes nothing. A name several notifications share is never guessed at: use the id. On a row threshold, pause, resume and delete act on every row.
channels
List the workspace’s destinations: id, kind, label, target. These are what --to accepts. See Destinations.
contract-dev channelscmh2chan0001tg0000000aaa telegram Ops group -1001234567890
cmh2chan0002slack000000bb slack #alerts C07ALERTS1A destination is named by its id, its label (with or without the #), or its kind when the workspace has one of that kind. A disabled destination is refused by --to; enable it first.
channels add telegram
Connect a Telegram chat or group. The command prints a link for a chat with the bot and one for a group; open one in Telegram and press Start. It waits until the chat is connected.
contract-dev channels add telegramOpen one of these in Telegram and press Start:
a chat with the bot https://t.me/…
a group https://t.me/…
Waiting for Telegram…
Connected telegram Ops group (cmh2chan0001tg0000000aaa). Send it a test with: contract-dev channels test cmh2chan0001tg0000000aaachannels add slack
Connect Slack, then add a channel.
contract-dev channels add slack [--channel <name>] [--workspace <name>] [--connect] [--no-browser]| Flag | Description |
|---|---|
--channel <name> | Add this channel as a destination; the bot posts a note there. Without it, the command lists the channels it can add. |
--workspace <name> | The connected Slack workspace the channel is in. |
--connect | Connect another Slack workspace. |
--no-browser | Print Slack’s approval link instead of opening it. |
The first time, the command opens Slack’s approval page in a browser signed in to contract.dev and waits for the connection. A private channel appears once the bot is invited to it (/invite @contract.dev). Write the channel without its #, or quote it: an unquoted # starts a comment in most shells.
contract-dev channels add slack --channel analyticsAdded #analytics in Acme (cmh2chan0002slack000000bb); the bot posted a note there.Email destinations are added in the app, under Settings → Message destinations. Discord and webhook destinations can no longer be added; existing ones are listed here, and can be tested, disabled and removed.
Test, disable, enable, remove
contract-dev channels test <id|label> # send a test alert
contract-dev channels disable <id|label> # keep it, send nothing
contract-dev channels enable <id|label>
contract-dev channels remove <id|label> # disconnect it| Action | Needs |
|---|---|
test, add telegram, add slack | Write access. |
enable, disable, remove | An owner or admin. |