v2 params iteration (#555)
This commit is contained in:
@@ -1050,7 +1050,7 @@ const main = async (): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const inputParams = createMarketBasedAuctionParams(auctionParamsInput);
|
const inputParams = createMarketBasedAuctionParams(auctionParamsInput, undefined, apiVersion);
|
||||||
|
|
||||||
const result = await mapToMarketOrderParams(
|
const result = await mapToMarketOrderParams(
|
||||||
inputParams,
|
inputParams,
|
||||||
|
|||||||
@@ -678,7 +678,8 @@ export const selectMostRecentBySlot = (
|
|||||||
|
|
||||||
export function createMarketBasedAuctionParams(
|
export function createMarketBasedAuctionParams(
|
||||||
args: AuctionParamArgs,
|
args: AuctionParamArgs,
|
||||||
overrideDefaults?: Partial<AuctionParamArgs>
|
overrideDefaults?: Partial<AuctionParamArgs>,
|
||||||
|
version: number = 1
|
||||||
): AuctionParamArgs {
|
): AuctionParamArgs {
|
||||||
// Determine if this is a major market (PERP with marketIndex 0, 1, or 2)
|
// Determine if this is a major market (PERP with marketIndex 0, 1, or 2)
|
||||||
const isMajorMarket =
|
const isMajorMarket =
|
||||||
@@ -705,8 +706,8 @@ export function createMarketBasedAuctionParams(
|
|||||||
// Set market-specific defaults (only used if values are undefined)
|
// Set market-specific defaults (only used if values are undefined)
|
||||||
const marketSpecificDefaults: Partial<AuctionParamArgs> = {
|
const marketSpecificDefaults: Partial<AuctionParamArgs> = {
|
||||||
...DEFAULT_AUCTION_PARAMS,
|
...DEFAULT_AUCTION_PARAMS,
|
||||||
auctionStartPriceOffsetFrom: isMajorMarket ? 'mark' : 'bestOffer',
|
auctionStartPriceOffsetFrom: isMajorMarket && version === 1 ? 'mark' : 'bestOffer',
|
||||||
auctionStartPriceOffset: isMajorMarket ? 0 : -0.1,
|
auctionStartPriceOffset: isMajorMarket && version === 1 ? 0 : -0.1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Apply custom overrides if provided
|
// Apply custom overrides if provided
|
||||||
@@ -1186,7 +1187,8 @@ export const mapToMarketOrderParams = async (
|
|||||||
driftClient,
|
driftClient,
|
||||||
l2Formatted,
|
l2Formatted,
|
||||||
startPrice,
|
startPrice,
|
||||||
estimatedPrices.worstPrice
|
estimatedPrices.worstPrice,
|
||||||
|
apiVersion
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1392,7 +1394,8 @@ export const calculateDynamicSlippage = (
|
|||||||
driftClient: DriftClient,
|
driftClient: DriftClient,
|
||||||
l2Formatted: L2OrderBook,
|
l2Formatted: L2OrderBook,
|
||||||
startPrice: BN,
|
startPrice: BN,
|
||||||
worstPrice: BN
|
worstPrice: BN,
|
||||||
|
apiVersion?: number
|
||||||
): number => {
|
): number => {
|
||||||
// Determine if this is a major market (PERP with marketIndex 0, 1, or 2)
|
// Determine if this is a major market (PERP with marketIndex 0, 1, or 2)
|
||||||
const isPerp = marketType.toLowerCase() === 'perp';
|
const isPerp = marketType.toLowerCase() === 'perp';
|
||||||
@@ -1474,7 +1477,14 @@ export const calculateDynamicSlippage = (
|
|||||||
const minSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MIN || '0.035'); // 0.035% minimum
|
const minSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MIN || '0.035'); // 0.035% minimum
|
||||||
const maxSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MAX || '5'); // 5% maximum
|
const maxSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MAX || '5'); // 5% maximum
|
||||||
|
|
||||||
return Math.min(Math.max(dynamicSlippage, minSlippage), maxSlippage);
|
let finalSlippage = Math.min(Math.max(dynamicSlippage, minSlippage), maxSlippage);
|
||||||
|
|
||||||
|
// Apply 10% boost for API v2
|
||||||
|
if (apiVersion === 2) {
|
||||||
|
finalSlippage = finalSlippage * 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return finalSlippage;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user