Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-seo-audit-1777280932.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Notification Producer
The Notification Producer is a background service that monitors blockchain events and generates push notifications for users subscribed to CoW Protocol updates. It tracks trades, expired orders, and CMS notifications across multiple chains.Purpose and Responsibilities
The Notification Producer performs the following tasks:- Trade Notifications: Monitors executed trades and generates notifications for users
- Expired Order Notifications: Detects expired orders and notifies affected users
- CMS Notifications: Fetches and distributes content management system notifications
- Multi-Chain Indexing: Tracks events across all supported CoW Protocol chains
- State Persistence: Maintains indexer state to resume from the last processed block after restarts
How to Run
Development
Run for Specific Chains
You can limit the producer to specific chains using theNOTIFICATIONS_PRODUCER_CHAINS environment variable:
Production
Docker
Key Configuration Options
Chain Selection
| Variable | Description | Default |
|---|---|---|
NOTIFICATIONS_PRODUCER_CHAINS | Comma-separated chain IDs to monitor | All supported chains |
NOTIFICATIONS_PRODUCER_CHAINS=1,100,137
RPC Configuration
The producer requires RPC endpoints for each chain being monitored:Database Configuration
RabbitMQ Configuration
Optional: Redis Cache
Producer Components
The service runs three types of notification producers concurrently:1. Trade Notification Producer
Purpose: Generates notifications when users’ orders are executed. How it works:- Polls blockchain for new blocks
- Queries CoW Protocol settlement events
- Matches trades to subscribed user accounts
- Enriches notifications with token information and USD values
- Sends notifications to RabbitMQ queue
- Batch processing (up to 5000 blocks per batch)
- State persistence for crash recovery
- Handles blockchain reorgs gracefully
2. Expired Orders Notification Producer
Purpose: Notifies users when their orders expire without being filled. How it works:- Monitors orders approaching expiration
- Checks if orders were filled or cancelled
- Generates notifications for truly expired orders
- Sends to notification queue
3. CMS Notification Producer
Purpose: Fetches and distributes notifications from the content management system. How it works:- Polls CMS for new announcements
- Distributes to all subscribed users
- Handles general protocol updates and announcements
Main Functionality
Block Indexing
The trade notification producer implements a robust block indexing mechanism:Notification Queue
Notifications are sent to RabbitMQ for consumption by delivery services (e.g., Telegram bot):Dependencies
Required Services
-
PostgreSQL Database - Stores indexer state and subscription information. Required tables:
indexer_state,push_subscriptions,on_chain_placed_orders,expired_orders -
RabbitMQ - Message queue for distributing notifications to consumers. Queue:
notifications - Blockchain RPC Nodes - HTTP or WebSocket endpoints for each monitored chain
Optional Services
- Redis - Caching layer for token metadata and frequently accessed data. Improves performance by reducing redundant API calls and blockchain queries.
Database Schema
The indexer state table stores progress for each producer:Graceful Shutdown
The producer implements graceful shutdown with a 30-second timeout:- In-progress block processing completes
- Database state is saved
- No notifications are lost
- Clean disconnection from RabbitMQ and database
Testing Notifications
Quick test to send a notification to your subscribed account:- Create a test notification
- Send it to the RabbitMQ queue
- Be delivered by connected consumers (e.g., Telegram bot)
Nx Commands
Monitoring and Logs
The producer outputs structured logs with prefixes:trace- No new blocks to indexdebug- Block processing detailsinfo- Notifications sent, producer lifecyclewarn- RPC lag, temporary issueserror- Critical errors, retries
Related Services
- Telegram Bot - Consumes notifications and delivers via Telegram
- API Service - Manages user subscriptions