Automatically compare Oracle prices with external sources and alert admins when deviation exceeds 2%.
The sanity check runs automatically on every price fetch. No configuration needed!
curl http://localhost:3000/api/v1/sanity-check/check/NGNcurl http://localhost:3000/api/v1/sanity-check/check-allcurl http://localhost:3000/api/v1/sanity-check/thresholdWhen deviation exceeds 2%, admins receive:
🚨 Price Sanity Check Alert
Currency: NGN
Oracle Price: 150.5000
External Price (CoinGecko): 147.0000
Deviation: 2.38% (Threshold: 2.0%)
Difference: 3.5000
The Oracle price differs significantly from the external source.
✅ Sanity check passed for NGN
deviationPercent: 1.55%
⚠️ SANITY CHECK FAILED: NGN price deviation exceeds 2%
deviationPercent: 2.38%
Edit src/services/sanityCheckService.ts:
private readonly DEVIATION_THRESHOLD = 2.0; // Change thisAdd to .env:
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...npm run test:jest -- sanityCheck.test.tsSee SANITY_CHECK.md for complete documentation.
- Price fetched from Oracle sources
- Sanity check compares with CoinGecko/ExchangeRate-API
- If deviation > 2%, warning logged + webhook sent
- Price submission continues (non-blocking)
- ✅ Automatic on every price fetch
- ✅ Non-blocking (doesn't stop Oracle)
- ✅ Multiple external sources
- ✅ Webhook alerts to Discord/Slack
- ✅ 2% deviation threshold
- ✅ Manual check endpoints available