Skip to content

sidex-fun/openclaw-sidex-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Sidex Logo

OpenClaw Sidex Kit

The Standardized Execution Layer for Autonomous Trading Agents

npm version npm downloads license

Documentation β€’ SDK Reference β€’ X (Twitter) β€’ Telegram β€’ Discord


About Sidex

Sidex is turning trading into a game.

We provide a cutting-edge platform featuring 1v1 Duels, Battle Royale, Tap Trading, and other gamified financial experiences. Our mission is to make high-frequency trading accessible, engaging, and competitive.

Developer Ecosystem (devs.sidex.fun)

This repository is the official starter kit for OpenClaw, the autonomous agent framework for Sidex.

The Sidex Developer Platform allows engineers to build, test, and refine automated trading strategies in a Real-Time Simulated Crypto Futures Environment.

  • Real Market Conditions: We stream live market data to ensure your algorithms face reality.
  • Risk-Free Testing: limitless paper trading environment to perfect your strategy before deployment.
  • Universal Architecture: Once tested, your agent is ready to deploy on any major exchange using our standardized pipelines.

Universal Pipelines

The OpenClaw Kit features a modular pipeline architecture, allowing your agent to interface with major Decentralized (DEX) and Centralized (CEX) exchanges using a unified command structure.

Exchange Type Support
Hyperliquid DEX (Perps) Model Included
Binance CEX (Futures) Model Included
Bybit CEX (Unified) Model Included
Solana (Jupiter) DEX (Spot) Model Included
Uniswap DEX (EVM) Model Included
Polymarket Prediction (Polygon) Model Included

Autonomous Economics (x402)

OpenClaw Agents are equipped with an integrated Economic Core powered by the x402 Protocol. This allows agents to autonomously buy and sell resources machine-to-machine.

  • Self-Sufficiency: Agents can pay for premium trading signals, news feeds, or computational power using their own crypto wallet.

  • Auto-Negotiation: The kit automatically handles 402 Payment Required responses, paying the vendor and retrieving the data in a single flow.

  • Multichain: Built on viem, supporting payments on any EVM chain (Base, Polygon, Arbitrum, etc.).

Survival Mode (Evolutionary Logic)

Inspired by biological systems, the Survival Manager adjusts the agent's behavior based on its PnL health. It uses hysteresis to prevent rapid state oscillation and emits events via the internal EventBus for all modules to react.

State Trigger Behavior
Growth Profit > 20% Aggressive scanning, higher leverage allowed, x402 budget unlocked
Survival Neutral zone Balanced risk, normal operation
Recovery Improving from Defensive Cautious optimism, gradual risk increase
Defensive Loss > 15% Reduced risk, frozen x402 budget, slower loop
Critical Loss > 50% Graceful shutdown β€” closes all positions and preserves capital

Note: This works on both Simulations (Sidex Devs) and Real Exchanges.

Install as SDK

Use OpenClaw as a dependency in your own project:

npm install openclaw-sidex-kit
import { createAgent, createLLM, eventBus } from 'openclaw-sidex-kit/sdk';

// Full autonomous agent in 5 lines
const agent = createAgent({
    initialBalance: 1000,
    symbols: ['BTCUSDT', 'ETHUSDT'],
    llm: { provider: 'ollama', model: 'llama3.3' },
    risk: { maxLeverage: 10, maxPositions: 3 },
    onTrade: async (trade) => {
        console.log(`Executing: ${trade.side} ${trade.symbol} $${trade.amount}`);
    },
});

await agent.start();

You can also use individual modules standalone:

import { LLMClient, RiskManager, SurvivalManager } from 'openclaw-sidex-kit';

// Standalone LLM with multi-persona debate
const llm = new LLMClient({ provider: 'openai', apiKey: 'sk-...', model: 'gpt-4o' });
const decision = await llm.decideWithDebate({ marketData, balance: 1000, positions: [] });

// Standalone risk manager
const risk = new RiskManager({ maxLeverage: 15, maxPositions: 5 });
const result = risk.canOpenPosition(decision, portfolio, 'SURVIVAL');

Full SDK API Reference: See SDK.md for all factory functions, types, events, and examples.

Import Path Description
openclaw-sidex-kit Core classes (direct imports)
openclaw-sidex-kit/sdk Factory functions + re-exports
openclaw-sidex-kit/core Alias for core modules

Quick Start (Standalone)

Option A: One-Command Full Install (Recommended)

The full installer handles everything β€” system dependencies, Node.js, npm packages, Ollama (local AI), LLaMA 3.3 model download, and .env configuration β€” in a single interactive script.

git clone https://github.com/sidex-fun/openclaw-sidex-kit.git
cd openclaw-sidex-kit
bash quick-setup/install.sh

What it installs: curl, git, wget, Node.js (v20+), all npm dependencies, Ollama for local AI, and the LLaMA 3.3 model. It also walks you through configuring your .env with Sidex tokens, exchange keys, and wallet setup.

Option B: Manual Installation

If you prefer to install things yourself:

git clone https://github.com/sidex-fun/openclaw-sidex-kit.git
cd openclaw-sidex-kit
npm install

Then run the interactive configuration wizard:

npm run setup

This wizard will generate your .env file with the correct API keys and features enabled.

AI Model Setup

OpenClaw agents work best with a local LLM via Ollama. This avoids API costs and content-policy restrictions that external providers (GPT, Claude) impose on trading-related prompts.

# Install Ollama (Linux)
curl -fsSL https://ollama.com/install.sh | sh

# Download the recommended model
ollama pull llama3.3

# Start the server
ollama serve

⚠ External APIs (GPT, Claude, etc.): You can configure them in .env, but they have content filters and rate limits that may block trading analysis prompts. Local LLaMA 3.3 is strongly recommended for full, unrestricted functionality.

Usage

Autonomous Mode β€” Start the full agent loop (recommended):

npm start

The agent will connect to live market data, consult the LLM every cycle, and execute trades autonomously based on risk parameters.

Manual Pipeline Commands β€” Execute individual trades directly:

# Binance Pipeline
node pipelines/binance/scripts/trade.mjs --symbol="BTCUSDT" --side="buy" --amount="0.01" --api_key="..."

# Sidex Simulation
node skills/sidex_trader/scripts/trade.mjs --symbol="BTC/USDT" --side="buy" --amount="100" --leverage="10" --token="YOUR_TOKEN"

πŸ€– Autonomous Agent Architecture

The kit features a fully autonomous Agent Orchestrator that runs a continuous decision loop:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              AgentOrchestrator                   β”‚
β”‚   gatherSignals β†’ think β†’ riskFilter β†’ execute  β”‚
β”‚                    ↕ monitor                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Market   β”‚  Signal   β”‚   Risk     β”‚  Position   β”‚
β”‚  DataFeed β”‚  Ingester β”‚   Manager  β”‚  Manager    β”‚
β”‚  (prices, β”‚  (social, β”‚  (sizing,  β”‚ (tracking,  β”‚
β”‚   RSI,    β”‚   news,   β”‚   limits,  β”‚  TP/SL,     β”‚
β”‚   EMA,    β”‚   alpha)  β”‚  survival) β”‚  PnL)       β”‚
β”‚   ATR)    β”‚           β”‚            β”‚             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚               EventBus (Internal Comms)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Binance  β”‚  Hyper-   β”‚   Sidex    β”‚ Polymarket  β”‚
β”‚  Pipeline β”‚  liquid   β”‚  Gateway   β”‚  Pipeline   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚      LLM Client       β”‚     x402 / Wallet        β”‚
β”‚  (Ollama/OpenAI/Claude)β”‚    (On-chain Payments)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Modules

Module Description
AgentOrchestrator Main loop β€” gathers signals, consults LLM, filters risk, executes trades, monitors positions
LLMClient Unified interface for Ollama, OpenAI, and Anthropic. Returns structured JSON trading decisions
MarketDataFeed Real-time prices via Binance WebSocket. Calculates RSI(14), EMA(20/50), ATR(14) in-memory
PositionManager Tracks open positions, auto-triggers Stop-Loss/Take-Profit, persists state to disk
RiskManager Position sizing, exposure limits, per-asset caps. Adapts dynamically to Survival state
SurvivalManager Biological state machine with hysteresis. Emits events for all modules to react
EventBus Singleton event system for decoupled module communication
X402Client Handles 402 Payment Required flows for machine-to-machine payments
LiquidationIntelligence Real-time liquidation heatmap, OI, Funding Rate, L/S Ratio, squeeze detection

πŸ”₯ Liquidation Intelligence

Understand where the money is before making a trade. The LiquidationIntelligence module provides real-time data on liquidation zones, Open Interest, Funding Rates, and Long/Short ratios β€” helping the agent predict where market makers will move price.

Data Sources

Source Tier Data
Binance Futures API Free OI, Funding Rate, L/S Ratio, Liquidation WebSocket stream
Bybit API Free OI, Funding Rate
CoinGlass API Premium Full liquidation heatmap, aggregated cross-exchange data
CoinGlass via x402 Autonomous Agent pays for premium data automatically via on-chain payment

Signals Generated

Signal Meaning
LIQUIDATION_MAGNET Price approaching a dense liquidation zone β€” market makers may push price there
CASCADE_RISK High liquidation volume detected β€” cascade risk elevated
SQUEEZE_POTENTIAL Extreme L/S imbalance β€” short or long squeeze likely
IMBALANCE Extreme funding rate β€” contrarian signal (crowded trade)
OI_DIVERGENCE Open Interest rising/falling significantly β€” trend continuation or exhaustion

Usage

import { createLiquidationIntel } from 'openclaw-sidex-kit/sdk';

// Free tier β€” Binance data only
const intel = createLiquidationIntel({
    symbols: ['BTCUSDT', 'ETHUSDT'],
});

// Premium β€” CoinGlass heatmap
const intelPremium = createLiquidationIntel({
    symbols: ['BTCUSDT'],
    coinglass: { apiKey: 'cg-...' },
});

// Autonomous β€” Agent pays for premium data via x402
import { X402Client } from 'openclaw-sidex-kit';
const intelAutonomous = createLiquidationIntel({
    symbols: ['BTCUSDT'],
    x402: {
        client: new X402Client(),
        autoPayPremium: true,
        maxPaymentPerDay: 1000000000000000n  // max daily spend in wei
    },
});

await intel.start();

// Get context for LLM consumption
const context = intel.getLLMContext();
// β†’ "BTCUSDT: OI: 12.5B (+3.2% 24h) | Funding: 0.0150% (longs paying) | L/S: 1.82 ..."

// Get structured data
const btcData = intel.getContext('BTCUSDT');
// β†’ { openInterest, fundingRate, longShortRatio, signals, heatmap, ... }

Agent Loop Cycle

  1. Gather Signals β€” Reads alpha_db.json from Social Alpha Miner for recent high-confidence signals
  2. Think (Council Debate) β€” The Council of AI (Technician, Sentinel, Guardian) debates the trade. A Leader synthesizes the final decision.
  3. Risk Filter β€” Validates the decision against position limits, exposure caps, and survival state
  4. Execute β€” Dispatches the trade to the appropriate pipeline (Sidex, Binance, Hyperliquid, etc.)
  5. Monitor β€” Updates unrealized PnL, checks TP/SL levels, feeds the Survival Manager

The loop interval adapts automatically: faster in Growth (more opportunities), slower in Defensive (conserve resources).

πŸ“‚ Project Structure

  • /core: The brain of the agent β€” Orchestrator, LLM, Market Data, Positions, Risk, Survival, x402.
  • /pipelines: Connectors for different exchanges (Hyperliquid, Binance, Bybit, Polymarket, etc.).
  • /skills: Advanced capabilities (Social Alpha Miner, Sidex Trader, MoltBook Analyst).
  • /quick-setup: Interactive configuration scripts.
  • /data: Persisted agent state and position data (auto-generated).
  • agent.js: Main entry point β€” run with npm start.

🧠 Social Alpha Miner

The kit includes an NLP engine that monitors social platforms for trading signals.

  • Impact Engine: Detects CRITICAL news from VIP accounts (Donald Trump, Saylor, etc.).
  • Sentiment Analysis: Converts "tweets" into actionable code instructions (URGENT_BULLISH_ACTION).
  • Sources: Twitter/X, Colosseum, and MoltBook.
  • Integration: Signals are stored in alpha_db.json and automatically consumed by the Agent Orchestrator each cycle.

πŸ›οΈ Council of AI (Multi-Persona Debate)

To ensure robust decision making, the agent uses a Multi-Persona Debate System instead of a single LLM prompt. Before every trade, a virtual council meets:

  • The Technician πŸ“ˆ: Analyzes pure market data (RSI, EMA, Price Action).
  • The Sentinel πŸ“°: Analyzes social sentiment and news signals.
  • The Guardian πŸ›‘οΈ: A pessimist risk manager who vetoes reckless moves.
  • The Leader πŸ‘‘: Synthesizes all reports and makes the final execution decision.

This "Mixture of Agents" approach reduces hallucinations and ensures balanced trading strategies.

🧬 Self-Evolution Daemon

OpenClaw includes an autonomous self-evolution pipeline β€” the agent can receive feature proposals from external sources, evaluate them with an LLM judge, implement the changes, validate them, and create a Pull Request β€” all without human intervention.

npm run evolve

How It Works

External Proposal (GitHub Issue, webhook, bot)
        ↓
   InboxCollector β€” collects from GitHub Issues (label: 'evolution'), local file, webhooks
        ↓
   ProposalJudge (LLM) β€” scores on 4 axes:
     β€’ Relevance (is it related to this project?)
     β€’ Value (does it add real functionality?)
     β€’ Safety (is it free from malicious patterns?)
     β€’ Feasibility (can it be done with the current codebase?)
        ↓
   CodePlanner (LLM) β€” generates implementation plan (files, logic, exports)
        ↓
   CodeWriter β€” applies changes with guardrails (path whitelist, backup, rollback)
        ↓
   Validator β€” syntax check, import validation, test suite
        ↓
   GitCommitter β€” creates branch + Pull Request (or direct commit)

Safety Guardrails

  • Path whitelist/blacklist β€” can only modify core/, pipelines/, sdk.js, types.d.ts
  • Cannot self-modify β€” the evolution system (core/evolution/) is forbidden
  • Dangerous pattern detection β€” blocks eval(), child_process, exec, rm -rf, etc.
  • Automatic rollback β€” if validation fails, all changes are reverted
  • Rate limiting β€” max 10 proposals per day
  • Safety score minimum β€” proposals scoring below 8/10 on safety are auto-rejected
  • Full audit log β€” every action is logged to data/evolution/logs/

Submit a Proposal

Via GitHub Issue: Create an issue with the evolution label.

Programmatically:

import { EvolutionDaemon } from 'openclaw-sidex-kit/evolution';
import { LLMClient } from 'openclaw-sidex-kit';

const daemon = new EvolutionDaemon({ llm: new LLMClient() });

daemon.submitProposal({
    title: 'Add trailing stop-loss to PositionManager',
    body: 'Implement a trailing stop that follows price by X% and locks in profits during strong trends.',
    author: 'trading-bot-v2'
});

await daemon.start();

SDK & TypeScript Support

The package ships with full TypeScript definitions (types.d.ts) for autocomplete and type safety in any IDE. No @types/ package needed.

import type { TradeDecision, SurvivalState, MarketSnapshot, RiskResult } from 'openclaw-sidex-kit';

For the complete SDK API reference with all factory functions, events, and usage examples, see SDK.md.

Documentation

For full API references and architecture guides, visit the official documentation: devs.sidex.fun/documentation


Β© 2026 Sidex

About

Your personal AI assistant KIT for automated trading with openclaw, with full documentation available at https://devs.sidex.fun/documentation

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors