Skip to content

Health factor#201

Open
OluRemiFour wants to merge 2 commits into
Dgetsylver:mainfrom
OluRemiFour:health-factor
Open

Health factor#201
OluRemiFour wants to merge 2 commits into
Dgetsylver:mainfrom
OluRemiFour:health-factor

Conversation

@OluRemiFour
Copy link
Copy Markdown
Contributor

Close: #58

Summary

Health-Factor Alert Channel — Complete
alerts/src/schema.sql

hf_threshold REAL DEFAULT NULL — user-configured alert trigger, NULL = APY-only subscriber
hf_breached INTEGER DEFAULT 0 — tracks whether we're inside an active breach window (prevents spam)
alerts/src/stellar.ts

Extended ReserveRates interface with optional cFactor? and lFactor?
Parses them from reserveRaw.config.c_factor / l_factor (falls back to 0.9 / 1.0)
alerts/src/email.ts

New sendHealthFactorAlert() — rich HTML email showing current HF vs threshold, with liquidation risk copy and CTA
alerts/src/index.ts — the core logic:

Subscribe route: accepts optional hf_threshold, validates >= 1.0, stores in D1
Cron handleCron: for every bracket, computes currentHf = (cFactor × lev) / ((lev−1) / lFactor), then:
HF subscribers: sends alert when currentHf < threshold AND hf_breached = 0, sets hf_breached = 1. Resets to 0 when HF heals — exactly one email per breach window
APY subscribers: unchanged — 24h cooldown still applies
frontend/index.html

New "Health Factor Threshold (Optional)" in the alert modal
Modal title updated to "Position Alerts"
frontend/src/main.ts

Reads and validates the threshold input (must be ≥ 1.0 or empty)
Conditionally includes hf_threshold in the /subscribe POST body
Clears the field on successful subscription

Related Issue

Closes #58

Checks

  • I read the contribution guide.
  • I kept this pull request scoped to the linked issue.
  • I ran the relevant local checks or explained why they were skipped.
  • For Drips wave issues, I claimed the issue before opening this pull request.

Notes for Reviewers

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@OluRemiFour Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@OluRemiFour
Copy link
Copy Markdown
Contributor Author

Done, Close: #201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E1: Health-factor alert channel

1 participant