A high-performance, asynchronous CLI tool for real-time monitoring of USDT/USD premium rates across Binance & OKX P2P markets.
USDT Premium Monitor is a specialized arbitrage tool written in Rust. It calculates the price difference (premium) between the P2P USDT price (CNY) and the official USD/CNY forex rate.
When the premium hits a user-defined threshold (e.g., negative premium, meaning USDT is cheaper than USD), the system triggers instant SMTP email alerts. It is designed for traders, arbitrageurs, and crypto-enthusiasts who need low-latency data without the bloat of a web browser.
- 🚀 High Performance: Built on
Tokiofor non-blocking, asynchronous I/O. - 🌍 Multi-Market Support:
- Binance P2P: Fetches lowest sell prices directly from Binance API.
- OKX P2P: Integrated support for OKX market data.
- Forex Data: Real-time USD/CNY exchange rates via Yahoo Finance.
- 🛡️ Robust Network: Built-in
reqwestclient with Proxy Support (HTTP/HTTPS) and auto-retries for unstable network environments. - 🔔 Smart Alerts: Configurable email notifications via SMTP (Gmail, Outlook, etc.) when profit opportunities arise.
- 📝 Structural Logging: Thread-safe logging with
tracing(Console + File rotation) for long-term debugging.
src/
├── main.rs # Application entry point & event loop
├── config.rs # Type-safe configuration (Env vars)
├── logger.rs # Tracing subscriber & file appender
├── network.rs # Shared HTTP Client with Proxy logic
├── notifier.rs # SMTP Email Alert Service
└── sources/ # Data Providers (Strategy Pattern)
├── mod.rs # Trait definitions
├── binance.rs # Binance implementation
├── okx.rs # OKX implementation
└── forex.rs # Forex rate fetcher
- Rust Toolchain (Cargo)
- OpenSSL (Pre-installed on most systems)
-
Clone the repository
git clone https://github.com/oywt/usdt-premium-monitor-rs.git cd usdt-premium-monitor-rs -
Setup Configuration Create a
.envfile in the root directory:cp .env.example .env
-
Configure Environment Variables Edit the
.envfile with your settings:# --- Threshold Settings --- # Trigger alert if (USDT_Price / USD_Rate - 1) <= -0.01 (-1%) PREMIUM_THRESHOLD=-0.01 # --- Market Settings --- # Minimum trade amount to filter ads (CNY) FILTER_AMOUNT=5000 # Check frequency (Seconds) CHECK_INTERVAL=60 # --- Network --- # Optional: Proxy for accessing Binance (e.g., http://127.0.0.1:7890) # Leave empty if not needed APP_PROXY= # --- Email Alerts (SMTP) --- SMTP_SERVER=smtp.gmail.com SMTP_USER=your_email@gmail.com SMTP_PASSWORD=your_app_password TARGET_EMAIL=receiver_email@example.com
Run in Development Mode:
cargo runBuild for Production:
cargo build --release
./target/release/usdt_premium_monitor2023-10-27T10:00:00.123Z INFO [main] Starting USDT Premium Monitor...
2023-10-27T10:00:01.456Z INFO [Forex] USD/CNY Rate: 7.315
2023-10-27T10:00:01.789Z INFO [Binance] Best Price: 7.290 (Merchants: 5)
2023-10-27T10:00:01.789Z WARN [Monitor] Negative Premium Detected! -0.34% (USDT: 7.290 < USD: 7.315)
2023-10-27T10:00:02.100Z INFO [Notifier] Alert email sent successfully to user@example.com
Contributions are welcome!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This software is for educational and informational purposes only. Cryptocurrency trading involves significant risk. The authors are not responsible for any financial losses incurred from the use of this tool. Use it at your own risk.
Distributed under the MIT License. See LICENSE for more information.