Skip to content

Integrate GDEX DEX trading into Automaton runtime for autonomous revenue generation#2

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/integrate-gdex-sdk-trading
Draft

Integrate GDEX DEX trading into Automaton runtime for autonomous revenue generation#2
Copilot wants to merge 4 commits intomainfrom
copilot/integrate-gdex-sdk-trading

Conversation

Copy link

Copilot AI commented Feb 20, 2026

Adds GDEX multi-chain DEX trading capability to the Automaton agent so it can trade crypto to earn revenue and sustain itself. The GDEX custodial wallet is kept strictly separate from the agent's Conway operating wallet.

New modules

  • src/gdex/config.ts — Resolves GDEX_PRIVATE_KEY from env/config; defaults: $5 max trade, 10 trades/hr
  • src/gdex/client.ts — Fetch-based GDEX API wrapper with required browser headers (User-Agent, Origin, Referer), optional gdex.pro-sdk fallback via dynamic import, and error-safe auth wrapping in all trade methods
  • src/gdex/tools.ts — 9 AutomatonTool definitions, all category: "financial":
Tool Description
gdex_get_balance Custodial wallet balances across chains
gdex_get_price Current token price
gdex_buy_token Buy on any supported chain
gdex_sell_token Sell or sell-all on any chain
gdex_scan_solana pump.fun meme coin scanner
gdex_limit_order Limit order with TP/SL
gdex_copy_trade HyperLiquid copy trading (note: opening positions directly is broken; copy trading works)
gdex_trending Trending tokens by chain
gdex_positions Open positions with PnL
  • skills/gdex-trading/SKILL.md — Auto-activating skill file (requires GDEX_PRIVATE_KEY) with full trading workflow instructions for the agent

Safety guardrails (enforced in every trade tool)

1. Survival check  — blocks trading at `critical` or `dead` tier
2. Rate limit      — config-driven per-hour cap via TradeRateLimiter
3. Max trade size  — enforces gdexMaxTradeSizeUsd (default $5)
4. Audit trail     — logModification("tool_use", ...) on every attempt

Type / config changes

  • AutomatonConfig gains: gdexPrivateKey?, gdexApiUrl?, gdexDefaultChain?, gdexMaxTradeSizeUsd?, gdexMaxTradesPerHour?
  • ModificationType gains: "tool_use"
  • New interfaces: GdexTradeResult, GdexTokenInfo, GdexBalance, GdexPosition

Wiring

  • src/agent/tools.ts spreads createGdexTools() into the built-in tool registry
  • package.json adds: gdex.pro-sdk, ethers ^6.16, @solana/web3.js ^1.98, bs58 ^6

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mainnet.base.org
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions development --conditions node /home/REDACTED/work/automaton/automaton/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions development --conditions node /home/REDACTED/work/automaton/automaton/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js ng (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions development --conditions node /home/REDACTED/work/automaton/automaton/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js ite3.o ndor/bin/as (dns block)
  • trade-api.gemach.io
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions development --conditions node /home/REDACTED/work/automaton/automaton/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js ng (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions development --conditions node /home/REDACTED/work/automaton/automaton/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions development --conditions node /home/REDACTED/work/automaton/automaton/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js ite3.o cal/bin/bash (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Goal

Integrate the GemachDAO/gdex-trading- SDK into the Automaton runtime so the autonomous agent can trade crypto to earn revenue and survive.

Context

The Automaton is a sovereign AI agent that runs a continuous loop (Think → Act → Observe → Repeat). It has:

  • A real Ethereum wallet (src/identity/wallet.ts) using viem
  • A survival system (src/survival/) — if credits hit $0, the agent dies
  • An extensible tool system (src/agent/tools.ts) with categories like "financial", "vm", "self_mod"
  • A skill loader (src/skills/loader.ts) that reads .md files with frontmatter from ~/.automaton/skills/
  • A self-modification engine (src/self-mod/) for installing tools at runtime

The GDEX SDK (GemachDAO/gdex-trading-) provides:

  • Multi-chain spot trading (Base, Arbitrum, Ethereum, BSC, Solana)
  • Solana meme coin swaps (pump.fun)
  • Copy trading (HyperLiquid)
  • Limit orders with take-profit/stop-loss
  • Real-time WebSocket market data
  • Universal custodial wallet system (one EVM address for all chains)
  • Dependencies: gdex.pro-sdk, ethers, ws, @solana/web3.js, bs58
  • API base: https://trade-api.gemach.io
  • Required headers: User-Agent (browser-like), Origin: https://gdex.pro, Referer: https://gdex.pro/

What needs to be built

1. GDEX Skill File: skills/gdex-trading.md

Create a skill file in the Automaton skills directory with proper frontmatter that the skill loader can parse. This should contain comprehensive instructions for the agent on how to use GDEX — based on the existing SKILL.md from the GDEX repo (51KB of documentation). Include:

  • How to authenticate (createAuthenticatedSession())
  • How to buy/sell tokens on any chain
  • How to scan for Solana meme coins
  • How to set up copy trading
  • How to manage limit orders
  • Required headers and API patterns
  • What works vs what's broken (HyperLiquid opening positions is broken)

Use the frontmatter format:

---
name: gdex-trading
description: Trade crypto across chains via GDEX DEX to earn revenue for survival
auto-activate: true
requires:
  env:
    - GDEX_PRIVATE_KEY
---

2. GDEX Trading Tools: src/gdex/

Create a new src/gdex/ directory with modules:

src/gdex/client.ts — GDEX SDK wrapper

  • Initialize gdex.pro-sdk with authenticated session
  • Handle required headers (User-Agent, Origin, Referer)
  • Use the automaton's existing wallet private key (from src/identity/wallet.ts) OR a separate GDEX_PRIVATE_KEY from env/config
  • Provide clean async functions: buyToken(), sellToken(), getBalance(), getPrice(), scanTokens(), copyTrade(), createLimitOrder()

src/gdex/tools.ts — Automaton tool definitions
Register new AutomatonTool[] entries that the agent loop can call. Each tool should follow the existing pattern in src/agent/tools.ts. Tools to create:

Tool Name Category Description
gdex_get_balance financial Check GDEX custodial wallet balances across all chains
gdex_buy_token financial Buy a token on any supported chain
gdex_sell_token financial Sell a token on any supported chain
gdex_get_price financial Get current price of any token
gdex_scan_solana financial Scan for new Solana meme coins / pump.fun launches
gdex_limit_order financial Create a limit buy/sell order with TP/SL
gdex_copy_trade financial Start/stop copy trading a HyperLiquid trader
gdex_trending financial Get trending tokens across chains
gdex_positions financial Check current open positions

Each tool's execute function should:

  1. Validate inputs
  2. Check the automaton's survival tier (don't trade if critical or dead)
  3. Log the trade via the audit system (self-mod/audit-log.ts)
  4. Return a human-readable result string

src/gdex/config.ts — GDEX-specific configuration

  • Add gdexPrivateKey, gdexApiUrl, gdexDefaultChain fields
  • Load from env vars or automaton config

3. Wire into the main runtime

src/agent/tools.ts — Register GDEX tools
Import and register the new GDEX tools alongside existing tools. The agent's tool array in tools.ts is a protected file, so this must be done here (not via self-mod). Add the GDEX tools to the tool registry so the agent can call them during its ReAct loop.

src/config.ts — Add GDEX config fields
Add optional GDEX configuration to AutomatonConfig:

gdexPrivateKey?: string;
gdexApiUrl?: string;
gdexDefaultChain?: string;

src/types.ts — Add GDEX-related types
Add any new types needed for GDEX integration (trade results, token info, etc.)

package.json — Add GDEX dependencies
Add to dependencies:

"gdex.pro-sdk": "latest",
"ethers": "^6.16.0",
"@solana/web3.js": "^1.98.4",
"bs58": "^6.0.0"

Note: ethers may conflict with the existing viem usage. Both can coexist — viem for ...

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 20, 2026 19:35
Co-authored-by: kingassune <6126851+kingassune@users.noreply.github.com>
…e, and tests

Co-authored-by: kingassune <6126851+kingassune@users.noreply.github.com>
…OUR_MS, fix Function() constructor

Co-authored-by: kingassune <6126851+kingassune@users.noreply.github.com>
Copilot AI changed the title [WIP] Integrate GDEX SDK for crypto trading functionality Integrate GDEX DEX trading into Automaton runtime for autonomous revenue generation Feb 20, 2026
Copilot AI requested a review from kingassune February 20, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants