replace MMOracleData again

This commit is contained in:
Nick Caradonna
2025-10-29 18:24:25 -04:00
parent 748f130101
commit a70ebb26f8

View File

@@ -97,12 +97,15 @@ export function parsePositiveIntArray(
export const getOracleForMarket = ( export const getOracleForMarket = (
driftClient: DriftClient, driftClient: DriftClient,
marketType: MarketType, marketType: MarketType,
marketIndex: number marketIndex: number,
useMMOracleData = false
): number => { ): number => {
if (isVariant(marketType, 'spot')) { if (isVariant(marketType, 'spot')) {
return driftClient.getOracleDataForSpotMarket(marketIndex).price.toNumber(); return driftClient.getOracleDataForSpotMarket(marketIndex).price.toNumber();
} else if (isVariant(marketType, 'perp')) { } else if (isVariant(marketType, 'perp')) {
return driftClient.getOracleDataForPerpMarket(marketIndex).price.toNumber(); return useMMOracleData
? driftClient.getMMOracleDataForPerpMarket(marketIndex).price.toNumber()
: driftClient.getOracleDataForPerpMarket(marketIndex).price.toNumber();
} }
}; };
@@ -1021,7 +1024,7 @@ export const mapToMarketOrderParams = async (
const isSpot = isVariant(marketType, 'spot'); const isSpot = isVariant(marketType, 'spot');
const oracleData = isSpot const oracleData = isSpot
? driftClient.getOracleDataForSpotMarket(params.marketIndex) ? driftClient.getOracleDataForSpotMarket(params.marketIndex)
: driftClient.getOracleDataForPerpMarket(params.marketIndex); : driftClient.getMMOracleDataForPerpMarket(params.marketIndex);
const oraclePrice = oracleData.price ?? ZERO; const oraclePrice = oracleData.price ?? ZERO;
// Detect if orderbook is crossed // Detect if orderbook is crossed
@@ -1415,7 +1418,7 @@ export const calculateDynamicSlippage = (
)?.toNum(); )?.toNum();
if (spreadInfo?.spreadPct) { if (spreadInfo?.spreadPct) {
spreadBaseSlippage = spreadPctNum * .9; spreadBaseSlippage = spreadPctNum * 0.9;
// If the L2 is crossed (best bid > best ask), cap the spread contribution // If the L2 is crossed (best bid > best ask), cap the spread contribution
const bestBid = spreadInfo.bestBidPrice; const bestBid = spreadInfo.bestBidPrice;