The Mento Analytics API is a service designed to provide real-time analytics for the Mento Protocol's stablecoins and reserve assets across multiple blockchains (Celo, Ethereum, and Bitcoin). It serves as the data backbone for the Mento Reserve dashboard, offering insights into reserve holdings and stablecoin metrics.
The API can be used by consumers to fetch information about the Mento Stables, the Reserve and it's composition.
- Node.js (v21+)
- pnpm
# Install dependencies
pnpm install
# Start development server
pnpm run start:dev
# Build for production
pnpm run build
# Start production server
pnpm run start:prod
Create a .env
file in the root directory:
cp .env.example .env
You'll need to obtain API keys for the Coinmarket cap & exchange rates API then add them to your env file
- Stablecoin Analytics: Tracks the total supply of all Mento stables
- Multi-Chain Reserve Tracking: Monitors reserve assets across Celo, Ethereum and Bitcoin networks
- Reserve Composition Analysis: Detailed breakdown of reserve holdings and their USD values
- Collateralization Metrics: Real-time tracking of reserve-to-stablecoin ratios
- Automated Cache Management: Optimized data delivery with cache warming
- Health Monitoring: System health checks across all integrated services
Below is the project structure:
src/
├── app.module.ts # Root module
├── main.ts # Entry point
├── api/ # API features
│ ├── stablecoins/ # Stablecoin-related endpoints
│ ├── reserve/ # Reserve-related endpoints
│ └── health/ # Health check endpoints
├── common/
│ └── services/ # Shared services
├── types/ # Shared types/interfaces
└── utils/ # Utility functions
The Mento Analytics API is hosted on Google Cloud Platform (GCP) using Cloud Run with logging handled by Cloud Logging. The diagram below illustrates the high-level architecture and data flow:
Detailed documentaion for the API endpoints is available at /docs
when running the application.
- On-chain data from multiple networks:
- Celo: Mento SDK beta + Infura
- Ethereum: Mento SDK beta + Infura
- Bitcoin: Blockchain.info & Blockstream
- Price feeds: CoinmarketCap API for real-time asset pricing
- Exchange rate data: API Layer exchange rates API
Data provided by the API will be < 1 hour old. Data is only updated on an hourly schedule.
The API implements a cache warming strategy to ensure data availability:
- Initial warmup on service start
- Scheduled refreshes every hour
- Manual invalidation via admin endpoints - To Be Added
Stablecoins are fetched directly from the blockchain using the Mento SDK. Additional information is requred for the price and image.
- Add a fiat ticker for the stablecoin in the SDK repo
- Publish the new sdk package version and update the verion in the API repo
- Add an svg image for the stablecoin to the tokens directory, ensuring the filename matches the symbol.
- Deploy changes and verify in
/stablecoins
endpoint
- Update addresses in
api/reserve/config/addresses.config.ts
- Deploy changes and verify in
/reserve
endpoints
Reserve assets are fetched directly from the blockchain using the Mento SDK. However the metadata is needed to enrich the data. This is hardcoded to reduce the number of external calls.
- Add asset configuration to
api/reserve/config/assets.config.ts
- Deploy changes and verify in
/reserve
endpoints
- GCP Cloud Logging: View Logs
- Log levels:
- INFO: Regular operation events
- WARN: Potential issues requiring attention
- ERROR: Critical issues affecting operation
- DEBUG: Detailed information for development
- System metrics: Cloud Monitoring
- Sentry error tracking: View Issues
- Health checks:
/health
endpoint
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.