Gabagool uses a hybrid architecture combining the best components from 4 proven Polymarket bot repositories.
| Component | Source Repository | Purpose |
|---|---|---|
| Base Infrastructure | discountry/polymarket-trading-bot | API client, wallet, orders |
| Position Tracker | Trust412/Polymarket-spike-bot-v1 | Thread-safe position management |
| Risk Manager | lorine93s/polymarket-market-maker-bot | Pre-trade validation |
| Auto Redeemer | lorine93s/polymarket-market-maker-bot | Settlement automation |
| Stats Tracker | warproxxx/poly-maker | Performance metrics |
| Position Merger | warproxxx/poly-maker | Gas optimization |
┌─────────────────────────────────────────────────────────────────┐
│ GABAGOOL BOT │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Gamma │ │ WebSocket │ │ CLOB │ │
│ │ Client │ │ Client │ │ Client │ │
│ │ (markets) │ │ (prices) │ │ (orders) │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └──────────────────┴──────────────────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ Trading Bot │ │
│ └──────┬──────┘ │
│ │ │
│ ┌─────────────────────────┼─────────────────────────┐ │
│ │ │ │ │
│ │ ┌───────────────────┐│┌───────────────────┐ │ │
│ │ │ Risk Manager │││ Position Tracker │ │ │
│ │ │ (pre-validate) │││ (track pairs) │ │ │
│ │ └─────────┬─────────┘│└─────────┬─────────┘ │ │
│ │ │ │ │ │ │
│ │ └──────────┴──────────┘ │ │
│ │ │ │ │
│ │ ┌──────────▼──────────┐ │ │
│ │ │ Gabagool Strategy │ │ │
│ │ │ (arbitrage logic) │ │ │
│ │ └──────────┬──────────┘ │ │
│ │ │ │ │
│ └─────────────────────────┼────────────────────────┘ │
│ │ │
│ ┌─────────────────────────┼─────────────────────────┐ │
│ │ │ │ │
│ │ ┌──────────────┐ ┌────▼─────┐ ┌─────────────┐ │ │
│ │ │ Auto Redeem │ │ Database │ │Stats Tracker│ │ │
│ │ │ (settlement) │ │ (SQLite) │ │ (metrics) │ │ │
│ │ └──────────────┘ └──────────┘ └─────────────┘ │ │
│ │ │ │
│ └───────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Gamma API → GammaClient → find_15min_markets() → Market objects
WebSocket → price updates → Strategy.scan_opportunities()
Opportunity detected
→ RiskManager.validate_arbitrage()
→ Bot.place_order(YES)
→ Bot.place_order(NO)
→ PositionTracker.add_position()
→ StatsTracker.record_trade()
→ Database.save_trade()
AutoRedeemer.run_continuous()
→ check_market_resolved()
→ redeem_position()
→ PositionTracker.mark_resolved()
→ StatsTracker.update_trade_result()
→ Database.save_settlement()
The PositionTracker uses threading locks for concurrent access:
class PositionTracker:
def __init__(self):
self.lock = threading.Lock()
def add_position(self, ...):
with self.lock:
# Thread-safe updatesConfiguration follows a hierarchy:
- Default values (code)
config/default.yamlconfig/production.yaml(overrides)- Environment variables (highest priority)
- market_id (PK)
- yes_shares, yes_avg_cost, yes_total_cost
- no_shares, no_avg_cost, no_total_cost
- opened_at, resolved, profit
- id, market_id, side, shares, price, cost, timestamp
- id, market_id, winning_side, profit, settled_at