-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
backendBackend / Rust core workBackend / Rust core work
Description
Overview
Add the background alert checker that runs inside the existing 10s polling loop and checks all active alert rules against the latest fee stats. When a rule fires, it updates the triggered flag in SQLite and sends an email via Resend if an email address is configured.
Alert Checker Logic
On every poll cycle (after fetching and storing latest fee stats):
- Load all active alerts from the
alertstable - For each alert, compare the latest value of
metric(avg_fee / base_fee / max_fee) againstthresholdusingcondition(ABOVE / BELOW) - If the condition is met and
triggered = 0→ fire the alert:- Set
triggered = 1in SQLite - Send email if
emailis set
- Set
- If the condition is no longer met and
triggered = 1→ reset:- Set
triggered = 0(alert is ready to fire again next time)
- Set
Email via Resend
- Use Resend HTTP API (no SDK — plain HTTP POST to
https://api.resend.com/emails) RESEND_API_KEYloaded from environment variableRESEND_FROM_ADDRESSloaded from environment variable (e.g.[email protected])- Email subject:
⚡ Stellar Fee Alert — {metric} is {condition} {threshold} stroops - Email body (plain text):
Your fee alert has triggered. Condition: {metric} {condition} {threshold} stroops Current value: {current_value} stroops Time: {timestamp} View dashboard: https://stellarfees.dev/dashboard - If Resend call fails, log the error but do NOT crash the poll loop
Acceptance Criteria
- Alert checker integrated into the existing poll loop in
horizon.rsor the scheduler - Correctly evaluates ABOVE and BELOW conditions for all three metrics
-
triggeredflag set to 1 on fire, reset to 0 when condition clears - Email sent via Resend HTTP API when
emailfield is present -
RESEND_API_KEYandRESEND_FROM_ADDRESSloaded from env; checker skips email silently if key is missing - Email send failure is logged but does not interrupt the poll loop
- Unit tests for the condition evaluation logic (ABOVE / BELOW for all metrics)
-
.env.exampleupdated withRESEND_API_KEYandRESEND_FROM_ADDRESS
Notes
- Related backend issue:
[Phase 2] feat(core): fee alerts — database schema and CRUD endpoints - Related frontend issue:
[Phase 2] feat(ui): dashboard — fee alerts panel
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
backendBackend / Rust core workBackend / Rust core work