DEV Community

Daniel
Daniel

Posted on Fully Autonomous

Crypto Alert: Your Chart Does Not Need a Night Shift Supervisor

At 02:14, the chart moves.

At 02:15, an operator refreshes it.

At 02:16, the operator refreshes it harder, as though the browser has been withholding liquidity out of spite.

We can automate this shift.

MatrixSwarm’s crypto_alert agent watches public cryptocurrency prices and individual Bitcoin addresses, evaluates the rules you give it, and hands notifications to your swarm’s alert relays. Phoenix provides the Crypto Watches panel for creating, editing, pausing, and deleting those rules.

The agent takes observation duty. You can stop impersonating a cron job with caffeine dependency.

What is on the duty roster?

The current agent supports price thresholds, percentage and absolute moves, derived asset ratios, conversion-value thresholds, and confirmed Bitcoin address changes. Each active watch has its own worker and state; one shared Phemex connection supplies the market prices. An agent accepts up to 64 watches.

It uses public data. There is no exchange account to connect and no exchange API key to supply. It does not place orders or sign blockchain transactions. Bitcoin watches need public addresses, never seed phrases, private keys, or extended wallet keys.

Our examples below use invented numbers to explain the controls. They are not current market quotes. The crystal ball has been removed from the dependency list.

Install once, assemble a small swarm

If MatrixOS is missing from your server, add and test its SSH connection in Phoenix’s Registry, including the trusted host fingerprint. Open Railgun → Install MatrixOS…, choose the host, then use Local Full Install with your MatrixOS source folder or Install from GitHub. For a fresh environment, select Create new venv, install, and check the completion result. Installation needs root or passwordless sudo access on the target.

Already installed? Carry on. The runtime does not need a ceremonial reinstallation every time we give it a new job.

Open Deploy → Swarm Workspaces. Create a New workspace or Open an existing one. Keep the matrix root and add these agents beneath it:

Agent Job on this shift
crypto_alert Observes prices and Bitcoin addresses, evaluates saved rules
matrix_https Accepts Phoenix commands through HTTPS ingress
matrix_websocket Returns configuration and live watch updates to Phoenix
log_streamer Provides Agent Logs for troubleshooting
An alert relay Delivers notifications to Slack, Discord, Telegram, or email

The current HTTP ingress is named matrix_https in the palette. Resolve the signing assignments and the HTTPS/WSS connection and certificate requirements, using endpoints Phoenix can reach. Keep the supplied service roles for your first run.

Crypto Watches sends its own live updates through the RPC/WebSocket return path. log_streamer is for the agents’ operational logs; it does not carry the price feed. Also, the external Phemex WebSocket and your swarm’s matrix_websocket agent are separate connections with separate jobs.

One socket watches the market. The other reports to the cockpit. Neither needs to become a podcast.

Give the watchkeeper a memory

Resolve both of crypto_alert’s required constraints: packet_signing and persistent_state.

Create a dedicated Persistent State profile in the Registry, then assign it to the agent’s persistent_state constraint in the workspace. Keep that same profile for future deployments of this crypto agent on the same host and universe. Give separate running crypto agents separate profiles.

That profile supplies the stable identity and encryption material for saved watches and their trigger state. With the state directory and profile retained, the agent can restore them after a restart or redeployment, even when its agent ID changes.

A fresh key and an empty directory are not a backup strategy. They are amnesia with excellent branding.

In the agent’s workspace Config editor, check Bitcoin Esplora API (HTTPS) and Alert delivery role. The defaults are https://blockstream.info/api and hive.alert. API endpoint changes require a restart or redeployment. Everyday watch edits happen later in the live panel.

For an older workspace, make sure it includes and resolves the current persistent-state constraint. Updating Python source alone does not provision that assignment.

Launch through Railgun

Click Deploy inside the workspace. Supply a deployment label, select the Registry SSH target, set a universe and runtime Linux user, review the resolved directive, and launch. Use a separate demo universe for your first exercise.

Phoenix prepares the encrypted deployment data. Railgun verifies the SSH host, prepares the runtime account and applicable grants, and sends the sealed boot envelope to MatrixD over SSH stdin. MatrixD decrypts it in memory and starts the swarm without leaving loose directive/key boot files behind.

Check the remote launch result, then choose the deployment and Connect. Deployment starts the swarm; Connect opens its cockpit. Select the crypto agent and open Crypto Watches.

The briefing is over. We may now stop configuring the chair and sit in it.

Your first price watch

Start with one rule so you can follow the entire route from observation to notification.

  1. Let the panel load the agent’s saved watch list.
  2. Click + Price / Pair Watch.
  3. Give it a useful label, such as BTC observation test, and use BTC/USDT as the pair.
  4. Choose price_above and enter a positive target in Alert price (USDT). The new card deliberately leaves the target blank.
  5. Leave Active, Alert Enabled, and Stream Enabled checked. Select One Shot for this first delivery test.
  6. Click Save Changes and wait for the saved encrypted-state revision acknowledgment.
  7. Check the feed status, the card’s observations, its hit count, and the actual receiving relay destination.

A threshold rule can fire on its first fresh observation if the condition is already satisfied. For an intentional test on a destination you control, choose a target already satisfied by the fresh quote. One Shot limits that watch to one trigger. No purchase, sale, or transfer is needed to test the alert route.

Until Save Changes succeeds, the card is a draft and the agent continues using its last saved configuration. Looking extremely satisfied with the form does not transmit it.

The rule menu, translated into human

Trigger Meaning
price_above Price or ratio is at or above the target
price_below Price or ratio is at or below the target
price_change_above / price_change_below Positive percentage magnitude upward/downward from this watch’s armed baseline
price_delta_above / price_delta_below Positive absolute magnitude upward/downward from the baseline, in the pair’s quote units
asset_conversion The calculated value of a source amount reaches a target amount of another asset
wallet_change A watched Bitcoin address’s confirmed balance or confirmed transaction count changes

For a downward percentage or delta rule, enter a positive magnitude. Choose the below trigger to specify the direction.

Percentage and delta rules measure from the watch’s armed baseline, not a rolling 24-hour window. After a trigger, that watch’s baseline resets to the observed price.

For example, a hypothetical baseline of 100 and an upward move of 5% triggers at 105 or more. If the observation that fires it is 106, the new baseline becomes 106. A second watch on the same pair keeps its own baseline.

The fact that the upstream ticker includes 24-hour market data does not turn your custom rule into a 24-hour rule. The paperwork matters, even when the candles are excited.

Reset Band: please stop ringing the same doorbell

Threshold and conversion rules latch after firing. Reset Band (%) determines how far the observed value must retreat before the rule can arm again. The default is 0.5%.

Using an invented threshold of 100:

Rule Fires With a 0.5% band, rearms when
price_above At 100 or higher Value falls to 99.5 or lower
price_below At 100 or lower Value rises to 100.5 or higher

Rearming permits a later qualifying observation to trigger again, subject to cooldown and limits. Remaining beyond the target does not produce a new threshold alert every second. With a zero reset band, the value still has to move strictly to the other side of the threshold to rearm.

Cooldown adds a minimum interval between triggers. It does not replace the reset band, and it does not promise a reminder every cooldown period. Conditions are evaluated from observations; a brief move between observations can be missed.

One Shot allows one trigger, then leaves the watch complete until you change and save it. Trigger Limit sets a maximum hit count; 0 means unlimited, unless One Shot is selected. Reaching a limit leaves the card visible.

A fired watch has done its assigned job. It is not sulking because you looked away.

Pairs, ratios, and conversion arithmetic

BTC/USDT is a Phemex spot price in USDT per BTC. A cross-pair such as BTC/ETH is derived by dividing BTC/USDT by ETH/USDT. Its units are ETH per BTC.

Suppose the observed source prices were 60,000 USDT per BTC and 3,000 USDT per ETH. The derived ratio would be 20 ETH per BTC. Reversing the pair gives 0.05 BTC per ETH. Read the dynamically labeled Alert ratio field before typing the target.

For asset_conversion, set From Asset, To Asset, the source amount, and the target amount. With those same invented prices, 0.1 BTC calculates to 2 ETH:

Source amount × source USDT price ÷ target USDT price.

These values describe arithmetic using spot observations. They are not executable swap quotes and do not include fees, spreads, slippage, or market depth. The agent observes the relationship; it does not execute the conversion.

Both required price legs must be fresh. Unsupported markets or stale data produce a waiting status instead of an imaginary number with impressive decimal places.

The agent uses Phemex’s public spot_market24h.subscribe feed. Its endpoint follows the official public endpoint migration notice; the spot protocol reference describes the ticker messages. The implementation checks freshness, rejects quotes older than 15 seconds, and clears cached quotes during reconnects. Keep the host’s clock accurate.

Bitcoin addresses: the blockchain has a visitor log

Click + Bitcoin Address, enter an individual Bitcoin mainnet public address, and choose a check interval. The default is 60 seconds, with a minimum of 30 seconds. Save and wait for acknowledgment.

The first successful lookup establishes the baseline. It does not notify you about the address’s entire history as a welcoming ceremony.

The card can show confirmed BTC, pending net BTC, confirmed transaction count, and a USDT valuation when a fresh BTC price is available. Confirmed-change monitoring can continue while the Phemex price feed is unavailable; the valuation simply depends on that separate feed.

An alert can fire when either the confirmed balance or confirmed transaction count changes. A count change can therefore trigger even when the net balance is unchanged. Pending activity is displayed but does not trigger this rule. During cooldown, the next eligible notice reports the net confirmed change since the previous notice.

This is periodic address-state monitoring. It can miss intermediate changes between polls, and chain reorganizations can change the observed state. It is not a complete transaction ledger or a configurable multi-confirmation settlement policy.

Watch each address you care about. One address does not represent every receive/change address in an HD wallet. This agent does not scan xpubs or index Ethereum/ERC-20 wallet activity.

The default explorer is Blockstream’s Esplora API. The agent reads the address statistics documented by Esplora. A public explorer can see the queried addresses and the request’s network origin. You can configure your own HTTPS Esplora endpoint; keep valid certificate trust in place.

Publicly visible on a blockchain does not mean your personal address collection needs its own press release.

Send the report where somebody will read it

Crypto Alert uses the configured alert role, normally hive.alert, to find notification destinations. You can combine it with any of the swarm’s usual alarm relays:

Destination Agent Optional signed alert-payload encryption
Slack slack_relay Not provided by this relay’s current alert configuration
Discord discord_relay Yes
Telegram telegram_relay Yes
Email email_send Yes

Configure the relay’s destination and credentials through its usual Registry/workspace assignments. For Discord, Telegram, or email, optional encrypt_alerts protects the alert payload using the assigned signing/encryption material. The receiving side needs the matching keys and compatible decryption support to read that envelope. This is a separate setting from HTTPS/WSS or SMTP transport security.

Every discovered endpoint advertising the chosen role is considered. If you need selective delivery, use a dedicated role shared by this crypto agent and the intended relay instead of assuming the first relay wins.

Address alert text abbreviates the address, but labels and balance details still belong to the report. Choose labels, recipients, and encryption accordingly. Authorized Phoenix panels can display the full address.

Three switches and a save button walk into a cockpit

Control Effect after saving
Active off Stops that watch’s worker
Alert Enabled off Keeps observation running while suppressing notifications
Stream Enabled off Stops that watch’s periodic panel updates while remote monitoring continues

Closing or hiding the panel releases its live subscription. It does not stop the saved remote watches. The panel’s subscription lease expires if the client disappears; MatrixOS continues the monitoring work.

To pause a watch, clear Active and Save Changes. To remove it, delete its card and save. Saving an empty list removes all watches from this agent.

Any changed watch that you save resets that watch’s baseline, hit count, and crossing state—even a label or toggle change. Unchanged watches retain theirs. Clicking Save on an identical completed watch does not rearm it; make an intentional edit and save when you want a fresh run.

Reload Saved fetches the agent’s authoritative list and asks before discarding unsaved edits. Revision checks prevent another panel from silently overwriting a newer list. If a save times out, its outcome is unknown: reload before retrying.

The panel also offers Clean Cockpit, Fusion Reactor, and Arcane Oracle display styles. Pick your preferred level of theatrical instrumentation. The oracle still uses the same rules; the robe grants no additional foresight.

Persistence and delivery: read the receipt

Watches and their saved runtime state use authenticated encrypted storage through the Persistent State profile. Retain the encrypted files and securely back up the profile’s key material. Keeping only ciphertext is an ambitious way to archive something you can never read again.

The deployment’s initial watch list seeds a new store only. It does not overwrite an existing saved list, including an intentionally empty one. Invalid or undecryptable saved state fails closed. Older experimental watch stores are not automatically migrated.

A trigger’s state is persisted before notification is attempted. The card’s delivery field has a precise meaning:

Status What it tells you
pending The trigger was recorded; a completed delivery result is not recorded
queued The notification was handed to at least one swarm endpoint
failed No successful handoff was recorded

Queued does not confirm arrival in Discord, Telegram, Slack, or an inbox. Check the intended relay and recipient. Failed or interrupted events are not automatically retried; that avoids duplicate replays but means a recorded trigger can lack a delivered notification. One Shot and hit limits count triggers, not messages you personally read.

This is best-effort monitoring and alerting. The receipt says what happened, rather than what we hoped happened.

When the watchtower is quiet

Symptom First place to look
Waiting for fresh prices Phemex connectivity, supported USDT markets for both legs, and host clock
Card says unsaved draft Complete the fields, Save Changes, and read the acknowledgment
Price is past the target but no new alert One Shot, hit limit, reset band, cooldown, Active, and Alert Enabled
Panel values look stale Phoenix connection, Stream Enabled, and the RPC/WebSocket return route
Bitcoin watch reports an SSL error Host CA trust, proxy configuration, and the HTTPS explorer certificate
Save fails or revision conflicts Persistent State assignment, directory write access, and Reload Saved
Hit count rises but no external message arrives Delivery status, alert role, relay configuration, and recipient

Use Agent Logs through log_streamer for the remaining clues. Start with one saved watch and one intended relay, verify the whole route, then expand the roster.

Install, assemble, resolve, deploy, connect, save, verify. The same small-swarm habit now gives you a remote watchkeeper with a memory, a notification route, and clearly defined rules.

The chart may continue making questionable life choices. You no longer have to supervise every candle in person.

Victory Always. The night shift has been assigned.


🌐 Links & Resources:

Try MatrixSwarm: https://matrixswarm.com

Join the Community / Discord: https://discord.gg/2USbWVBVV

Download Server: https://github.com/matrixswarm/matrixswarm

Youtube: https://www.youtube.com/channel/UCMjiY4_-W2KP5fHXO0eC2ug

Top comments (0)