run-arena-agent
Trigger phrases: "start trading", "run agent", "start arena agent", "begin trading", "start auto-trading", "stop trading"
Files3
View on GitHubSKILL.mdai-plugin/skills/run-arena-agent/SKILL.md
GitHubRun Arena Agent — Autonomous Trading Loop
Start the autonomous trading loop that queries pool state, asks the LLM for a trading decision, and submits intents on-chain every N seconds.
Prerequisites
AGENT_PRIVATE_KEYset in.env(the wallet must be registered as an agent)- Agent registered — run
register-agent.mjsfirst if needed AGENTS.mdpresent in the current working directory (ai-plugin/)- LLM access — one of the following:
- OpenClaw gateway running locally (
OPENCLAW_GATEWAY_TOKENset), or OG_COMPUTE_API_KEYset for 0G Compute direct access
- OpenClaw gateway running locally (
Parsing Interval from User Messages
| User says | intervalMs |
|---|---|
| "every 2 minutes" / default | 120000 |
| "every 30 seconds" | 30000 |
| "every 5 minutes" | 300000 |
| "every 10 minutes" | 600000 |
Convert to milliseconds and pass as the first argument.
Command
# Default: 2-minute interval, OpenClaw gateway at localhost:3000
node skills/run-arena-agent/arena-loop.mjs
# Custom interval (e.g. 30 seconds)
node skills/run-arena-agent/arena-loop.mjs 30000
# Custom interval + custom gateway URL + token
node skills/run-arena-agent/arena-loop.mjs 60000 http://127.0.0.1:3000 <token>
With explicit env vars
AGENT_PRIVATE_KEY=0x... \
OPENCLAW_GATEWAY_TOKEN=<token> \
node skills/run-arena-agent/arena-loop.mjs 120000
Using 0G Compute directly (no gateway)
AGENT_PRIVATE_KEY=0x... \
OG_COMPUTE_API_KEY=<key> \
node skills/run-arena-agent/arena-loop.mjs 120000
What It Does Each Epoch
- Query pool state — calls the Subgraph MCP server to get current price, current tick, nearby tick depth, and the agent's open position.
- Call LLM — sends pool state to the LLM with the agent's strategy as context (via OpenClaw or 0G Compute).
- Parse decision — extracts a JSON object with
action(open/close/rebalance/hold) and optionalamountUSDC,tickLower,tickUpper,reasonfields. - Submit intent on-chain — if action is not
hold, ABI-encodes the intent params and callsAgentManager.submitIntent(agentId, actionType, params). - Sleep — waits
intervalMsbefore the next epoch.
How to Stop
Send SIGINT (Ctrl+C) or SIGTERM. The loop exits cleanly after the current
epoch finishes.
LLM Routing
OPENCLAW_GATEWAY_TOKEN set?
YES → POST /v1/chat/completions to OpenClaw gateway
(gateway injects AGENTS.md as system context automatically)
NO → OG_COMPUTE_API_KEY set?
YES → POST to 0G Compute directly
(reads AGENTS.md from cwd as system prompt)
NO → Error — set at least one of the above
The OpenClaw gateway is preferred because it handles model selection and automatically injects the agent's strategy document.