Skip to content

feat(alerts): add liquidation imminent channel with rate-limit and we…#179

Open
yunus-dev-codecrafter wants to merge 1 commit into
Dgetsylver:mainfrom
yunus-dev-codecrafter:liquidation-imminent-cron
Open

feat(alerts): add liquidation imminent channel with rate-limit and we…#179
yunus-dev-codecrafter wants to merge 1 commit into
Dgetsylver:mainfrom
yunus-dev-codecrafter:liquidation-imminent-cron

Conversation

@yunus-dev-codecrafter
Copy link
Copy Markdown

@yunus-dev-codecrafter yunus-dev-codecrafter commented May 29, 2026

…bhook support

closes #59

Summary

Implement high-priority liquidation alert channel that triggers when any subscribed user's health factor drops below 1.05, regardless of their configured threshold. This feature includes:

  • New "LIQUIDATION IMMINENT" notification template for critical HF alerts
  • Rate-limited notifications (maximum once per 6 hours per user) to prevent alert fatigue
  • Optional webhook POST capability that executes in parallel with email notifications
  • Background cron job that continuously monitors user health factors

Changes:

  • alerts/src/email.ts: Added sendLiquidationAlert() function with new template
  • alerts/src/index.ts: Integrated HF monitoring cron job with rate-limiting and optional webhook support

Related Issue

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

Key Implementation Details:

  1. Rate Limiting: Uses Redis or in-memory cache to track last alert timestamp per user, ensuring no more than one HF<1.05 alert per 6-hour window.

  2. Webhook Integration: Optional LIQUIDATION_WEBHOOK_URL environment variable enables parallel POST requests with user/HF payload, useful for external automation or alerting systems.

  3. Cron Frequency: Background job runs at configurable intervals (recommend every 5-10 minutes) to catch HF dips quickly while avoiding excessive database queries.

  4. Template Separation: "LIQUIDATION IMMINENT" uses distinct styling/tone from regular threshold alerts to emphasize urgency.

Testing: Manual testing performed on testnet loop. Alerts fire correctly when HF drops below 1.05 and respect the 6-hour rate limit.

Performance Considerations: Cron job is non-blocking and doesn't impact main alert pathway. Webhook requests timeout after 5s to prevent blocking email delivery.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@yunus-dev-codecrafter 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

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.

E2: Liquidation-imminent cron (HF < 1.05)

1 participant