mirror of
https://github.com/floor-licker/polyfill-rs.git
synced 2026-08-21 08:28:08 +00:00
chore: default live CLOB host to production
This commit is contained in:
@@ -32,7 +32,7 @@ use polyfill_rs::{ClobClient, Side, OrderType};
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let client = ClobClient::new("https://clob-v2.polymarket.com");
|
let client = ClobClient::new("https://clob.polymarket.com");
|
||||||
let markets = client.get_sampling_markets(None).await?;
|
let markets = client.get_sampling_markets(None).await?;
|
||||||
println!("Found {} markets", markets.data.len());
|
println!("Found {} markets", markets.data.len());
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ fn benchmark_real_simplified_markets(c: &mut Criterion) {
|
|||||||
c.bench_function("real_fetch_simplified_markets", |b| {
|
c.bench_function("real_fetch_simplified_markets", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
let client = ClobClient::new("https://clob-v2.polymarket.com");
|
let client = ClobClient::new("https://clob.polymarket.com");
|
||||||
|
|
||||||
// This is the real network request + JSON parsing
|
// This is the real network request + JSON parsing
|
||||||
let result = client.get_sampling_simplified_markets(None).await;
|
let result = client.get_sampling_simplified_markets(None).await;
|
||||||
@@ -28,7 +28,7 @@ fn benchmark_real_markets(c: &mut Criterion) {
|
|||||||
c.bench_function("real_fetch_markets", |b| {
|
c.bench_function("real_fetch_markets", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
let client = ClobClient::new("https://clob-v2.polymarket.com");
|
let client = ClobClient::new("https://clob.polymarket.com");
|
||||||
|
|
||||||
// This is the real network request + JSON parsing
|
// This is the real network request + JSON parsing
|
||||||
let result = client.get_sampling_markets(None).await;
|
let result = client.get_sampling_markets(None).await;
|
||||||
@@ -52,7 +52,7 @@ fn benchmark_real_order_creation(c: &mut Criterion) {
|
|||||||
c.bench_function("real_create_order_eip712", |b| {
|
c.bench_function("real_create_order_eip712", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
let client = ClobClient::new("https://clob-v2.polymarket.com");
|
let client = ClobClient::new("https://clob.polymarket.com");
|
||||||
|
|
||||||
// Set up credentials
|
// Set up credentials
|
||||||
if let Ok(_key) = std::env::var("POLYMARKET_PRIVATE_KEY") {
|
if let Ok(_key) = std::env::var("POLYMARKET_PRIVATE_KEY") {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
println!("Benchmark with Keep-Alive Enabled");
|
println!("Benchmark with Keep-Alive Enabled");
|
||||||
println!("==================================\n");
|
println!("==================================\n");
|
||||||
|
|
||||||
let client = ClobClient::new("https://clob-v2.polymarket.com");
|
let client = ClobClient::new("https://clob.polymarket.com");
|
||||||
|
|
||||||
// Start keep-alive
|
// Start keep-alive
|
||||||
println!("Starting keep-alive...");
|
println!("Starting keep-alive...");
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ impl PolyfillDemo {
|
|||||||
pub fn new() -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
// Create basic client
|
// Create basic client
|
||||||
let config = ClientConfig {
|
let config = ClientConfig {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137,
|
chain: 137,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
api_credentials: None,
|
api_credentials: None,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
for i in 1..=20 {
|
for i in 1..=20 {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let response = client
|
let response = client
|
||||||
.get("https://clob-v2.polymarket.com/simplified-markets?next_cursor=MA==")
|
.get("https://clob.polymarket.com/simplified-markets?next_cursor=MA==")
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ async fn test_config(
|
|||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
match client
|
match client
|
||||||
.get("https://clob-v2.polymarket.com/simplified-markets?next_cursor=MA==")
|
.get("https://clob.polymarket.com/simplified-markets?next_cursor=MA==")
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create client with API credentials only (no private key needed for custodial trading)
|
// Create client with API credentials only (no private key needed for custodial trading)
|
||||||
let mut client = ClobClient::new("https://clob-v2.polymarket.com");
|
let mut client = ClobClient::new("https://clob.polymarket.com");
|
||||||
client.set_api_creds(api_creds);
|
client.set_api_creds(api_creds);
|
||||||
|
|
||||||
println!("✅ Client configured for custodial API trading");
|
println!("✅ Client configured for custodial API trading");
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ async fn main() -> Result<()> {
|
|||||||
info!("======================");
|
info!("======================");
|
||||||
|
|
||||||
// Create client
|
// Create client
|
||||||
let client = ClobClient::new("https://clob-v2.polymarket.com");
|
let client = ClobClient::new("https://clob.polymarket.com");
|
||||||
|
|
||||||
// Test 1: Basic connectivity
|
// Test 1: Basic connectivity
|
||||||
info!("\nTesting API Connectivity...");
|
info!("\nTesting API Connectivity...");
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
for i in 1..=20 {
|
for i in 1..=20 {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
match baseline_http
|
match baseline_http
|
||||||
.get("https://clob-v2.polymarket.com/simplified-markets?next_cursor=MA==")
|
.get("https://clob.polymarket.com/simplified-markets?next_cursor=MA==")
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@@ -68,7 +68,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
println!("Test 2: polyfill-rs (with keep-alive)");
|
println!("Test 2: polyfill-rs (with keep-alive)");
|
||||||
println!("══════════════════════════════════════");
|
println!("══════════════════════════════════════");
|
||||||
|
|
||||||
let our_client = polyfill_rs::ClobClient::new("https://clob-v2.polymarket.com");
|
let our_client = polyfill_rs::ClobClient::new("https://clob.polymarket.com");
|
||||||
our_client
|
our_client
|
||||||
.start_keepalive(std::time::Duration::from_secs(30))
|
.start_keepalive(std::time::Duration::from_secs(30))
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@@ -101,14 +101,14 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_connection_manager_creation() {
|
async fn test_connection_manager_creation() {
|
||||||
let client = reqwest::ClientBuilder::new().no_proxy().build().unwrap();
|
let client = reqwest::ClientBuilder::new().no_proxy().build().unwrap();
|
||||||
let manager = ConnectionManager::new(client, "https://clob-v2.polymarket.com".to_string());
|
let manager = ConnectionManager::new(client, "https://clob.polymarket.com".to_string());
|
||||||
assert!(!manager.is_running());
|
assert!(!manager.is_running());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_keepalive_start_stop() {
|
async fn test_keepalive_start_stop() {
|
||||||
let client = reqwest::ClientBuilder::new().no_proxy().build().unwrap();
|
let client = reqwest::ClientBuilder::new().no_proxy().build().unwrap();
|
||||||
let manager = ConnectionManager::new(client, "https://clob-v2.polymarket.com".to_string());
|
let manager = ConnectionManager::new(client, "https://clob.polymarket.com".to_string());
|
||||||
|
|
||||||
manager.start_keepalive(Duration::from_secs(30)).await;
|
manager.start_keepalive(Duration::from_secs(30)).await;
|
||||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||||
|
|||||||
+3
-3
@@ -105,7 +105,7 @@ mod tests {
|
|||||||
#[ignore = "requires external DNS/network access"]
|
#[ignore = "requires external DNS/network access"]
|
||||||
async fn test_dns_cache_resolve() {
|
async fn test_dns_cache_resolve() {
|
||||||
let cache = DnsCache::new().await.unwrap();
|
let cache = DnsCache::new().await.unwrap();
|
||||||
let ips = cache.resolve("clob-v2.polymarket.com").await.unwrap();
|
let ips = cache.resolve("clob.polymarket.com").await.unwrap();
|
||||||
assert!(!ips.is_empty());
|
assert!(!ips.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ mod tests {
|
|||||||
#[ignore = "requires external DNS/network access"]
|
#[ignore = "requires external DNS/network access"]
|
||||||
async fn test_dns_cache_prewarm() {
|
async fn test_dns_cache_prewarm() {
|
||||||
let cache = DnsCache::new().await.unwrap();
|
let cache = DnsCache::new().await.unwrap();
|
||||||
cache.prewarm("clob-v2.polymarket.com").await.unwrap();
|
cache.prewarm("clob.polymarket.com").await.unwrap();
|
||||||
assert_eq!(cache.cache_size().await, 1);
|
assert_eq!(cache.cache_size().await, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ mod tests {
|
|||||||
#[ignore = "requires external DNS/network access"]
|
#[ignore = "requires external DNS/network access"]
|
||||||
async fn test_dns_cache_clear() {
|
async fn test_dns_cache_clear() {
|
||||||
let cache = DnsCache::new().await.unwrap();
|
let cache = DnsCache::new().await.unwrap();
|
||||||
cache.prewarm("clob-v2.polymarket.com").await.unwrap();
|
cache.prewarm("clob.polymarket.com").await.unwrap();
|
||||||
cache.clear().await;
|
cache.clear().await;
|
||||||
assert_eq!(cache.cache_size().await, 0);
|
assert_eq!(cache.cache_size().await, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -20,7 +20,7 @@
|
|||||||
//! #[tokio::main]
|
//! #[tokio::main]
|
||||||
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! let bootstrap = ClobClient::from_config(ClientConfig {
|
//! let bootstrap = ClobClient::from_config(ClientConfig {
|
||||||
//! base_url: "https://clob-v2.polymarket.com".to_string(),
|
//! base_url: "https://clob.polymarket.com".to_string(),
|
||||||
//! chain: 137,
|
//! chain: 137,
|
||||||
//! private_key: Some("your_private_key".to_string()),
|
//! private_key: Some("your_private_key".to_string()),
|
||||||
//! ..ClientConfig::default()
|
//! ..ClientConfig::default()
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
//!
|
//!
|
||||||
//! let api_creds = bootstrap.create_or_derive_api_key(None).await?;
|
//! let api_creds = bootstrap.create_or_derive_api_key(None).await?;
|
||||||
//! let client = ClobClient::from_config(ClientConfig {
|
//! let client = ClobClient::from_config(ClientConfig {
|
||||||
//! base_url: "https://clob-v2.polymarket.com".to_string(),
|
//! base_url: "https://clob.polymarket.com".to_string(),
|
||||||
//! chain: 137,
|
//! chain: 137,
|
||||||
//! private_key: Some("your_private_key".to_string()),
|
//! private_key: Some("your_private_key".to_string()),
|
||||||
//! api_credentials: Some(api_creds),
|
//! api_credentials: Some(api_creds),
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
//! #[tokio::main]
|
//! #[tokio::main]
|
||||||
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! // Create a basic client
|
//! // Create a basic client
|
||||||
//! let client = ClobClient::new("https://clob-v2.polymarket.com");
|
//! let client = ClobClient::new("https://clob.polymarket.com");
|
||||||
//!
|
//!
|
||||||
//! // Get market data
|
//! // Get market data
|
||||||
//! let markets = client.get_sampling_markets(None).await.unwrap();
|
//! let markets = client.get_sampling_markets(None).await.unwrap();
|
||||||
@@ -77,7 +77,7 @@ use tracing::info;
|
|||||||
|
|
||||||
// Global constants
|
// Global constants
|
||||||
pub const DEFAULT_CHAIN_ID: u64 = 137; // Polygon
|
pub const DEFAULT_CHAIN_ID: u64 = 137; // Polygon
|
||||||
pub const DEFAULT_BASE_URL: &str = "https://clob-v2.polymarket.com";
|
pub const DEFAULT_BASE_URL: &str = "https://clob.polymarket.com";
|
||||||
pub const DEFAULT_TIMEOUT_SECS: u64 = 30;
|
pub const DEFAULT_TIMEOUT_SECS: u64 = 30;
|
||||||
pub const DEFAULT_MAX_RETRIES: u32 = 3;
|
pub const DEFAULT_MAX_RETRIES: u32 = 3;
|
||||||
pub const DEFAULT_RATE_LIMIT_RPS: u32 = 100;
|
pub const DEFAULT_RATE_LIMIT_RPS: u32 = 100;
|
||||||
|
|||||||
+1
-1
@@ -815,7 +815,7 @@ pub struct ClientConfig {
|
|||||||
impl Default for ClientConfig {
|
impl Default for ClientConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137, // Polygon mainnet
|
chain: 137, // Polygon mainnet
|
||||||
private_key: None,
|
private_key: None,
|
||||||
api_credentials: None,
|
api_credentials: None,
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ impl Default for TestConfig {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
host: env::var("POLYMARKET_HOST")
|
host: env::var("POLYMARKET_HOST")
|
||||||
.unwrap_or_else(|_| "https://clob-v2.polymarket.com".to_string()),
|
.unwrap_or_else(|_| "https://clob.polymarket.com".to_string()),
|
||||||
chain: env::var("POLYMARKET_CHAIN_ID")
|
chain: env::var("POLYMARKET_CHAIN_ID")
|
||||||
.unwrap_or_else(|_| "137".to_string())
|
.unwrap_or_else(|_| "137".to_string())
|
||||||
.parse()
|
.parse()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use polyfill_rs::{ClientConfig, ClobClient, OrderArgs, Side};
|
|||||||
use rust_decimal_macros::dec;
|
use rust_decimal_macros::dec;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
const HOST: &str = "https://clob-v2.polymarket.com";
|
const HOST: &str = "https://clob.polymarket.com";
|
||||||
const CHAIN_ID: u64 = 137;
|
const CHAIN_ID: u64 = 137;
|
||||||
|
|
||||||
fn load_env_vars() -> (String, Option<String>, Option<String>, Option<String>) {
|
fn load_env_vars() -> (String, Option<String>, Option<String>, Option<String>) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ async fn test_post_order_authentication() {
|
|||||||
env::var("POLYMARKET_PRIVATE_KEY").expect("POLYMARKET_PRIVATE_KEY must be set in .env");
|
env::var("POLYMARKET_PRIVATE_KEY").expect("POLYMARKET_PRIVATE_KEY must be set in .env");
|
||||||
|
|
||||||
let bootstrap = ClobClient::from_config(ClientConfig {
|
let bootstrap = ClobClient::from_config(ClientConfig {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137,
|
chain: 137,
|
||||||
private_key: Some(private_key.clone()),
|
private_key: Some(private_key.clone()),
|
||||||
..ClientConfig::default()
|
..ClientConfig::default()
|
||||||
@@ -26,7 +26,7 @@ async fn test_post_order_authentication() {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to create API key");
|
.expect("Failed to create API key");
|
||||||
let client = ClobClient::from_config(ClientConfig {
|
let client = ClobClient::from_config(ClientConfig {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137,
|
chain: 137,
|
||||||
private_key: Some(private_key),
|
private_key: Some(private_key),
|
||||||
api_credentials: Some(creds),
|
api_credentials: Some(creds),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
use polyfill_rs::{ClobClient, PricesHistoryInterval};
|
use polyfill_rs::{ClobClient, PricesHistoryInterval};
|
||||||
|
|
||||||
const HOST: &str = "https://clob-v2.polymarket.com";
|
const HOST: &str = "https://clob.polymarket.com";
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::env;
|
|||||||
|
|
||||||
fn build_bootstrap_client(private_key: &str) -> ClobClient {
|
fn build_bootstrap_client(private_key: &str) -> ClobClient {
|
||||||
ClobClient::from_config(ClientConfig {
|
ClobClient::from_config(ClientConfig {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137,
|
chain: 137,
|
||||||
private_key: Some(private_key.to_string()),
|
private_key: Some(private_key.to_string()),
|
||||||
..ClientConfig::default()
|
..ClientConfig::default()
|
||||||
@@ -30,7 +30,7 @@ async fn test_create_api_key_simple() {
|
|||||||
println!("Successfully created/derived API key");
|
println!("Successfully created/derived API key");
|
||||||
println!(" API Key created (len={})", creds.api_key.len());
|
println!(" API Key created (len={})", creds.api_key.len());
|
||||||
let client = ClobClient::from_config(ClientConfig {
|
let client = ClobClient::from_config(ClientConfig {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137,
|
chain: 137,
|
||||||
private_key: Some(private_key),
|
private_key: Some(private_key),
|
||||||
api_credentials: Some(creds),
|
api_credentials: Some(creds),
|
||||||
@@ -77,7 +77,7 @@ async fn test_get_api_keys() {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to create API key");
|
.expect("Failed to create API key");
|
||||||
let client = ClobClient::from_config(ClientConfig {
|
let client = ClobClient::from_config(ClientConfig {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137,
|
chain: 137,
|
||||||
private_key: Some(private_key),
|
private_key: Some(private_key),
|
||||||
api_credentials: Some(creds),
|
api_credentials: Some(creds),
|
||||||
@@ -118,7 +118,7 @@ async fn test_get_trades() {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to create API key");
|
.expect("Failed to create API key");
|
||||||
let client = ClobClient::from_config(ClientConfig {
|
let client = ClobClient::from_config(ClientConfig {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137,
|
chain: 137,
|
||||||
private_key: Some(private_key),
|
private_key: Some(private_key),
|
||||||
api_credentials: Some(creds),
|
api_credentials: Some(creds),
|
||||||
@@ -159,7 +159,7 @@ async fn test_get_notifications() {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to create API key");
|
.expect("Failed to create API key");
|
||||||
let client = ClobClient::from_config(ClientConfig {
|
let client = ClobClient::from_config(ClientConfig {
|
||||||
base_url: "https://clob-v2.polymarket.com".to_string(),
|
base_url: "https://clob.polymarket.com".to_string(),
|
||||||
chain: 137,
|
chain: 137,
|
||||||
private_key: Some(private_key),
|
private_key: Some(private_key),
|
||||||
api_credentials: Some(creds),
|
api_credentials: Some(creds),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use polyfill_rs::{
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
const HOST: &str = "https://clob-v2.polymarket.com";
|
const HOST: &str = "https://clob.polymarket.com";
|
||||||
const WS_MARKET_URL: &str = "wss://ws-subscriptions-clob.polymarket.com/ws/market";
|
const WS_MARKET_URL: &str = "wss://ws-subscriptions-clob.polymarket.com/ws/market";
|
||||||
const WS_USER_URL: &str = "wss://ws-subscriptions-clob.polymarket.com/ws/user";
|
const WS_USER_URL: &str = "wss://ws-subscriptions-clob.polymarket.com/ws/user";
|
||||||
const CHAIN_ID: u64 = 137;
|
const CHAIN_ID: u64 = 137;
|
||||||
|
|||||||
Reference in New Issue
Block a user