Skip to content

Commit

Permalink
master -> mainnet (#324)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: wphan <[email protected]>
  • Loading branch information
4 people authored Dec 19, 2024
1 parent 9832991 commit 0d354ff
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 115 deletions.
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

0 comments on commit 0d354ff

Please sign in to comment.