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:
co-authored by
Claude Sonnet 4.6
parent
097148c501
commit
b52892172e
@@ -179,10 +179,16 @@ export async function executeBuy(trade) {
|
|||||||
let totalSharesFilled = 0;
|
let totalSharesFilled = 0;
|
||||||
let totalCostFilled = 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++) {
|
for (let attempt = 1; attempt <= config.maxRetries; attempt++) {
|
||||||
try {
|
try {
|
||||||
const remainingAmount = tradeSize - totalCostFilled;
|
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)}`);
|
logger.info(`Buy attempt ${attempt}/${config.maxRetries} | Amount: $${remainingAmount.toFixed(2)}`);
|
||||||
|
|
||||||
@@ -209,8 +215,8 @@ export async function executeBuy(trade) {
|
|||||||
totalSharesFilled += sharesFilled;
|
totalSharesFilled += sharesFilled;
|
||||||
totalCostFilled += costFilled || (sharesFilled * price);
|
totalCostFilled += costFilled || (sharesFilled * price);
|
||||||
filled = true;
|
filled = true;
|
||||||
// If remainder is below minimum, stop; otherwise loop for partial fill
|
// If remainder is below $1 minimum, stop; otherwise loop for partial fill
|
||||||
if (tradeSize - totalCostFilled < config.minTradeSize) break;
|
if (tradeSize - totalCostFilled < Math.max(config.minTradeSize, CLOB_MIN_ORDER_USDC)) break;
|
||||||
} else {
|
} else {
|
||||||
logger.warn(`No liquidity — FAK filled 0 shares (attempt ${attempt})`);
|
logger.warn(`No liquidity — FAK filled 0 shares (attempt ${attempt})`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user