Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master -> mainnet #324

Merged
merged 9 commits into from
Dec 19, 2024
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 17 additions & 16 deletions src/bots/filler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1427,22 +1427,6 @@ export class FillerBot extends TxThreaded implements Bot {
nodeToFill: NodeToFill,
buildForBundle: boolean
): Promise<boolean> {
const ixs: Array<TransactionInstruction> = [
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,
Expand Down Expand Up @@ -1477,6 +1461,23 @@ export class FillerBot extends TxThreaded implements Bot {
ixs: Array<TransactionInstruction>;
simResult: SimulateAndGetTxWithCUsResponse;
}> => {
const ixs: Array<TransactionInstruction> = [
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(
Expand Down
34 changes: 17 additions & 17 deletions src/bots/spotFiller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1741,23 +1741,6 @@ export class SpotFillerBot implements Bot {
buildForBundle: boolean,
spotPrecision: BN
): Promise<boolean> {
const ixs: Array<TransactionInstruction> = [
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,
Expand Down Expand Up @@ -1788,6 +1771,23 @@ export class SpotFillerBot implements Bot {
const buildTxWithMakerInfos = async (
makers: DataAndSlot<MakerInfo>[]
): Promise<SimulateAndGetTxWithCUsResponse> => {
const ixs: Array<TransactionInstruction> = [
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),
Expand Down
107 changes: 55 additions & 52 deletions src/experimental-bots/filler/fillerMultithreaded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1546,12 +1546,6 @@ export class FillerMultithreaded {
fillTxId: number,
nodeToFill: NodeToFillWithBuffer
): Promise<boolean> {
let ixs: Array<TransactionInstruction> = [
ComputeBudgetProgram.setComputeUnitLimit({
units: 1_400_000,
}),
];

try {
const {
makerInfos,
Expand All @@ -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<MakerInfo>[]
): Promise<SimulateAndGetTxWithCUsResponse | undefined> => {
if (makers.length === 0) {
return undefined;
}

let ixs: Array<TransactionInstruction> = [
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(
Expand Down
40 changes: 21 additions & 19 deletions src/experimental-bots/spotFiller/spotFillerMultithreaded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,25 +948,6 @@ export class SpotFillerMultithreaded {
)!.decimals
)
);
const ixs: Array<TransactionInstruction> = [
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 {
Expand Down Expand Up @@ -1002,6 +983,27 @@ export class SpotFillerMultithreaded {
if (makers.length === 0) {
return undefined;
}

const ixs: Array<TransactionInstruction> = [
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),
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,19 @@
enabled "2.0.x"
kuler "^2.0.0"

"@drift-labs/[email protected].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/[email protected].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/[email protected].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/[email protected].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/[email protected]"
Expand Down