Skip to content

Commit 4c2de20

Browse files
authored
Merge pull request #367 from drift-labs/master
change swift url based on driftenv
2 parents df254ee + 0a8a8d2 commit 4c2de20

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/experimental-bots/swift/makerExample.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,20 @@ import { simulateAndGetTxWithCUs } from '../../utils';
2020
export class SwiftMaker {
2121
interval: NodeJS.Timeout | null = null;
2222
private ws: WebSocket | null = null;
23+
private swiftUrl: string;
2324
private heartbeatTimeout: NodeJS.Timeout | null = null;
2425
private readonly heartbeatIntervalMs = 80_000;
2526
constructor(
2627
private driftClient: DriftClient,
2728
private userMap: UserMap,
2829
runtimeSpec: RuntimeSpec,
2930
private dryRun?: boolean
30-
) {}
31+
) {
32+
this.swiftUrl =
33+
runtimeSpec.driftEnv === 'mainnet-beta'
34+
? 'wss://swift.drift.trade/ws'
35+
: 'wss://master.swift.drift.trade/ws';
36+
}
3137

3238
async init() {
3339
await this.subscribeWs();
@@ -36,7 +42,7 @@ export class SwiftMaker {
3642
async subscribeWs() {
3743
const keypair = this.driftClient.wallet.payer!;
3844
const ws = new WebSocket(
39-
`wss://master.swift.drift.trade/ws?pubkey=` + keypair.publicKey.toBase58()
45+
this.swiftUrl + '?pubkey=' + keypair.publicKey.toBase58()
4046
);
4147

4248
ws.on('open', async () => {

src/experimental-bots/swift/takerExample.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ const CONFIRM_TIMEOUT = 30_000;
1616

1717
export class SwiftTaker {
1818
interval: NodeJS.Timeout | null = null;
19+
swiftUrl: string;
1920

2021
constructor(
2122
private driftClient: DriftClient,
2223
runtimeSpec: RuntimeSpec,
2324
private intervalMs: number
24-
) {}
25+
) {
26+
this.swiftUrl =
27+
runtimeSpec.driftEnv === 'mainnet-beta'
28+
? 'https://swift.drift.trade/orders'
29+
: 'https://master.swift.drift.trade/orders';
30+
}
2531

2632
async init() {
2733
await this.startInterval();
@@ -76,8 +82,7 @@ export class SwiftTaker {
7682
);
7783

7884
const response = await axios.default.post(
79-
// 'http://0.0.0.0:3000/orders',
80-
'https://master.swift.drift.trade/orders',
85+
this.swiftUrl,
8186
{
8287
market_index: marketIndex,
8388
market_type: 'perp',

0 commit comments

Comments
 (0)