feat(alerts): add liquidation imminent channel with rate-limit and we…#179
Open
yunus-dev-codecrafter wants to merge 1 commit into
Open
Conversation
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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:
Changes:
alerts/src/email.ts: AddedsendLiquidationAlert()function with new templatealerts/src/index.ts: Integrated HF monitoring cron job with rate-limiting and optional webhook supportRelated Issue
Checks
Notes for Reviewers
Key Implementation Details:
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.
Webhook Integration: Optional
LIQUIDATION_WEBHOOK_URLenvironment variable enables parallel POST requests with user/HF payload, useful for external automation or alerting systems.Cron Frequency: Background job runs at configurable intervals (recommend every 5-10 minutes) to catch HF dips quickly while avoiding excessive database queries.
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.