drm-exchange-polymarket

Crates.iodrm-exchange-polymarket
lib.rsdrm-exchange-polymarket
version0.1.3
created_at2025-12-25 17:07:23.773699+00
updated_at2025-12-28 08:42:30.145107+00
descriptionPolymarket exchange implementation for dr-manhattan
homepage
repositoryhttps://github.com/gtg7784/dr-manhattan-rust
max_upload_size
id2004752
size214,776
Taegeon Alan Go (gtg7784)

documentation

README

drm-exchange-polymarket

Crates.io Documentation License: MIT

Polymarket exchange implementation for dr-manhattan.

Overview

This crate provides a complete Polymarket integration including:

  • REST API: Fetch markets, create/cancel orders, manage positions
  • WebSocket: Real-time orderbook streaming
  • CLOB Client: Direct access to Polymarket's Central Limit Order Book
  • Authentication: Ethereum wallet signing for trading

Installation

[dependencies]
drm-exchange-polymarket = "0.1"

Quick Start

use drm_core::Exchange;
use drm_exchange_polymarket::{Polymarket, PolymarketConfig};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Public API (no auth required)
    let exchange = Polymarket::with_default_config()?;
    
    // Fetch markets
    let markets = exchange.fetch_markets(None).await?;
    for market in markets.iter().take(5) {
        println!("{}: {:?}", market.question, market.prices);
    }
    
    Ok(())
}

Authentication

For trading operations, you need to provide your Ethereum private key:

use drm_exchange_polymarket::{Polymarket, PolymarketConfig};

let config = PolymarketConfig::new()
    .with_private_key("0x...")
    .with_funder("0x...");

let exchange = Polymarket::new(config)?;
exchange.init_trading().await?;

// Now you can create orders, cancel orders, etc.

WebSocket Streaming

use drm_exchange_polymarket::PolymarketWebSocket;
use drm_core::WebSocketClient;

let ws = PolymarketWebSocket::new();
let mut stream = ws.subscribe_orderbook("token_id").await?;

while let Some(orderbook) = stream.next().await {
    println!("Bids: {:?}, Asks: {:?}", orderbook.bids, orderbook.asks);
}

Features

Feature Status
Fetch markets
Fetch orderbook
Create orders
Cancel orders
Fetch positions
Fetch balance
WebSocket orderbook

Part of dr-manhattan-rust

This crate is part of the dr-manhattan-rust project, a Rust port of guzus/dr-manhattan.

License

MIT

Commit count: 0

cargo fmt