From 0d354ffc7d5dc140cd4e7641c0e277bf88936eeb Mon Sep 17 00:00:00 2001 From: lowkeynicc <85139158+lowkeynicc@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:27:21 -0500 Subject: [PATCH] master -> mainnet (#324) * Bumping sdk and jit dependencies to 2.104.0-beta.31 and 0.12.18 * Bumping sdk and jit dependencies to 2.104.0-beta.32 and 0.12.19 * Nour/pyth lazer cranker (#321) * add pyth lazer cranker * rm unncessary libraries * remove unnecessary code * add entrypoint for the cranker * added improvements * increase the chunk size * Bumping sdk and jit dependencies to 2.104.0-beta.33 and 0.12.20 * Bumping sdk and jit dependencies to 2.104.0-beta.34 and 0.12.21 * liquidator: use SOL routes when swapping LSTs (#322) * Bumping sdk and jit dependencies to 2.104.0-beta.35 and 0.12.22 * fillers: fix multimaker retry logic (#325) * fillers: fix multimaker retry logic * add missing tip ix --------- Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: moosecat Co-authored-by: wphan --- package.json | 4 +- src/bots/filler.ts | 33 +++--- src/bots/spotFiller.ts | 34 +++--- .../filler/fillerMultithreaded.ts | 107 +++++++++--------- .../spotFiller/spotFillerMultithreaded.ts | 40 +++---- yarn.lock | 18 +-- 6 files changed, 121 insertions(+), 115 deletions(-) diff --git a/package.json b/package.json index eb108a09..37148eb5 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "main": "lib/index.js", "license": "Apache-2.0", "dependencies": { - "@drift-labs/jit-proxy": "0.12.21", - "@drift-labs/sdk": "2.104.0-beta.34", + "@drift-labs/jit-proxy": "0.12.22", + "@drift-labs/sdk": "2.104.0-beta.35", "@opentelemetry/api": "1.7.0", "@opentelemetry/auto-instrumentations-node": "0.31.2", "@opentelemetry/exporter-prometheus": "0.31.0", 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), diff --git a/yarn.lock b/yarn.lock index 1b8936de..1d5f97c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -168,19 +168,19 @@ enabled "2.0.x" kuler "^2.0.0" -"@drift-labs/jit-proxy@0.12.21": - version "0.12.21" - resolved "https://registry.yarnpkg.com/@drift-labs/jit-proxy/-/jit-proxy-0.12.21.tgz#7f4303b78966b7ef23d53cdd58ce252086b5a8ee" - integrity sha512-RQ5wvvzesYAgVXW+KhRGZNlEgQYF1TUoZAiUtT6vskuKronXMRI8HPzE9f8YeOAx2CsIWDBUhXqaduUMuy7EwQ== +"@drift-labs/jit-proxy@0.12.22": + version "0.12.22" + resolved "https://registry.yarnpkg.com/@drift-labs/jit-proxy/-/jit-proxy-0.12.22.tgz#76682541b6af0642153c16309f63badd53228982" + integrity sha512-y0qcfBN0ENde7OsaRCNSOtCGY7A6JYOuBY/C/s3zyJcjNzibhPR8GtrvU27zViu1vrusV3BUHRZnItGf88Jndw== dependencies: "@coral-xyz/anchor" "0.26.0" - "@drift-labs/sdk" "2.104.0-beta.34" + "@drift-labs/sdk" "2.104.0-beta.35" "@solana/web3.js" "1.91.7" -"@drift-labs/sdk@2.104.0-beta.34": - version "2.104.0-beta.34" - resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.104.0-beta.34.tgz#665ade52bc9af6333110246d597948e613e75fa3" - integrity sha512-ObXjbuAEP+hYzUVkvccMPCZbC00EwV6lEWPEb3fyHPqQUjjxklwTdZqpOJYyBBq/bKD/FYtoqw6PS4qgZ+m0wQ== +"@drift-labs/sdk@2.104.0-beta.35": + version "2.104.0-beta.35" + resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.104.0-beta.35.tgz#4dacbea1fa58ec86731859064cb88ac1e953ee8c" + integrity sha512-2KpU9fKtjTFjMPIKnL1CRbSggePl3sVxN2eY5m3yd8v3oc1v1SCW31bCj8M6ESur1kf9E6N0mABuFE3uzsv6KA== dependencies: "@coral-xyz/anchor" "0.29.0" "@coral-xyz/anchor-30" "npm:@coral-xyz/anchor@0.30.1"