From 2cdb0376422f8b1a9b3088a95c024d5021ebac08 Mon Sep 17 00:00:00 2001 From: Jack Waller Date: Mon, 22 Sep 2025 15:57:02 +1000 Subject: [PATCH 1/3] chore: update laser 0.1.8 --- sdk/package.json | 2 +- .../accounts/laserProgramAccountSubscriber.ts | 18 +++-- sdk/src/isomorphic/grpc.node.ts | 15 ++++ sdk/yarn.lock | 80 +++++++++---------- 4 files changed, 66 insertions(+), 49 deletions(-) diff --git a/sdk/package.json b/sdk/package.json index 9c6d00acca..acad577968 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -55,7 +55,7 @@ "@triton-one/yellowstone-grpc": "1.3.0", "anchor-bankrun": "0.3.0", "gill": "^0.10.2", - "helius-laserstream": "^0.1.7", + "helius-laserstream": "0.1.8", "nanoid": "3.3.4", "node-cache": "5.1.2", "rpc-websockets": "7.5.1", diff --git a/sdk/src/accounts/laserProgramAccountSubscriber.ts b/sdk/src/accounts/laserProgramAccountSubscriber.ts index babfb1704f..e10239a2cc 100644 --- a/sdk/src/accounts/laserProgramAccountSubscriber.ts +++ b/sdk/src/accounts/laserProgramAccountSubscriber.ts @@ -5,13 +5,13 @@ import * as Buffer from 'buffer'; import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber'; import { - CommitmentLevel as LaserCommitmentLevel, - subscribe as LaserSubscribe, + LaserCommitmentLevel, + LaserSubscribe, LaserstreamConfig, - SubscribeRequest, - SubscribeUpdate, + LaserSubscribeRequest, + LaserSubscribeUpdate, CompressionAlgorithms, -} from 'helius-laserstream'; +} from '../isomorphic/grpc.node'; import { CommitmentLevel } from '@triton-one/yellowstone-grpc'; type LaserCommitment = @@ -24,7 +24,7 @@ export class LaserstreamProgramAccountSubscriber< | { id: string; cancel: () => void; - write?: (req: SubscribeRequest) => Promise; + write?: (req: LaserSubscribeRequest) => Promise; } | undefined; @@ -66,6 +66,8 @@ export class LaserstreamProgramAccountSubscriber< }, resubOpts?: ResubOpts ): Promise> { + console.log('using laser stream client'); + const laserConfig: LaserstreamConfig = { apiKey: grpcConfigs.token, endpoint: grpcConfigs.endpoint, @@ -112,7 +114,7 @@ export class LaserstreamProgramAccountSubscriber< }; }); - const request: SubscribeRequest = { + const request: LaserSubscribeRequest = { slots: {}, accounts: { drift: { @@ -134,7 +136,7 @@ export class LaserstreamProgramAccountSubscriber< const stream = await LaserSubscribe( this.laserConfig, request, - async (update: SubscribeUpdate) => { + async (update: LaserSubscribeUpdate) => { if (update.account) { const slot = Number(update.account.slot); const acc = update.account.account; diff --git a/sdk/src/isomorphic/grpc.node.ts b/sdk/src/isomorphic/grpc.node.ts index 4d58f734d1..8652858ef0 100644 --- a/sdk/src/isomorphic/grpc.node.ts +++ b/sdk/src/isomorphic/grpc.node.ts @@ -6,6 +6,15 @@ import type { } from '@triton-one/yellowstone-grpc'; import { ClientDuplexStream, ChannelOptions } from '@grpc/grpc-js'; +import { + CommitmentLevel as LaserCommitmentLevel, + subscribe as LaserSubscribe, + LaserstreamConfig, + SubscribeRequest as LaserSubscribeRequest, + SubscribeUpdate as LaserSubscribeUpdate, + CompressionAlgorithms, +} from 'helius-laserstream'; + export { ClientDuplexStream, ChannelOptions, @@ -13,6 +22,12 @@ export { SubscribeUpdate, CommitmentLevel, Client, + LaserSubscribe, + LaserCommitmentLevel, + LaserstreamConfig, + LaserSubscribeRequest, + LaserSubscribeUpdate, + CompressionAlgorithms, }; // Export a function to create a new Client instance diff --git a/sdk/yarn.lock b/sdk/yarn.lock index fdcc859a96..a18bd777e8 100644 --- a/sdk/yarn.lock +++ b/sdk/yarn.lock @@ -2794,50 +2794,50 @@ he@^1.2.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -helius-laserstream-darwin-arm64@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/helius-laserstream-darwin-arm64/-/helius-laserstream-darwin-arm64-0.1.7.tgz#c84df402bdb8a2159bcfc2711bf2b64fe09edd24" - integrity sha512-oMkt6qr7EQLfgiOCVO/9lTQLi8futBVqhUSRvsCmYcAqmaFNsvmf+/rRVq/o56+iq0PseqV6DcRF+5s88tYEIg== - -helius-laserstream-darwin-x64@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/helius-laserstream-darwin-x64/-/helius-laserstream-darwin-x64-0.1.7.tgz#fe15b0513a8d1f55075f27b1a5836bf73ec470ff" - integrity sha512-88utpg/ZMtsnF9RX268D50fl6B3kQOFS0nCzoenS1CwMvMprTqHSEDqYFgBX8O7t52gox5aw8+x3XqhHX0fIMQ== - -helius-laserstream-linux-arm64-gnu@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/helius-laserstream-linux-arm64-gnu/-/helius-laserstream-linux-arm64-gnu-0.1.7.tgz#cc7a636bc12961d314a4c46008d63f4fb6fe6b03" - integrity sha512-4YQuISaa3OWOBQCUnslT+HguuGRMO1KRQeWSjtuSHDYn7oO/KXePCtEo9vqnQx7HtQFDnS1/kuFExIa2L4Sp2w== - -helius-laserstream-linux-arm64-musl@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/helius-laserstream-linux-arm64-musl/-/helius-laserstream-linux-arm64-musl-0.1.7.tgz#96dcf87b855698e9f28214d96031d0934324db45" - integrity sha512-VyN/5nzqUtBN88PLDIMVJmFDgImMCL1sjBWKf49ppAWKN3LVvYVYT8tGMi4nzb5vj7ObduIi1ZZ+cGWNM6H2kA== - -helius-laserstream-linux-x64-gnu@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/helius-laserstream-linux-x64-gnu/-/helius-laserstream-linux-x64-gnu-0.1.7.tgz#0bcaed9697b975033e86a74ab4d734ee3d4d3e1c" - integrity sha512-0//p5wlITWbWKBaW2CIYfS3/9fBJCvMn8fBvBKot28psIWSQ6Uc5u/IqS2ls438NvTiEvBp6pgScWoYHXKU+VQ== - -helius-laserstream-linux-x64-musl@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/helius-laserstream-linux-x64-musl/-/helius-laserstream-linux-x64-musl-0.1.7.tgz#6c38ca7f97bd1ff46947794fd907ecd8492a0249" - integrity sha512-4VFxsKE+X3Jj/DBrdKQCUs/6ljuYadiPrF5QBMIyaflzZka/hOOvd2bDAo8Bi9/qGGCCaJG6F3U3OFKGKSiE9w== - -helius-laserstream@^0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/helius-laserstream/-/helius-laserstream-0.1.7.tgz#67f9d570f56ba9bb801d210ebff5e9cf1cc97faa" - integrity sha512-xsCbc8dApJpLb6OShOCeJ5/6pQMdGk6sQojEgihTNGZaGhaAzwYzJcxL5q4uszE3qG/viJO67Mi/MxArDb+QaQ== +helius-laserstream-darwin-arm64@0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/helius-laserstream-darwin-arm64/-/helius-laserstream-darwin-arm64-0.1.8.tgz#d78ad15e6cd16dc9379a9a365f9fcb3f958e6c01" + integrity sha512-p/K2Mi3wZnMxEYSLCvu858VyMvtJFonhdF8cLaMcszFv04WWdsK+hINNZpVRfakypvDfDPbMudEhL1Q9USD5+w== + +helius-laserstream-darwin-x64@0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/helius-laserstream-darwin-x64/-/helius-laserstream-darwin-x64-0.1.8.tgz#e57bc8f03135fd3b5c01a5aebd7b87c42129da50" + integrity sha512-Hd5irFyfOqQZLdoj5a+OV7vML2YfySSBuKlOwtisMHkUuIXZ4NpAexslDmK7iP5VWRI+lOv9X/tA7BhxW7RGSQ== + +helius-laserstream-linux-arm64-gnu@0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/helius-laserstream-linux-arm64-gnu/-/helius-laserstream-linux-arm64-gnu-0.1.8.tgz#1b3c8440804d143f650166842620fc334f9c319b" + integrity sha512-PlPm1dvOvTGBL1nuzK98Xe40BJq1JWNREXlBHKDVA/B+KCGQnIMJ1s6e1MevSvFE7SOix5i1BxhYIxGioK2GMg== + +helius-laserstream-linux-arm64-musl@0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/helius-laserstream-linux-arm64-musl/-/helius-laserstream-linux-arm64-musl-0.1.8.tgz#28e0645bebc3253d2a136cf0bd13f8cb5256f47b" + integrity sha512-LFadfMRuTd1zo6RZqLTgHQapo3gJYioS7wFMWFoBOFulG0BpAqHEDNobkxx0002QArw+zX29MQ/5OaOCf8kKTA== + +helius-laserstream-linux-x64-gnu@0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/helius-laserstream-linux-x64-gnu/-/helius-laserstream-linux-x64-gnu-0.1.8.tgz#e59990ca0bcdc27e46f71a8fc2c18fddbe6f07e3" + integrity sha512-IZWK/OQIe0647QqfYikLb1DFK+nYtXLJiMcpj24qnNVWBOtMXmPc1hL6ebazdEiaKt7fxNd5IiM1RqeaqZAZMw== + +helius-laserstream-linux-x64-musl@0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/helius-laserstream-linux-x64-musl/-/helius-laserstream-linux-x64-musl-0.1.8.tgz#42aa0919ef266c40f50ac74d6f9d871d4e2e7c9c" + integrity sha512-riTS6VgxDae1fHOJ2XC/o/v1OZRbEv/3rcoa3NlAOnooDKp5HDgD0zJTcImjQHpYWwGaejx1oX/Ht53lxNoijw== + +helius-laserstream@0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/helius-laserstream/-/helius-laserstream-0.1.8.tgz#6ee5e0bc9fe2560c03a0d2c9079b9f875c3e6bb7" + integrity sha512-jXQkwQRWiowbVPGQrGacOkI5shKPhrEixCu93OpoMtL5fs9mnhtD7XKMPi8CX0W8gsqsJjwR4NlaR+EflyANbQ== dependencies: "@types/protobufjs" "^6.0.0" protobufjs "^7.5.3" optionalDependencies: - helius-laserstream-darwin-arm64 "0.1.7" - helius-laserstream-darwin-x64 "0.1.7" - helius-laserstream-linux-arm64-gnu "0.1.7" - helius-laserstream-linux-arm64-musl "0.1.7" - helius-laserstream-linux-x64-gnu "0.1.7" - helius-laserstream-linux-x64-musl "0.1.7" + 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" humanize-ms@^1.2.1: version "1.2.1" From 8b681355df9a6b1ef9d8d9598efa26760e1a3396 Mon Sep 17 00:00:00 2001 From: Jack Waller Date: Mon, 22 Sep 2025 15:59:46 +1000 Subject: [PATCH 2/3] chore: remove logging --- sdk/src/accounts/laserProgramAccountSubscriber.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/src/accounts/laserProgramAccountSubscriber.ts b/sdk/src/accounts/laserProgramAccountSubscriber.ts index e10239a2cc..914cf1f34a 100644 --- a/sdk/src/accounts/laserProgramAccountSubscriber.ts +++ b/sdk/src/accounts/laserProgramAccountSubscriber.ts @@ -66,8 +66,6 @@ export class LaserstreamProgramAccountSubscriber< }, resubOpts?: ResubOpts ): Promise> { - console.log('using laser stream client'); - const laserConfig: LaserstreamConfig = { apiKey: grpcConfigs.token, endpoint: grpcConfigs.endpoint, From 0656f34328b74e1e4613ce38083e58abdc666e90 Mon Sep 17 00:00:00 2001 From: Jack Waller Date: Tue, 23 Sep 2025 09:49:32 +1000 Subject: [PATCH 3/3] chore: add grpc client to order subscriber --- sdk/src/accounts/types.ts | 1 + sdk/src/orderSubscriber/grpcSubscription.ts | 42 +++++++++++++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/sdk/src/accounts/types.ts b/sdk/src/accounts/types.ts index 98ab7133fb..c572ae2798 100644 --- a/sdk/src/accounts/types.ts +++ b/sdk/src/accounts/types.ts @@ -234,6 +234,7 @@ export type GrpcConfigs = { * Defaults to false, will throw on connection loss. */ enableReconnect?: boolean; + client?: 'yellowstone' | 'laser'; }; export interface HighLeverageModeConfigAccountSubscriber { diff --git a/sdk/src/orderSubscriber/grpcSubscription.ts b/sdk/src/orderSubscriber/grpcSubscription.ts index 41101435ab..04160c0bff 100644 --- a/sdk/src/orderSubscriber/grpcSubscription.ts +++ b/sdk/src/orderSubscriber/grpcSubscription.ts @@ -5,6 +5,7 @@ import { OrderSubscriber } from './OrderSubscriber'; import { GrpcConfigs, ResubOpts } from '../accounts/types'; import { UserAccount } from '../types'; import { getUserFilter, getNonIdleUserFilter } from '../memcmp'; +import { LaserstreamProgramAccountSubscriber } from '../accounts/laserProgramAccountSubscriber'; export class grpcSubscription { private orderSubscriber: OrderSubscriber; @@ -12,7 +13,9 @@ export class grpcSubscription { private resubOpts?: ResubOpts; private resyncIntervalMs?: number; - private subscriber?: grpcProgramAccountSubscriber; + private subscriber?: + | grpcProgramAccountSubscriber + | LaserstreamProgramAccountSubscriber; private resyncTimeoutId?: ReturnType; private decoded?: boolean; @@ -47,17 +50,32 @@ export class grpcSubscription { return; } - this.subscriber = await grpcProgramAccountSubscriber.create( - this.grpcConfigs, - 'OrderSubscriber', - 'User', - this.orderSubscriber.driftClient.program, - this.orderSubscriber.decodeFn, - { - filters: [getUserFilter(), getNonIdleUserFilter()], - }, - this.resubOpts - ); + if (this.grpcConfigs.client === 'laser') { + this.subscriber = + await LaserstreamProgramAccountSubscriber.create( + this.grpcConfigs, + 'OrderSubscriber', + 'User', + this.orderSubscriber.driftClient.program, + this.orderSubscriber.decodeFn, + { + filters: [getUserFilter(), getNonIdleUserFilter()], + }, + this.resubOpts + ); + } else { + this.subscriber = await grpcProgramAccountSubscriber.create( + this.grpcConfigs, + 'OrderSubscriber', + 'User', + this.orderSubscriber.driftClient.program, + this.orderSubscriber.decodeFn, + { + filters: [getUserFilter(), getNonIdleUserFilter()], + }, + this.resubOpts + ); + } await this.subscriber.subscribe( (