A sophisticated arbitrage and trading system for the XRPL DEX, featuring flash loans, automated market making, and risk management.
-
Flash Loan Agent
- Execute flash loans on XRPL
- Manage loan lifecycle and repayment
- Calculate optimal loan sizes and profits
-
XRPL AMM Agent
- Monitor liquidity pools
- Calculate exchange rates
- Find arbitrage paths
- Execute optimal trades
-
Risk Management Agent
- Assess trade risks
- Track positions and P&L
- Calculate risk metrics
- Monitor market conditions
-
Monitoring Agent
- Track system health
- Log performance metrics
- Monitor errors and issues
- Export system metrics
- Real-time DEX monitoring
- Direct and triangular arbitrage detection
- Flash loan integration
- Risk assessment and management
- Performance tracking and reporting
- Comprehensive error handling
- Extensive logging
- Clone the repository:
git clone https://github.com/Hobie1Kenobi/Thoth-Oracle.git
cd Thoth-Oracle- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows- Install dependencies:
pip install -e .-
Set up your XRPL testnet wallet:
- Replace
TEST_WALLET_SEEDinexamples/live_arbitrage_test.py - Ensure your wallet has sufficient XRP for testing
- Replace
-
Configure trading pairs:
- Edit
TRADING_PAIRSinexamples/live_arbitrage_test.py - Add or remove pairs based on your strategy
- Edit
-
Adjust risk parameters:
- Modify thresholds in
agents/risk_management_agent/risk_management_agent.py - Set position limits and profit targets
- Modify thresholds in
Run the live arbitrage test script:
python examples/live_arbitrage_test.pyThis will:
- Initialize all agents
- Monitor specified trading pairs
- Detect arbitrage opportunities
- Execute trades when profitable
- Log performance and results
The system provides extensive monitoring through:
- Real-time logging
- Performance metrics
- Health checks
- Error tracking
Logs are stored in the logs directory.
The system uses a multi-agent architecture:
- Each agent handles specific functionality
- Agents communicate asynchronously
- Central coordination through the ArbitrageTrader
Multiple layers of risk control:
- Pre-trade risk assessment
- Position monitoring
- P&L tracking
- System health checks
- Asynchronous operations
- Efficient path finding
- Smart order routing
- Optimal trade sizing
Run the test suite:
pytest tests/- Create new agent in
agents/directory - Update main trading loop in
examples/live_arbitrage_test.py - Add tests in
tests/directory
MIT License - See LICENSE file for details
- Fork the repository
- Create feature branch
- Submit pull request
Open an issue for:
- Bug reports
- Feature requests
- Documentation improvements