@lasersell/lasersell-sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/exitApi.d.ts +87 -0
- package/dist/exitApi.js +238 -0
- package/dist/exitApi.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/retry.d.ts +15 -0
- package/dist/retry.js +74 -0
- package/dist/retry.js.map +1 -0
- package/dist/stream/client.d.ts +144 -0
- package/dist/stream/client.js +995 -0
- package/dist/stream/client.js.map +1 -0
- package/dist/stream/index.d.ts +3 -0
- package/dist/stream/index.js +4 -0
- package/dist/stream/index.js.map +1 -0
- package/dist/stream/proto.d.ts +148 -0
- package/dist/stream/proto.js +266 -0
- package/dist/stream/proto.js.map +1 -0
- package/dist/stream/session.d.ts +64 -0
- package/dist/stream/session.js +243 -0
- package/dist/stream/session.js.map +1 -0
- package/dist/tx.d.ts +85 -0
- package/dist/tx.js +408 -0
- package/dist/tx.js.map +1 -0
- package/package.json +87 -0
- package/src/exitApi.ts +385 -0
- package/src/index.ts +5 -0
- package/src/retry.ts +102 -0
- package/src/stream/client.ts +1362 -0
- package/src/stream/index.ts +3 -0
- package/src/stream/proto.ts +565 -0
- package/src/stream/session.ts +372 -0
- package/src/tx.ts +617 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { type ClientMessage, type ServerMessage, type StrategyConfigMsg } from "./proto.js";
|
|
2
|
+
export declare const STREAM_ENDPOINT = "wss://stream.lasersell.io/v1/ws";
|
|
3
|
+
export declare const LOCAL_STREAM_ENDPOINT = "ws://localhost:8082/v1/ws";
|
|
4
|
+
export interface StreamConfigure {
|
|
5
|
+
wallet_pubkeys: string[];
|
|
6
|
+
strategy: StrategyConfigMsg;
|
|
7
|
+
deadline_timeout_sec?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface OptionalStrategyConfig {
|
|
10
|
+
target_profit_pct?: number;
|
|
11
|
+
stop_loss_pct?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface StreamLanesOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of low-priority messages (currently `pnl_update`) to buffer.
|
|
16
|
+
*
|
|
17
|
+
* When full, the oldest low-priority message is dropped to keep the stream hot path responsive.
|
|
18
|
+
*
|
|
19
|
+
* Defaults to 1024.
|
|
20
|
+
*/
|
|
21
|
+
lowPriorityCapacity?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function singleWalletStreamConfigure(walletPubkey: string, strategy: StrategyConfigMsg, deadlineTimeoutSec?: number): StreamConfigure;
|
|
24
|
+
export declare function strategyConfigFromOptional(strategy?: OptionalStrategyConfig): StrategyConfigMsg;
|
|
25
|
+
export declare function singleWalletStreamConfigureOptional(walletPubkey: string, strategy?: OptionalStrategyConfig, deadlineTimeoutSec?: number): StreamConfigure;
|
|
26
|
+
export type PositionSelector = {
|
|
27
|
+
token_account: string;
|
|
28
|
+
position_id?: never;
|
|
29
|
+
} | {
|
|
30
|
+
position_id: number;
|
|
31
|
+
token_account?: never;
|
|
32
|
+
};
|
|
33
|
+
export type PositionSelectorInput = PositionSelector | string | number | {
|
|
34
|
+
tokenAccount: string;
|
|
35
|
+
} | {
|
|
36
|
+
positionId: number;
|
|
37
|
+
} | {
|
|
38
|
+
token_account: string;
|
|
39
|
+
} | {
|
|
40
|
+
position_id: number;
|
|
41
|
+
};
|
|
42
|
+
export type StreamClientErrorKind = "websocket" | "json" | "invalid_api_key_header" | "send_queue_closed" | "protocol";
|
|
43
|
+
export declare class StreamClientError extends Error {
|
|
44
|
+
readonly kind: StreamClientErrorKind;
|
|
45
|
+
private constructor();
|
|
46
|
+
static websocket(cause: unknown): StreamClientError;
|
|
47
|
+
static json(cause: unknown): StreamClientError;
|
|
48
|
+
static invalidApiKeyHeader(cause: unknown): StreamClientError;
|
|
49
|
+
static sendQueueClosed(): StreamClientError;
|
|
50
|
+
static protocol(message: string): StreamClientError;
|
|
51
|
+
}
|
|
52
|
+
export declare class StreamClient {
|
|
53
|
+
private readonly apiKey;
|
|
54
|
+
private local;
|
|
55
|
+
private endpointOverride?;
|
|
56
|
+
constructor(apiKey: string);
|
|
57
|
+
withLocalMode(local: boolean): this;
|
|
58
|
+
withEndpoint(endpoint: string): this;
|
|
59
|
+
connect(configure: StreamConfigure): Promise<StreamConnection>;
|
|
60
|
+
connectLanes(configure: StreamConfigure, options?: StreamLanesOptions): Promise<StreamConnectionLanes>;
|
|
61
|
+
private endpoint;
|
|
62
|
+
}
|
|
63
|
+
export declare function validateStrategyAndDeadline(strategy: StrategyConfigMsg, deadlineTimeoutSec: number): void;
|
|
64
|
+
export declare class StreamConnection {
|
|
65
|
+
private readonly worker;
|
|
66
|
+
constructor(worker: StreamConnectionWorker);
|
|
67
|
+
sender(): StreamSender;
|
|
68
|
+
split(): [StreamSender, StreamReceiver];
|
|
69
|
+
recv(): Promise<ServerMessage | null>;
|
|
70
|
+
close(): void;
|
|
71
|
+
}
|
|
72
|
+
export declare class StreamConnectionLanes {
|
|
73
|
+
private readonly worker;
|
|
74
|
+
constructor(worker: StreamConnectionWorker);
|
|
75
|
+
sender(): StreamSender;
|
|
76
|
+
highReceiver(): StreamHighReceiver;
|
|
77
|
+
lowReceiver(): StreamLowReceiver;
|
|
78
|
+
split(): [StreamSender, StreamHighReceiver, StreamLowReceiver];
|
|
79
|
+
close(): void;
|
|
80
|
+
}
|
|
81
|
+
export declare class StreamHighReceiver {
|
|
82
|
+
private readonly worker;
|
|
83
|
+
constructor(worker: StreamConnectionWorker);
|
|
84
|
+
recv(): Promise<ServerMessage | null>;
|
|
85
|
+
[Symbol.asyncIterator](): AsyncGenerator<ServerMessage, void, void>;
|
|
86
|
+
}
|
|
87
|
+
export declare class StreamLowReceiver {
|
|
88
|
+
private readonly worker;
|
|
89
|
+
constructor(worker: StreamConnectionWorker);
|
|
90
|
+
recv(): Promise<ServerMessage | null>;
|
|
91
|
+
[Symbol.asyncIterator](): AsyncGenerator<ServerMessage, void, void>;
|
|
92
|
+
}
|
|
93
|
+
export declare class StreamReceiver {
|
|
94
|
+
private readonly worker;
|
|
95
|
+
constructor(worker: StreamConnectionWorker);
|
|
96
|
+
recv(): Promise<ServerMessage | null>;
|
|
97
|
+
[Symbol.asyncIterator](): AsyncGenerator<ServerMessage, void, void>;
|
|
98
|
+
}
|
|
99
|
+
export declare class StreamSender {
|
|
100
|
+
private readonly worker;
|
|
101
|
+
constructor(worker: StreamConnectionWorker);
|
|
102
|
+
send(message: ClientMessage): void;
|
|
103
|
+
ping(client_time_ms: number): void;
|
|
104
|
+
updateStrategy(strategy: StrategyConfigMsg): void;
|
|
105
|
+
closePosition(selector: PositionSelectorInput): void;
|
|
106
|
+
closeById(positionId: number): void;
|
|
107
|
+
requestExitSignal(selector: PositionSelectorInput, slippage_bps?: number): void;
|
|
108
|
+
requestExitSignalById(positionId: number, slippage_bps?: number): void;
|
|
109
|
+
}
|
|
110
|
+
type InboundMode = "combined" | "lanes";
|
|
111
|
+
interface StreamConnectionWorkerOptions {
|
|
112
|
+
inboundMode?: InboundMode;
|
|
113
|
+
lowPriorityCapacity?: number;
|
|
114
|
+
}
|
|
115
|
+
declare class StreamConnectionWorker {
|
|
116
|
+
private readonly endpoint;
|
|
117
|
+
private readonly apiKey;
|
|
118
|
+
private readonly configure;
|
|
119
|
+
private readonly inboundMode;
|
|
120
|
+
private readonly inboundCombined?;
|
|
121
|
+
private readonly inboundHigh?;
|
|
122
|
+
private readonly inboundLow?;
|
|
123
|
+
private readonly outbound;
|
|
124
|
+
private currentSocket;
|
|
125
|
+
private stopped;
|
|
126
|
+
private readonly readyPromise;
|
|
127
|
+
private readySettled;
|
|
128
|
+
private resolveReady;
|
|
129
|
+
private rejectReady;
|
|
130
|
+
constructor(endpoint: string, apiKey: string, configure: StreamConfigure, options?: StreamConnectionWorkerOptions);
|
|
131
|
+
waitReady(): Promise<void>;
|
|
132
|
+
enqueue(message: ClientMessage): void;
|
|
133
|
+
recv(): Promise<ServerMessage | null>;
|
|
134
|
+
recvHigh(): Promise<ServerMessage | null>;
|
|
135
|
+
recvLow(): Promise<ServerMessage | null>;
|
|
136
|
+
close(): void;
|
|
137
|
+
private run;
|
|
138
|
+
private runConnectedSession;
|
|
139
|
+
private handleFrame;
|
|
140
|
+
private setReadyError;
|
|
141
|
+
private pushInbound;
|
|
142
|
+
private closeInbound;
|
|
143
|
+
}
|
|
144
|
+
export {};
|