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 #319

Merged
merged 11 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ jobs:
kubectl get deployments -n $BRANCH_NAME -o name | grep filler | xargs -I {} kubectl rollout restart {} -n $BRANCH_NAME
kubectl rollout restart -n $BRANCH_NAME deployment/liquidator-bot
kubectl rollout restart -n $BRANCH_NAME deployment/pyth-cranker-bot
kubectl rollout restart -n $BRANCH_NAME deployment/switchboard-cranker-bot
kubectl rollout restart -n $BRANCH_NAME deployment/switchboard-cranker-bot
kubectl rollout restart -n $BRANCH_NAME deployment/swift-taker-example-bot
kubectl rollout restart -n $BRANCH_NAME deployment/swift-maker-example-bot
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.7",
"@drift-labs/sdk": "2.104.0-beta.12",
"@drift-labs/jit-proxy": "0.12.15",
"@drift-labs/sdk": "2.104.0-beta.28",
"@opentelemetry/api": "1.7.0",
"@opentelemetry/auto-instrumentations-node": "0.31.2",
"@opentelemetry/exporter-prometheus": "0.31.0",
Expand Down
65 changes: 35 additions & 30 deletions src/bots/filler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import {
validRebalanceSettledPnlThreshold,
} from '../utils';
import { selectMakers } from '../makerSelection';
import { BundleSender } from '../bundleSender';
import { BundleSender, JITO_METRIC_TYPES } from '../bundleSender';
import { Metrics } from '../metrics';
import { LRUCache } from 'lru-cache';
import { bs58 } from '@project-serum/anchor/dist/cjs/utils/bytes';
Expand Down Expand Up @@ -147,11 +147,6 @@ enum METRIC_TYPES {
simulate_tx_duration_histogram = 'simulate_tx_duration_histogram',
expired_nodes_set_size = 'expired_nodes_set_size',

jito_bundles_accepted = 'jito_bundles_accepted',
jito_bundles_simulation_failure = 'jito_simulation_failure',
jito_dropped_bundle = 'jito_dropped_bundle',
jito_landed_tips = 'jito_landed_tips',
jito_bundle_count = 'jito_bundle_count',
clock_subscriber_ts = 'clock_subscriber_ts',
wall_clock_ts = 'wall_clock_ts',
}
Expand Down Expand Up @@ -225,6 +220,7 @@ export class FillerBot extends TxThreaded implements Bot {
protected mutexBusyCounter?: CounterValue;
protected attemptedTriggersCounter?: CounterValue;
protected txSimErrorCounter?: CounterValue;
protected jitoConnectedGauge?: GaugeValue;
protected jitoBundlesAcceptedGauge?: GaugeValue;
protected jitoBundlesSimulationFailureGauge?: GaugeValue;
protected jitoDroppedBundleGauge?: GaugeValue;
Expand Down Expand Up @@ -450,24 +446,28 @@ export class FillerBot extends TxThreaded implements Bot {
METRIC_TYPES.tx_sim_error_count,
'Count of errors from simulating transactions'
);
this.jitoConnectedGauge = this.metrics.addGauge(
JITO_METRIC_TYPES.jito_connected,
'Whether the jito bundle sender is connected'
);
this.jitoBundlesAcceptedGauge = this.metrics.addGauge(
METRIC_TYPES.jito_bundles_accepted,
JITO_METRIC_TYPES.jito_bundles_accepted,
'Count of jito bundles that were accepted'
);
this.jitoBundlesSimulationFailureGauge = this.metrics.addGauge(
METRIC_TYPES.jito_bundles_simulation_failure,
JITO_METRIC_TYPES.jito_bundles_simulation_failure,
'Count of jito bundles that failed simulation'
);
this.jitoDroppedBundleGauge = this.metrics.addGauge(
METRIC_TYPES.jito_dropped_bundle,
JITO_METRIC_TYPES.jito_dropped_bundle,
'Count of jito bundles that were dropped'
);
this.jitoLandedTipsGauge = this.metrics.addGauge(
METRIC_TYPES.jito_landed_tips,
JITO_METRIC_TYPES.jito_landed_tips,
'Gauge of historic bundle tips that landed'
);
this.jitoBundleCount = this.metrics.addGauge(
METRIC_TYPES.jito_bundle_count,
JITO_METRIC_TYPES.jito_bundle_count,
'Count of jito bundles that were sent, and their status'
);
this.clockSubscriberTs = this.metrics.addGauge(
Expand Down Expand Up @@ -1453,15 +1453,16 @@ export class FillerBot extends TxThreaded implements Bot {
marketType,
} = await this.getNodeFillInfo(nodeToFill);

logger.info(
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
`Filling multi maker perp node with ${nodeToFill.makerNodes.length} makers (fillTxId: ${fillTxId})`
)
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
fillTxId,
'multiMakerPerpFill',
this.revertOnFailure ?? false,
false
);

if (!isVariant(marketType, 'perp')) {
Expand Down Expand Up @@ -1645,7 +1646,7 @@ export class FillerBot extends TxThreaded implements Bot {
const nodesSent: Array<NodeToFill> = [];
const fillTxId = this.fillTxId++;

for (const [idx, nodeToFill] of nodesToFill.entries()) {
for (const [_idx, nodeToFill] of nodesToFill.entries()) {
let ixs: Array<TransactionInstruction> = [
ComputeBudgetProgram.setComputeUnitLimit({
units: 1_400_000,
Expand Down Expand Up @@ -1681,15 +1682,16 @@ export class FillerBot extends TxThreaded implements Bot {
marketType,
} = await this.getNodeFillInfo(nodeToFill);

logger.info(
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
`Filling perp node ${idx} (fillTxId: ${fillTxId})`
)
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
fillTxId,
'fillPerpNode',
this.revertOnFailure ?? false,
false
);
this.logSlots();

Expand Down Expand Up @@ -2260,6 +2262,9 @@ export class FillerBot extends TxThreaded implements Bot {
}
return slotsUntilJito < SLOTS_UNTIL_JITO_LEADER_TO_SEND;
}
if (!this.bundleSender?.connected()) {
return false;
}
return true;
}

Expand Down
69 changes: 36 additions & 33 deletions src/bots/spotFiller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import {
validMinimumGasAmount,
validRebalanceSettledPnlThreshold,
} from '../utils';
import { BundleSender } from '../bundleSender';
import { JITO_METRIC_TYPES, BundleSender } from '../bundleSender';
import {
CACHED_BLOCKHASH_OFFSET,
CONFIRM_TX_INTERVAL_MS,
Expand Down Expand Up @@ -139,11 +139,6 @@ enum METRIC_TYPES {
simulate_tx_duration_histogram = 'simulate_tx_duration_histogram',
expired_nodes_set_size = 'expired_nodes_set_size',

jito_bundles_accepted = 'jito_bundles_accepted',
jito_bundles_simulation_failure = 'jito_simulation_failure',
jito_dropped_bundle = 'jito_dropped_bundle',
jito_landed_tips = 'jito_landed_tips',
jito_bundle_count = 'jito_bundle_count',
clock_subscriber_ts = 'clock_subscriber_ts',
wall_clock_ts = 'wall_clock_ts',
}
Expand Down Expand Up @@ -309,6 +304,7 @@ export class SpotFillerBot implements Bot {
protected pendingTxSigsLoopRateLimitedCounter?: CounterValue;
protected evictedPendingTxSigsToConfirmCounter?: CounterValue;
protected expiredNodesSetSize?: GaugeValue;
protected jitoConnectedGauge?: GaugeValue;
protected jitoBundlesAcceptedGauge?: GaugeValue;
protected jitoBundlesSimulationFailureGauge?: GaugeValue;
protected jitoDroppedBundleGauge?: GaugeValue;
Expand Down Expand Up @@ -583,24 +579,28 @@ export class SpotFillerBot implements Bot {
METRIC_TYPES.expired_nodes_set_size,
'Count of nodes that are expired'
);
this.jitoConnectedGauge = this.metrics.addGauge(
JITO_METRIC_TYPES.jito_connected,
'Whether the jito bundle sender is connected'
);
this.jitoBundlesAcceptedGauge = this.metrics.addGauge(
METRIC_TYPES.jito_bundles_accepted,
JITO_METRIC_TYPES.jito_bundles_accepted,
'Count of jito bundles that were accepted'
);
this.jitoBundlesSimulationFailureGauge = this.metrics.addGauge(
METRIC_TYPES.jito_bundles_simulation_failure,
JITO_METRIC_TYPES.jito_bundles_simulation_failure,
'Count of jito bundles that failed simulation'
);
this.jitoDroppedBundleGauge = this.metrics.addGauge(
METRIC_TYPES.jito_dropped_bundle,
JITO_METRIC_TYPES.jito_dropped_bundle,
'Count of jito bundles that were dropped'
);
this.jitoLandedTipsGauge = this.metrics.addGauge(
METRIC_TYPES.jito_landed_tips,
JITO_METRIC_TYPES.jito_landed_tips,
'Gauge of historic bundle tips that landed'
);
this.jitoBundleCount = this.metrics.addGauge(
METRIC_TYPES.jito_bundle_count,
JITO_METRIC_TYPES.jito_bundle_count,
'Count of jito bundles that were sent, and their status'
);
this.clockSubscriberTs = this.metrics.addGauge(
Expand Down Expand Up @@ -1571,6 +1571,9 @@ export class SpotFillerBot implements Bot {
}
return slotsUntilJito < SLOTS_UNTIL_JITO_LEADER_TO_SEND;
}
if (!this.bundleSender?.connected()) {
return false;
}
return true;
}

Expand Down Expand Up @@ -1764,17 +1767,17 @@ export class SpotFillerBot implements Bot {
marketType,
} = await this.getNodeFillInfo(nodeToFill);

logger.info(
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
`Filling multi maker spot node with ${nodeToFill.makerNodes.length} makers (fillTxId: ${fillTxId})`,
spotPrecision,
'SHOULD_NOT_HAVE_NO_MAKERS'
)
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
fillTxId,
'multiMakerSpotFill',
this.revertOnFailure ?? false,
false,
spotPrecision
);

if (!isVariant(marketType, 'spot')) {
Expand Down Expand Up @@ -2015,17 +2018,17 @@ export class SpotFillerBot implements Bot {
}
}

logger.info(
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
`Filling spot node with ${nodeToFill.makerNodes.length} makers (fillTxId: ${fillTxId})`,
spotMarketPrecision,
fallbackSource as string
)
logMessageForNodeToFill(
nodeToFill,
takerUserPubKey,
takerUserSlot,
makerInfos,
this.getMaxSlot(),
fillTxId,
'fillSpotNode',
this.revertOnFailure ?? false,
false,
spotMarketPrecision
);

const ixs = [
Expand Down
15 changes: 13 additions & 2 deletions src/bots/switchboardCranker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ export class SwitchboardCrankerBot implements Bot {
return recentBlockhash.blockhash;
}

private shouldBuildForBundle(): boolean {
if (!this.globalConfig.useJito) {
return false;
}
if (!this.bundleSender?.connected()) {
return false;
}
return true;
}

async runCrankLoop() {
const pullFeedAliases = chunks(
shuffle(Object.keys(this.crankConfigs.pullFeedConfigs)),
Expand All @@ -119,7 +129,8 @@ export class SwitchboardCrankerBot implements Bot {
}),
];

if (this.globalConfig.useJito) {
const shouldBuildForBundle = this.shouldBuildForBundle();
if (shouldBuildForBundle) {
ixs.push(this.bundleSender!.getTipIx());
} else {
const priorityFees =
Expand All @@ -143,7 +154,7 @@ export class SwitchboardCrankerBot implements Bot {
await this.getBlockhashForTx()
);

if (this.globalConfig.useJito) {
if (shouldBuildForBundle) {
tx.sign([
// @ts-ignore;
this.driftClient.wallet.payer,
Expand Down
Loading