From 3a4dbf2b02bd18f9068d96bb80ff7dc39bac0b11 Mon Sep 17 00:00:00 2001 From: direkturcrypto Date: Tue, 31 Mar 2026 14:19:25 +0700 Subject: [PATCH] feat: add MAKER_MM_REENTRY_ENABLED config + fix float combined check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MAKER_MM_REENTRY_ENABLED=false disables re-entry (one cycle per market) - Fix floating point bug: 0.1+0.5=0.6000000000000001 caused "combined > max" loop when MAKER_MM_MAX_COMBINED=0.60 — now rounds combined to 4dp before compare Co-Authored-By: Claude Sonnet 4.6 --- .env.example | 3 +++ src/config/index.js | 1 + src/maker-mm-bot.js | 2 +- src/services/makerRebateExecutor.js | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 9daf578..0236346 100644 --- a/.env.example +++ b/.env.example @@ -92,6 +92,9 @@ MAKER_MM_POLL_INTERVAL=5 # Delay between re-entry cycles within the same market (seconds) MAKER_MM_REENTRY_DELAY=30 +# Set to false to disable re-entry — bot places one order per market then waits for next +MAKER_MM_REENTRY_ENABLED=true + # Price range for maker rebate eligibility (both sides must be in range) # Polymarket rebates are earned on orders within ~30-70% range MAKER_MM_MIN_PRICE=0.30 diff --git a/src/config/index.js b/src/config/index.js index c5feabb..60f582e 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -96,6 +96,7 @@ const config = { makerMmEntryWindow: parseInt(process.env.MAKER_MM_ENTRY_WINDOW || '45', 10), // max secs after open to enter makerMmPollInterval: parseInt(process.env.MAKER_MM_POLL_INTERVAL || process.env.MM_POLL_INTERVAL || '5', 10) * 1000, makerMmReentryDelay: parseInt(process.env.MAKER_MM_REENTRY_DELAY || '30', 10) * 1000, // ms delay between re-entry cycles + makerMmReentryEnabled: process.env.MAKER_MM_REENTRY_ENABLED !== 'false', // set false to disable re-entry (one cycle per market) makerMmRepriceThreshold: parseFloat(process.env.MAKER_MM_REPRICE_THRESHOLD || '0.02'), // reprice if bid drifts > this (default 2c) makerMmMinPrice: parseFloat(process.env.MAKER_MM_MIN_PRICE || '0.30'), // min bid for rebate range (both sides) makerMmMaxPrice: parseFloat(process.env.MAKER_MM_MAX_PRICE || '0.69'), // max bid for rebate range (both sides) diff --git a/src/maker-mm-bot.js b/src/maker-mm-bot.js index a34ea27..cb7e2c8 100644 --- a/src/maker-mm-bot.js +++ b/src/maker-mm-bot.js @@ -182,7 +182,7 @@ async function runStrategy(market) { const secsLeft = Math.round(msRemaining / 1000); const minTimeForReentry = 180; // 3 minutes minimum - if (secsLeft > config.makerMmCutLossTime + minTimeForReentry) { + if (config.makerMmReentryEnabled && secsLeft > config.makerMmCutLossTime + minTimeForReentry) { // ── CURRENT MARKET: Check odds before re-entry ────────────────────── if (isCurrentMarket && config.currentMarketEnabled) { const oddsValid = await isCurrentMarketOddsValidForReentry( diff --git a/src/services/makerRebateExecutor.js b/src/services/makerRebateExecutor.js index 7f426e4..73653c9 100644 --- a/src/services/makerRebateExecutor.js +++ b/src/services/makerRebateExecutor.js @@ -649,7 +649,7 @@ export async function executeMakerRebateStrategy(market) { continue; } - combined = yesBid + noBid; + combined = parseFloat((yesBid + noBid).toFixed(4)); if (combined > config.makerMmMaxCombined) { logger.info(`MakerMM${tag}: combined $${combined.toFixed(4)} > max — waiting`);