Skip to content

d-EURO/monitoring

Repository files navigation

dEURO Monitoring

Real-time monitoring service for the dEURO protocol on Ethereum mainnet.

Architecture

The monitoring service continuously syncs blockchain data to provide real-time insights:

  1. Event Collection: Fetches all protocol events (PositionOpened, MinterApplied, ChallengeStarted, etc.) from blockchain logs
  2. Dynamic Discovery: Automatically detects new positions, minters, and bridges as they're created on-chain
  3. State Tracking: Maintains current state for:
    • Positions (collateral, debt, status, cooldowns)
    • Challenges (active auctions, liquidations)
    • Minters (generic minters and bridge contracts)
    • Collateral aggregation by token type
  4. Token Prices: Fetches real-time prices from GeckoTerminal API with caching
  5. API Endpoints: Serves data via REST API for frontend consumption

Local Development

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • Ethereum RPC endpoint (Alchemy/Infura)

Setup

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit .env with your settings:
# - DATABASE_URL: PostgreSQL connection string
# - RPC_URL: Ethereum mainnet RPC endpoint
# - BLOCKCHAIN_ID: Must be 1 (Ethereum mainnet)
# - COINGECKO_BASE_URL: required, see "CoinGecko" section below

# Generate Prisma client
npm run prisma:generate

# Run database migrations
node src/monitoringV2/prisma/migrate.js

# Start the service
npm run build
npm run start:prod

Docker

# Build the image
docker build -t deuro-monitoring:test .

# Run with your .env file
docker run --name deuro-test -p 3001:3001 --env-file .env deuro-monitoring:test

# Test the API
curl http://localhost:3001/health

# Clean up
docker rm -f deuro-test

API Documentation

Swagger documentation available at: http://localhost:3001/swagger

CoinGecko

The monitoring service needs a CoinGecko-compatible endpoint for USD/EUR and USD/CHF FX rates — they drive EUR-denominated price conversions and the staleness watchdog. Configuration is two env vars:

Var Required Purpose
COINGECKO_BASE_URL yes Origin the service calls.
COINGECKO_API_KEY no Attached as the x-cg-pro-api-key header on every request when set.

The recommended deployment is the pricing-proxy — a small caching reverse-proxy in front of CoinGecko Pro. It holds the upstream key, serves a 60 s shared cache, validates upstream error envelopes, and coalesces concurrent identical requests. When you use the proxy:

COINGECKO_BASE_URL=http://pricing-proxy:8080/coingecko
# COINGECKO_API_KEY left unset — the proxy injects its own key

Without the proxy you can talk to CoinGecko directly:

COINGECKO_BASE_URL=https://pro-api.coingecko.com
COINGECKO_API_KEY=CG-xxxxxxxxxxxxxxxxxxxxxxxx

The service refuses to start without COINGECKO_BASE_URL.

Deployment

  • Development: Push to develop branch → auto-deploys to dev.monitoring.deuro.com
  • Production: Push to main branch → auto-deploys to monitoring.deuro.com

About

Independent monitoring of the dEURO ecosystem.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages