chore: test different logic
This commit is contained in:
@@ -312,32 +312,39 @@ export function publishGroupings(
|
||||
|
||||
// Count crossed levels at the beginning
|
||||
let crossedBids = 0;
|
||||
const bestAsk = fullAggregatedAsks[0]?.[0];
|
||||
const bestAsk = fullAggregatedAsks[0]?.price;
|
||||
if (bestAsk !== undefined) {
|
||||
for (const bid of fullAggregatedBids) {
|
||||
if (bid[0] >= bestAsk) {
|
||||
if (bid.price >= bestAsk) {
|
||||
crossedBids++;
|
||||
} else {
|
||||
break; // Stop at first uncrossed level
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let crossedAsks = 0;
|
||||
const bestBid = fullAggregatedBids[0]?.[0];
|
||||
const bestBid = fullAggregatedBids[0]?.price;
|
||||
if (bestBid !== undefined) {
|
||||
for (const ask of fullAggregatedAsks) {
|
||||
if (ask[0] <= bestBid) {
|
||||
if (ask.price <= bestBid) {
|
||||
crossedAsks++;
|
||||
} else {
|
||||
break; // Stop at first uncrossed level
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const aggregatedBids = fullAggregatedBids.slice(0, 20 + crossedBids);
|
||||
const aggregatedAsks = fullAggregatedAsks.slice(0, 20 + crossedAsks);
|
||||
|
||||
|
||||
const maxCrossed = Math.max(crossedBids, crossedAsks);
|
||||
const levelsToTake = 20 + maxCrossed;
|
||||
|
||||
if (group === 10) {
|
||||
console.log(bestAsk, bestBid, crossedAsks, crossedBids, levelsToTake);
|
||||
}
|
||||
|
||||
const aggregatedBids = fullAggregatedBids.slice(0, levelsToTake);
|
||||
const aggregatedAsks = fullAggregatedAsks.slice(0, levelsToTake);
|
||||
|
||||
const l2Formatted_grouped20 = Object.assign({}, l2Formatted, {
|
||||
bids: aggregatedBids,
|
||||
asks: aggregatedAsks,
|
||||
@@ -719,7 +726,8 @@ export function createMarketBasedAuctionParams(
|
||||
// Set market-specific defaults (only used if values are undefined)
|
||||
const marketSpecificDefaults: Partial<AuctionParamArgs> = {
|
||||
...DEFAULT_AUCTION_PARAMS,
|
||||
auctionStartPriceOffsetFrom: isMajorMarket && version === 1 ? 'mark' : 'bestOffer',
|
||||
auctionStartPriceOffsetFrom:
|
||||
isMajorMarket && version === 1 ? 'mark' : 'bestOffer',
|
||||
auctionStartPriceOffset: isMajorMarket && version === 1 ? 0 : -0.1,
|
||||
};
|
||||
|
||||
@@ -1490,8 +1498,11 @@ export const calculateDynamicSlippage = (
|
||||
const minSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MIN || '0.035'); // 0.035% minimum
|
||||
const maxSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MAX || '5'); // 5% maximum
|
||||
|
||||
let finalSlippage = 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;
|
||||
|
||||
Reference in New Issue
Block a user