Skip to content
Closed
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
22 changes: 22 additions & 0 deletions core/src/exchanges/polymarket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}