Skip to content

feat(stables): add stablecoin depeg price monitoring#185

Open
spalen0 wants to merge 7 commits intomainfrom
feat/stablecoin-price-monitoring
Open

feat(stables): add stablecoin depeg price monitoring#185
spalen0 wants to merge 7 commits intomainfrom
feat/stablecoin-price-monitoring

Conversation

@spalen0
Copy link
Collaborator

@spalen0 spalen0 commented Mar 22, 2026

Summary

  • Adds stables/main.py that monitors stablecoin prices via DeFiLlama API
  • Sends critical Telegram alert when any token drops below $0.995
  • Tracks: DAI, USDS, USDe, sUSDe, syrupUSDC, syrupUSDT, USDT, USDC, FRAX, crvUSD, GHO, PYUSD, USD0
  • Runs hourly alongside other monitoring scripts

Closes #184

Setup required

  • Add TELEGRAM_BOT_TOKEN_STABLES and TELEGRAM_CHAT_ID_STABLES secrets to the repo (or it will fall back to TELEGRAM_BOT_TOKEN_DEFAULT)

Test plan

  • Verify DeFiLlama API returns prices for all configured tokens
  • Confirm Telegram alert fires correctly when threshold is breached
  • Validate hourly workflow runs the new script without errors

🤖 Generated with Claude Code

spalen0 and others added 5 commits March 22, 2026 13:23
Monitor stablecoin prices via DeFiLlama and send critical Telegram
alerts when any token drops below $0.995. Tracks DAI, USDS, USDe,
sUSDe, syrupUSDC, syrupUSDT, USDT, USDC, FRAX, crvUSD, GHO, PYUSD,
and USD0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add shared DeFiLlama price check utility (utils/defillama.py) and
integrate per-protocol stablecoin price monitoring:
- Maple: syrupUSDC, syrupUSDT
- Ethena: USDe, sUSDe

Alerts via Telegram when any token drops below $0.995.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ical alerts

Alerts route through each protocol's existing Telegram channel (maple,
ethena) — no separate stables channel needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add shared DeFiLlama price check utility (utils/defillama.py) using
the Alert system with CRITICAL severity for depeg alerts.

Per-protocol stablecoin price monitoring:
- Maple: syrupUSDC, syrupUSDT
- Ethena: USDe, sUSDe
- Infinifi: iUSD

Alerts fire when any token drops below $0.995.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

logger = get_logger("defillama")

DEPEG_THRESHOLD = Decimal("0.995")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is too high imo. This should be 0.98 even 0.97.

spalen0 and others added 2 commits March 23, 2026 18:08
…o remaining protocols

- Auto-register dispatch_emergency_withdrawal in utils/alert.py on import,
  removing manual register_alert_hook calls from 5 protocol files
- Add try/except ImportError guard on lazy import for resilience
- Add "maple" to DISPATCHABLE_PROTOCOLS
- Add stablecoin price monitoring to cap/liquidity.py with relaxed
  threshold (0.93) for DeFiLlama's unreliable cUSD pricing
- Clean up now-redundant dispatch imports

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@spalen0 spalen0 marked this pull request as ready for review March 23, 2026 17:15
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.

Token prices

2 participants