Skip to content

Commit

Permalink
filler: parallelize fills across perp markets (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney authored Jan 18, 2024
1 parent d6caedd commit e0c3723
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/bots/filler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,28 @@ export class FillerBot implements Bot {

protected async tryBulkFillPerpNodes(
nodesToFill: Array<NodeToFill>
): Promise<number> {
let nodesSent = 0;
const marketNodeMap = new Map<number, Array<NodeToFill>>();
for (const nodeToFill of nodesToFill) {
const marketIndex = nodeToFill.node.order!.marketIndex;
if (!marketNodeMap.has(marketIndex)) {
marketNodeMap.set(marketIndex, []);
}
marketNodeMap.get(marketIndex)!.push(nodeToFill);
}

for (const nodesToFillForMarket of marketNodeMap.values()) {
nodesSent += await this.tryBulkFillPerpNodesForMarket(
nodesToFillForMarket
);
}

return nodesSent;
}

protected async tryBulkFillPerpNodesForMarket(
nodesToFill: Array<NodeToFill>
): Promise<number> {
const ixs = [
ComputeBudgetProgram.setComputeUnitLimit({
Expand Down

0 comments on commit e0c3723

Please sign in to comment.