Stay ahead of liquidations. Monitor β Detect β Analyze β Deliver.
DeFi traders often lose funds to liquidations because monitoring multiple derivative positions 24/7 is virtually impossible. Liquidation risks change dynamically based on market volatility, entry prices, and funding rates.
Sentrix is a lightweight, edge-native terminal client and daemon that continuously monitors your Injective derivative and spot portfolios. When a risk metric (such as a drop in margin ratio or proximity to liquidation price) is violated, Sentrix leverages advanced LLMs to explain the danger in plain English and deliver an actionable alert to Telegram or Discord before it is too late.
Key Features:
- β‘ Real-Time On-chain Monitoring: Polls Injective derivative positions and spot balances every 30s.
- π Deterministic Risk Detection: Instantly detects liquidation proximity, sudden balance drops, and margin ratio degradation.
- π€ AI Risk Analysis: Natural-language risk analysis and action plans generated via OpenAI GPT-4o-mini or Google Gemini Flash.
- π Multi-Channel Alert Delivery: Integrated Discord and Telegram notification alerts.
- π Terminal Interface: Built-in Click & Rich CLI to view status, history, and real-time logs.
Sentrix is an AI-native utility designed to bridge the gap between raw blockchain data and human action.
- Natural-Language Risk Synthesis: Rather than sending cryptic numeric alerts (e.g.,
margin_ratio = 1.15), Sentrix feeds the entire position context (leverage, size, entry price, current mark price, distance to liquidation, and available spot collateral) to the LLM (src/sentrix/clients/llm.py). - Actionable Recommendations: The LLM translates the complex status into plain English, determining the exact USD margin injection needed to restore the position to a safe 1.5x margin level (e.g., "Urgent: Deposit $2,100 to avoid liquidation").
- Flexible LLM Backend Providers: Out-of-the-box integration with both OpenAI (GPT-4o-mini) and Google Gemini (Gemini 1.5 Flash).
- Resilient Fallback Mode: If API limits or connectivity issues prevent contact with the LLM, Sentrix gracefully falls back to deterministic template-based risk reports to guarantee safety.
Sentrix connects directly to the Injective ecosystem using the official SDK (injective-py), leveraging 5 core integration interfaces:
IndexerGrpcDerivativeApi(viaAsyncClient.fetch_derivative_positions): Periodically polls open perpetual derivative positions for target accounts, retrieving entry prices, margins, leverage, and liquidation prices.ChainGrpcBankApi(viaAsyncClient.fetch_bank_balances): Queries native token balances (e.g.,inj,usdt) held in the user's main wallet.IndexerGrpcAccountApi: Tracks subaccount portfolios to accurately measure margin isolation and asset cross-collateralization.IndexerGrpcSpotApi: Evaluates spot market balances to check if free assets are available to shore up deteriorating margin positions.IndexerGrpcOracleApi: Moniters oracle price feeds to verify mark prices and calculate margin degradation under high volatility.
- Judge-Optimized Demo Mode: Includes a deterministic chain-mocking mode (
--demoflag) that generates simulated derivative positions and spot balances (using real Injective ticker formats likeINJ/USDTandBTC/USDT) to allow judges to evaluate the app immediately without requiring a funded private key or wallet connections.
Sentrix is built specifically for Injective's on-chain architecture:
- On-chain Orderbook & Derivatives Engine: On other networks, tracking open positions and liquidation thresholds requires querying multiple indexing APIs or running custom margin calculation databases. Injective provides derivative position state natively at the ledger level, enabling sub-second local risk evaluation.
- Unified Subaccount Architecture: Sentrix is optimized for Injective's subaccounts, allowing traders to monitor isolated risk profiles independently.
- Strictly Read-Only: Sentrix is a passive monitoring daemon. It does not take custody of your private keys or sign transactions. It is physically incapable of executing trades, transferring funds, or liquidating positions. Even in the event of a full server compromise, your funds remain secure.
- Actionable, Non-Custodial Alerts: Sentrix analyzes and alerts you of the exact dollar amount needed to save a position, leaving the actual transaction to be executed securely by the user via Keplr, Leap, or standard dashboards.
graph TD
A[Injective Chain / Mock Data] -->|pyinjective / HTTP| B(Sentrix Poller)
B -->|Snapshot Data| C[Risk Detector]
C -->|Rules Triggered| D[LLM Client]
D -->|Prompt Context| E{OpenAI / Gemini}
E -->|AI Explanation| F[Alert Synthesizer]
F -->|Telegram/Discord Alerts| G((User Notifications))
B -->|Save History| H[(SQLite Local DB)]
| Layer | Technology |
|---|---|
| Runtime | Python 3.12 |
| Chain SDK | injective-py (v1.7+) |
| AI Integrations | OpenAI gpt-4o-mini / Google gemini-1.5-flash |
| Alerts / Webhooks | python-telegram-bot (v21.0+) / Discord Webhooks |
| CLI / Interface | Click (v8.0+) + Rich (v13.0+) |
| Database | SQLite via aiosqlite (v0.20+) |
- Python β₯ 3.11
- Telegram Bot Token / Discord Webhook URL (optional)
- OpenAI API Key or Gemini API Key (optional, defaults to template alerts)
- Clone the repository:
git clone https://github.com/edycutjong/sentrix.git cd sentrix - Set up virtual environment and install dependencies:
python -m venv .venv source .venv/bin/activate pip install -e ".[dev]"
- Set up your environment variables:
cp .env.example .env # Open .env and add your address, LLM keys, or bot tokens - Configure your alert parameters:
cp config.example.yaml config.yaml # Customize thresholds for liquidations and notification channels
Start the monitoring daemon. Use --demo to simulate live risk changes and test alert configurations.
# Run in Demo mode (Recommended for judges!)
sentrix watch --demo
# Run live on-chain watching a specific address
sentrix watch --address inj1youraddresshere
# Run with specific configuration file
sentrix watch --config config.yamlRetrieve a beautiful terminal summary of current positions and spot balances.
# Show status of mock positions
sentrix status --demo
# Show status of an active Injective address
sentrix status --address inj1youraddresshereBrowse historical alarms stored in the local SQLite engine:
sentrix historySentrix is designed to run as a lightweight background daemon (worker process) and can be easily deployed to Railway to monitor Injective portfolios 24/7.
For detailed setup instructions, environment configurations, and Railway deployment steps, see the Sentrix Deployment Guide.
The codebase maintains 100% test coverage. You can run the entire linting and testing suite locally:
# Run Ruff linting
ruff check .
# Run all test suites with coverage report
pytest --covContinuous Integration is set up via GitHub Actions (.github/workflows/ci.yml) to validate code quality and correctness on every push.
Sentrix is optimized for edge-native, sub-millisecond execution to ensure alerts are generated immediately when risk rules are violated. You can run the performance simulation benchmark locally:
python3 scripts/bench.pyTypical Benchmark Results (100 runs):
- Risk Detection Latency:
p50 = 0.01ms|p95 = 0.01ms(Evaluation of margin and balance rules) - Full Cycle Processing Latency:
p50 = 0.08ms|p95 = 0.11ms(From raw chain snapshot ingestion to structured alert packaging, excluding async external API calls)
sentrix/
βββ .github/
β βββ dependabot.yml # Dependency update schedule
β βββ workflows/
β βββ ci.yml # Github Actions CI Pipeline
β βββ codeql.yml # Automated Security Scanning
βββ docs/ # Documentation and asset store
β βββ DEPLOYMENT.md # Railway deployment guide
βββ src/
β βββ sentrix/
β βββ cli.py # Click Command line interface
β βββ config.py # Configuration loading/parsing
β βββ core/
β β βββ detector.py # Risk assessment logic
β β βββ poller.py # Main async polling loop
β βββ clients/
β β βββ injective.py # Injective blockchain wrapper
β β βββ llm.py # OpenAI/Gemini client
β β βββ telegram.py # Telegram bot sender
β β βββ discord.py # Discord webhook sender
β βββ models/ # Pydantic schemas (alert, position, etc.)
β βββ storage/
β βββ db.py # SQLite persistence store
βββ tests/ # 14 test suite files
βββ .env.example # Template environment variables
βββ pyproject.toml # Package definitions and tooling
βββ railway.json # Railway build/deploy configuration
βββ README.md # You are here
MIT Β© 2026 Edy Cu
Built for the Injective Solo AI Builder Sprint (HackQuest 2026). Special thanks to Injective Labs and Google for the AI tools and libraries.

