Skip to content

atakdoteth/pmx-bot

Repository files navigation

PMX BTC Hold Bot

Simple Node.js and TypeScript bot for PMX BTC Hourly markets on Solana. It opens a position shortly before resolution, holds it, and redeems automatically if the selected side wins. The repo also includes a small dashboard for monitoring state, balances, positions, and recent history.

Overview

  • Selects the nearest active BTC Hourly market.
  • Uses Binance price data to choose UP or DOWN.
  • Sizes the trade with an EV-based optimizer instead of always buying the maximum.
  • Sends buy and redeem transactions on Solana.
  • Exposes a local dashboard and can be deployed with Railway + Vercel.

Setup

Install dependencies and create your local env file:

npm install
cp .env.example .env

PowerShell:

Copy-Item .env.example .env

Most setups only need these values in .env:

  • RPC_URL
  • PRIVATE_KEY or PUBLIC_KEY for dry-run mode
  • ENTRY_WINDOW_MINUTES
  • MAX_STAKE_USDC
  • DIFF_BET_CAPS
  • MIN_EV_USDC
  • MIN_ROI_PCT
  • DASHBOARD_HOST
  • DASHBOARD_PORT
  • RAILWAY_API_BASE_URL if you use Vercel as a public frontend

Keep the real PRIVATE_KEY only in .env. Never commit it.

Commands

Run the bot once:

npm run bot:once

Run the bot continuously:

npm run bot

Start the dashboard:

npm run dashboard

Open:

http://127.0.0.1:8787

Live buy test:

npm run buy:test

Build and typecheck:

npm run typecheck
npm run build

Docker

Run locally with Docker Compose:

docker compose up --build

To use a different env file:

$env:APP_ENV_FILE=".env.example"
docker compose config

Deploy

Railway

Railway can run both the bot worker and the dashboard/status API in one container through:

node dist/run-railway.js

Recommended environment values:

DASHBOARD_HOST=0.0.0.0
HTTP_TIMEOUT_MS=0
RUN_ONCE=false
STATE_FILE=/data/state.json

Using a persistent volume mounted at /data is recommended.

Vercel

Vercel serves index.html and api/status.js. Set:

RAILWAY_API_BASE_URL=https://your-railway-url

The Vercel /api/status route proxies Railway /api/status.

Notes

  • Start with DRY_RUN=true before enabling real trading.
  • npm run buy:test sends a real transaction and requires a real private key.
  • This bot is hold-to-resolution only; it does not do active intra-market trading.
  • By default state is stored in .data/state.json.
  • Do not set PRIVATE_KEY on Vercel.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages