From 1da662313d51febc7a39edeec2bb99a31d053da3 Mon Sep 17 00:00:00 2001 From: direkturcrypto Date: Fri, 27 Mar 2026 05:15:01 +0700 Subject: [PATCH] fix: use mid price for initial adaptive CL sell instead of fixed breakeven floor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check mid price first, place limit at market price (capped at mmSellPrice). Only falls back to breakeven floor if mid price is below it. Example: YES filled @ 70c, NO mid = 38c → sell @ 38c (not 30c breakeven) This gives profit potential instead of always targeting breakeven. Co-Authored-By: Claude Opus 4.6 --- src/services/mmExecutor.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/services/mmExecutor.js b/src/services/mmExecutor.js index 8e99483..8e6d216 100644 --- a/src/services/mmExecutor.js +++ b/src/services/mmExecutor.js @@ -517,11 +517,17 @@ async function adaptiveLegCL(pos, unfilledKey) { let currentFloor = is5m ? breakevenFloor : minAdaptivePrice; if (is5m && sellShares >= CLOB_MIN_ORDER_SHARES) { - logger.info(`MM adaptive CL: placing standing limit sell @ $${breakevenFloor.toFixed(3)} (breakeven floor)`); - const standing = await placeLimitSell(s.tokenId, sellShares, breakevenFloor, tickSize, negRisk); + // Check mid price first — place at market price (not just breakeven floor) + const initMid = await getMidprice(s.tokenId); + // Use mid price if above floor, otherwise use floor as safety net + const initSellPrice = initMid >= currentFloor + ? Math.min(initMid, config.mmSellPrice) + : currentFloor; + logger.info(`MM adaptive CL: mid=$${initMid.toFixed(3)}, placing initial limit sell @ $${initSellPrice.toFixed(3)} (floor=$${currentFloor.toFixed(3)})`); + const standing = await placeLimitSell(s.tokenId, sellShares, initSellPrice, tickSize, negRisk); if (standing.success) { activeOrderId = standing.orderId; - activeLimitPrice = breakevenFloor; + activeLimitPrice = initSellPrice; } } else { logger.info(`MM adaptive CL: monitoring ${unfilledKey.toUpperCase()} — floor $${currentFloor.toFixed(3)}, market-sell at CL time`);