Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/api-doc-config.generated.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"_generated": "Auto-generated by extract-jsdoc.js on 2026-06-08T08:19:24.013Z. Do not edit manually.",
"_generated": "Auto-generated by extract-jsdoc.js on 2026-06-08T08:22:11.508Z. Do not edit manually.",
"methods": {
"has": {
"summary": "HTTP verb for the endpoint (e.g. GET, POST). */",
Expand Down Expand Up @@ -950,7 +950,7 @@
"description": "Result"
},
"exchangeOnly": "polymarket",
"source": "index.ts:143"
"source": "index.ts:144"
},
"preWarmMarket": {
"summary": "Pre-warm the SDK's internal caches for a market outcome.",
Expand All @@ -968,7 +968,7 @@
"description": "Result"
},
"exchangeOnly": "polymarket",
"source": "index.ts:209"
"source": "index.ts:210"
},
"getEventById": {
"summary": "Fetch a single event by its numeric ID (Probable only).",
Expand Down
6 changes: 3 additions & 3 deletions core/src/exchanges/limitless/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClient, OrderClient, OrderBuilder, OrderSigner, MarketFetcher, Side, OrderType } from '@limitless-exchange/sdk';
import { Wallet, providers, Contract } from 'ethers';
import { LIMITLESS_RPC_URL } from './config';
import { LIMITLESS_CHAIN_ID, LIMITLESS_RPC_URL } from './config';
import { scaledIntegerToNumber } from './utils';

const DEFAULT_LIMITLESS_API_URL = process.env.LIMITLESS_BASE_URL || 'https://api.limitless.exchange';
Expand Down Expand Up @@ -204,7 +204,7 @@ export class LimitlessClient {
// Sign with the EOA private key.
const orderSigner = new OrderSigner(wallet);
const signature = await orderSigner.signOrder(unsignedOrder, {
chainId: 8453,
chainId: LIMITLESS_CHAIN_ID,
contractAddress: market.venue.exchange,
});

Expand Down Expand Up @@ -387,7 +387,7 @@ export class LimitlessClient {
const ABI = ["function balanceOf(address) view returns (uint256)", "function decimals() view returns (uint8)"];

const provider = new providers.StaticJsonRpcProvider(LIMITLESS_RPC_URL, {
chainId: 8453,
chainId: LIMITLESS_CHAIN_ID,
name: 'base',
});
const contract = new Contract(USDC_ADDRESS, ABI, provider);
Expand Down
2 changes: 2 additions & 0 deletions core/src/exchanges/limitless/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const LIMITLESS_BASE_URL = process.env.LIMITLESS_BASE_URL || 'https://api.limitless.exchange';
export const LIMITLESS_RPC_URL = process.env.LIMITLESS_RPC_URL || 'https://mainnet.base.org';
export const LIMITLESS_CHAIN_ID = 8453; // Base mainnet
4 changes: 2 additions & 2 deletions core/src/exchanges/limitless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { FetcherContext } from '../interfaces';
import { limitlessApiSpec } from './api';
import { LimitlessAuth } from './auth';
import { LimitlessClient } from './client';
import { LIMITLESS_RPC_URL } from './config';
import { LIMITLESS_CHAIN_ID, LIMITLESS_RPC_URL } from './config';
import { limitlessErrorMapper } from './errors';
import { LimitlessFetcher } from './fetcher';
import { LimitlessNormalizer } from './normalizer';
Expand Down Expand Up @@ -572,7 +572,7 @@ export class LimitlessExchange extends PredictionMarketExchange {
// Static network avoids ethers v5 auto-detect (eth_chainId), which can throw
// noNetwork / NETWORK_ERROR on flaky public RPCs (#92).
const provider = new providers.StaticJsonRpcProvider(LIMITLESS_RPC_URL, {
chainId: 8453,
chainId: LIMITLESS_CHAIN_ID,
name: 'base',
});

Expand Down
6 changes: 3 additions & 3 deletions core/src/exchanges/polymarket/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { polygon } from 'viem/chains';
import axios from 'axios';
import { ExchangeCredentials } from '../../BaseExchange';
import { logger } from '../../utils/logger';
import { POLYMARKET_CHAIN_ID } from './config';
import { polymarketErrorMapper } from './errors';

const DEFAULT_POLYMARKET_HOST = process.env.POLYMARKET_CLOB_URL || 'https://clob.polymarket.com';
const POLYGON_CHAIN_ID = 137;

// Polymarket CLOB signature types — determines how the CLOB API
// resolves the on-chain address holding the user's funds.
Expand Down Expand Up @@ -93,7 +93,7 @@ export class PolymarketAuth {
// Otherwise, derive/create them using L1 auth
const l1Client = new ClobClient({
host: this.host,
chain: POLYGON_CHAIN_ID,
chain: POLYMARKET_CHAIN_ID,
signer: this.signer,
});

Expand Down Expand Up @@ -278,7 +278,7 @@ export class PolymarketAuth {

this.clobClient = new ClobClient({
host: this.host,
chain: POLYGON_CHAIN_ID,
chain: POLYMARKET_CHAIN_ID,
signer: this.signer,
creds: apiCreds,
signatureType: finalSignatureType,
Expand Down
1 change: 1 addition & 0 deletions core/src/exchanges/polymarket/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const POLYMARKET_CHAIN_ID = 137; // Polygon mainnet
3 changes: 2 additions & 1 deletion core/src/exchanges/polymarket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { polymarketClobSpec } from './api-clob';
import { polymarketDataSpec } from './api-data';
import { polymarketGammaSpec } from './api-gamma';
import { PolymarketAuth } from './auth';
import { POLYMARKET_CHAIN_ID } from './config';
import { logger } from '../../utils/logger';
import { polymarketErrorMapper } from './errors';
import { PolymarketFetcher } from './fetcher';
Expand Down Expand Up @@ -752,7 +753,7 @@ export class PolymarketExchange extends PredictionMarketExchange {
// Static network avoids ethers v5 auto-detect (eth_chainId), which can throw
// noNetwork / NETWORK_ERROR on flaky public RPCs (#92).
const provider = new ethers.providers.StaticJsonRpcProvider('https://polygon-rpc.com', {
chainId: 137,
chainId: POLYMARKET_CHAIN_ID,
name: 'matic',
});
const pusdAddress = '0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB'; // pUSD (Polymarket USD)
Expand Down
9 changes: 5 additions & 4 deletions core/src/exchanges/probable/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { privateKeyToAccount } from 'viem/accounts';
import { createWalletClient, http } from 'viem';
import { bsc, bscTestnet } from 'viem/chains';
import { ExchangeCredentials } from '../../BaseExchange';
import { PROBABLE_CHAIN_ID, PROBABLE_TESTNET_CHAIN_ID } from './config';

/**
* Manages Probable authentication and CLOB client initialization.
Expand Down Expand Up @@ -36,8 +37,8 @@ export class ProbableAuth {
return this.clobClient;
}

const chainId = parseInt(process.env.PROBABLE_CHAIN_ID || '56', 10);
const chain = chainId === 97 ? bscTestnet : bsc;
const chainId = parseInt(process.env.PROBABLE_CHAIN_ID || String(PROBABLE_CHAIN_ID), 10);
const chain = chainId === PROBABLE_TESTNET_CHAIN_ID ? bscTestnet : bsc;

const account = privateKeyToAccount(this.credentials.privateKey as `0x${string}`);
const wallet = createWalletClient({
Expand All @@ -56,9 +57,9 @@ export class ProbableAuth {
// disagree on WalletClient. Runtime shape is identical.
const walletForClob = wallet as any;

if (chainId === 56) {
if (chainId === PROBABLE_CHAIN_ID) {
this.clobClient = createClobClient({
chainId: 56,
chainId: PROBABLE_CHAIN_ID,
wallet: walletForClob,
credential,
});
Expand Down
2 changes: 2 additions & 0 deletions core/src/exchanges/probable/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const PROBABLE_CHAIN_ID = 56; // BSC mainnet
export const PROBABLE_TESTNET_CHAIN_ID = 97; // BSC testnet
3 changes: 2 additions & 1 deletion core/src/exchanges/probable/websocket.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { createClobClient } from '@prob/clob';
import { OrderBook, OrderLevel } from '../../types';
import { DEFAULT_WATCH_TIMEOUT_MS, withWatchTimeout } from '../../utils/watch-timeout';
import { PROBABLE_CHAIN_ID } from './config';

interface QueuedPromise<T> {
resolve: (value: T | PromiseLike<T>) => void;
Expand Down Expand Up @@ -37,7 +38,7 @@ export class ProbableWebSocket {
private async ensureClient(): Promise<ReturnType<typeof createClobClient>> {
if (this.client) return this.client;

const chainId = this.config.chainId || parseInt(process.env.PROBABLE_CHAIN_ID || '56', 10);
const chainId = this.config.chainId || parseInt(process.env.PROBABLE_CHAIN_ID || String(PROBABLE_CHAIN_ID), 10);
const wsUrl = this.config.wsUrl || process.env.PROBABLE_WS_URL || 'wss://ws.probable.markets/public/api/v1';
const baseUrl = this.config.baseUrl || process.env.PROBABLE_BASE_URL || 'https://api.probable.markets/public/api/v1';

Expand Down
Loading