ADAM (Autonomous Decentralized Algorithmic Market-Maker) represents a novel approach to algorithmic trading through the integration of physical computing hardware with decentralized finance protocols. This project combines embedded systems engineering with quantitative finance to create a tangible, observable trading system that executes autonomous market-making strategies on the Bags protocol. Unlike traditional software-only trading bots, ADAM operates as a physical manifestation of trading logic, providing transparency and physicality to automated financial operations.
- Introduction
- System Architecture
- Hardware Specification
- Software Stack
- Integration with Bags Protocol
- Trading Logic and Strategy Framework
- Risk Management System
- Physical Interface and Observability
- Security Considerations
- Deployment and Operations
- Future Development Roadmap
- Technical Specifications
The cryptocurrency trading ecosystem has increasingly relied on automated systems operating in opaque server environments. ADAM challenges this paradigm by creating a physical trading entity that makes algorithmic trading tangible and observable. By building trading logic into a Raspberry Pi-based humanoid robot, we bridge the gap between digital finance and physical reality.
ADAM is architected around three core principles:
Transparency: All trading activity is executed on-device with physical indicators showing system state and trading activity in real time.
Autonomy: The system operates independently once initialized, making trading decisions based on predefined strategies without requiring manual intervention.
Modularity: Trading strategies, risk parameters, and execution logic are designed as swappable modules, allowing for rapid iteration and strategy optimization.
Bags protocol aligns with ADAM's design philosophy through its support for:
- Long-lived mechanical systems rather than short-term speculative instruments
- Real activity routing to genuine market flows
- Integration frameworks supporting continuous operation
- Redistribution mechanisms compatible with autonomous systems
This is not a hype cycle or fast liquidity event. ADAM is designed as an ongoing system that routes real activity into real flows, matching the sustainable economics that Bags supports.
ADAM consists of four primary subsystems operating in concert:
┌─────────────────────────────────────────────────────────┐
│ ADAM Trading Robot │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Market │ │ Strategy │ │ Risk │ │
│ │ Data │→ │ Execution │→ │ Management │ │
│ │ Ingestion │ │ Engine │ │ Layer │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ ↓ ↓ ↓ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Transaction Signing & Broadcast │ │
│ └──────────────────────────────────────────────────┘ │
│ ↓ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Bags Protocol Interface │ │
│ └──────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Physical Interface & Sensors │ │
│ └──────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
Market Data Ingestion Module: Handles real-time price feeds, order book data, and on-chain state monitoring. Implements websocket connections to decentralized exchange APIs and direct RPC calls to blockchain nodes for verification.
Strategy Execution Engine: Core decision-making component implementing trading algorithms. Designed as a plugin architecture supporting multiple concurrent strategies with independent state management.
Risk Management Layer: Pre-trade and post-trade risk controls including position limits, maximum drawdown enforcement, correlation monitoring, and emergency shutdown mechanisms.
Transaction Signing Module: Secure key management and transaction construction. Implements hardware-based key isolation with the Raspberry Pi's cryptographic capabilities.
Physical Interface System: Motor controllers, sensors, and visual indicators providing real-time feedback on system state and trading activity.
Processor: Raspberry Pi 4 Model B (4GB RAM variant)
- Quad-core Cortex-A72 (ARM v8) 64-bit SoC at 1.5GHz
- Sufficient computational capacity for market data processing and strategy execution
- Low power consumption enabling continuous operation
- Native GPIO support for sensor and actuator control
Storage: 128GB microSD card (Class 10, UHS-I)
- Operating system and application code
- Local market data cache
- Transaction logs and audit trail
- Strategy configuration files
Network: Gigabit Ethernet connection
- Reduced latency compared to WiFi
- Stable connection for continuous market data streaming
- Redundant connection failover capability
Servomotors:
- 6x SG90 micro servos for head and arm articulation
- 4x MG996R digital servos for torso and base movement
- PWM control via PCA9685 16-channel servo driver
Sensors:
- DHT22 temperature and humidity sensor (system thermal monitoring)
- MPU6050 accelerometer/gyroscope (stability monitoring)
- Photoresistor array (ambient light detection for display brightness)
Visual Feedback:
- 16x2 LCD display showing current trading pair and PnL
- WS2812B RGB LED strip (32 LEDs) indicating system state
- OLED display (128x64) for real-time order book visualization
Camera: Raspberry Pi Camera Module v2
- Documentation of physical state during trading operations
- Optional future integration for environmental awareness
Primary Power: 5V 3A USB-C power supply Battery Backup: 10,000mAh power bank with automatic failover Power Monitoring: INA219 current/voltage sensor for consumption analytics
Base OS: Raspberry Pi OS Lite (64-bit Debian-based)
- Minimal installation reducing attack surface
- Optimized for headless operation
- Long-term support and security updates
Primary Language: Python 3.11
- Extensive library ecosystem for trading and data analysis
- Native async/await support for concurrent market monitoring
- Strong typing support via type hints for reliability
Secondary Language: Rust
- Performance-critical components (order matching, risk calculations)
- Memory safety guarantees for long-running processes
- Cross-compilation to ARM64 architecture
Blockchain Interaction:
- web3.py: Ethereum JSON-RPC interaction
- eth-account: Transaction signing and key management
- ecdsa: Cryptographic primitives
Market Data:
- ccxt: Unified exchange API interface
- websockets: Real-time data streaming
- aiohttp: Async HTTP requests for REST APIs
Data Processing:
- numpy: Numerical computations for strategy calculations
- pandas: Time-series data manipulation
- scipy: Statistical analysis and optimization
Hardware Control:
- RPi.GPIO: GPIO pin control
- adafruit-circuitpython-pca9685: Servo driver interface
- smbus2: I2C communication for sensors
Database:
- SQLite: Local transaction and state persistence
- Redis: In-memory caching for market data
adam/
├── core/
│ ├── __init__.py
│ ├── engine.py # Main trading engine
│ ├── config.py # Configuration management
│ └── state.py # System state manager
├── data/
│ ├── __init__.py
│ ├── market_feed.py # Market data ingestion
│ ├── blockchain_monitor.py # On-chain event monitoring
│ └── cache.py # Data caching layer
├── strategies/
│ ├── __init__.py
│ ├── base.py # Abstract strategy class
│ ├── market_making.py # Market making strategies
│ ├── arbitrage.py # Cross-market arbitrage
│ └── grid_trading.py # Grid trading implementation
├── risk/
│ ├── __init__.py
│ ├── position_limits.py # Position size controls
│ ├── drawdown.py # Drawdown monitoring
│ └── emergency_shutdown.py # Kill switch implementation
├── execution/
│ ├── __init__.py
│ ├── order_manager.py # Order lifecycle management
│ ├── signer.py # Transaction signing
│ └── broadcaster.py # Transaction submission
├── physical/
│ ├── __init__.py
│ ├── servo_control.py # Humanoid movement control
│ ├── display.py # Visual feedback systems
│ └── sensors.py # Environmental monitoring
├── bags/
│ ├── __init__.py
│ ├── protocol.py # Bags protocol interface
│ ├── contracts.py # Smart contract ABIs
│ └── events.py # Event listener and parser
└── utils/
├── __init__.py
├── logging.py # Structured logging
├── metrics.py # Performance metrics
└── alerts.py # Notification system
Bags protocol provides the economic infrastructure for ADAM's trading operations. The integration focuses on three primary interaction patterns: liquidity provision, position management, and protocol governance participation.
Contract Addresses (configured per deployment):
BAGS_CONTRACTS = {
'router': '0x...', # Main routing contract
'liquidity_pool': '0x...', # LP token management
'position_manager': '0x...', # Position tracking
'rewards': '0x...', # Reward distribution
}ABI Loading:
All contract ABIs are stored locally in bags/abis/ directory and loaded at initialization. Contracts are instantiated with web3.py Contract objects for type-safe interaction.
ADAM constructs transactions following the EIP-1559 standard with dynamic fee calculation:
def build_transaction(self, contract_function, params):
# Estimate gas with 20% buffer
gas_estimate = contract_function.estimate_gas(params)
gas_limit = int(gas_estimate * 1.2)
# Dynamic fee calculation based on network conditions
base_fee = self.w3.eth.get_block('latest')['baseFeePerGas']
max_priority_fee = self.w3.eth.max_priority_fee
max_fee = (base_fee * 2) + max_priority_fee
transaction = {
'from': self.address,
'gas': gas_limit,
'maxFeePerGas': max_fee,
'maxPriorityFeePerGas': max_priority_fee,
'nonce': self.get_nonce(),
'chainId': self.chain_id,
}
return contract_function.build_transaction(transaction)ADAM provides liquidity to Bags protocol pools using a dynamic adjustment algorithm:
Initial Deployment: Capital is deployed across multiple pools based on historical volume and volatility metrics.
Rebalancing Logic: Positions are rebalanced when:
- Impermanent loss exceeds configurable threshold
- Pool utilization drops below minimum efficiency target
- Superior opportunities identified in alternative pools
Fee Optimization: ADAM monitors fee generation across pools and adjusts allocations to maximize risk-adjusted returns.
ADAM maintains websocket connections to monitor relevant protocol events:
MONITORED_EVENTS = [
'Swap', # Track trading volume and price impact
'AddLiquidity', # Monitor pool depth changes
'RemoveLiquidity', # Detect large withdrawals
'PositionOpened', # Track competitive positions
'PositionClosed', # Analyze exit patterns
'RewardsDistributed' # Claim timing optimization
]Event data is processed in real-time to update internal state and trigger strategy adjustments.
Efficient gas usage is critical for profitability. ADAM implements:
Batch Transactions: Multiple operations are batched when possible to amortize base gas costs.
Conditional Execution: Transactions are only submitted when expected profit exceeds gas costs by configurable margin.
Gas Price Monitoring: Continuous monitoring of network congestion with transaction timing optimization to reduce costs.
Flashbots Integration: MEV-sensitive transactions are routed through Flashbots RPC to prevent front-running.
All strategies inherit from an abstract base class defining the interface:
class BaseStrategy(ABC):
@abstractmethod
async def initialize(self):
"""Strategy initialization and resource allocation"""
pass
@abstractmethod
async def process_market_data(self, data: MarketData):
"""Process incoming market data and update internal state"""
pass
@abstractmethod
async def generate_signals(self) -> List[Signal]:
"""Generate trading signals based on current state"""
pass
@abstractmethod
async def cleanup(self):
"""Resource cleanup and final state persistence"""
passThe primary strategy implements a hybrid market making approach combining:
Spread Optimization: Dynamic spread calculation based on:
- Current volatility (exponentially weighted moving average)
- Order book depth analysis
- Inventory risk premium
Inventory Management:
- Target neutral inventory position
- Asymmetric quoting when inventory deviates from target
- Increased urgency as position limits approach
Adverse Selection Protection:
- Short-term alpha signals to avoid toxic flow
- Quote cancellation on rapid price movements
- Minimum quote lifetime to reduce cancellation costs
Automated grid placement across price ranges:
Grid Construction:
- Geometric or arithmetic spacing based on asset volatility
- Dynamic grid density adjustment
- Multiple concurrent grids at different scales
Execution Logic:
- Limit orders placed at grid levels
- Automatic rebalancing as levels execute
- Profit taking at configurable intervals
Cross-market and triangular arbitrage detection:
Opportunity Identification:
- Continuous monitoring of price differences across venues
- Triangle path enumeration for multi-hop arbitrage
- Profitability calculation including gas costs and slippage
Execution:
- Atomic execution via smart contract when possible
- Sequential execution with partial fill handling
- Automatic rollback on failed legs
Multiple strategies operate concurrently with:
Capital Allocation: Each strategy receives allocation based on historical Sharpe ratio and maximum drawdown metrics.
Conflict Resolution: Order manager prevents conflicting signals from multiple strategies for the same asset.
Performance Attribution: Individual strategy performance tracking for continuous optimization.
Hard limits enforced at multiple levels:
Per-Asset Limits: Maximum exposure to any single asset as percentage of total capital.
Per-Strategy Limits: Individual strategy capital allocation caps to limit strategy-specific risk.
Total Exposure Limit: Aggregate exposure across all positions cannot exceed configured maximum.
Leverage Restrictions: Maximum leverage ratio enforced at portfolio level.
Real-time Drawdown Monitoring: Continuous calculation of current drawdown from historical high-water mark.
Tiered Response:
- 5% drawdown: Warning logged, risk parameters tightened
- 10% drawdown: Position sizing reduced by 50%
- 15% drawdown: New position opening suspended
- 20% drawdown: Emergency shutdown triggered
Recovery Protocol: Graduated return to normal operations as drawdown recovers.
Correlation Matrix: Real-time calculation of rolling correlation between all held assets.
Concentration Risk: Positions with high correlation are treated as single exposure for limit purposes.
Diversification Score: Portfolio-level diversification metric with minimum threshold enforcement.
Trigger Conditions:
- Maximum drawdown exceeded
- Critical system error detected
- Manual trigger via physical button
- Remote shutdown command received
Shutdown Sequence:
- Cancel all open orders
- Close positions at market (configurable threshold)
- Withdraw liquidity from pools
- Transfer assets to secure wallet
- Halt all trading operations
- Send notifications to monitoring systems
Contract Verification: All interacted contracts verified on blockchain explorer before deployment.
Interaction Limits: Maximum value per transaction and daily interaction limits.
Approval Management: Token approvals limited to specific amounts and automatically revoked when not needed.
Upgrade Monitoring: Alerts on proxy contract upgrades for manual review.
LED Status Indicators:
- Green: System operational, no active positions
- Blue pulsing: Active position, positive PnL
- Red pulsing: Active position, negative PnL
- Yellow: Warning state, risk limits approached
- Red solid: Error state or emergency shutdown
- Purple: System initializing or updating
LCD Display: Line 1: Current trading pair and position size Line 2: Current PnL (USD and percentage)
OLED Display: Real-time order book visualization with ADAM's orders highlighted.
Motor actuation provides observable trading activity:
Head Movement:
- Nod down: Order executed (buy)
- Nod up: Order executed (sell)
- Shake: Order cancelled
- Tilt right: Monitoring market data
- Tilt left: Calculating strategy signals
Arm Movement:
- Left arm raise: Position opened
- Right arm raise: Position closed
- Both arms raise: Profitable trade completed
- Arms crossed: Risk limit reached
Torso Rotation: Speed indicates trading frequency (faster rotation = higher activity).
Trade Log: Complete record of all orders and executions with timestamp, price, size, and strategy attribution.
System Log: Application logs with configurable verbosity levels stored locally and optionally transmitted to remote logging service.
Performance Metrics: Regular snapshots of portfolio value, strategy performance, system resource usage, and network statistics.
Audit Trail: Cryptographically signed log entries for compliance and verification purposes.
Local Monitoring: Web interface accessible on local network showing real-time system state and performance metrics.
Remote Monitoring: Optional integration with external monitoring services via encrypted API.
Alert Channels:
- LCD display for immediate local visibility
- Email notifications for significant events
- SMS for critical alerts
- Webhook integrations for custom handlers
Hardware Isolation: Private keys never exposed to network-connected components. Signing operations performed in isolated process.
Encryption: Keys encrypted at rest using AES-256. Decryption key derived from hardware-based entropy.
Backup: Encrypted key backups stored offline with multi-signature recovery mechanism.
Rotation: Periodic key rotation with automated migration of positions to new address.
Firewall: Restrictive iptables rules allowing only essential outbound connections.
VPN: Optional VPN connection for all internet traffic.
RPC Endpoint Security: Authenticated connections to blockchain RPC endpoints. Fallback endpoints for redundancy.
Rate Limiting: Outbound request rate limiting to prevent resource exhaustion attacks.
Input Validation: All external data validated and sanitized before processing.
Dependency Management: Regular security audits of dependencies. Automated vulnerability scanning.
Principle of Least Privilege: Application runs as non-root user with minimal required permissions.
Secure Coding Practices: Type safety enforcement, bounds checking, memory safety via Rust for critical components.
Tamper Detection: Accelerometer monitoring for unauthorized physical access.
Secure Boot: UEFI secure boot preventing unauthorized firmware modification.
Case Lock: Physical enclosure with tamper-evident seals.
Camera Monitoring: Optional camera activation on tamper detection.
Hardware Assembly:
- Mount Raspberry Pi in humanoid chassis
- Connect servo motors to PCA9685 controller
- Wire sensors and displays to GPIO pins
- Install camera module
- Connect power supply and battery backup
- Seal enclosure and apply tamper seals
Software Installation:
- Flash Raspberry Pi OS to microSD card
- Configure SSH access and disable unnecessary services
- Install system dependencies
- Clone ADAM repository
- Install Python dependencies in virtual environment
- Configure environment variables and secrets
- Initialize database and run migrations
- Verify hardware component functionality
Network Configuration:
- Configure static IP address
- Set up firewall rules
- Configure RPC endpoints
- Test connectivity to exchanges and blockchain nodes
- Enable monitoring and alerting
Strategy Configuration:
- Set initial capital allocation
- Configure risk parameters
- Select active strategies
- Set position limits
- Configure emergency shutdown thresholds
Startup Sequence:
- System health check and hardware verification
- Network connectivity verification
- Blockchain node synchronization check
- Market data feed initialization
- Strategy loading and initialization
- Risk system activation
- Begin trading operations
Daily Operations:
- Automated daily health reports generated at 00:00 UTC
- Performance metrics calculation and storage
- Log rotation and compression
- Backup creation and verification
- System resource monitoring
Maintenance Windows:
- Weekly: Dependency updates and security patches
- Monthly: Full system backup and recovery test
- Quarterly: Hardware inspection and cleaning
- Annual: Comprehensive security audit
Web-based dashboard accessible at http://adam.local:8080 provides:
Portfolio View:
- Current positions and allocations
- Total portfolio value and historical chart
- Per-strategy performance attribution
- Risk metrics and exposure analysis
Trading Activity:
- Recent trades table
- Order book visualization
- Execution quality metrics
- Slippage analysis
System Health:
- CPU, memory, and storage utilization
- Network latency and throughput
- Hardware sensor readings
- Error logs and warnings
Strategy Performance:
- Individual strategy PnL
- Sharpe ratio and maximum drawdown
- Win rate and profit factor
- Trade frequency and average trade size
Adaptive Strategy Parameters: Machine learning integration for dynamic parameter optimization based on market regime detection.
Multi-Chain Support: Expansion beyond initial blockchain to support trading across multiple EVM-compatible chains.
Advanced Order Types: Implementation of iceberg orders, TWAP execution, and algorithmic order splitting.
Portfolio Optimization: Modern portfolio theory integration for optimal capital allocation across strategies.
Decentralized Governance Participation: Automated governance token voting based on proposal analysis and alignment with protocol objectives.
Yield Farming Integration: Automated yield farming across protocols with risk-adjusted return optimization.
Options Strategies: Integration of decentralized options protocols for hedging and income generation.
Social Integration: Automated posting of performance metrics and trading insights to social platforms.
Multi-Agent Coordination: Network of ADAM instances coordinating strategies and sharing market intelligence.
Natural Language Interface: Voice control and conversational interaction for configuration and monitoring.
Predictive Analytics: Time-series forecasting models for price prediction and volatility estimation.
Hardware Upgrades: Integration of additional sensors and more sophisticated physical feedback mechanisms.
Swarm Intelligence: Large-scale deployment of coordinated ADAM instances forming decentralized market-making network.
Self-Modification: Genetic algorithm-based strategy evolution with automated backtesting and deployment.
Physical Presence: Multiple humanoid form factors for different trading environments and applications.
Open Protocol: Standardized protocol for inter-ADAM communication and strategy sharing.
Latency Targets:
- Market data processing: < 10ms per update
- Strategy signal generation: < 50ms per cycle
- Order construction and signing: < 100ms
- Transaction broadcast: < 200ms
- End-to-end order execution: < 500ms
Throughput Capacity:
- Market data updates: 1000+ per second
- Concurrent strategies: 10+ active strategies
- Order management: 100+ active orders
- Transaction signing: 50+ transactions per minute
Reliability Targets:
- System uptime: 99.9% (excluding planned maintenance)
- Order success rate: > 98%
- Data accuracy: 100% (verified against multiple sources)
- Recovery time objective: < 5 minutes
Compute:
- CPU utilization: 40-60% average, 80% peak
- Memory usage: 2-3 GB typical
- Storage I/O: < 10 MB/s sustained
Network:
- Bandwidth: 1-5 Mbps sustained
- Connections: 20-50 concurrent websocket connections
- RPC requests: 100-500 per minute
Storage:
- Application code: 500 MB
- Market data cache: 10-20 GB
- Logs and audit trail: 1 GB per week
- Database: 5-10 GB
Operational Transparency: All trading activity logged with complete audit trail for regulatory review if required.
Jurisdictional Compliance: System configuration adaptable to local regulatory requirements regarding automated trading.
Data Retention: Configurable retention periods for trading data and logs to meet regulatory requirements.
Reporting: Automated generation of trading reports in standard formats for tax and compliance purposes.
ADAM represents a synthesis of embedded systems engineering, quantitative finance, and decentralized protocol integration. By manifesting trading logic in physical form, ADAM makes algorithmic trading transparent and observable while maintaining the autonomy and efficiency of software-based systems.
The integration with Bags protocol provides the economic foundation for sustainable, long-term automated market-making operations. Unlike speculative trading systems designed for short-term profit extraction, ADAM is built for continuous operation, routing real trading activity into genuine market flows.
This project demonstrates that decentralized finance can extend beyond purely digital abstractions to encompass physical, observable systems that operate with transparency and accountability. As ADAM evolves, the vision is to create a network of autonomous trading entities that collectively provide liquidity and market efficiency while remaining grounded in physical reality.
This project is released under the MIT License. See LICENSE file for details.
ADAM is built on the shoulders of giants. We acknowledge the contributions of:
- The Bags protocol team for creating sustainable DeFi infrastructure
- The Raspberry Pi Foundation for accessible computing hardware
- The open-source community for the extensive library ecosystem
- The DeFi community for pioneering decentralized financial systems
Version: 1.0.0
Last Updated: February 2026
Status: Active Development for Bags Hackathon
