@drift-labs/sdk-browser 2.139.0-beta.1 → 2.139.0-beta.10
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/VERSION +1 -1
- package/bun.lock +21 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +1 -1
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +1 -1
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +154 -0
- package/lib/browser/accounts/types.d.ts +1 -0
- package/lib/browser/constants/perpMarkets.js +12 -0
- package/lib/browser/math/auction.js +3 -0
- package/lib/browser/math/orders.js +1 -1
- package/lib/browser/orderSubscriber/grpcSubscription.js +12 -3
- package/lib/node/accounts/grpcAccountSubscriber.js +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.js +154 -0
- package/lib/node/accounts/types.d.ts +1 -0
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +12 -0
- package/lib/node/isomorphic/grpc.node.d.ts.map +1 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +3 -0
- package/lib/node/math/orders.js +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +12 -3
- package/package.json +2 -1
- package/src/accounts/laserProgramAccountSubscriber.ts +215 -0
- package/src/accounts/types.ts +1 -0
- package/src/constants/perpMarkets.ts +13 -0
- package/src/isomorphic/grpc.node.ts +16 -1
- package/src/math/auction.ts +4 -0
- package/src/math/orders.ts +1 -1
- package/src/orderSubscriber/grpcSubscription.ts +30 -12
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.139.0-beta.
|
|
1
|
+
2.139.0-beta.10
|
package/bun.lock
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@triton-one/yellowstone-grpc": "1.3.0",
|
|
21
21
|
"anchor-bankrun": "0.3.0",
|
|
22
22
|
"gill": "^0.10.2",
|
|
23
|
+
"helius-laserstream": "0.1.8",
|
|
23
24
|
"nanoid": "3.3.4",
|
|
24
25
|
"node-cache": "5.1.2",
|
|
25
26
|
"rpc-websockets": "7.5.1",
|
|
@@ -335,6 +336,8 @@
|
|
|
335
336
|
|
|
336
337
|
"@types/node": ["@types/node@22.13.8", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-G3EfaZS+iOGYWLLRCEAXdWK9my08oHNZ+FHluRiggIYJPOXzhOiDgpVCUHaUvyIC5/fj7C/p637jdzC666AOKQ=="],
|
|
337
338
|
|
|
339
|
+
"@types/protobufjs": ["@types/protobufjs@6.0.0", "", { "dependencies": { "protobufjs": "*" } }, "sha512-A27RDExpAf3rdDjIrHKiJK6x8kqqJ4CmoChwtipfhVAn1p7+wviQFFP7dppn8FslSbHtQeVPvi8wNKkDjSYjHw=="],
|
|
340
|
+
|
|
338
341
|
"@types/semver": ["@types/semver@7.7.0", "", {}, "sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA=="],
|
|
339
342
|
|
|
340
343
|
"@types/stack-utils": ["@types/stack-utils@2.0.3", "", {}, "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw=="],
|
|
@@ -711,6 +714,20 @@
|
|
|
711
714
|
|
|
712
715
|
"he": ["he@1.2.0", "", { "bin": { "he": "bin/he" } }, "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="],
|
|
713
716
|
|
|
717
|
+
"helius-laserstream": ["helius-laserstream@0.1.8", "", { "dependencies": { "@types/protobufjs": "^6.0.0", "protobufjs": "^7.5.3" }, "optionalDependencies": { "helius-laserstream-darwin-arm64": "0.1.8", "helius-laserstream-darwin-x64": "0.1.8", "helius-laserstream-linux-arm64-gnu": "0.1.8", "helius-laserstream-linux-arm64-musl": "0.1.8", "helius-laserstream-linux-x64-gnu": "0.1.8", "helius-laserstream-linux-x64-musl": "0.1.8" }, "os": [ "linux", "darwin", ], "cpu": [ "x64", "arm64", ] }, "sha512-jXQkwQRWiowbVPGQrGacOkI5shKPhrEixCu93OpoMtL5fs9mnhtD7XKMPi8CX0W8gsqsJjwR4NlaR+EflyANbQ=="],
|
|
718
|
+
|
|
719
|
+
"helius-laserstream-darwin-arm64": ["helius-laserstream-darwin-arm64@0.1.8", "", { "os": "darwin", "cpu": "arm64" }, "sha512-p/K2Mi3wZnMxEYSLCvu858VyMvtJFonhdF8cLaMcszFv04WWdsK+hINNZpVRfakypvDfDPbMudEhL1Q9USD5+w=="],
|
|
720
|
+
|
|
721
|
+
"helius-laserstream-darwin-x64": ["helius-laserstream-darwin-x64@0.1.8", "", { "os": "darwin", "cpu": "x64" }, "sha512-Hd5irFyfOqQZLdoj5a+OV7vML2YfySSBuKlOwtisMHkUuIXZ4NpAexslDmK7iP5VWRI+lOv9X/tA7BhxW7RGSQ=="],
|
|
722
|
+
|
|
723
|
+
"helius-laserstream-linux-arm64-gnu": ["helius-laserstream-linux-arm64-gnu@0.1.8", "", { "os": "linux", "cpu": "arm64" }, "sha512-PlPm1dvOvTGBL1nuzK98Xe40BJq1JWNREXlBHKDVA/B+KCGQnIMJ1s6e1MevSvFE7SOix5i1BxhYIxGioK2GMg=="],
|
|
724
|
+
|
|
725
|
+
"helius-laserstream-linux-arm64-musl": ["helius-laserstream-linux-arm64-musl@0.1.8", "", { "os": "linux", "cpu": "arm64" }, "sha512-LFadfMRuTd1zo6RZqLTgHQapo3gJYioS7wFMWFoBOFulG0BpAqHEDNobkxx0002QArw+zX29MQ/5OaOCf8kKTA=="],
|
|
726
|
+
|
|
727
|
+
"helius-laserstream-linux-x64-gnu": ["helius-laserstream-linux-x64-gnu@0.1.8", "", { "os": "linux", "cpu": "x64" }, "sha512-IZWK/OQIe0647QqfYikLb1DFK+nYtXLJiMcpj24qnNVWBOtMXmPc1hL6ebazdEiaKt7fxNd5IiM1RqeaqZAZMw=="],
|
|
728
|
+
|
|
729
|
+
"helius-laserstream-linux-x64-musl": ["helius-laserstream-linux-x64-musl@0.1.8", "", { "os": "linux", "cpu": "x64" }, "sha512-riTS6VgxDae1fHOJ2XC/o/v1OZRbEv/3rcoa3NlAOnooDKp5HDgD0zJTcImjQHpYWwGaejx1oX/Ht53lxNoijw=="],
|
|
730
|
+
|
|
714
731
|
"humanize-ms": ["humanize-ms@1.2.1", "", { "dependencies": { "ms": "^2.0.0" } }, "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ=="],
|
|
715
732
|
|
|
716
733
|
"iconv-lite": ["iconv-lite@0.6.3", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],
|
|
@@ -1195,6 +1212,8 @@
|
|
|
1195
1212
|
|
|
1196
1213
|
"@switchboard-xyz/on-demand/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="],
|
|
1197
1214
|
|
|
1215
|
+
"@types/protobufjs/protobufjs": ["protobufjs@7.5.4", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg=="],
|
|
1216
|
+
|
|
1198
1217
|
"@typescript-eslint/project-service/@typescript-eslint/types": ["@typescript-eslint/types@8.38.0", "", {}, "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw=="],
|
|
1199
1218
|
|
|
1200
1219
|
"@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.3", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg=="],
|
|
@@ -1221,6 +1240,8 @@
|
|
|
1221
1240
|
|
|
1222
1241
|
"glob/minimatch": ["minimatch@5.1.6", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g=="],
|
|
1223
1242
|
|
|
1243
|
+
"helius-laserstream/protobufjs": ["protobufjs@7.5.4", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg=="],
|
|
1244
|
+
|
|
1224
1245
|
"jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="],
|
|
1225
1246
|
|
|
1226
1247
|
"jayson/commander": ["commander@2.20.3", "", {}, "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="],
|
|
@@ -39,7 +39,7 @@ class grpcAccountSubscriber extends webSocketAccountSubscriber_1.WebSocketAccoun
|
|
|
39
39
|
const client = await (0, grpc_1.createClient)(grpcConfigs.endpoint, grpcConfigs.token, (_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {});
|
|
40
40
|
const commitmentLevel =
|
|
41
41
|
// @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
|
|
42
|
-
(_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : CommitmentLevel.CONFIRMED;
|
|
42
|
+
(_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : grpc_1.CommitmentLevel.CONFIRMED;
|
|
43
43
|
return new grpcAccountSubscriber(client, commitmentLevel, accountName, program, accountPublicKey, decodeBuffer, resubOpts);
|
|
44
44
|
}
|
|
45
45
|
async subscribe(onChange) {
|
|
@@ -47,7 +47,7 @@ class grpcProgramAccountSubscriber extends webSocketProgramAccountSubscriber_1.W
|
|
|
47
47
|
const client = await (0, grpc_1.createClient)(grpcConfigs.endpoint, grpcConfigs.token, (_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {});
|
|
48
48
|
const commitmentLevel =
|
|
49
49
|
// @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
|
|
50
|
-
(_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : CommitmentLevel.CONFIRMED;
|
|
50
|
+
(_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : grpc_1.CommitmentLevel.CONFIRMED;
|
|
51
51
|
return new grpcProgramAccountSubscriber(client, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
52
52
|
}
|
|
53
53
|
async subscribe(onChange) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { GrpcConfigs, ResubOpts } from './types';
|
|
4
|
+
import { Program } from '@coral-xyz/anchor';
|
|
5
|
+
import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
6
|
+
import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber';
|
|
7
|
+
import { LaserCommitmentLevel } from '../isomorphic/grpc';
|
|
8
|
+
type LaserCommitment = (typeof LaserCommitmentLevel)[keyof typeof LaserCommitmentLevel];
|
|
9
|
+
export declare class LaserstreamProgramAccountSubscriber<T> extends WebSocketProgramAccountSubscriber<T> {
|
|
10
|
+
private stream;
|
|
11
|
+
private commitmentLevel;
|
|
12
|
+
listenerId?: number;
|
|
13
|
+
private readonly laserConfig;
|
|
14
|
+
private constructor();
|
|
15
|
+
static create<U>(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options?: {
|
|
16
|
+
filters: MemcmpFilter[];
|
|
17
|
+
}, resubOpts?: ResubOpts): Promise<LaserstreamProgramAccountSubscriber<U>>;
|
|
18
|
+
subscribe(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void): Promise<void>;
|
|
19
|
+
unsubscribe(onResub?: boolean): Promise<void>;
|
|
20
|
+
toLaserCommitment(level: string | number | undefined): LaserCommitment;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.LaserstreamProgramAccountSubscriber = void 0;
|
|
27
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
28
|
+
const Buffer = __importStar(require("buffer"));
|
|
29
|
+
const webSocketProgramAccountSubscriber_1 = require("./webSocketProgramAccountSubscriber");
|
|
30
|
+
const grpc_1 = require("../isomorphic/grpc");
|
|
31
|
+
class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber {
|
|
32
|
+
constructor(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = { filters: [] }, resubOpts) {
|
|
33
|
+
super(subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
34
|
+
this.laserConfig = laserConfig;
|
|
35
|
+
this.commitmentLevel = this.toLaserCommitment(commitmentLevel);
|
|
36
|
+
}
|
|
37
|
+
static async create(grpcConfigs, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
38
|
+
filters: [],
|
|
39
|
+
}, resubOpts) {
|
|
40
|
+
var _a;
|
|
41
|
+
const laserConfig = {
|
|
42
|
+
apiKey: grpcConfigs.token,
|
|
43
|
+
endpoint: grpcConfigs.endpoint,
|
|
44
|
+
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
45
|
+
channelOptions: {
|
|
46
|
+
'grpc.default_compression_algorithm': grpc_1.CompressionAlgorithms.zstd,
|
|
47
|
+
'grpc.max_receive_message_length': 1000000000,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const commitmentLevel = (_a = grpcConfigs.commitmentLevel) !== null && _a !== void 0 ? _a : grpc_1.CommitmentLevel.CONFIRMED;
|
|
51
|
+
return new LaserstreamProgramAccountSubscriber(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
52
|
+
}
|
|
53
|
+
async subscribe(onChange) {
|
|
54
|
+
var _a;
|
|
55
|
+
if (this.listenerId != null || this.isUnsubscribing)
|
|
56
|
+
return;
|
|
57
|
+
this.onChange = onChange;
|
|
58
|
+
const filters = this.options.filters.map((filter) => {
|
|
59
|
+
return {
|
|
60
|
+
memcmp: {
|
|
61
|
+
offset: filter.memcmp.offset,
|
|
62
|
+
base58: filter.memcmp.bytes,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const request = {
|
|
67
|
+
slots: {},
|
|
68
|
+
accounts: {
|
|
69
|
+
drift: {
|
|
70
|
+
account: [],
|
|
71
|
+
owner: [this.program.programId.toBase58()],
|
|
72
|
+
filters,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
transactions: {},
|
|
76
|
+
blocks: {},
|
|
77
|
+
blocksMeta: {},
|
|
78
|
+
accountsDataSlice: [],
|
|
79
|
+
commitment: this.commitmentLevel,
|
|
80
|
+
entry: {},
|
|
81
|
+
transactionsStatus: {},
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
const stream = await (0, grpc_1.LaserSubscribe)(this.laserConfig, request, async (update) => {
|
|
85
|
+
var _a;
|
|
86
|
+
if (update.account) {
|
|
87
|
+
const slot = Number(update.account.slot);
|
|
88
|
+
const acc = update.account.account;
|
|
89
|
+
const accountInfo = {
|
|
90
|
+
owner: new web3_js_1.PublicKey(acc.owner),
|
|
91
|
+
lamports: Number(acc.lamports),
|
|
92
|
+
data: Buffer.Buffer.from(acc.data),
|
|
93
|
+
executable: acc.executable,
|
|
94
|
+
rentEpoch: Number(acc.rentEpoch),
|
|
95
|
+
};
|
|
96
|
+
const payload = {
|
|
97
|
+
accountId: new web3_js_1.PublicKey(acc.pubkey),
|
|
98
|
+
accountInfo,
|
|
99
|
+
};
|
|
100
|
+
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) {
|
|
101
|
+
this.receivingData = true;
|
|
102
|
+
clearTimeout(this.timeoutId);
|
|
103
|
+
this.handleRpcResponse({ slot }, payload);
|
|
104
|
+
this.setTimeout();
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.handleRpcResponse({ slot }, payload);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, async (error) => {
|
|
111
|
+
console.error('LaserStream client error:', error);
|
|
112
|
+
throw error;
|
|
113
|
+
});
|
|
114
|
+
this.stream = stream;
|
|
115
|
+
this.listenerId = 1;
|
|
116
|
+
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) {
|
|
117
|
+
this.receivingData = true;
|
|
118
|
+
this.setTimeout();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
console.error('Failed to start LaserStream client:', err);
|
|
123
|
+
throw err;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async unsubscribe(onResub = false) {
|
|
127
|
+
if (!onResub && this.resubOpts) {
|
|
128
|
+
this.resubOpts.resubTimeoutMs = undefined;
|
|
129
|
+
}
|
|
130
|
+
this.isUnsubscribing = true;
|
|
131
|
+
clearTimeout(this.timeoutId);
|
|
132
|
+
this.timeoutId = undefined;
|
|
133
|
+
if (this.listenerId != null && this.stream) {
|
|
134
|
+
try {
|
|
135
|
+
this.stream.cancel();
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
this.listenerId = undefined;
|
|
139
|
+
this.isUnsubscribing = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.isUnsubscribing = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
toLaserCommitment(level) {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
if (typeof level === 'string') {
|
|
149
|
+
return ((_a = grpc_1.LaserCommitmentLevel[level.toUpperCase()]) !== null && _a !== void 0 ? _a : grpc_1.LaserCommitmentLevel.CONFIRMED);
|
|
150
|
+
}
|
|
151
|
+
return (_b = level) !== null && _b !== void 0 ? _b : grpc_1.LaserCommitmentLevel.CONFIRMED;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.LaserstreamProgramAccountSubscriber = LaserstreamProgramAccountSubscriber;
|
|
@@ -165,6 +165,7 @@ export type GrpcConfigs = {
|
|
|
165
165
|
* Defaults to false, will throw on connection loss.
|
|
166
166
|
*/
|
|
167
167
|
enableReconnect?: boolean;
|
|
168
|
+
client?: 'yellowstone' | 'laser';
|
|
168
169
|
};
|
|
169
170
|
export interface HighLeverageModeConfigAccountSubscriber {
|
|
170
171
|
eventEmitter: StrictEventEmitter<EventEmitter, HighLeverageModeConfigAccountEvents>;
|
|
@@ -1216,6 +1216,18 @@ exports.MainnetPerpMarkets = [
|
|
|
1216
1216
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
1217
1217
|
pythLazerId: 1578,
|
|
1218
1218
|
},
|
|
1219
|
+
{
|
|
1220
|
+
fullName: 'ASTER',
|
|
1221
|
+
category: ['DEX'],
|
|
1222
|
+
symbol: 'ASTER-PERP',
|
|
1223
|
+
baseAssetSymbol: 'ASTER',
|
|
1224
|
+
marketIndex: 76,
|
|
1225
|
+
oracle: new web3_js_1.PublicKey('E4tyjB3os4jVczLVQ258uxLdcwjuqmhcsPquVWgrpah4'),
|
|
1226
|
+
launchTs: 1758632629000,
|
|
1227
|
+
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
1228
|
+
pythFeedId: '0xa903b5a82cb572397e3d47595d2889cf80513f5b4cf7a36b513ae10cc8b1e338',
|
|
1229
|
+
pythLazerId: 2310,
|
|
1230
|
+
},
|
|
1219
1231
|
];
|
|
1220
1232
|
exports.PerpMarkets = {
|
|
1221
1233
|
devnet: exports.DevnetPerpMarkets,
|
|
@@ -17,6 +17,9 @@ function isFallbackAvailableLiquiditySource(order, minAuctionDuration, slot) {
|
|
|
17
17
|
if (minAuctionDuration === 0) {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
|
+
if ((order.bitFlags & types_2.OrderBitFlag.SafeTriggerOrder) !== 0) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
20
23
|
return new anchor_1.BN(slot).sub(order.slot).gt(new anchor_1.BN(minAuctionDuration));
|
|
21
24
|
}
|
|
22
25
|
exports.isFallbackAvailableLiquiditySource = isFallbackAvailableLiquiditySource;
|
|
@@ -147,7 +147,7 @@ function hasAuctionPrice(order, slot) {
|
|
|
147
147
|
exports.hasAuctionPrice = hasAuctionPrice;
|
|
148
148
|
function isFillableByVAMM(order, market, mmOraclePriceData, slot, ts, minAuctionDuration) {
|
|
149
149
|
return (((0, auction_1.isFallbackAvailableLiquiditySource)(order, minAuctionDuration, slot) &&
|
|
150
|
-
calculateBaseAssetAmountForAmmToFulfill(order, market, mmOraclePriceData, slot).
|
|
150
|
+
calculateBaseAssetAmountForAmmToFulfill(order, market, mmOraclePriceData, slot).gt(numericConstants_1.ZERO)) ||
|
|
151
151
|
isOrderExpired(order, ts));
|
|
152
152
|
}
|
|
153
153
|
exports.isFillableByVAMM = isFillableByVAMM;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.grpcSubscription = void 0;
|
|
4
4
|
const grpcProgramAccountSubscriber_1 = require("../accounts/grpcProgramAccountSubscriber");
|
|
5
5
|
const memcmp_1 = require("../memcmp");
|
|
6
|
+
const laserProgramAccountSubscriber_1 = require("../accounts/laserProgramAccountSubscriber");
|
|
6
7
|
class grpcSubscription {
|
|
7
8
|
constructor({ grpcConfigs, orderSubscriber, skipInitialLoad = false, resubOpts, resyncIntervalMs, decoded = true, }) {
|
|
8
9
|
this.orderSubscriber = orderSubscriber;
|
|
@@ -16,9 +17,17 @@ class grpcSubscription {
|
|
|
16
17
|
if (this.subscriber) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (this.grpcConfigs.client === 'laser') {
|
|
21
|
+
this.subscriber =
|
|
22
|
+
await laserProgramAccountSubscriber_1.LaserstreamProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'User', this.orderSubscriber.driftClient.program, this.orderSubscriber.decodeFn, {
|
|
23
|
+
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
24
|
+
}, this.resubOpts);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'User', this.orderSubscriber.driftClient.program, this.orderSubscriber.decodeFn, {
|
|
28
|
+
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
29
|
+
}, this.resubOpts);
|
|
30
|
+
}
|
|
22
31
|
await this.subscriber.subscribe((accountId, account, context, buffer) => {
|
|
23
32
|
var _a;
|
|
24
33
|
const userKey = accountId.toBase58();
|
|
@@ -39,7 +39,7 @@ class grpcAccountSubscriber extends webSocketAccountSubscriber_1.WebSocketAccoun
|
|
|
39
39
|
const client = await (0, grpc_1.createClient)(grpcConfigs.endpoint, grpcConfigs.token, (_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {});
|
|
40
40
|
const commitmentLevel =
|
|
41
41
|
// @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
|
|
42
|
-
(_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : CommitmentLevel.CONFIRMED;
|
|
42
|
+
(_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : grpc_1.CommitmentLevel.CONFIRMED;
|
|
43
43
|
return new grpcAccountSubscriber(client, commitmentLevel, accountName, program, accountPublicKey, decodeBuffer, resubOpts);
|
|
44
44
|
}
|
|
45
45
|
async subscribe(onChange) {
|
|
@@ -47,7 +47,7 @@ class grpcProgramAccountSubscriber extends webSocketProgramAccountSubscriber_1.W
|
|
|
47
47
|
const client = await (0, grpc_1.createClient)(grpcConfigs.endpoint, grpcConfigs.token, (_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {});
|
|
48
48
|
const commitmentLevel =
|
|
49
49
|
// @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
|
|
50
|
-
(_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : CommitmentLevel.CONFIRMED;
|
|
50
|
+
(_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : grpc_1.CommitmentLevel.CONFIRMED;
|
|
51
51
|
return new grpcProgramAccountSubscriber(client, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
52
52
|
}
|
|
53
53
|
async subscribe(onChange) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { GrpcConfigs, ResubOpts } from './types';
|
|
4
|
+
import { Program } from '@coral-xyz/anchor';
|
|
5
|
+
import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
6
|
+
import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber';
|
|
7
|
+
import { LaserCommitmentLevel } from '../isomorphic/grpc';
|
|
8
|
+
type LaserCommitment = (typeof LaserCommitmentLevel)[keyof typeof LaserCommitmentLevel];
|
|
9
|
+
export declare class LaserstreamProgramAccountSubscriber<T> extends WebSocketProgramAccountSubscriber<T> {
|
|
10
|
+
private stream;
|
|
11
|
+
private commitmentLevel;
|
|
12
|
+
listenerId?: number;
|
|
13
|
+
private readonly laserConfig;
|
|
14
|
+
private constructor();
|
|
15
|
+
static create<U>(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options?: {
|
|
16
|
+
filters: MemcmpFilter[];
|
|
17
|
+
}, resubOpts?: ResubOpts): Promise<LaserstreamProgramAccountSubscriber<U>>;
|
|
18
|
+
subscribe(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void): Promise<void>;
|
|
19
|
+
unsubscribe(onResub?: boolean): Promise<void>;
|
|
20
|
+
toLaserCommitment(level: string | number | undefined): LaserCommitment;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=laserProgramAccountSubscriber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"laserProgramAccountSubscriber.d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G,OAAO,CAAC,IAAI,CAAC;IAoBjD,iBAAiB,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAChC,eAAe;CASlB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.LaserstreamProgramAccountSubscriber = void 0;
|
|
27
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
28
|
+
const Buffer = __importStar(require("buffer"));
|
|
29
|
+
const webSocketProgramAccountSubscriber_1 = require("./webSocketProgramAccountSubscriber");
|
|
30
|
+
const grpc_1 = require("../isomorphic/grpc");
|
|
31
|
+
class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber {
|
|
32
|
+
constructor(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = { filters: [] }, resubOpts) {
|
|
33
|
+
super(subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
34
|
+
this.laserConfig = laserConfig;
|
|
35
|
+
this.commitmentLevel = this.toLaserCommitment(commitmentLevel);
|
|
36
|
+
}
|
|
37
|
+
static async create(grpcConfigs, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
38
|
+
filters: [],
|
|
39
|
+
}, resubOpts) {
|
|
40
|
+
var _a;
|
|
41
|
+
const laserConfig = {
|
|
42
|
+
apiKey: grpcConfigs.token,
|
|
43
|
+
endpoint: grpcConfigs.endpoint,
|
|
44
|
+
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
45
|
+
channelOptions: {
|
|
46
|
+
'grpc.default_compression_algorithm': grpc_1.CompressionAlgorithms.zstd,
|
|
47
|
+
'grpc.max_receive_message_length': 1000000000,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const commitmentLevel = (_a = grpcConfigs.commitmentLevel) !== null && _a !== void 0 ? _a : grpc_1.CommitmentLevel.CONFIRMED;
|
|
51
|
+
return new LaserstreamProgramAccountSubscriber(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
52
|
+
}
|
|
53
|
+
async subscribe(onChange) {
|
|
54
|
+
var _a;
|
|
55
|
+
if (this.listenerId != null || this.isUnsubscribing)
|
|
56
|
+
return;
|
|
57
|
+
this.onChange = onChange;
|
|
58
|
+
const filters = this.options.filters.map((filter) => {
|
|
59
|
+
return {
|
|
60
|
+
memcmp: {
|
|
61
|
+
offset: filter.memcmp.offset,
|
|
62
|
+
base58: filter.memcmp.bytes,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const request = {
|
|
67
|
+
slots: {},
|
|
68
|
+
accounts: {
|
|
69
|
+
drift: {
|
|
70
|
+
account: [],
|
|
71
|
+
owner: [this.program.programId.toBase58()],
|
|
72
|
+
filters,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
transactions: {},
|
|
76
|
+
blocks: {},
|
|
77
|
+
blocksMeta: {},
|
|
78
|
+
accountsDataSlice: [],
|
|
79
|
+
commitment: this.commitmentLevel,
|
|
80
|
+
entry: {},
|
|
81
|
+
transactionsStatus: {},
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
const stream = await (0, grpc_1.LaserSubscribe)(this.laserConfig, request, async (update) => {
|
|
85
|
+
var _a;
|
|
86
|
+
if (update.account) {
|
|
87
|
+
const slot = Number(update.account.slot);
|
|
88
|
+
const acc = update.account.account;
|
|
89
|
+
const accountInfo = {
|
|
90
|
+
owner: new web3_js_1.PublicKey(acc.owner),
|
|
91
|
+
lamports: Number(acc.lamports),
|
|
92
|
+
data: Buffer.Buffer.from(acc.data),
|
|
93
|
+
executable: acc.executable,
|
|
94
|
+
rentEpoch: Number(acc.rentEpoch),
|
|
95
|
+
};
|
|
96
|
+
const payload = {
|
|
97
|
+
accountId: new web3_js_1.PublicKey(acc.pubkey),
|
|
98
|
+
accountInfo,
|
|
99
|
+
};
|
|
100
|
+
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) {
|
|
101
|
+
this.receivingData = true;
|
|
102
|
+
clearTimeout(this.timeoutId);
|
|
103
|
+
this.handleRpcResponse({ slot }, payload);
|
|
104
|
+
this.setTimeout();
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.handleRpcResponse({ slot }, payload);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, async (error) => {
|
|
111
|
+
console.error('LaserStream client error:', error);
|
|
112
|
+
throw error;
|
|
113
|
+
});
|
|
114
|
+
this.stream = stream;
|
|
115
|
+
this.listenerId = 1;
|
|
116
|
+
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) {
|
|
117
|
+
this.receivingData = true;
|
|
118
|
+
this.setTimeout();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
console.error('Failed to start LaserStream client:', err);
|
|
123
|
+
throw err;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async unsubscribe(onResub = false) {
|
|
127
|
+
if (!onResub && this.resubOpts) {
|
|
128
|
+
this.resubOpts.resubTimeoutMs = undefined;
|
|
129
|
+
}
|
|
130
|
+
this.isUnsubscribing = true;
|
|
131
|
+
clearTimeout(this.timeoutId);
|
|
132
|
+
this.timeoutId = undefined;
|
|
133
|
+
if (this.listenerId != null && this.stream) {
|
|
134
|
+
try {
|
|
135
|
+
this.stream.cancel();
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
this.listenerId = undefined;
|
|
139
|
+
this.isUnsubscribing = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.isUnsubscribing = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
toLaserCommitment(level) {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
if (typeof level === 'string') {
|
|
149
|
+
return ((_a = grpc_1.LaserCommitmentLevel[level.toUpperCase()]) !== null && _a !== void 0 ? _a : grpc_1.LaserCommitmentLevel.CONFIRMED);
|
|
150
|
+
}
|
|
151
|
+
return (_b = level) !== null && _b !== void 0 ? _b : grpc_1.LaserCommitmentLevel.CONFIRMED;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.LaserstreamProgramAccountSubscriber = LaserstreamProgramAccountSubscriber;
|
|
@@ -165,6 +165,7 @@ export type GrpcConfigs = {
|
|
|
165
165
|
* Defaults to false, will throw on connection loss.
|
|
166
166
|
*/
|
|
167
167
|
enableReconnect?: boolean;
|
|
168
|
+
client?: 'yellowstone' | 'laser';
|
|
168
169
|
};
|
|
169
170
|
export interface HighLeverageModeConfigAccountSubscriber {
|
|
170
171
|
eventEmitter: StrictEventEmitter<EventEmitter, HighLeverageModeConfigAccountEvents>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/accounts/types.ts"],"names":[],"mappings":";;;AAAA,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErE,MAAM,WAAW,iBAAiB,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC7B,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC;IAC1C,SAAS,CACR,QAAQ,EAAE,CACT,SAAS,EAAE,SAAS,EACpB,IAAI,EA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C1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpMarkets.d.ts","sourceRoot":"","sources":["../../../src/constants/perpMarkets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,EA6W/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"perpMarkets.d.ts","sourceRoot":"","sources":["../../../src/constants/perpMarkets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,EA6W/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EA+6BhD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE;KAAG,GAAG,IAAI,QAAQ,GAAG,gBAAgB,EAAE;CAGhE,CAAC"}
|
|
@@ -1216,6 +1216,18 @@ exports.MainnetPerpMarkets = [
|
|
|
1216
1216
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
1217
1217
|
pythLazerId: 1578,
|
|
1218
1218
|
},
|
|
1219
|
+
{
|
|
1220
|
+
fullName: 'ASTER',
|
|
1221
|
+
category: ['DEX'],
|
|
1222
|
+
symbol: 'ASTER-PERP',
|
|
1223
|
+
baseAssetSymbol: 'ASTER',
|
|
1224
|
+
marketIndex: 76,
|
|
1225
|
+
oracle: new web3_js_1.PublicKey('E4tyjB3os4jVczLVQ258uxLdcwjuqmhcsPquVWgrpah4'),
|
|
1226
|
+
launchTs: 1758632629000,
|
|
1227
|
+
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
1228
|
+
pythFeedId: '0xa903b5a82cb572397e3d47595d2889cf80513f5b4cf7a36b513ae10cc8b1e338',
|
|
1229
|
+
pythLazerId: 2310,
|
|
1230
|
+
},
|
|
1219
1231
|
];
|
|
1220
1232
|
exports.PerpMarkets = {
|
|
1221
1233
|
devnet: exports.DevnetPerpMarkets,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.node.d.ts","sourceRoot":"","sources":["../../../src/isomorphic/grpc.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,8BAA8B,CAAC;AACvD,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,eAAe,
|
|
1
|
+
{"version":3,"file":"grpc.node.d.ts","sourceRoot":"","sources":["../../../src/isomorphic/grpc.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,8BAA8B,CAAC;AACvD,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EACN,eAAe,IAAI,oBAAoB,EACvC,SAAS,IAAI,cAAc,EAC3B,iBAAiB,EACjB,gBAAgB,IAAI,qBAAqB,EACzC,eAAe,IAAI,oBAAoB,EACvC,qBAAqB,EACrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,MAAM,EACN,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GACrB,CAAC;AAGF,wBAAsB,YAAY,CACjC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,MAAM,CAAC,GAC3C,OAAO,CAAC,MAAM,CAAC,CAGjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auction.d.ts","sourceRoot":"","sources":["../../../src/math/auction.ts"],"names":[],"mappings":";AAAA,OAAO,EAA6B,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAOvC,OAAO,EAA4B,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGvE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMrE;AAED,wBAAgB,kCAAkC,CACjD,KAAK,EAAE,KAAK,EACZ,kBAAkB,EAAE,MAAM,EAC1B,IAAI,EAAE,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eAAe,EAAE,EAAE,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAsC5E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IACnD,UAAU,EAAE,iBAAiB,CAAC;IAC9B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,WAAW,EAAE,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,EAAE,CAAC;CAChB,GAAG,EAAE,CA8EL;AAED;;;;GAIG;AACH,wBAAgB,uCAAuC,CAAC,MAAM,EAAE;IAC/D,UAAU,EAAE,iBAAiB,CAAC;IAC9B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,WAAW,EAAE,EAAE,CAAC;IAChB,aAAa,EAAE,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,EAAE,CAAC;CAChB,GAAG;IAAE,UAAU,EAAE,EAAE,CAAC;IAAC,cAAc,EAAE,EAAE,CAAA;CAAE,CAuBzC"}
|
package/lib/node/math/auction.js
CHANGED
|
@@ -17,6 +17,9 @@ function isFallbackAvailableLiquiditySource(order, minAuctionDuration, slot) {
|
|
|
17
17
|
if (minAuctionDuration === 0) {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
|
+
if ((order.bitFlags & types_2.OrderBitFlag.SafeTriggerOrder) !== 0) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
20
23
|
return new anchor_1.BN(slot).sub(order.slot).gt(new anchor_1.BN(minAuctionDuration));
|
|
21
24
|
}
|
|
22
25
|
exports.isFallbackAvailableLiquiditySource = isFallbackAvailableLiquiditySource;
|
package/lib/node/math/orders.js
CHANGED
|
@@ -147,7 +147,7 @@ function hasAuctionPrice(order, slot) {
|
|
|
147
147
|
exports.hasAuctionPrice = hasAuctionPrice;
|
|
148
148
|
function isFillableByVAMM(order, market, mmOraclePriceData, slot, ts, minAuctionDuration) {
|
|
149
149
|
return (((0, auction_1.isFallbackAvailableLiquiditySource)(order, minAuctionDuration, slot) &&
|
|
150
|
-
calculateBaseAssetAmountForAmmToFulfill(order, market, mmOraclePriceData, slot).
|
|
150
|
+
calculateBaseAssetAmountForAmmToFulfill(order, market, mmOraclePriceData, slot).gt(numericConstants_1.ZERO)) ||
|
|
151
151
|
isOrderExpired(order, ts));
|
|
152
152
|
}
|
|
153
153
|
exports.isFillableByVAMM = isFillableByVAMM;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpcSubscription.d.ts","sourceRoot":"","sources":["../../../src/orderSubscriber/grpcSubscription.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"grpcSubscription.d.ts","sourceRoot":"","sources":["../../../src/orderSubscriber/grpcSubscription.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK3D,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAElC,OAAO,CAAC,UAAU,CAAC,CAEiC;IACpD,OAAO,CAAC,eAAe,CAAC,CAAgC;IAExD,OAAO,CAAC,OAAO,CAAC,CAAU;IAE1B,OAAO,CAAC,WAAW,CAAc;gBAErB,EACX,WAAW,EACX,eAAe,EACf,eAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,OAAc,GACd,EAAE;QACF,WAAW,EAAE,WAAW,CAAC;QACzB,eAAe,EAAE,eAAe,CAAC;QACjC,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;KAClB;IASY,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAkF1B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CASzC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.grpcSubscription = void 0;
|
|
4
4
|
const grpcProgramAccountSubscriber_1 = require("../accounts/grpcProgramAccountSubscriber");
|
|
5
5
|
const memcmp_1 = require("../memcmp");
|
|
6
|
+
const laserProgramAccountSubscriber_1 = require("../accounts/laserProgramAccountSubscriber");
|
|
6
7
|
class grpcSubscription {
|
|
7
8
|
constructor({ grpcConfigs, orderSubscriber, skipInitialLoad = false, resubOpts, resyncIntervalMs, decoded = true, }) {
|
|
8
9
|
this.orderSubscriber = orderSubscriber;
|
|
@@ -16,9 +17,17 @@ class grpcSubscription {
|
|
|
16
17
|
if (this.subscriber) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (this.grpcConfigs.client === 'laser') {
|
|
21
|
+
this.subscriber =
|
|
22
|
+
await laserProgramAccountSubscriber_1.LaserstreamProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'User', this.orderSubscriber.driftClient.program, this.orderSubscriber.decodeFn, {
|
|
23
|
+
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
24
|
+
}, this.resubOpts);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'User', this.orderSubscriber.driftClient.program, this.orderSubscriber.decodeFn, {
|
|
28
|
+
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
29
|
+
}, this.resubOpts);
|
|
30
|
+
}
|
|
22
31
|
await this.subscriber.subscribe((accountId, account, context, buffer) => {
|
|
23
32
|
var _a;
|
|
24
33
|
const userKey = accountId.toBase58();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drift-labs/sdk-browser",
|
|
3
|
-
"version": "2.139.0-beta.
|
|
3
|
+
"version": "2.139.0-beta.10",
|
|
4
4
|
"main": "lib/node/index.js",
|
|
5
5
|
"types": "lib/node/index.d.ts",
|
|
6
6
|
"browser": "./lib/browser/index.js",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@triton-one/yellowstone-grpc": "1.3.0",
|
|
56
56
|
"anchor-bankrun": "0.3.0",
|
|
57
57
|
"gill": "^0.10.2",
|
|
58
|
+
"helius-laserstream": "0.1.8",
|
|
58
59
|
"nanoid": "3.3.4",
|
|
59
60
|
"node-cache": "5.1.2",
|
|
60
61
|
"rpc-websockets": "7.5.1",
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { GrpcConfigs, ResubOpts } from './types';
|
|
2
|
+
import { Program } from '@coral-xyz/anchor';
|
|
3
|
+
import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
4
|
+
import * as Buffer from 'buffer';
|
|
5
|
+
import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
LaserCommitmentLevel,
|
|
9
|
+
LaserSubscribe,
|
|
10
|
+
LaserstreamConfig,
|
|
11
|
+
LaserSubscribeRequest,
|
|
12
|
+
LaserSubscribeUpdate,
|
|
13
|
+
CompressionAlgorithms,
|
|
14
|
+
CommitmentLevel,
|
|
15
|
+
} from '../isomorphic/grpc';
|
|
16
|
+
|
|
17
|
+
type LaserCommitment =
|
|
18
|
+
(typeof LaserCommitmentLevel)[keyof typeof LaserCommitmentLevel];
|
|
19
|
+
|
|
20
|
+
export class LaserstreamProgramAccountSubscriber<
|
|
21
|
+
T,
|
|
22
|
+
> extends WebSocketProgramAccountSubscriber<T> {
|
|
23
|
+
private stream:
|
|
24
|
+
| {
|
|
25
|
+
id: string;
|
|
26
|
+
cancel: () => void;
|
|
27
|
+
write?: (req: LaserSubscribeRequest) => Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
| undefined;
|
|
30
|
+
|
|
31
|
+
private commitmentLevel: CommitmentLevel;
|
|
32
|
+
public listenerId?: number;
|
|
33
|
+
|
|
34
|
+
private readonly laserConfig: LaserstreamConfig;
|
|
35
|
+
|
|
36
|
+
private constructor(
|
|
37
|
+
laserConfig: LaserstreamConfig,
|
|
38
|
+
commitmentLevel: CommitmentLevel,
|
|
39
|
+
subscriptionName: string,
|
|
40
|
+
accountDiscriminator: string,
|
|
41
|
+
program: Program,
|
|
42
|
+
decodeBufferFn: (accountName: string, ix: Buffer) => T,
|
|
43
|
+
options: { filters: MemcmpFilter[] } = { filters: [] },
|
|
44
|
+
resubOpts?: ResubOpts
|
|
45
|
+
) {
|
|
46
|
+
super(
|
|
47
|
+
subscriptionName,
|
|
48
|
+
accountDiscriminator,
|
|
49
|
+
program,
|
|
50
|
+
decodeBufferFn,
|
|
51
|
+
options,
|
|
52
|
+
resubOpts
|
|
53
|
+
);
|
|
54
|
+
this.laserConfig = laserConfig;
|
|
55
|
+
this.commitmentLevel = this.toLaserCommitment(commitmentLevel);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public static async create<U>(
|
|
59
|
+
grpcConfigs: GrpcConfigs,
|
|
60
|
+
subscriptionName: string,
|
|
61
|
+
accountDiscriminator: string,
|
|
62
|
+
program: Program,
|
|
63
|
+
decodeBufferFn: (accountName: string, ix: Buffer) => U,
|
|
64
|
+
options: { filters: MemcmpFilter[] } = {
|
|
65
|
+
filters: [],
|
|
66
|
+
},
|
|
67
|
+
resubOpts?: ResubOpts
|
|
68
|
+
): Promise<LaserstreamProgramAccountSubscriber<U>> {
|
|
69
|
+
const laserConfig: LaserstreamConfig = {
|
|
70
|
+
apiKey: grpcConfigs.token,
|
|
71
|
+
endpoint: grpcConfigs.endpoint,
|
|
72
|
+
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
73
|
+
channelOptions: {
|
|
74
|
+
'grpc.default_compression_algorithm': CompressionAlgorithms.zstd,
|
|
75
|
+
'grpc.max_receive_message_length': 1_000_000_000,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const commitmentLevel =
|
|
80
|
+
grpcConfigs.commitmentLevel ?? CommitmentLevel.CONFIRMED;
|
|
81
|
+
|
|
82
|
+
return new LaserstreamProgramAccountSubscriber<U>(
|
|
83
|
+
laserConfig,
|
|
84
|
+
commitmentLevel,
|
|
85
|
+
subscriptionName,
|
|
86
|
+
accountDiscriminator,
|
|
87
|
+
program,
|
|
88
|
+
decodeBufferFn,
|
|
89
|
+
options,
|
|
90
|
+
resubOpts
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async subscribe(
|
|
95
|
+
onChange: (
|
|
96
|
+
accountId: PublicKey,
|
|
97
|
+
data: T,
|
|
98
|
+
context: Context,
|
|
99
|
+
buffer: Buffer
|
|
100
|
+
) => void
|
|
101
|
+
): Promise<void> {
|
|
102
|
+
if (this.listenerId != null || this.isUnsubscribing) return;
|
|
103
|
+
|
|
104
|
+
this.onChange = onChange;
|
|
105
|
+
|
|
106
|
+
const filters = this.options.filters.map((filter) => {
|
|
107
|
+
return {
|
|
108
|
+
memcmp: {
|
|
109
|
+
offset: filter.memcmp.offset,
|
|
110
|
+
base58: filter.memcmp.bytes,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const request: LaserSubscribeRequest = {
|
|
116
|
+
slots: {},
|
|
117
|
+
accounts: {
|
|
118
|
+
drift: {
|
|
119
|
+
account: [],
|
|
120
|
+
owner: [this.program.programId.toBase58()],
|
|
121
|
+
filters,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
transactions: {},
|
|
125
|
+
blocks: {},
|
|
126
|
+
blocksMeta: {},
|
|
127
|
+
accountsDataSlice: [],
|
|
128
|
+
commitment: this.commitmentLevel,
|
|
129
|
+
entry: {},
|
|
130
|
+
transactionsStatus: {},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
const stream = await LaserSubscribe(
|
|
135
|
+
this.laserConfig,
|
|
136
|
+
request,
|
|
137
|
+
async (update: LaserSubscribeUpdate) => {
|
|
138
|
+
if (update.account) {
|
|
139
|
+
const slot = Number(update.account.slot);
|
|
140
|
+
const acc = update.account.account;
|
|
141
|
+
|
|
142
|
+
const accountInfo = {
|
|
143
|
+
owner: new PublicKey(acc.owner),
|
|
144
|
+
lamports: Number(acc.lamports),
|
|
145
|
+
data: Buffer.Buffer.from(acc.data),
|
|
146
|
+
executable: acc.executable,
|
|
147
|
+
rentEpoch: Number(acc.rentEpoch),
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const payload = {
|
|
151
|
+
accountId: new PublicKey(acc.pubkey),
|
|
152
|
+
accountInfo,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
if (this.resubOpts?.resubTimeoutMs) {
|
|
156
|
+
this.receivingData = true;
|
|
157
|
+
clearTimeout(this.timeoutId);
|
|
158
|
+
this.handleRpcResponse({ slot }, payload);
|
|
159
|
+
this.setTimeout();
|
|
160
|
+
} else {
|
|
161
|
+
this.handleRpcResponse({ slot }, payload);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
async (error) => {
|
|
166
|
+
console.error('LaserStream client error:', error);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
this.stream = stream;
|
|
172
|
+
this.listenerId = 1;
|
|
173
|
+
|
|
174
|
+
if (this.resubOpts?.resubTimeoutMs) {
|
|
175
|
+
this.receivingData = true;
|
|
176
|
+
this.setTimeout();
|
|
177
|
+
}
|
|
178
|
+
} catch (err) {
|
|
179
|
+
console.error('Failed to start LaserStream client:', err);
|
|
180
|
+
throw err;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public async unsubscribe(onResub = false): Promise<void> {
|
|
185
|
+
if (!onResub && this.resubOpts) {
|
|
186
|
+
this.resubOpts.resubTimeoutMs = undefined;
|
|
187
|
+
}
|
|
188
|
+
this.isUnsubscribing = true;
|
|
189
|
+
clearTimeout(this.timeoutId);
|
|
190
|
+
this.timeoutId = undefined;
|
|
191
|
+
|
|
192
|
+
if (this.listenerId != null && this.stream) {
|
|
193
|
+
try {
|
|
194
|
+
this.stream.cancel();
|
|
195
|
+
} finally {
|
|
196
|
+
this.listenerId = undefined;
|
|
197
|
+
this.isUnsubscribing = false;
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
this.isUnsubscribing = false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
public toLaserCommitment(
|
|
205
|
+
level: string | number | undefined
|
|
206
|
+
): LaserCommitment {
|
|
207
|
+
if (typeof level === 'string') {
|
|
208
|
+
return (
|
|
209
|
+
(LaserCommitmentLevel as any)[level.toUpperCase()] ??
|
|
210
|
+
LaserCommitmentLevel.CONFIRMED
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return (level as LaserCommitment) ?? LaserCommitmentLevel.CONFIRMED;
|
|
214
|
+
}
|
|
215
|
+
}
|
package/src/accounts/types.ts
CHANGED
|
@@ -1312,6 +1312,19 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
1312
1312
|
oracleSource: OracleSource.PYTH_LAZER,
|
|
1313
1313
|
pythLazerId: 1578,
|
|
1314
1314
|
},
|
|
1315
|
+
{
|
|
1316
|
+
fullName: 'ASTER',
|
|
1317
|
+
category: ['DEX'],
|
|
1318
|
+
symbol: 'ASTER-PERP',
|
|
1319
|
+
baseAssetSymbol: 'ASTER',
|
|
1320
|
+
marketIndex: 76,
|
|
1321
|
+
oracle: new PublicKey('E4tyjB3os4jVczLVQ258uxLdcwjuqmhcsPquVWgrpah4'),
|
|
1322
|
+
launchTs: 1758632629000,
|
|
1323
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
1324
|
+
pythFeedId:
|
|
1325
|
+
'0xa903b5a82cb572397e3d47595d2889cf80513f5b4cf7a36b513ae10cc8b1e338',
|
|
1326
|
+
pythLazerId: 2310,
|
|
1327
|
+
},
|
|
1315
1328
|
];
|
|
1316
1329
|
|
|
1317
1330
|
export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {
|
|
@@ -2,10 +2,19 @@ import type Client from '@triton-one/yellowstone-grpc';
|
|
|
2
2
|
import type {
|
|
3
3
|
SubscribeRequest,
|
|
4
4
|
SubscribeUpdate,
|
|
5
|
-
CommitmentLevel,
|
|
6
5
|
} from '@triton-one/yellowstone-grpc';
|
|
6
|
+
import { CommitmentLevel } from '@triton-one/yellowstone-grpc';
|
|
7
7
|
import { ClientDuplexStream, ChannelOptions } from '@grpc/grpc-js';
|
|
8
8
|
|
|
9
|
+
import {
|
|
10
|
+
CommitmentLevel as LaserCommitmentLevel,
|
|
11
|
+
subscribe as LaserSubscribe,
|
|
12
|
+
LaserstreamConfig,
|
|
13
|
+
SubscribeRequest as LaserSubscribeRequest,
|
|
14
|
+
SubscribeUpdate as LaserSubscribeUpdate,
|
|
15
|
+
CompressionAlgorithms,
|
|
16
|
+
} from 'helius-laserstream';
|
|
17
|
+
|
|
9
18
|
export {
|
|
10
19
|
ClientDuplexStream,
|
|
11
20
|
ChannelOptions,
|
|
@@ -13,6 +22,12 @@ export {
|
|
|
13
22
|
SubscribeUpdate,
|
|
14
23
|
CommitmentLevel,
|
|
15
24
|
Client,
|
|
25
|
+
LaserSubscribe,
|
|
26
|
+
LaserCommitmentLevel,
|
|
27
|
+
LaserstreamConfig,
|
|
28
|
+
LaserSubscribeRequest,
|
|
29
|
+
LaserSubscribeUpdate,
|
|
30
|
+
CompressionAlgorithms,
|
|
16
31
|
};
|
|
17
32
|
|
|
18
33
|
// Export a function to create a new Client instance
|
package/src/math/auction.ts
CHANGED
package/src/math/orders.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { OrderSubscriber } from './OrderSubscriber';
|
|
|
5
5
|
import { GrpcConfigs, ResubOpts } from '../accounts/types';
|
|
6
6
|
import { UserAccount } from '../types';
|
|
7
7
|
import { getUserFilter, getNonIdleUserFilter } from '../memcmp';
|
|
8
|
+
import { LaserstreamProgramAccountSubscriber } from '../accounts/laserProgramAccountSubscriber';
|
|
8
9
|
|
|
9
10
|
export class grpcSubscription {
|
|
10
11
|
private orderSubscriber: OrderSubscriber;
|
|
@@ -12,7 +13,9 @@ export class grpcSubscription {
|
|
|
12
13
|
private resubOpts?: ResubOpts;
|
|
13
14
|
private resyncIntervalMs?: number;
|
|
14
15
|
|
|
15
|
-
private subscriber?:
|
|
16
|
+
private subscriber?:
|
|
17
|
+
| grpcProgramAccountSubscriber<UserAccount>
|
|
18
|
+
| LaserstreamProgramAccountSubscriber<UserAccount>;
|
|
16
19
|
private resyncTimeoutId?: ReturnType<typeof setTimeout>;
|
|
17
20
|
|
|
18
21
|
private decoded?: boolean;
|
|
@@ -47,17 +50,32 @@ export class grpcSubscription {
|
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
if (this.grpcConfigs.client === 'laser') {
|
|
54
|
+
this.subscriber =
|
|
55
|
+
await LaserstreamProgramAccountSubscriber.create<UserAccount>(
|
|
56
|
+
this.grpcConfigs,
|
|
57
|
+
'OrderSubscriber',
|
|
58
|
+
'User',
|
|
59
|
+
this.orderSubscriber.driftClient.program,
|
|
60
|
+
this.orderSubscriber.decodeFn,
|
|
61
|
+
{
|
|
62
|
+
filters: [getUserFilter(), getNonIdleUserFilter()],
|
|
63
|
+
},
|
|
64
|
+
this.resubOpts
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
this.subscriber = await grpcProgramAccountSubscriber.create<UserAccount>(
|
|
68
|
+
this.grpcConfigs,
|
|
69
|
+
'OrderSubscriber',
|
|
70
|
+
'User',
|
|
71
|
+
this.orderSubscriber.driftClient.program,
|
|
72
|
+
this.orderSubscriber.decodeFn,
|
|
73
|
+
{
|
|
74
|
+
filters: [getUserFilter(), getNonIdleUserFilter()],
|
|
75
|
+
},
|
|
76
|
+
this.resubOpts
|
|
77
|
+
);
|
|
78
|
+
}
|
|
61
79
|
|
|
62
80
|
await this.subscriber.subscribe(
|
|
63
81
|
(
|