Merge pull request #552 from drift-labs/nick/add-param-to-derive-mkt-order

add param to deriveMarketOrderParams
This commit is contained in:
lowkeynicc
2025-11-06 14:12:55 -05:00
committed by GitHub

View File

@@ -992,6 +992,8 @@ export const mapToMarketOrderParams = async (
appliedV2Adjustment: false,
};
let conditionalParams = {};
if (driftClient && fetchFromRedis && selectMostRecentBySlot) {
// Get L2 orderbook data using the utility function
const redisL2 = await fetchL2FromRedis(
@@ -1033,6 +1035,13 @@ export const mapToMarketOrderParams = async (
oraclePrice
);
// TODO - apply this to all apiVersions once testing is complete.
conditionalParams = {
ensureCrossingEndPrice: true,
bestBidPrice: spreadInfo.bestBidPrice,
bestAskPrice: spreadInfo.bestAskPrice,
};
const isCrossed =
spreadInfo.bestBidPrice &&
spreadInfo.bestAskPrice &&
@@ -1295,6 +1304,7 @@ export const mapToMarketOrderParams = async (
additionalEndPriceBuffer,
forceUpToSlippage: params.forceUpToSlippage,
userOrderId: params.userOrderId,
...conditionalParams,
},
estimatedPrices,
},