@lifi/perps-sdk-provider-lighter 8.0.0 → 8.0.1
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/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/signers/LighterKeyStore.d.ts.map +1 -1
- package/dist/cjs/signers/LighterKeyStore.js.map +1 -1
- package/dist/cjs/signers/LighterReadOnlyTokenManager.d.ts.map +1 -1
- package/dist/cjs/signers/LighterReadOnlyTokenManager.js.map +1 -1
- package/dist/cjs/signers/LighterSigner.d.ts.map +1 -1
- package/dist/cjs/signers/LighterSigner.js.map +1 -1
- package/dist/cjs/signers/createAuthToken.d.ts.map +1 -1
- package/dist/cjs/signers/createAuthToken.js.map +1 -1
- package/dist/cjs/signers/wasmLoader.d.ts.map +1 -1
- package/dist/cjs/signers/wasmLoader.js.map +1 -1
- package/dist/cjs/types/account.d.ts.map +1 -1
- package/dist/cjs/types/action.d.ts.map +1 -1
- package/dist/cjs/types/action.js.map +1 -1
- package/dist/cjs/types/activity.d.ts.map +1 -1
- package/dist/cjs/types/asset.d.ts.map +1 -1
- package/dist/cjs/types/fill.d.ts.map +1 -1
- package/dist/cjs/types/order.d.ts.map +1 -1
- package/dist/cjs/types/submit.d.ts.map +1 -1
- package/dist/cjs/types/ws.d.ts.map +1 -1
- package/dist/cjs/utils/lighterAsset.d.ts.map +1 -1
- package/dist/cjs/utils/lighterAsset.js.map +1 -1
- package/dist/cjs/utils/ohlcvInterval.d.ts.map +1 -1
- package/dist/cjs/utils/ohlcvInterval.js.map +1 -1
- package/dist/cjs/utils/transferMargin.d.ts.map +1 -1
- package/dist/cjs/utils/transferMargin.js +1 -2
- package/dist/cjs/utils/transferMargin.js.map +1 -1
- package/dist/cjs/utils/wireEncoding.d.ts.map +1 -1
- package/dist/cjs/utils/wireEncoding.js.map +1 -1
- package/dist/cjs/websocket/LighterWsProvider.d.ts.map +1 -1
- package/dist/cjs/websocket/LighterWsProvider.js.map +1 -1
- package/dist/esm/constants.d.ts +15 -2
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +15 -2
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/signers/LighterKeyStore.d.ts +31 -2
- package/dist/esm/signers/LighterKeyStore.d.ts.map +1 -1
- package/dist/esm/signers/LighterKeyStore.js +24 -1
- package/dist/esm/signers/LighterKeyStore.js.map +1 -1
- package/dist/esm/signers/LighterReadOnlyTokenManager.d.ts +23 -3
- package/dist/esm/signers/LighterReadOnlyTokenManager.d.ts.map +1 -1
- package/dist/esm/signers/LighterReadOnlyTokenManager.js +4 -0
- package/dist/esm/signers/LighterReadOnlyTokenManager.js.map +1 -1
- package/dist/esm/signers/LighterSigner.d.ts +49 -7
- package/dist/esm/signers/LighterSigner.d.ts.map +1 -1
- package/dist/esm/signers/LighterSigner.js +11 -1
- package/dist/esm/signers/LighterSigner.js.map +1 -1
- package/dist/esm/signers/createAuthToken.d.ts +8 -2
- package/dist/esm/signers/createAuthToken.d.ts.map +1 -1
- package/dist/esm/signers/createAuthToken.js.map +1 -1
- package/dist/esm/signers/wasmLoader.d.ts +14 -2
- package/dist/esm/signers/wasmLoader.d.ts.map +1 -1
- package/dist/esm/signers/wasmLoader.js.map +1 -1
- package/dist/esm/types/account.d.ts +58 -8
- package/dist/esm/types/account.d.ts.map +1 -1
- package/dist/esm/types/action.d.ts +72 -18
- package/dist/esm/types/action.d.ts.map +1 -1
- package/dist/esm/types/action.js +72 -18
- package/dist/esm/types/action.js.map +1 -1
- package/dist/esm/types/activity.d.ts +64 -10
- package/dist/esm/types/activity.d.ts.map +1 -1
- package/dist/esm/types/asset.d.ts +72 -12
- package/dist/esm/types/asset.d.ts.map +1 -1
- package/dist/esm/types/fill.d.ts +14 -2
- package/dist/esm/types/fill.d.ts.map +1 -1
- package/dist/esm/types/order.d.ts +27 -4
- package/dist/esm/types/order.d.ts.map +1 -1
- package/dist/esm/types/submit.d.ts +26 -4
- package/dist/esm/types/submit.d.ts.map +1 -1
- package/dist/esm/types/ws.d.ts +56 -8
- package/dist/esm/types/ws.d.ts.map +1 -1
- package/dist/esm/utils/lighterAsset.d.ts +7 -1
- package/dist/esm/utils/lighterAsset.d.ts.map +1 -1
- package/dist/esm/utils/lighterAsset.js +7 -1
- package/dist/esm/utils/lighterAsset.js.map +1 -1
- package/dist/esm/utils/ohlcvInterval.d.ts +6 -1
- package/dist/esm/utils/ohlcvInterval.d.ts.map +1 -1
- package/dist/esm/utils/ohlcvInterval.js +6 -1
- package/dist/esm/utils/ohlcvInterval.js.map +1 -1
- package/dist/esm/utils/transferMargin.d.ts.map +1 -1
- package/dist/esm/utils/transferMargin.js +2 -3
- package/dist/esm/utils/transferMargin.js.map +1 -1
- package/dist/esm/utils/wireEncoding.d.ts +58 -23
- package/dist/esm/utils/wireEncoding.d.ts.map +1 -1
- package/dist/esm/utils/wireEncoding.js +58 -23
- package/dist/esm/utils/wireEncoding.js.map +1 -1
- package/dist/esm/websocket/LighterWsProvider.d.ts +6 -0
- package/dist/esm/websocket/LighterWsProvider.d.ts.map +1 -1
- package/dist/esm/websocket/LighterWsProvider.js +6 -0
- package/dist/esm/websocket/LighterWsProvider.js.map +1 -1
- package/dist/types/constants.d.ts +15 -2
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/signers/LighterKeyStore.d.ts +31 -2
- package/dist/types/signers/LighterKeyStore.d.ts.map +1 -1
- package/dist/types/signers/LighterReadOnlyTokenManager.d.ts +23 -3
- package/dist/types/signers/LighterReadOnlyTokenManager.d.ts.map +1 -1
- package/dist/types/signers/LighterSigner.d.ts +49 -7
- package/dist/types/signers/LighterSigner.d.ts.map +1 -1
- package/dist/types/signers/createAuthToken.d.ts +8 -2
- package/dist/types/signers/createAuthToken.d.ts.map +1 -1
- package/dist/types/signers/wasmLoader.d.ts +14 -2
- package/dist/types/signers/wasmLoader.d.ts.map +1 -1
- package/dist/types/types/account.d.ts +58 -8
- package/dist/types/types/account.d.ts.map +1 -1
- package/dist/types/types/action.d.ts +72 -18
- package/dist/types/types/action.d.ts.map +1 -1
- package/dist/types/types/activity.d.ts +64 -10
- package/dist/types/types/activity.d.ts.map +1 -1
- package/dist/types/types/asset.d.ts +72 -12
- package/dist/types/types/asset.d.ts.map +1 -1
- package/dist/types/types/fill.d.ts +14 -2
- package/dist/types/types/fill.d.ts.map +1 -1
- package/dist/types/types/order.d.ts +27 -4
- package/dist/types/types/order.d.ts.map +1 -1
- package/dist/types/types/submit.d.ts +26 -4
- package/dist/types/types/submit.d.ts.map +1 -1
- package/dist/types/types/ws.d.ts +56 -8
- package/dist/types/types/ws.d.ts.map +1 -1
- package/dist/types/utils/lighterAsset.d.ts +7 -1
- package/dist/types/utils/lighterAsset.d.ts.map +1 -1
- package/dist/types/utils/ohlcvInterval.d.ts +6 -1
- package/dist/types/utils/ohlcvInterval.d.ts.map +1 -1
- package/dist/types/utils/transferMargin.d.ts.map +1 -1
- package/dist/types/utils/wireEncoding.d.ts +58 -23
- package/dist/types/utils/wireEncoding.d.ts.map +1 -1
- package/dist/types/websocket/LighterWsProvider.d.ts +6 -0
- package/dist/types/websocket/LighterWsProvider.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/constants.ts +15 -2
- package/src/signers/LighterKeyStore.ts +31 -2
- package/src/signers/LighterReadOnlyTokenManager.ts +23 -3
- package/src/signers/LighterSigner.ts +49 -7
- package/src/signers/createAuthToken.ts +8 -2
- package/src/signers/wasmLoader.ts +14 -2
- package/src/types/account.ts +58 -8
- package/src/types/action.ts +72 -18
- package/src/types/activity.ts +64 -10
- package/src/types/asset.ts +72 -12
- package/src/types/fill.ts +14 -2
- package/src/types/order.ts +27 -4
- package/src/types/submit.ts +26 -4
- package/src/types/ws.ts +56 -8
- package/src/utils/lighterAsset.ts +7 -1
- package/src/utils/ohlcvInterval.ts +6 -1
- package/src/utils/transferMargin.ts +2 -6
- package/src/utils/wireEncoding.ts +58 -23
- package/src/websocket/LighterWsProvider.ts +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../src/types/order.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../src/types/order.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,qBAAqB,EAAE,MAAM,CAAA;IAC7B,MAAM,EAAE,OAAO,CAAA;IACf,kBAAkB,EAAE,MAAM,CAAA;IAC1B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;IACvB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,OAAO,EAAE,CAAA;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,EAAE,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,EAAE,CAAA;CACzB"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Request body for Lighter's `/api/v1/sendTx` endpoint. `tx_type` and
|
|
3
|
+
* `tx_info` are the signed WASM transaction envelope; `price_protection` is an
|
|
4
|
+
* optional venue-side execution guard.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
2
8
|
export interface LtSendTxRequest {
|
|
3
9
|
tx_type: number;
|
|
4
10
|
tx_info: string;
|
|
5
11
|
price_protection?: boolean;
|
|
6
12
|
}
|
|
7
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Response from Lighter's `/api/v1/sendTx` endpoint. `tx_hash` identifies the
|
|
15
|
+
* submitted transaction; timing and quota fields are optional venue estimates.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
8
19
|
export interface LtSendTxResponse {
|
|
9
20
|
code: number;
|
|
10
21
|
message: string;
|
|
@@ -12,12 +23,23 @@ export interface LtSendTxResponse {
|
|
|
12
23
|
predicted_execution_time_ms?: number;
|
|
13
24
|
volume_quota_remaining?: number;
|
|
14
25
|
}
|
|
15
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Batch request body for Lighter's transaction submission endpoint.
|
|
28
|
+
* `tx_types` is a JSON-encoded number array and `tx_infos` a JSON-encoded
|
|
29
|
+
* string array; corresponding entries are submitted in array order.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
16
33
|
export interface LtSendTxBatchRequest {
|
|
17
34
|
tx_types: string;
|
|
18
35
|
tx_infos: string;
|
|
19
36
|
}
|
|
20
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Batch submission response from Lighter. Each `tx_hash` corresponds to the
|
|
39
|
+
* transaction at the same index in the submitted batch.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
21
43
|
export interface LtSendTxBatchResponse {
|
|
22
44
|
code: number;
|
|
23
45
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../../src/types/submit.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../../src/types/submit.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,2BAA2B,CAAC,EAAE,MAAM,CAAA;IACpC,sBAAsB,CAAC,EAAE,MAAM,CAAA;CAChC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,2BAA2B,CAAC,EAAE,MAAM,CAAA;IACpC,sBAAsB,CAAC,EAAE,MAAM,CAAA;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,MAAM,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,qBAAqB,EAAE,MAAM,CAAA;CAC9B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
package/dist/types/types/ws.d.ts
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Common envelope fields on every Lighter WebSocket frame.
|
|
3
|
+
*
|
|
4
|
+
* `channel` identifies the subscribed stream when present; `type` is the
|
|
5
|
+
* subscription, update, or control-frame discriminator.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
2
9
|
export type LtWsMessage = {
|
|
3
10
|
channel?: string;
|
|
4
11
|
type: string;
|
|
5
12
|
};
|
|
6
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Lighter WebSocket keepalive frame.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
7
18
|
export type LtWsPingMessage = LtWsMessage & {
|
|
8
19
|
type: 'ping';
|
|
9
20
|
};
|
|
10
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Perpetual-market statistics pushed by Lighter's `market_stats` channels.
|
|
23
|
+
* Price, interest, volume, and funding values are decimal strings; the funding
|
|
24
|
+
* timestamp is a Unix timestamp in milliseconds.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
11
28
|
export type LtWsMarketStats = {
|
|
12
29
|
market_id: number;
|
|
13
30
|
index_price: string;
|
|
@@ -59,18 +76,32 @@ export type LtWsSpotMarketStatsAllMessage = LtWsMessage & {
|
|
|
59
76
|
type: 'subscribed/spot_market_stats' | 'update/spot_market_stats';
|
|
60
77
|
spot_market_stats?: LtWsSpotMarketStats | Record<string, LtWsSpotMarketStats>;
|
|
61
78
|
};
|
|
62
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* One bid or ask level in a Lighter order-book snapshot or delta. Price and
|
|
81
|
+
* size are decimal strings in the market's native precision.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
63
85
|
export type LtWsOrderBookLevel = {
|
|
64
86
|
price: string;
|
|
65
87
|
size: string;
|
|
66
88
|
};
|
|
67
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Lighter order-book state containing ask and bid levels. `offset`, when
|
|
91
|
+
* present, identifies the sequence offset used for stateful delta updates.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
68
95
|
export type LtWsOrderBook = {
|
|
69
96
|
asks: LtWsOrderBookLevel[];
|
|
70
97
|
bids: LtWsOrderBookLevel[];
|
|
71
98
|
offset?: number;
|
|
72
99
|
};
|
|
73
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Subscription or update frame carrying a Lighter order-book snapshot/delta.
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
74
105
|
export type LtWsOrderBookMessage = LtWsMessage & {
|
|
75
106
|
type: 'subscribed/order_book' | 'update/order_book';
|
|
76
107
|
order_book: LtWsOrderBook;
|
|
@@ -89,7 +120,11 @@ export type LtWsTrade = {
|
|
|
89
120
|
is_maker_ask: boolean;
|
|
90
121
|
timestamp: number;
|
|
91
122
|
};
|
|
92
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Subscription or update frame carrying public trades from a Lighter market.
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
93
128
|
export type LtWsTradeMessage = LtWsMessage & {
|
|
94
129
|
type: 'subscribed/trade' | 'update/trade';
|
|
95
130
|
trades?: LtWsTrade[];
|
|
@@ -118,7 +153,13 @@ export type LtWsAccountAllOrdersMessage = LtWsMessage & {
|
|
|
118
153
|
orders?: Record<string, unknown[]> | unknown[];
|
|
119
154
|
};
|
|
120
155
|
};
|
|
121
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* Authenticated account trade-history frame. Trade arrays may be flat or
|
|
158
|
+
* market-indexed depending on whether the frame is an initial snapshot or
|
|
159
|
+
* update.
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
122
163
|
export type LtWsAccountAllTradesMessage = LtWsMessage & {
|
|
123
164
|
type: 'subscribed/account_all_trades' | 'update/account_all_trades';
|
|
124
165
|
trades?: Record<string, unknown[]> | unknown[];
|
|
@@ -149,6 +190,13 @@ export type LtWsUserStatsMessage = LtWsMessage & {
|
|
|
149
190
|
};
|
|
150
191
|
};
|
|
151
192
|
};
|
|
193
|
+
/**
|
|
194
|
+
* Authenticated account-position frame. Position and funding maps are keyed
|
|
195
|
+
* by Lighter market index; the provider normalizes the payload before emitting
|
|
196
|
+
* account updates.
|
|
197
|
+
*
|
|
198
|
+
* @public
|
|
199
|
+
*/
|
|
152
200
|
export type LtWsAccountAllPositionsMessage = LtWsMessage & {
|
|
153
201
|
type: 'subscribed/account_all_positions' | 'update/account_all_positions';
|
|
154
202
|
positions?: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../src/types/ws.ts"],"names":[],"mappings":"AAYA
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../src/types/ws.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,MAAM,CAAA;IACxB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,iBAAiB,EAAE,MAAM,CAAA;IACzB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,wBAAwB,EAAE,MAAM,CAAA;IAChC,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG;IACpD,IAAI,EAAE,yBAAyB,GAAG,qBAAqB,CAAA;IACvD,YAAY,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CACjE,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM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CAAA;SAC1B,CAAA;KACF,CAAA;CACF,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,GAAG,WAAW,GAAG;IACzD,IAAI,EAAE,kCAAkC,GAAG,8BAA8B,CAAA;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3C,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAA;CAC/C,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Asset } from '@lifi/perps-types';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Create the SDK asset descriptor for a Lighter asset identifier and display
|
|
4
|
+
* symbol. Lighter assets do not provide a package-level logo URI, so this
|
|
5
|
+
* helper leaves that field empty.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
3
9
|
export declare const lighterAsset: (id: string, displaySymbol: string) => Asset;
|
|
4
10
|
//# sourceMappingURL=lighterAsset.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lighterAsset.d.ts","sourceRoot":"","sources":["../../../src/utils/lighterAsset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG9C
|
|
1
|
+
{"version":3,"file":"lighterAsset.d.ts","sourceRoot":"","sources":["../../../src/utils/lighterAsset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG9C;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,EAAE,eAAe,MAAM,KAAG,KAK/D,CAAA"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Validate and map an SDK OHLCV interval to Lighter's resolution string.
|
|
3
|
+
* Unsupported intervals raise a validation error instead of being rounded.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
2
7
|
export declare const mapInterval: (interval: string) => string;
|
|
3
8
|
//# sourceMappingURL=ohlcvInterval.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ohlcvInterval.d.ts","sourceRoot":"","sources":["../../../src/utils/ohlcvInterval.ts"],"names":[],"mappings":"AAsBA
|
|
1
|
+
{"version":3,"file":"ohlcvInterval.d.ts","sourceRoot":"","sources":["../../../src/utils/ohlcvInterval.ts"],"names":[],"mappings":"AAsBA;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,MAAM,KAAG,MAU9C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transferMargin.d.ts","sourceRoot":"","sources":["../../../src/utils/transferMargin.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"transferMargin.d.ts","sourceRoot":"","sources":["../../../src/utils/transferMargin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,yBAAyB,EAE/B,MAAM,mBAAmB,CAAA;AAK1B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,QAAQ,GACjB,yBAAyB,GAAG,SAAS,CAWvC"}
|
|
@@ -1,49 +1,84 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Lighter wire encoding for the WASM signer:
|
|
3
|
-
*
|
|
4
|
-
* mirroring the lighter-go signer's rules.
|
|
2
|
+
* Lighter wire encoding for the WASM signer: basis-point margin fractions and
|
|
3
|
+
* order-type/time-in-force/expiry resolution mirroring lighter-go's rules.
|
|
5
4
|
*/
|
|
6
5
|
/**
|
|
7
|
-
* Lighter
|
|
8
|
-
*
|
|
6
|
+
* Convert Lighter's initial-margin fraction to the largest whole-number
|
|
7
|
+
* leverage exposed by the provider.
|
|
8
|
+
*
|
|
9
|
+
* Lighter expresses margin fractions in basis points (`10_000` = 100%), so
|
|
10
|
+
* the conversion is `floor(10_000 / fraction)`. Non-finite or non-positive
|
|
11
|
+
* input uses the safe `1x` fallback.
|
|
12
|
+
*
|
|
13
|
+
* @param fraction - Lighter's basis-point initial-margin fraction.
|
|
14
|
+
* @returns The floored maximum leverage, or `1` for invalid input.
|
|
9
15
|
* @public
|
|
10
16
|
*/
|
|
11
17
|
export declare const marginFractionToMaxLeverage: (fraction: number) => number;
|
|
12
18
|
/**
|
|
13
|
-
* Convert leverage to
|
|
19
|
+
* Convert requested leverage to Lighter's basis-point margin fraction.
|
|
20
|
+
*
|
|
21
|
+
* The signer expects `round(10_000 / leverage)`, where the result is the
|
|
22
|
+
* margin requirement in basis points.
|
|
23
|
+
*
|
|
24
|
+
* @param leverage - Requested leverage multiplier.
|
|
25
|
+
* @returns The rounded basis-point margin fraction.
|
|
26
|
+
* @throws {PerpsError} With `ValidationError` when leverage is less than
|
|
27
|
+
* or equal to zero.
|
|
14
28
|
* @public
|
|
15
29
|
*/
|
|
16
30
|
export declare const leverageToFraction: (leverage: number) => number;
|
|
17
31
|
/**
|
|
18
|
-
* Map
|
|
32
|
+
* Map a LI.FI `OrderType` value to Lighter's integer wire type.
|
|
33
|
+
*
|
|
34
|
+
* Supported mappings are LIMIT → 0, MARKET → 1, STOP_MARKET → 2,
|
|
35
|
+
* STOP_LIMIT → 3, TAKE_PROFIT_MARKET → 4, and TAKE_PROFIT_LIMIT → 5.
|
|
36
|
+
* Omitted or unknown values fall back to LIMIT.
|
|
37
|
+
*
|
|
38
|
+
* @param type - LI.FI order type value.
|
|
39
|
+
* @returns The corresponding Lighter order-type integer.
|
|
19
40
|
* @public
|
|
20
41
|
*/
|
|
21
42
|
export declare const mapOrderTypeToInt: (type?: string) => number;
|
|
22
43
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
44
|
+
* Resolve a Lighter `time_in_force` value that is valid for an order type.
|
|
45
|
+
*
|
|
46
|
+
* Market-style orders (MARKET, STOP_MARKET, TAKE_PROFIT_MARKET) are IOC-only.
|
|
47
|
+
* Limit-style orders default to GTC when no TIF is supplied. An explicit
|
|
48
|
+
* non-IOC TIF on a market-style order raises a validation error. For
|
|
49
|
+
* limit-style orders, unknown TIF strings use the GTC fallback from
|
|
50
|
+
* {@link mapTimeInForceToInt}.
|
|
51
|
+
*
|
|
52
|
+
* @param orderTypeInt - Lighter order-type integer.
|
|
53
|
+
* @param tif - Optional LI.FI time-in-force value.
|
|
54
|
+
* @returns The validated Lighter time-in-force integer.
|
|
55
|
+
* @throws {PerpsError} With `ValidationError` for a market-style/TIF mismatch.
|
|
30
56
|
* @public
|
|
31
57
|
*/
|
|
32
58
|
export declare const resolveTimeInForce: (orderTypeInt: number, tif?: string) => number;
|
|
33
59
|
/**
|
|
34
|
-
* Map
|
|
60
|
+
* Map a LI.FI time-in-force value to Lighter's integer wire value.
|
|
61
|
+
*
|
|
62
|
+
* IOC maps to 0, GTC maps to 1, and POST_ONLY maps to 2. Omitted or unknown
|
|
63
|
+
* values fall back to GTC.
|
|
64
|
+
*
|
|
65
|
+
* @param tif - LI.FI time-in-force value.
|
|
66
|
+
* @returns The corresponding Lighter time-in-force integer.
|
|
35
67
|
* @public
|
|
36
68
|
*/
|
|
37
69
|
export declare const mapTimeInForceToInt: (tif?: string) => number;
|
|
38
70
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
71
|
+
* Select the `order_expiry` sentinel required for a regular Lighter limit
|
|
72
|
+
* order from its resolved time-in-force.
|
|
73
|
+
*
|
|
74
|
+
* IOC uses Lighter's nil expiry (`0`). Every other TIF uses
|
|
75
|
+
* `LT_DEFAULT_ORDER_EXPIRY` (`-1`), which the WASM signer expands to its
|
|
76
|
+
* canonical future expiry (`now + 28d`) as an absolute Unix-millisecond
|
|
77
|
+
* timestamp. Trigger-order expiry handling is provider-specific; see
|
|
78
|
+
* {@link LT_DEFAULT_ORDER_EXPIRY} and its call sites.
|
|
79
|
+
*
|
|
80
|
+
* @param tifInt - Lighter time-in-force integer.
|
|
81
|
+
* @returns `0` for IOC, otherwise the default-expiry sentinel.
|
|
47
82
|
* @public
|
|
48
83
|
*/
|
|
49
84
|
export declare const orderExpiryForTif: (tifInt: number) => number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireEncoding.d.ts","sourceRoot":"","sources":["../../../src/utils/wireEncoding.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wireEncoding.d.ts","sourceRoot":"","sources":["../../../src/utils/wireEncoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,GAAI,UAAU,MAAM,KAAG,MAK9D,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,KAAG,MAQrD,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,MAUjD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,GAC7B,cAAc,MAAM,EACpB,MAAM,MAAM,KACX,MAgBF,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,MAOlD,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,MAKlD,CAAA"}
|
|
@@ -69,6 +69,12 @@ export declare class LighterWsProvider extends WsProviderBase<SubState> {
|
|
|
69
69
|
* `resolveAuthToken`. `undefined` when neither is available.
|
|
70
70
|
*/
|
|
71
71
|
private authTokenResolver;
|
|
72
|
+
/**
|
|
73
|
+
* Subscribe to a live quote stream resolved through the registered Lighter
|
|
74
|
+
* market registry. Returns an unsubscribe function; quote subscription
|
|
75
|
+
* requires the provider to be constructed through `lighterWsProvider` with a
|
|
76
|
+
* bound {@link PerpsSDKClient}.
|
|
77
|
+
*/
|
|
72
78
|
subscribeQuote(params: ProviderGetQuoteParams, onQuote: QuoteListener): Promise<() => void>;
|
|
73
79
|
protected openChannel(sub: Subscription): Promise<() => void>;
|
|
74
80
|
protected onClose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LighterWsProvider.d.ts","sourceRoot":"","sources":["../../../src/websocket/LighterWsProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAKlB,cAAc,EACd,KAAK,iBAAiB,EAEvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAIV,YAAY,EACb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AA4EnC;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,wBAAwB,GAAG,CACrC,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;AAEhC,UAAU,QAAQ;IAChB,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAA;IACf,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yEAAyE;IACzE,SAAS,EAAE,OAAO,CAAA;CACnB;AAkBD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;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AAC,KAAK,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM;YA2B5B,cAAc;YAsFd,mBAAmB;YAqBnB,iBAAiB;IAK/B,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAqB1C,OAAO,CAAC,QAAQ;IAkFhB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,eAAe;IAuDvB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,sBAAsB;IAiC9B;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,iBAAiB;IAuCzB,OAAO,CAAC,eAAe;IA+BvB,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,mBAAmB;CAc5B;AAkID;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,GAC3B,UAAU,wBAAwB,KAAG,iBAEmB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/perps-sdk-provider-lighter",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Lighter provider plugin for @lifi/perps-sdk",
|
|
5
5
|
"homepage": "https://github.com/lifinance/perps-sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"big.js": "^7.0.1",
|
|
48
48
|
"viem": "^2.48.8",
|
|
49
|
-
"@lifi/perps-types": "^4.
|
|
49
|
+
"@lifi/perps-types": "^4.1.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@lifi/perps-sdk": "^6.
|
|
52
|
+
"@lifi/perps-sdk": "^6.1.0"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
package/src/constants.ts
CHANGED
|
@@ -22,6 +22,11 @@ export const LIGHTER_SPOT_CATEGORY_ID = 'spot'
|
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
24
|
export const DEFAULT_LIGHTER_REST_URL = 'https://mainnet.zklighter.elliot.ai'
|
|
25
|
+
/**
|
|
26
|
+
* Default mainnet WebSocket stream URL for Lighter.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
25
30
|
export const DEFAULT_LIGHTER_WS_URL = 'wss://mainnet.zklighter.elliot.ai/stream'
|
|
26
31
|
|
|
27
32
|
/**
|
|
@@ -85,9 +90,17 @@ export const LIGHTER_MAINNET_INSTANCE: LighterInstanceConfig = {
|
|
|
85
90
|
*/
|
|
86
91
|
export const LIGHTER_RH_PROVIDER_KEY = 'lighter-rh'
|
|
87
92
|
|
|
88
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Default REST base URL for the Lighter Robinhood deployment.
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
89
98
|
export const LIGHTER_RH_REST_URL = 'https://api.rh.lighter.xyz'
|
|
90
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Default WebSocket URL for the Lighter Robinhood deployment.
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
91
104
|
export const LIGHTER_RH_WS_URL = 'wss://api.rh.lighter.xyz/stream'
|
|
92
105
|
|
|
93
106
|
/**
|
|
@@ -11,7 +11,13 @@ import { LIGHTER_PROVIDER_KEY } from '../constants.js'
|
|
|
11
11
|
|
|
12
12
|
const STORAGE_PREFIX = 'lifi-perps-lighter-key'
|
|
13
13
|
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Persisted Lighter API-key material associated with one L2 account.
|
|
16
|
+
* `apiKeyPrivateKey` is a Lighter-native signing key, not an Ethereum key;
|
|
17
|
+
* `apiKeyIndex` identifies its registered on-chain slot.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
15
21
|
export interface LighterApiKey {
|
|
16
22
|
/** Lighter account index, looked up once via accountsByL1Address. */
|
|
17
23
|
accountIndex: number
|
|
@@ -41,12 +47,23 @@ const isLighterApiKey = (value: unknown): value is LighterApiKey => {
|
|
|
41
47
|
)
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Storage-backed cache for Lighter API keys. Records are namespaced by L1
|
|
52
|
+
* address and provider instance so multiple Lighter deployments can share one
|
|
53
|
+
* {@link StorageAdapter} without collisions.
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
45
57
|
export class LighterKeyStore {
|
|
46
58
|
private readonly storage: StorageAdapter
|
|
47
59
|
private readonly cache = new Map<string, LighterApiKey>()
|
|
48
60
|
private providerKey: LighterProviderKey
|
|
49
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Create a key store using `storage` and the optional provider namespace.
|
|
64
|
+
* The default provider key preserves the package's standard Lighter storage
|
|
65
|
+
* namespace.
|
|
66
|
+
*/
|
|
50
67
|
constructor(
|
|
51
68
|
storage: StorageAdapter,
|
|
52
69
|
providerKey: LighterProviderKey = LIGHTER_PROVIDER_KEY
|
|
@@ -74,6 +91,10 @@ export class LighterKeyStore {
|
|
|
74
91
|
: `${STORAGE_PREFIX}:${this.providerKey}:${lower}`
|
|
75
92
|
}
|
|
76
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Load the API key for an L1 address, or `null` when no valid record exists.
|
|
96
|
+
* Invalid persisted records are ignored by the storage validation boundary.
|
|
97
|
+
*/
|
|
77
98
|
async get(address: Address): Promise<LighterApiKey | null> {
|
|
78
99
|
const key = this.storageKey(address)
|
|
79
100
|
const cached = this.cache.get(key)
|
|
@@ -88,12 +109,20 @@ export class LighterKeyStore {
|
|
|
88
109
|
return parsed
|
|
89
110
|
}
|
|
90
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Persist an API key for an L1 address, replacing any existing record under
|
|
114
|
+
* that provider namespace.
|
|
115
|
+
*/
|
|
91
116
|
async set(address: Address, value: LighterApiKey): Promise<void> {
|
|
92
117
|
const key = this.storageKey(address)
|
|
93
118
|
this.cache.set(key, value)
|
|
94
119
|
await this.storage.set(key, JSON.stringify(value))
|
|
95
120
|
}
|
|
96
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Remove the persisted API key for an L1 address and clear its in-memory
|
|
124
|
+
* cache entry.
|
|
125
|
+
*/
|
|
97
126
|
async remove(address: Address): Promise<void> {
|
|
98
127
|
const key = this.storageKey(address)
|
|
99
128
|
this.cache.delete(key)
|
|
@@ -69,7 +69,13 @@ export type LighterTokenFetcher = (params: {
|
|
|
69
69
|
scopes: string
|
|
70
70
|
}) => Promise<LighterCreateTokenResponse>
|
|
71
71
|
|
|
72
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Dependencies and overrides for {@link LighterReadOnlyTokenManager}.
|
|
74
|
+
* Storage and token-fetching defaults target the browser's local storage and
|
|
75
|
+
* Lighter's mainnet REST API.
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
73
79
|
export interface LighterReadOnlyTokenManagerOptions {
|
|
74
80
|
storage?: StorageAdapter
|
|
75
81
|
/**
|
|
@@ -87,13 +93,23 @@ export interface LighterReadOnlyTokenManagerOptions {
|
|
|
87
93
|
now?: () => number
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Input to the read-only-token approval flow. Extends the shared approval
|
|
98
|
+
* parameters with the L1 address whose wallet authorizes token creation.
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
91
102
|
export interface ApproveReadOnlyTokenInputs extends ApproveReadOnlyTokenParams {
|
|
92
103
|
/** L1 wallet address that signs the create message. */
|
|
93
104
|
address: Address
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Result of approving or creating a Lighter read-only token. `config` is the
|
|
109
|
+
* account-state projection callers can persist alongside the token.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
97
113
|
export interface ApproveReadOnlyTokenResult {
|
|
98
114
|
token: LighterReadOnlyToken
|
|
99
115
|
/** Projection of the post-create Lighter account state. */
|
|
@@ -239,6 +255,10 @@ export class LighterReadOnlyTokenManager {
|
|
|
239
255
|
await this.storage.set(key, JSON.stringify(token))
|
|
240
256
|
}
|
|
241
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Remove the stored token for an `(address, accountIndex)` pair and clear
|
|
260
|
+
* the corresponding cache entry.
|
|
261
|
+
*/
|
|
242
262
|
async remove(address: Address, accountIndex: number): Promise<void> {
|
|
243
263
|
const key = this.storageKey(address, accountIndex)
|
|
244
264
|
this.cache.delete(key)
|