diff --git a/src/bots/filler.ts b/src/bots/filler.ts index d6d90130..5ba0f3ac 100644 --- a/src/bots/filler.ts +++ b/src/bots/filler.ts @@ -1427,22 +1427,6 @@ export class FillerBot extends TxThreaded implements Bot { nodeToFill: NodeToFill, buildForBundle: boolean ): Promise { - const ixs: Array = [ - ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, - }), - ]; - if (!buildForBundle) { - ixs.push( - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: Math.floor( - this.priorityFeeSubscriber.getCustomStrategyResult() * - this.driftClient.txSender.getSuggestedPriorityFeeMultiplier() - ), - }) - ); - } - try { const { makerInfos, @@ -1477,6 +1461,23 @@ export class FillerBot extends TxThreaded implements Bot { ixs: Array; simResult: SimulateAndGetTxWithCUsResponse; }> => { + const ixs: Array = [ + ComputeBudgetProgram.setComputeUnitLimit({ + units: 1_400_000, + }), + ]; + if (buildForBundle) { + ixs.push(this.bundleSender!.getTipIx()); + } else { + ixs.push( + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: Math.floor( + this.priorityFeeSubscriber.getCustomStrategyResult() * + this.driftClient.txSender.getSuggestedPriorityFeeMultiplier() + ), + }) + ); + } ixs.push( await this.driftClient.getFillPerpOrderIx( await getUserAccountPublicKey( diff --git a/src/bots/spotFiller.ts b/src/bots/spotFiller.ts index 34ae5d59..ae57e4f3 100644 --- a/src/bots/spotFiller.ts +++ b/src/bots/spotFiller.ts @@ -1741,23 +1741,6 @@ export class SpotFillerBot implements Bot { buildForBundle: boolean, spotPrecision: BN ): Promise { - const ixs: Array = [ - ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, - }), - ]; - if (buildForBundle) { - ixs.push(this.bundleSender!.getTipIx()); - } else { - ixs.push( - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: Math.floor( - this.priorityFeeSubscriber.getCustomStrategyResult() - ), - }) - ); - } - try { const { makerInfos, @@ -1788,6 +1771,23 @@ export class SpotFillerBot implements Bot { const buildTxWithMakerInfos = async ( makers: DataAndSlot[] ): Promise => { + const ixs: Array = [ + ComputeBudgetProgram.setComputeUnitLimit({ + units: 1_400_000, + }), + ]; + if (buildForBundle) { + ixs.push(this.bundleSender!.getTipIx()); + } else { + ixs.push( + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: Math.floor( + this.priorityFeeSubscriber.getCustomStrategyResult() + ), + }) + ); + } + ixs.push( await this.driftClient.getFillSpotOrderIx( new PublicKey(takerUserPubKey), diff --git a/src/experimental-bots/filler/fillerMultithreaded.ts b/src/experimental-bots/filler/fillerMultithreaded.ts index 5b52ac85..8a224775 100644 --- a/src/experimental-bots/filler/fillerMultithreaded.ts +++ b/src/experimental-bots/filler/fillerMultithreaded.ts @@ -1546,12 +1546,6 @@ export class FillerMultithreaded { fillTxId: number, nodeToFill: NodeToFillWithBuffer ): Promise { - let ixs: Array = [ - ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, - }), - ]; - try { const { makerInfos, @@ -1563,60 +1557,69 @@ export class FillerMultithreaded { fillerRewardEstimate, } = await this.getNodeFillInfo(nodeToFill); - let removeLastIxPostSim = this.revertOnFailure; - if ( - this.pythPriceSubscriber && - ((makerInfos.length === 2 && !referrerInfo) || makerInfos.length < 2) - ) { - const pythIxs = await this.getPythIxsFromNode(nodeToFill); - ixs.push(...pythIxs); - removeLastIxPostSim = false; - } - - const priorityFeePrice = Math.floor( - this.priorityFeeSubscriber.getPriorityFees( - 'perp', - nodeToFill.node.order!.marketIndex! - )!.high * this.driftClient.txSender.getSuggestedPriorityFeeMultiplier() - ); const buildForBundle = this.shouldBuildForBundle(); - - if (buildForBundle) { - ixs.push(this.bundleSender!.getTipIx()); - } else { - ixs.push( - getPriorityFeeInstruction( - priorityFeePrice, - this.driftClient.getOracleDataForPerpMarket(0).price, - this.config.bidToFillerReward ? fillerRewardEstimate : undefined, - this.globalConfig.priorityFeeMultiplier - ) - ); - } - - logMessageForNodeToFill( - nodeToFill, - takerUserPubKey, - takerUserSlot, - makerInfos, - this.slotSubscriber.getSlot(), - fillTxId, - 'multiMakerFill', - this.revertOnFailure ?? false, - removeLastIxPostSim ?? false - ); - - if (!isVariant(marketType, 'perp')) { - throw new Error('expected perp market type'); - } - let makerInfosToUse = makerInfos; + const buildTxWithMakerInfos = async ( makers: DataAndSlot[] ): Promise => { if (makers.length === 0) { return undefined; } + + let ixs: Array = [ + ComputeBudgetProgram.setComputeUnitLimit({ + units: 1_400_000, + }), + ]; + + let removeLastIxPostSim = this.revertOnFailure; + if ( + this.pythPriceSubscriber && + ((makerInfos.length === 2 && !referrerInfo) || makerInfos.length < 2) + ) { + const pythIxs = await this.getPythIxsFromNode(nodeToFill); + ixs.push(...pythIxs); + removeLastIxPostSim = false; + } + + const priorityFeePrice = Math.floor( + this.priorityFeeSubscriber.getPriorityFees( + 'perp', + nodeToFill.node.order!.marketIndex! + )!.high * + this.driftClient.txSender.getSuggestedPriorityFeeMultiplier() + ); + + if (buildForBundle) { + ixs.push(this.bundleSender!.getTipIx()); + } else { + ixs.push( + getPriorityFeeInstruction( + priorityFeePrice, + this.driftClient.getOracleDataForPerpMarket(0).price, + this.config.bidToFillerReward ? fillerRewardEstimate : undefined, + this.globalConfig.priorityFeeMultiplier + ) + ); + } + + logMessageForNodeToFill( + nodeToFill, + takerUserPubKey, + takerUserSlot, + makerInfos, + this.slotSubscriber.getSlot(), + fillTxId, + 'multiMakerFill', + this.revertOnFailure ?? false, + removeLastIxPostSim ?? false + ); + + if (!isVariant(marketType, 'perp')) { + throw new Error('expected perp market type'); + } + ixs.push( await this.driftClient.getFillPerpOrderIx( await getUserAccountPublicKey( diff --git a/src/experimental-bots/spotFiller/spotFillerMultithreaded.ts b/src/experimental-bots/spotFiller/spotFillerMultithreaded.ts index db87e563..54ea7dd0 100644 --- a/src/experimental-bots/spotFiller/spotFillerMultithreaded.ts +++ b/src/experimental-bots/spotFiller/spotFillerMultithreaded.ts @@ -948,25 +948,6 @@ export class SpotFillerMultithreaded { )!.decimals ) ); - const ixs: Array = [ - ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, - }), - ]; - if (buildForBundle) { - ixs.push(this.bundleSender!.getTipIx()); - } else { - ixs.push( - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: Math.floor( - this.priorityFeeSubscriber.getPriorityFees( - 'spot', - nodeToFill.node.order!.marketIndex - )!.high - ), - }) - ); - } try { const { @@ -1002,6 +983,27 @@ export class SpotFillerMultithreaded { if (makers.length === 0) { return undefined; } + + const ixs: Array = [ + ComputeBudgetProgram.setComputeUnitLimit({ + units: 1_400_000, + }), + ]; + if (buildForBundle) { + ixs.push(this.bundleSender!.getTipIx()); + } else { + ixs.push( + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: Math.floor( + this.priorityFeeSubscriber.getPriorityFees( + 'spot', + nodeToFill.node.order!.marketIndex + )!.high + ), + }) + ); + } + ixs.push( await this.driftClient.getFillSpotOrderIx( new PublicKey(takerUserPubKey),