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 <noreply@anthropic.com>
This commit is contained in:
direkturcrypto
2026-02-25 03:43:38 +07:00
co-authored by Claude Sonnet 4.6
parent 097148c501
commit b52892172e
+9 -3
View File
@@ -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})`);
}