In https://github.com/eth-infinitism/bundler/blob/master/packages/bundler/src/modules/BundleManager.ts#L206, createBundle() calls this.mempoolManager.getSortedForInclusion() to obtain sorted UserOperations from mempool.
However, getSortedForInclusion() performs copy.sort((a, b) => cost(a.userOp) - cost(b.userOp)), which sorts the operations so that those with lower maxPriorityFeePerGas values come first.
getSortedForInclusion (): MempoolEntry[] {
const copy = Array.from(this.mempool)
function cost (op: OperationBase): number {
// TODO: need to consult basefee and maxFeePerGas
return BigNumber.from(op.maxPriorityFeePerGas).toNumber()
}
copy.sort((a, b) => cost(a.userOp) - cost(b.userOp))
return copy
}
To maximize profits for the Bundler, it should process gas prices in descending order. Therefore, it should be changed to copy.sort((a, b) => cost(b.userOp) - cost(a.userOp)).
In https://github.com/eth-infinitism/bundler/blob/master/packages/bundler/src/modules/BundleManager.ts#L206,
createBundle()callsthis.mempoolManager.getSortedForInclusion()to obtain sorted UserOperations from mempool.However,
getSortedForInclusion()performscopy.sort((a, b) => cost(a.userOp) - cost(b.userOp)), which sorts the operations so that those with lowermaxPriorityFeePerGasvalues come first.To maximize profits for the Bundler, it should process gas prices in descending order. Therefore, it should be changed to
copy.sort((a, b) => cost(b.userOp) - cost(a.userOp)).