Rust-based ETL (Extract-Transform-Load) service for the Nolus blockchain. Extracts blockchain data (transactions, events, smart contract states), transforms it, and loads it into PostgreSQL. Provides a REST API for querying the data.
- Real-time blockchain data synchronization via WebSocket
- Historical block backfilling
- Market price aggregation from oracles
- Push notifications for position alerts
- REST API with 70+ endpoints
- CSV export support
- Response caching with configurable TTLs
- Rust 1.80.0+ (Edition 2021)
- PostgreSQL 14+
# macOS
psql -U $USER postgres
# Linux
sudo -i -u postgres && psqlCREATE DATABASE etl_nolus;
GRANT ALL PRIVILEGES ON DATABASE etl_nolus TO your_user;
GRANT ALL ON SCHEMA public TO your_user;cp .env.example .env
# Edit .env with your settingsKey configuration options:
DATABASE_URL- PostgreSQL connection stringHOST- RPC endpoint (e.g.,rpc.nolus.network)GRPC_HOST- gRPC endpoint (e.g.,https://grpc.nolus.network)SERVER_HOST/PORT- API server bind address
# Development (with hot reload)
cargo install cargo-watch
cargo watch -c -w crates -x 'run -p etl-ingest'
cargo watch -c -w crates -x 'run -p etl-api'
# Production build
cargo build --release
./target/release/etl-ingest
./target/release/etl-apiDatabase migrations run automatically on startup of either binary.
src/
├── controller/ # REST API endpoints (consolidated by domain)
│ ├── treasury.rs # Revenue, buyback, distributed, incentives
│ ├── metrics.rs # TVL, borrowed, supplied, open interest
│ ├── pnl.rs # Realized/unrealized PnL
│ ├── leases.rs # Leases, loans, liquidations
│ ├── positions.rs # Positions, buckets, daily stats
│ ├── liquidity.rs # Pools, lenders, utilization
│ ├── misc.rs # Prices, blocks, subscriptions
│ └── admin.rs # Protected admin operations
├── handler/ # Business logic & event handlers
├── provider/ # External integrations (gRPC, WebSocket, DB)
├── dao/ # Database access objects
├── model/ # Data structures
└── types/ # Event types & API structures
GET /api/protocols- All protocols (active + deprecated)GET /api/protocols/active- Active protocols onlyGET /api/protocols/{name}- Single protocol by nameGET /api/currencies- All currencies (active + deprecated)GET /api/currencies/active- Active currencies onlyGET /api/currencies/{ticker}- Single currency by ticker
GET /api/revenue- Total protocol revenueGET /api/distributed- Total distributed rewardsGET /api/buyback- Buyback history (supports?period=3m|6m|12m|all)GET /api/buyback-total- Total buyback amountGET /api/incentives-pool- Incentives pool balanceGET /api/earnings?address=- Earnings by address
GET /api/total-value-locked- Platform TVLGET /api/supplied-funds- Total supplied fundsGET /api/borrowed- Total borrowed (optional?protocol=)GET /api/open-interest- Open interest valueGET /api/supplied-borrowed-history- Historical series
GET /api/positions- All open positionsGET /api/leases?address=- Leases by addressGET /api/liquidations- Liquidation historyGET /api/historically-opened- Historical openings
GET /api/pools- All pools with utilization & APRGET /api/utilization-level?protocol=- Pool utilization historyGET /api/current-lenders- Active lendersGET /api/historical-lenders- Lender history
Most list endpoints support:
?format=csv- CSV format response?period=3m|6m|12m|all- Time window filter?from=<timestamp>- Incremental sync filter?export=true- Streaming CSV export (full data)
# /lib/systemd/system/etl.service
[Unit]
Description=Nolus ETL Service
After=network.target
[Service]
Type=simple
Restart=always
User=root
RestartSec=10
ExecStart=/path/to/etl
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable etl
sudo systemctl start etl
journalctl -u etl -f # View logs| Network | RPC | gRPC | ETL |
|---|---|---|---|
| Mainnet | rpc.nolus.network | grpc.nolus.network | etl.nolus.network |
| Staging | - | - | etl-internal.nolus.network |
| Archive | archive-rpc.nolus.network | archive-grpc.nolus.network | - |
| Testnet | rila-cl.nolus.network:26657 | rila-cl.nolus.network:9090 | - |
Migrations use refinery and run automatically on startup.
- Versioned SQL files in
migrations/directory - Migration state tracked in
refinery_schema_historytable
API_MIGRATION_GUIDE.md- Frontend migration guide for API changesentities.md- Database schema documentation
Apache License 2.0 - See LICENSE for details.