From b52892172e4cc2b87c56b4f45eab1e3c22847ef4 Mon Sep 17 00:00:00 2001 From: direkturcrypto Date: Wed, 25 Feb 2026 03:43:38 +0700 Subject: [PATCH] fix: enforce $1 USDC minimum per FAK buy order (Polymarket hard minimum) Polymarket rejects market orders below $1 USDC. Added CLOB_MIN_ORDER_USDC=1 constant and applied Math.max(config.minTradeSize, CLOB_MIN_ORDER_USDC) at both the loop entry check and post-fill remainder check so sub-$1 remainders are silently skipped instead of causing API errors. Co-Authored-By: Claude Sonnet 4.6 --- src/services/executor.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/services/executor.js b/src/services/executor.js index 6398b55..5f0501a 100644 --- a/src/services/executor.js +++ b/src/services/executor.js @@ -179,10 +179,16 @@ export async function executeBuy(trade) { let totalSharesFilled = 0; let totalCostFilled = 0; + // Polymarket enforces a hard $1 minimum per market order. + const CLOB_MIN_ORDER_USDC = 1; + for (let attempt = 1; attempt <= config.maxRetries; attempt++) { try { const remainingAmount = tradeSize - totalCostFilled; - if (remainingAmount < config.minTradeSize) break; + if (remainingAmount < Math.max(config.minTradeSize, CLOB_MIN_ORDER_USDC)) { + if (remainingAmount > 0) logger.info(`Remaining $${remainingAmount.toFixed(2)} below $1 minimum — stopping`); + break; + } logger.info(`Buy attempt ${attempt}/${config.maxRetries} | Amount: $${remainingAmount.toFixed(2)}`); @@ -209,8 +215,8 @@ export async function executeBuy(trade) { totalSharesFilled += sharesFilled; totalCostFilled += costFilled || (sharesFilled * price); filled = true; - // If remainder is below minimum, stop; otherwise loop for partial fill - if (tradeSize - totalCostFilled < config.minTradeSize) break; + // If remainder is below $1 minimum, stop; otherwise loop for partial fill + if (tradeSize - totalCostFilled < Math.max(config.minTradeSize, CLOB_MIN_ORDER_USDC)) break; } else { logger.warn(`No liquidity — FAK filled 0 shares (attempt ${attempt})`); }