@velocity-exchange/sdk 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/bunfig.toml +3 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +4 -2
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +9 -4
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/browser/auctionSubscriber/types.d.ts +4 -2
- package/lib/browser/config.d.ts +3 -8
- package/lib/browser/config.js +14 -22
- package/lib/browser/constituentMap/constituentMap.d.ts +4 -2
- package/lib/browser/constituentMap/constituentMap.js +14 -10
- package/lib/browser/core/VelocityCore.d.ts +4 -0
- package/lib/browser/core/VelocityCore.js +3 -1
- package/lib/browser/dlob/DLOBSubscriber.d.ts +3 -1
- package/lib/browser/dlob/DLOBSubscriber.js +19 -10
- package/lib/browser/dlob/types.d.ts +3 -1
- package/lib/browser/idl/drift.d.ts +54 -1
- package/lib/browser/idl/drift.json +6046 -803
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +3 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +19 -11
- package/lib/browser/orderSubscriber/types.d.ts +3 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +4 -2
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +15 -11
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +18 -18
- package/lib/browser/priorityFee/types.d.ts +9 -5
- package/lib/browser/priorityFee/types.js +1 -1
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +10 -5
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +7 -4
- package/lib/browser/swift/swiftOrderSubscriber.js +19 -11
- package/lib/browser/user.d.ts +3 -1
- package/lib/browser/user.js +93 -86
- package/lib/browser/userConfig.d.ts +4 -2
- package/lib/browser/userMap/referrerMap.d.ts +5 -3
- package/lib/browser/userMap/referrerMap.js +18 -14
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +5 -3
- package/lib/browser/userMap/revenueShareEscrowMap.js +18 -14
- package/lib/browser/userMap/userMap.d.ts +3 -1
- package/lib/browser/userMap/userMap.js +24 -19
- package/lib/browser/userMap/userMapConfig.d.ts +4 -2
- package/lib/browser/userMap/userStatsMap.d.ts +5 -3
- package/lib/browser/userMap/userStatsMap.js +15 -11
- package/lib/browser/userStats.d.ts +3 -1
- package/lib/browser/userStats.js +21 -15
- package/lib/browser/userStatsConfig.d.ts +4 -2
- package/lib/browser/util/deprecatedAlias.d.ts +26 -0
- package/lib/browser/util/deprecatedAlias.js +10 -0
- package/lib/browser/velocityClient.js +5 -5
- package/lib/browser/velocityClientConfig.d.ts +7 -4
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +4 -2
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +9 -4
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/node/auctionSubscriber/types.d.ts +4 -2
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/config.d.ts +3 -8
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +14 -22
- package/lib/node/constituentMap/constituentMap.d.ts +4 -2
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +14 -10
- package/lib/node/core/VelocityCore.d.ts +4 -0
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +3 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts +3 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +19 -10
- package/lib/node/dlob/types.d.ts +3 -1
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/idl/drift.d.ts +54 -1
- package/lib/node/idl/drift.d.ts.map +1 -1
- package/lib/node/idl/drift.json +6046 -803
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +3 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +19 -11
- package/lib/node/orderSubscriber/types.d.ts +3 -1
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +4 -2
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +15 -11
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +18 -18
- package/lib/node/priorityFee/types.d.ts +9 -5
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/types.js +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +10 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts +7 -4
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +19 -11
- package/lib/node/user.d.ts +3 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +93 -86
- package/lib/node/userConfig.d.ts +4 -2
- package/lib/node/userConfig.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.d.ts +5 -3
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +18 -14
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +5 -3
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +18 -14
- package/lib/node/userMap/userMap.d.ts +3 -1
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +24 -19
- package/lib/node/userMap/userMapConfig.d.ts +4 -2
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +5 -3
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +15 -11
- package/lib/node/userStats.d.ts +3 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +21 -15
- package/lib/node/userStatsConfig.d.ts +4 -2
- package/lib/node/userStatsConfig.d.ts.map +1 -1
- package/lib/node/util/deprecatedAlias.d.ts +27 -0
- package/lib/node/util/deprecatedAlias.d.ts.map +1 -0
- package/lib/node/util/deprecatedAlias.js +10 -0
- package/lib/node/velocityClient.js +5 -5
- package/lib/node/velocityClientConfig.d.ts +7 -4
- package/lib/node/velocityClientConfig.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/auctionSubscriber/auctionSubscriber.ts +12 -6
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -6
- package/src/auctionSubscriber/types.ts +5 -2
- package/src/config.ts +35 -27
- package/src/constituentMap/constituentMap.ts +17 -9
- package/src/core/VelocityCore.ts +6 -0
- package/src/dlob/DLOBSubscriber.ts +21 -11
- package/src/dlob/types.ts +3 -1
- package/src/idl/drift.json +23940 -18697
- package/src/idl/drift.ts +54 -1
- package/src/orderSubscriber/OrderSubscriber.ts +17 -7
- package/src/orderSubscriber/types.ts +3 -1
- package/src/priorityFee/priorityFeeSubscriber.ts +13 -9
- package/src/priorityFee/priorityFeeSubscriberMap.ts +23 -25
- package/src/priorityFee/types.ts +14 -9
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +10 -23
- package/src/swift/signedMsgUserAccountSubscriber.ts +22 -14
- package/src/swift/swiftOrderSubscriber.ts +24 -16
- package/src/user.ts +93 -82
- package/src/userConfig.ts +5 -2
- package/src/userMap/referrerMap.ts +19 -15
- package/src/userMap/revenueShareEscrowMap.ts +20 -16
- package/src/userMap/userMap.ts +20 -15
- package/src/userMap/userMapConfig.ts +6 -3
- package/src/userMap/userStatsMap.ts +19 -15
- package/src/userStats.ts +13 -7
- package/src/userStatsConfig.ts +5 -2
- package/src/util/deprecatedAlias.ts +25 -0
- package/src/velocityClient.ts +6 -6
- package/src/velocityClientConfig.ts +25 -42
|
@@ -13,7 +13,9 @@ import StrictEventEmitter from 'strict-event-emitter-types';
|
|
|
13
13
|
import { EventEmitter } from 'events';
|
|
14
14
|
import { grpcSubscription } from './grpcSubscription';
|
|
15
15
|
export declare class OrderSubscriber {
|
|
16
|
-
|
|
16
|
+
velocityClient: VelocityClient;
|
|
17
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
18
|
+
get driftClient(): VelocityClient;
|
|
17
19
|
usersAccounts: Map<string, {
|
|
18
20
|
slot: number;
|
|
19
21
|
userAccount: UserAccount;
|
|
@@ -14,10 +14,18 @@ const grpcSubscription_1 = require("./grpcSubscription");
|
|
|
14
14
|
const orders_1 = require("../math/orders");
|
|
15
15
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
16
16
|
class OrderSubscriber {
|
|
17
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
18
|
+
get driftClient() {
|
|
19
|
+
return this.velocityClient;
|
|
20
|
+
}
|
|
17
21
|
constructor(config) {
|
|
18
|
-
var _a, _b, _c, _d, _e;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
23
|
this.usersAccounts = new Map();
|
|
20
|
-
|
|
24
|
+
const velocityClient = (_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient;
|
|
25
|
+
if (!velocityClient) {
|
|
26
|
+
throw new Error('OrderSubscriber: velocityClient (or deprecated driftClient) must be provided');
|
|
27
|
+
}
|
|
28
|
+
this.velocityClient = velocityClient;
|
|
21
29
|
this.commitment = config.subscriptionConfig.commitment || 'processed';
|
|
22
30
|
if (config.subscriptionConfig.type === 'polling') {
|
|
23
31
|
this.subscription = new PollingSubscription_1.PollingSubscription({
|
|
@@ -31,8 +39,8 @@ class OrderSubscriber {
|
|
|
31
39
|
grpcConfigs: config.subscriptionConfig.grpcConfigs,
|
|
32
40
|
skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
|
|
33
41
|
resubOpts: {
|
|
34
|
-
resubTimeoutMs: (
|
|
35
|
-
logResubMessages: (
|
|
42
|
+
resubTimeoutMs: (_b = config.subscriptionConfig) === null || _b === void 0 ? void 0 : _b.resubTimeoutMs,
|
|
43
|
+
logResubMessages: (_c = config.subscriptionConfig) === null || _c === void 0 ? void 0 : _c.logResubMessages,
|
|
36
44
|
},
|
|
37
45
|
resyncIntervalMs: config.subscriptionConfig.resyncIntervalMs,
|
|
38
46
|
decoded: config.decodeData,
|
|
@@ -44,18 +52,18 @@ class OrderSubscriber {
|
|
|
44
52
|
commitment: this.commitment,
|
|
45
53
|
skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
|
|
46
54
|
resubOpts: {
|
|
47
|
-
resubTimeoutMs: (
|
|
48
|
-
logResubMessages: (
|
|
55
|
+
resubTimeoutMs: (_d = config.subscriptionConfig) === null || _d === void 0 ? void 0 : _d.resubTimeoutMs,
|
|
56
|
+
logResubMessages: (_e = config.subscriptionConfig) === null || _e === void 0 ? void 0 : _e.logResubMessages,
|
|
49
57
|
},
|
|
50
58
|
resyncIntervalMs: config.subscriptionConfig.resyncIntervalMs,
|
|
51
59
|
decoded: config.decodeData,
|
|
52
60
|
});
|
|
53
61
|
}
|
|
54
|
-
if ((
|
|
62
|
+
if ((_f = config.fastDecode) !== null && _f !== void 0 ? _f : true) {
|
|
55
63
|
this.decodeFn = (name, data) => (0, user_1.decodeUser)(data);
|
|
56
64
|
}
|
|
57
65
|
else {
|
|
58
|
-
this.decodeFn = this.
|
|
66
|
+
this.decodeFn = this.velocityClient.program.account.user.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.user.coder.accounts);
|
|
59
67
|
}
|
|
60
68
|
this.eventEmitter = new events_1.EventEmitter();
|
|
61
69
|
this.fetchAllNonIdleUsers = config.fetchAllNonIdleUsers;
|
|
@@ -75,7 +83,7 @@ class OrderSubscriber {
|
|
|
75
83
|
: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getUserWithOrderFilter)()];
|
|
76
84
|
try {
|
|
77
85
|
const rpcRequestArgs = [
|
|
78
|
-
this.
|
|
86
|
+
this.velocityClient.program.programId.toBase58(),
|
|
79
87
|
{
|
|
80
88
|
commitment: this.commitment,
|
|
81
89
|
filters,
|
|
@@ -85,7 +93,7 @@ class OrderSubscriber {
|
|
|
85
93
|
];
|
|
86
94
|
const rpcJSONResponse =
|
|
87
95
|
// @ts-ignore
|
|
88
|
-
await this.
|
|
96
|
+
await this.velocityClient.connection._rpcRequest('getProgramAccounts', rpcRequestArgs);
|
|
89
97
|
const rpcResponseAndContext = rpcJSONResponse.result;
|
|
90
98
|
const slot = rpcResponseAndContext.context.slot;
|
|
91
99
|
for (const programAccount of rpcResponseAndContext.value) {
|
|
@@ -174,7 +182,7 @@ class OrderSubscriber {
|
|
|
174
182
|
return (_a = this.mostRecentSlot) !== null && _a !== void 0 ? _a : 0;
|
|
175
183
|
}
|
|
176
184
|
async addPubkey(userAccountPublicKey) {
|
|
177
|
-
const accountInfo = await this.
|
|
185
|
+
const accountInfo = await this.velocityClient.connection.getAccountInfoAndContext(userAccountPublicKey, this.commitment);
|
|
178
186
|
if (accountInfo) {
|
|
179
187
|
this.tryUpdateUserAccount(userAccountPublicKey.toString(), 'buffer', accountInfo.value.data, accountInfo.context.slot);
|
|
180
188
|
}
|
|
@@ -3,7 +3,9 @@ import { Order, UserAccount } from '../types';
|
|
|
3
3
|
import { VelocityClient } from '../velocityClient';
|
|
4
4
|
import { GrpcConfigs } from '../accounts/types';
|
|
5
5
|
export type OrderSubscriberConfig = {
|
|
6
|
-
|
|
6
|
+
velocityClient?: VelocityClient;
|
|
7
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
8
|
+
driftClient?: VelocityClient;
|
|
7
9
|
subscriptionConfig: {
|
|
8
10
|
type: 'polling';
|
|
9
11
|
frequency: number;
|
|
@@ -8,7 +8,9 @@ export declare class PriorityFeeSubscriber {
|
|
|
8
8
|
connection: Connection;
|
|
9
9
|
frequencyMs: number;
|
|
10
10
|
addresses: string[];
|
|
11
|
-
|
|
11
|
+
velocityMarkets?: VelocityMarketInfo[];
|
|
12
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
13
|
+
get driftMarkets(): VelocityMarketInfo[] | undefined;
|
|
12
14
|
customStrategy?: PriorityFeeStrategy;
|
|
13
15
|
averageStrategy: AverageOverSlotsStrategy;
|
|
14
16
|
maxStrategy: MaxOverSlotsStrategy;
|
|
@@ -44,5 +46,5 @@ export declare class PriorityFeeSubscriber {
|
|
|
44
46
|
load(): Promise<void>;
|
|
45
47
|
unsubscribe(): Promise<void>;
|
|
46
48
|
updateAddresses(addresses: PublicKey[]): void;
|
|
47
|
-
updateMarketTypeAndIndex(
|
|
49
|
+
updateMarketTypeAndIndex(velocityMarkets: VelocityMarketInfo[]): void;
|
|
48
50
|
}
|
|
@@ -8,12 +8,16 @@ const solanaPriorityFeeMethod_1 = require("./solanaPriorityFeeMethod");
|
|
|
8
8
|
const heliusPriorityFeeMethod_1 = require("./heliusPriorityFeeMethod");
|
|
9
9
|
const velocityPriorityFeeMethod_1 = require("./velocityPriorityFeeMethod");
|
|
10
10
|
class PriorityFeeSubscriber {
|
|
11
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
12
|
+
get driftMarkets() {
|
|
13
|
+
return this.velocityMarkets;
|
|
14
|
+
}
|
|
11
15
|
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
12
16
|
get driftPriorityFeeEndpoint() {
|
|
13
17
|
return this.velocityPriorityFeeEndpoint;
|
|
14
18
|
}
|
|
15
19
|
constructor(config) {
|
|
16
|
-
var _a, _b, _c, _d;
|
|
20
|
+
var _a, _b, _c, _d, _e;
|
|
17
21
|
this.averageStrategy = new averageOverSlotsStrategy_1.AverageOverSlotsStrategy();
|
|
18
22
|
this.maxStrategy = new maxOverSlotsStrategy_1.MaxOverSlotsStrategy();
|
|
19
23
|
this.priorityFeeMethod = types_1.PriorityFeeMethod.SOLANA;
|
|
@@ -28,14 +32,14 @@ class PriorityFeeSubscriber {
|
|
|
28
32
|
this.addresses = config.addresses
|
|
29
33
|
? config.addresses.map((address) => address.toBase58())
|
|
30
34
|
: [];
|
|
31
|
-
this.
|
|
35
|
+
this.velocityMarkets = (_b = config.velocityMarkets) !== null && _b !== void 0 ? _b : config.driftMarkets;
|
|
32
36
|
if (config.customStrategy) {
|
|
33
37
|
this.customStrategy = config.customStrategy;
|
|
34
38
|
}
|
|
35
39
|
else {
|
|
36
40
|
this.customStrategy = this.averageStrategy;
|
|
37
41
|
}
|
|
38
|
-
this.lookbackDistance = (
|
|
42
|
+
this.lookbackDistance = (_c = config.slotsToCheck) !== null && _c !== void 0 ? _c : 50;
|
|
39
43
|
if (config.priorityFeeMethod) {
|
|
40
44
|
this.priorityFeeMethod = config.priorityFeeMethod;
|
|
41
45
|
if (this.priorityFeeMethod === types_1.PriorityFeeMethod.HELIUS) {
|
|
@@ -51,9 +55,9 @@ class PriorityFeeSubscriber {
|
|
|
51
55
|
this.heliusRpcUrl = config.heliusRpcUrl;
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
|
-
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.
|
|
58
|
+
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
|
|
55
59
|
this.velocityPriorityFeeEndpoint =
|
|
56
|
-
(
|
|
60
|
+
(_d = config.velocityPriorityFeeEndpoint) !== null && _d !== void 0 ? _d : config.driftPriorityFeeEndpoint;
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
if (this.priorityFeeMethod === types_1.PriorityFeeMethod.SOLANA) {
|
|
@@ -62,7 +66,7 @@ class PriorityFeeSubscriber {
|
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
this.maxFeeMicroLamports = config.maxFeeMicroLamports;
|
|
65
|
-
this.priorityFeeMultiplier = (
|
|
69
|
+
this.priorityFeeMultiplier = (_e = config.priorityFeeMultiplier) !== null && _e !== void 0 ? _e : 1.0;
|
|
66
70
|
}
|
|
67
71
|
async subscribe() {
|
|
68
72
|
if (this.intervalId) {
|
|
@@ -98,10 +102,10 @@ class PriorityFeeSubscriber {
|
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
async loadForDrift() {
|
|
101
|
-
if (!this.
|
|
105
|
+
if (!this.velocityMarkets) {
|
|
102
106
|
return;
|
|
103
107
|
}
|
|
104
|
-
const sample = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.
|
|
108
|
+
const sample = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.velocityMarkets.map((m) => m.marketType), this.velocityMarkets.map((m) => m.marketIndex));
|
|
105
109
|
if (sample.length > 0) {
|
|
106
110
|
this.lastAvgStrategyResult = sample[heliusPriorityFeeMethod_1.HeliusPriorityLevel.MEDIUM];
|
|
107
111
|
this.lastMaxStrategyResult = sample[heliusPriorityFeeMethod_1.HeliusPriorityLevel.UNSAFE_MAX];
|
|
@@ -164,7 +168,7 @@ class PriorityFeeSubscriber {
|
|
|
164
168
|
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.HELIUS) {
|
|
165
169
|
await this.loadForHelius();
|
|
166
170
|
}
|
|
167
|
-
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.
|
|
171
|
+
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
|
|
168
172
|
await this.loadForDrift();
|
|
169
173
|
}
|
|
170
174
|
else {
|
|
@@ -186,8 +190,8 @@ class PriorityFeeSubscriber {
|
|
|
186
190
|
updateAddresses(addresses) {
|
|
187
191
|
this.addresses = addresses.map((k) => k.toBase58());
|
|
188
192
|
}
|
|
189
|
-
updateMarketTypeAndIndex(
|
|
190
|
-
this.
|
|
193
|
+
updateMarketTypeAndIndex(velocityMarkets) {
|
|
194
|
+
this.velocityMarkets = velocityMarkets;
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
197
|
exports.PriorityFeeSubscriber = PriorityFeeSubscriber;
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
import { VelocityMarketInfo, VelocityPriorityFeeLevels } from './velocityPriorityFeeMethod';
|
|
2
2
|
import { PriorityFeeSubscriberMapConfig } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* takes advantage of /batchPriorityFees endpoint from
|
|
4
|
+
* takes advantage of /batchPriorityFees endpoint from Velocity hosted priority fee service
|
|
5
5
|
*/
|
|
6
6
|
export declare class PriorityFeeSubscriberMap {
|
|
7
7
|
frequencyMs: number;
|
|
8
8
|
intervalId?: ReturnType<typeof setTimeout>;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
velocityMarkets?: VelocityMarketInfo[];
|
|
10
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
11
|
+
get driftMarkets(): VelocityMarketInfo[] | undefined;
|
|
12
|
+
velocityPriorityFeeEndpoint: string;
|
|
11
13
|
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
12
|
-
get driftPriorityFeeEndpoint(): string
|
|
14
|
+
get driftPriorityFeeEndpoint(): string;
|
|
13
15
|
feesMap: Map<string, Map<number, VelocityPriorityFeeLevels>>;
|
|
14
16
|
constructor(config: PriorityFeeSubscriberMapConfig);
|
|
15
17
|
private updateFeesMap;
|
|
16
18
|
subscribe(): Promise<void>;
|
|
17
19
|
unsubscribe(): Promise<void>;
|
|
18
20
|
load(): Promise<void>;
|
|
19
|
-
updateMarketTypeAndIndex(
|
|
21
|
+
updateMarketTypeAndIndex(velocityMarkets: VelocityMarketInfo[]): void;
|
|
20
22
|
getPriorityFees(marketType: string, marketIndex: number): VelocityPriorityFeeLevels | undefined;
|
|
21
23
|
}
|
|
22
24
|
/** Example usage:
|
|
23
25
|
async function main() {
|
|
24
|
-
const
|
|
26
|
+
const velocityMarkets: VelocityMarketInfo[] = [
|
|
25
27
|
{ marketType: 'perp', marketIndex: 0 },
|
|
26
28
|
{ marketType: 'perp', marketIndex: 1 },
|
|
27
29
|
{ marketType: 'spot', marketIndex: 2 }
|
|
28
30
|
];
|
|
29
31
|
|
|
30
32
|
const subscriber = new PriorityFeeSubscriberMap({
|
|
31
|
-
velocityPriorityFeeEndpoint: 'https://dlob.
|
|
33
|
+
velocityPriorityFeeEndpoint: 'https://dlob.velocity.trade',
|
|
32
34
|
frequencyMs: 5000,
|
|
33
|
-
|
|
35
|
+
velocityMarkets
|
|
34
36
|
});
|
|
35
37
|
await subscriber.subscribe();
|
|
36
38
|
|
|
37
39
|
for (let i = 0; i < 20; i++) {
|
|
38
40
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
39
|
-
|
|
41
|
+
velocityMarkets.forEach(market => {
|
|
40
42
|
const fees = subscriber.getPriorityFees(market.marketType, market.marketIndex);
|
|
41
43
|
console.log(`Priority fees for ${market.marketType} market ${market.marketIndex}:`, fees);
|
|
42
44
|
});
|
|
@@ -4,24 +4,24 @@ exports.PriorityFeeSubscriberMap = void 0;
|
|
|
4
4
|
const velocityPriorityFeeMethod_1 = require("./velocityPriorityFeeMethod");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
/**
|
|
7
|
-
* takes advantage of /batchPriorityFees endpoint from
|
|
7
|
+
* takes advantage of /batchPriorityFees endpoint from Velocity hosted priority fee service
|
|
8
8
|
*/
|
|
9
9
|
class PriorityFeeSubscriberMap {
|
|
10
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
11
|
+
get driftMarkets() {
|
|
12
|
+
return this.velocityMarkets;
|
|
13
|
+
}
|
|
10
14
|
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
11
15
|
get driftPriorityFeeEndpoint() {
|
|
12
16
|
return this.velocityPriorityFeeEndpoint;
|
|
13
17
|
}
|
|
14
18
|
constructor(config) {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
this.frequencyMs = config.frequencyMs;
|
|
19
|
+
var _a, _b, _c;
|
|
17
20
|
this.frequencyMs =
|
|
18
21
|
(_a = config.frequencyMs) !== null && _a !== void 0 ? _a : types_1.DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
this.velocityPriorityFeeEndpoint = endpoint;
|
|
24
|
-
this.driftMarkets = config.driftMarkets;
|
|
22
|
+
// Type-system guarantees at least one of the two is supplied.
|
|
23
|
+
this.velocityPriorityFeeEndpoint = ((_b = config.velocityPriorityFeeEndpoint) !== null && _b !== void 0 ? _b : config.driftPriorityFeeEndpoint);
|
|
24
|
+
this.velocityMarkets = (_c = config.velocityMarkets) !== null && _c !== void 0 ? _c : config.driftMarkets;
|
|
25
25
|
this.feesMap = new Map();
|
|
26
26
|
this.feesMap.set('perp', new Map());
|
|
27
27
|
this.feesMap.set('spot', new Map());
|
|
@@ -46,18 +46,18 @@ class PriorityFeeSubscriberMap {
|
|
|
46
46
|
}
|
|
47
47
|
async load() {
|
|
48
48
|
try {
|
|
49
|
-
if (!this.
|
|
49
|
+
if (!this.velocityMarkets) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
const fees = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.
|
|
52
|
+
const fees = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.velocityMarkets.map((m) => m.marketType), this.velocityMarkets.map((m) => m.marketIndex));
|
|
53
53
|
this.updateFeesMap(fees);
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
|
-
console.error('Error fetching
|
|
56
|
+
console.error('Error fetching priority fees', e);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
updateMarketTypeAndIndex(
|
|
60
|
-
this.
|
|
59
|
+
updateMarketTypeAndIndex(velocityMarkets) {
|
|
60
|
+
this.velocityMarkets = velocityMarkets;
|
|
61
61
|
}
|
|
62
62
|
getPriorityFees(marketType, marketIndex) {
|
|
63
63
|
var _a;
|
|
@@ -67,22 +67,22 @@ class PriorityFeeSubscriberMap {
|
|
|
67
67
|
exports.PriorityFeeSubscriberMap = PriorityFeeSubscriberMap;
|
|
68
68
|
/** Example usage:
|
|
69
69
|
async function main() {
|
|
70
|
-
const
|
|
70
|
+
const velocityMarkets: VelocityMarketInfo[] = [
|
|
71
71
|
{ marketType: 'perp', marketIndex: 0 },
|
|
72
72
|
{ marketType: 'perp', marketIndex: 1 },
|
|
73
73
|
{ marketType: 'spot', marketIndex: 2 }
|
|
74
74
|
];
|
|
75
75
|
|
|
76
76
|
const subscriber = new PriorityFeeSubscriberMap({
|
|
77
|
-
velocityPriorityFeeEndpoint: 'https://dlob.
|
|
77
|
+
velocityPriorityFeeEndpoint: 'https://dlob.velocity.trade',
|
|
78
78
|
frequencyMs: 5000,
|
|
79
|
-
|
|
79
|
+
velocityMarkets
|
|
80
80
|
});
|
|
81
81
|
await subscriber.subscribe();
|
|
82
82
|
|
|
83
83
|
for (let i = 0; i < 20; i++) {
|
|
84
84
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
85
|
-
|
|
85
|
+
velocityMarkets.forEach(market => {
|
|
86
86
|
const fees = subscriber.getPriorityFees(market.marketType, market.marketIndex);
|
|
87
87
|
console.log(`Priority fees for ${market.marketType} market ${market.marketIndex}:`, fees);
|
|
88
88
|
});
|
|
@@ -2,6 +2,7 @@ import { Connection, PublicKey } from '@solana/web3.js';
|
|
|
2
2
|
import { SolanaPriorityFeeResponse } from './solanaPriorityFeeMethod';
|
|
3
3
|
import { HeliusPriorityFeeResponse } from './heliusPriorityFeeMethod';
|
|
4
4
|
import { VelocityMarketInfo, VelocityPriorityFeeResponse } from './velocityPriorityFeeMethod';
|
|
5
|
+
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
5
6
|
export declare const DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS = 10000;
|
|
6
7
|
export interface PriorityFeeStrategy {
|
|
7
8
|
calculate(samples: SolanaPriorityFeeResponse[] | HeliusPriorityFeeResponse | VelocityPriorityFeeResponse): number;
|
|
@@ -9,12 +10,14 @@ export interface PriorityFeeStrategy {
|
|
|
9
10
|
export declare enum PriorityFeeMethod {
|
|
10
11
|
SOLANA = "solana",
|
|
11
12
|
HELIUS = "helius",
|
|
12
|
-
|
|
13
|
+
VELOCITY = "velocity"
|
|
13
14
|
}
|
|
14
15
|
export type PriorityFeeSubscriberConfig = {
|
|
15
16
|
connection?: Connection;
|
|
16
17
|
frequencyMs?: number;
|
|
17
18
|
addresses?: PublicKey[];
|
|
19
|
+
velocityMarkets?: VelocityMarketInfo[];
|
|
20
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
18
21
|
driftMarkets?: VelocityMarketInfo[];
|
|
19
22
|
customStrategy?: PriorityFeeStrategy;
|
|
20
23
|
priorityFeeMethod?: PriorityFeeMethod;
|
|
@@ -26,10 +29,11 @@ export type PriorityFeeSubscriberConfig = {
|
|
|
26
29
|
maxFeeMicroLamports?: number;
|
|
27
30
|
priorityFeeMultiplier?: number;
|
|
28
31
|
};
|
|
29
|
-
|
|
32
|
+
type PriorityFeeSubscriberMapConfigBase = {
|
|
30
33
|
frequencyMs?: number;
|
|
34
|
+
velocityMarkets?: VelocityMarketInfo[];
|
|
35
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
31
36
|
driftMarkets?: VelocityMarketInfo[];
|
|
32
|
-
velocityPriorityFeeEndpoint?: string;
|
|
33
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
34
|
-
driftPriorityFeeEndpoint?: string;
|
|
35
37
|
};
|
|
38
|
+
export type PriorityFeeSubscriberMapConfig = PriorityFeeSubscriberMapConfigBase & AtLeastOne<'velocityPriorityFeeEndpoint', 'driftPriorityFeeEndpoint', string>;
|
|
39
|
+
export {};
|
|
@@ -6,5 +6,5 @@ var PriorityFeeMethod;
|
|
|
6
6
|
(function (PriorityFeeMethod) {
|
|
7
7
|
PriorityFeeMethod["SOLANA"] = "solana";
|
|
8
8
|
PriorityFeeMethod["HELIUS"] = "helius";
|
|
9
|
-
PriorityFeeMethod["
|
|
9
|
+
PriorityFeeMethod["VELOCITY"] = "velocity";
|
|
10
10
|
})(PriorityFeeMethod || (exports.PriorityFeeMethod = PriorityFeeMethod = {}));
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Commitment } from '@solana/web3.js';
|
|
4
1
|
import { grpcProgramAccountSubscriber } from '../accounts/grpcProgramAccountSubscriber';
|
|
5
|
-
import { GrpcConfigs
|
|
2
|
+
import { GrpcConfigs } from '../accounts/types';
|
|
6
3
|
import { SignedMsgUserOrdersAccount } from '../types';
|
|
7
|
-
import { SignedMsgUserOrdersAccountSubscriber } from './signedMsgUserAccountSubscriber';
|
|
8
|
-
import { VelocityClient } from '../velocityClient';
|
|
4
|
+
import { SignedMsgUserOrdersAccountSubscriber, SignedMsgUserOrdersAccountSubscriberConfig } from './signedMsgUserAccountSubscriber';
|
|
9
5
|
export declare class grpcSignedMsgUserOrdersAccountSubscriber extends SignedMsgUserOrdersAccountSubscriber {
|
|
10
6
|
private grpcConfigs;
|
|
11
7
|
subscriber: grpcProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
|
|
12
|
-
constructor({ grpcConfigs,
|
|
8
|
+
constructor({ grpcConfigs, ...rest }: SignedMsgUserOrdersAccountSubscriberConfig & {
|
|
13
9
|
grpcConfigs: GrpcConfigs;
|
|
14
|
-
driftClient: VelocityClient;
|
|
15
|
-
commitment?: Commitment;
|
|
16
|
-
resubOpts?: ResubOpts;
|
|
17
|
-
decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
|
|
18
|
-
resyncIntervalMs?: number;
|
|
19
10
|
});
|
|
20
11
|
subscribe(): Promise<void>;
|
|
21
12
|
unsubscribe(): Promise<void>;
|
|
@@ -5,20 +5,14 @@ const grpcProgramAccountSubscriber_1 = require("../accounts/grpcProgramAccountSu
|
|
|
5
5
|
const memcmp_1 = require("../memcmp");
|
|
6
6
|
const signedMsgUserAccountSubscriber_1 = require("./signedMsgUserAccountSubscriber");
|
|
7
7
|
class grpcSignedMsgUserOrdersAccountSubscriber extends signedMsgUserAccountSubscriber_1.SignedMsgUserOrdersAccountSubscriber {
|
|
8
|
-
constructor({ grpcConfigs,
|
|
9
|
-
super(
|
|
10
|
-
driftClient,
|
|
11
|
-
commitment,
|
|
12
|
-
resubOpts,
|
|
13
|
-
decodeFn,
|
|
14
|
-
resyncIntervalMs,
|
|
15
|
-
});
|
|
8
|
+
constructor({ grpcConfigs, ...rest }) {
|
|
9
|
+
super(rest);
|
|
16
10
|
this.grpcConfigs = grpcConfigs;
|
|
17
11
|
}
|
|
18
12
|
async subscribe() {
|
|
19
13
|
if (!this.subscriber) {
|
|
20
14
|
this.subscriber =
|
|
21
|
-
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.
|
|
15
|
+
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.velocityClient.program, this.decodeFn, {
|
|
22
16
|
filters: [(0, memcmp_1.getSignedMsgUserOrdersFilter)()],
|
|
23
17
|
}, this.resubOpts);
|
|
24
18
|
}
|
|
@@ -6,14 +6,23 @@ import { SignedMsgOrderId, SignedMsgUserOrdersAccount } from '../types';
|
|
|
6
6
|
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
7
7
|
import { ResubOpts } from '../accounts/types';
|
|
8
8
|
import { VelocityClient } from '../velocityClient';
|
|
9
|
+
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
9
10
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
10
11
|
import { EventEmitter } from 'events';
|
|
12
|
+
export type SignedMsgUserOrdersAccountSubscriberConfig = {
|
|
13
|
+
commitment?: Commitment;
|
|
14
|
+
resubOpts?: ResubOpts;
|
|
15
|
+
decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
|
|
16
|
+
resyncIntervalMs?: number;
|
|
17
|
+
} & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
|
|
11
18
|
export interface SignedMsgUserOrdersAccountSubscriberEvents {
|
|
12
19
|
onAccountUpdate: (activeSignedMsgOrderIds: SignedMsgOrderId[], authorityPubkey: PublicKey, slot: number) => void;
|
|
13
20
|
newSignedMsgOrderIds: (newSignedMsgOrderIds: SignedMsgOrderId[], authorityPubkey: PublicKey, slot: number) => void;
|
|
14
21
|
}
|
|
15
22
|
export declare class SignedMsgUserOrdersAccountSubscriber {
|
|
16
|
-
protected
|
|
23
|
+
protected velocityClient: VelocityClient;
|
|
24
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
25
|
+
protected get driftClient(): VelocityClient;
|
|
17
26
|
protected commitment: Commitment;
|
|
18
27
|
protected resubOpts?: ResubOpts;
|
|
19
28
|
protected resyncTimeoutId?: ReturnType<typeof setTimeout>;
|
|
@@ -28,13 +37,7 @@ export declare class SignedMsgUserOrdersAccountSubscriber {
|
|
|
28
37
|
fetchPromiseResolver: () => void;
|
|
29
38
|
protected subscriber: WebSocketProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
|
|
30
39
|
eventEmitter: StrictEventEmitter<EventEmitter, SignedMsgUserOrdersAccountSubscriberEvents>;
|
|
31
|
-
constructor({ driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }:
|
|
32
|
-
driftClient: VelocityClient;
|
|
33
|
-
commitment?: Commitment;
|
|
34
|
-
resubOpts?: ResubOpts;
|
|
35
|
-
decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
|
|
36
|
-
resyncIntervalMs?: number;
|
|
37
|
-
});
|
|
40
|
+
constructor({ velocityClient, driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }: SignedMsgUserOrdersAccountSubscriberConfig);
|
|
38
41
|
subscribe(): Promise<void>;
|
|
39
42
|
fetch(): Promise<void>;
|
|
40
43
|
tryUpdateSignedMsgUserOrdersAccount(data: Buffer | SignedMsgUserOrdersAccount, dataType: 'buffer' | 'decoded', slot: number, skipEventEmitting?: boolean): void;
|
|
@@ -5,13 +5,18 @@ const memcmp_1 = require("../memcmp");
|
|
|
5
5
|
const webSocketProgramAccountSubscriber_1 = require("../accounts/webSocketProgramAccountSubscriber");
|
|
6
6
|
const events_1 = require("events");
|
|
7
7
|
class SignedMsgUserOrdersAccountSubscriber {
|
|
8
|
-
|
|
8
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
9
|
+
get driftClient() {
|
|
10
|
+
return this.velocityClient;
|
|
11
|
+
}
|
|
12
|
+
constructor({ velocityClient, driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }) {
|
|
9
13
|
this.signedMsgUserOrderAccounts = new Map();
|
|
10
14
|
this.commitment = commitment !== null && commitment !== void 0 ? commitment : 'confirmed';
|
|
11
15
|
this.resubOpts = resubOpts;
|
|
12
|
-
|
|
16
|
+
// Type-system guarantees at least one of the two is supplied.
|
|
17
|
+
this.velocityClient = (velocityClient !== null && velocityClient !== void 0 ? velocityClient : driftClient);
|
|
13
18
|
this.decodeFn =
|
|
14
|
-
decodeFn !== null && decodeFn !== void 0 ? decodeFn : this.
|
|
19
|
+
decodeFn !== null && decodeFn !== void 0 ? decodeFn : this.velocityClient.program.account.signedMsgUserOrders.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.signedMsgUserOrders.coder
|
|
15
20
|
.accounts);
|
|
16
21
|
this.resyncIntervalMs = resyncIntervalMs;
|
|
17
22
|
this.eventEmitter = new events_1.EventEmitter();
|
|
@@ -21,7 +26,7 @@ class SignedMsgUserOrdersAccountSubscriber {
|
|
|
21
26
|
if (!this.subscriber) {
|
|
22
27
|
const filters = [(0, memcmp_1.getSignedMsgUserOrdersFilter)()];
|
|
23
28
|
this.subscriber =
|
|
24
|
-
new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.
|
|
29
|
+
new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.velocityClient.program, this.decodeFn, {
|
|
25
30
|
filters,
|
|
26
31
|
commitment: this.commitment,
|
|
27
32
|
}, this.resubOpts);
|
|
@@ -57,7 +62,7 @@ class SignedMsgUserOrdersAccountSubscriber {
|
|
|
57
62
|
});
|
|
58
63
|
const skipEventEmitting = this.signedMsgUserOrderAccounts.size === 0;
|
|
59
64
|
try {
|
|
60
|
-
const rpcResponseAndContext = await this.
|
|
65
|
+
const rpcResponseAndContext = await this.velocityClient.connection.getProgramAccounts(this.velocityClient.program.programId, {
|
|
61
66
|
commitment: this.commitment,
|
|
62
67
|
filters: [(0, memcmp_1.getSignedMsgUserOrdersFilter)()],
|
|
63
68
|
encoding: 'base64',
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { VelocityClient } from '../velocityClient';
|
|
2
2
|
import { VelocityEnv } from '../config';
|
|
3
|
+
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
3
4
|
import { OptionalOrderParams, SignedMsgOrderParamsDelegateMessage, SignedMsgOrderParamsMessage, UserAccount } from '../types';
|
|
4
5
|
import { Keypair, TransactionInstruction } from '@solana/web3.js';
|
|
5
6
|
export interface AccountGetter {
|
|
6
7
|
mustGetUserAccount(publicKey: string): Promise<UserAccount>;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
driftClient: VelocityClient;
|
|
9
|
+
type SwiftOrderSubscriberConfigBase = {
|
|
10
10
|
userAccountGetter?: AccountGetter;
|
|
11
|
-
driftEnv: VelocityEnv;
|
|
12
11
|
endpoint?: string;
|
|
13
12
|
marketIndexes: number[];
|
|
14
13
|
/**
|
|
@@ -18,6 +17,7 @@ export type SwiftOrderSubscriberConfig = {
|
|
|
18
17
|
*/
|
|
19
18
|
keypair: Keypair;
|
|
20
19
|
};
|
|
20
|
+
export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase & AtLeastOne<'velocityEnv', 'driftEnv', VelocityEnv> & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
|
|
21
21
|
/**
|
|
22
22
|
* Swift order message received from WebSocket
|
|
23
23
|
*/
|
|
@@ -47,7 +47,9 @@ export declare class SwiftOrderSubscriber {
|
|
|
47
47
|
private heartbeatTimeout;
|
|
48
48
|
private readonly heartbeatIntervalMs;
|
|
49
49
|
private ws;
|
|
50
|
-
private
|
|
50
|
+
private velocityClient;
|
|
51
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
52
|
+
private get driftClient();
|
|
51
53
|
userAccountGetter?: AccountGetter;
|
|
52
54
|
onOrder: (orderMessageRaw: SwiftOrderMessage, signedMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, isDelegateSigner?: boolean) => Promise<void>;
|
|
53
55
|
subscribed: boolean;
|
|
@@ -61,3 +63,4 @@ export declare class SwiftOrderSubscriber {
|
|
|
61
63
|
private startHeartbeatTimer;
|
|
62
64
|
private reconnect;
|
|
63
65
|
}
|
|
66
|
+
export {};
|