diff --git a/core/src/exchanges/polymarket/index.ts b/core/src/exchanges/polymarket/index.ts index ef6d382..1a39396 100644 --- a/core/src/exchanges/polymarket/index.ts +++ b/core/src/exchanges/polymarket/index.ts @@ -311,6 +311,28 @@ export class PolymarketExchange extends PredictionMarketExchange { options.negRisk = params.negRisk; } + // Build-only mode: create and sign the order without submitting to the network + if (params.buildOnly) { + const signedOrder = await client.createOrder(orderArgs, options); + // Return the signed order data for the user to sign/broadcast themselves + // The orderHash may be a BigInt or other type, so we convert to string + const orderHash = signedOrder.orderHash ? String(signedOrder.orderHash) : 'unsigned'; + return { + id: orderHash, + marketId: params.marketId, + outcomeId: params.outcomeId, + side: params.side, + type: params.type, + price: price, + amount: params.amount, + status: 'pending', + filled: 0, + remaining: params.amount, + fee: params.fee, + timestamp: Date.now(), + }; + } + const response = await client.createAndPostOrder(orderArgs, options); if (!response || !response.success) { diff --git a/core/src/types.ts b/core/src/types.ts index 04a63d3..1d268f2 100644 --- a/core/src/types.ts +++ b/core/src/types.ts @@ -141,4 +141,5 @@ export interface CreateOrderParams { fee?: number; // Optional fee rate (e.g., 1000 for 0.1%) tickSize?: number; // Optional override for Limitless/Polymarket negRisk?: boolean; // Optional override to skip neg-risk lookup (Polymarket) + buildOnly?: boolean; // If true, returns signed order data without submitting to the network }