@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
|
@@ -21,7 +21,13 @@ import {
|
|
|
21
21
|
// is process-global inside the Go runtime; we track which keys are already
|
|
22
22
|
// initialized so CreateClient runs once per keypair.
|
|
23
23
|
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Credentials needed to initialize the Lighter WASM client for one account
|
|
26
|
+
* and API-key slot. The private key is Lighter-native signing material; the
|
|
27
|
+
* account and slot indexes select the registered L2 key.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
25
31
|
export interface LighterSignerContext {
|
|
26
32
|
/** Lighter-native private key (from GenerateAPIKey, NOT an Ethereum key). */
|
|
27
33
|
apiKeyPrivateKey: string
|
|
@@ -31,7 +37,12 @@ export interface LighterSignerContext {
|
|
|
31
37
|
accountIndex: number
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for {@link LighterSigner}, including optional WASM asset
|
|
42
|
+
* overrides and the Lighter REST base URL and signing chain ID.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
35
46
|
export interface LighterSignerConfig extends LoadLighterWasmOptions {
|
|
36
47
|
/** Lighter REST API base URL. */
|
|
37
48
|
apiUrl?: string
|
|
@@ -39,26 +50,47 @@ export interface LighterSignerConfig extends LoadLighterWasmOptions {
|
|
|
39
50
|
chainId?: number
|
|
40
51
|
}
|
|
41
52
|
|
|
42
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Signed Lighter transaction blob returned by the WASM signer. `txType`,
|
|
55
|
+
* `txInfo`, and `txHash` are passed to the venue's transaction submission
|
|
56
|
+
* endpoint; `txInfo` is an encoded transaction payload.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
43
60
|
export interface LighterSignedBlob {
|
|
44
61
|
txType: number
|
|
45
62
|
txInfo: string
|
|
46
63
|
txHash: string
|
|
47
64
|
}
|
|
48
65
|
|
|
49
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Signed REGISTER_API_KEY (ChangePubKey) result, including the EIP-191 message
|
|
68
|
+
* that the user's L1 wallet must countersign before submission.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
50
72
|
export interface ChangePubKeyResult extends LighterSignedBlob {
|
|
51
73
|
/** EIP-191 message the L1 Ethereum wallet must sign to authorize the key rotation. */
|
|
52
74
|
messageToSign: string
|
|
53
75
|
}
|
|
54
76
|
|
|
55
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Signed APPROVE_INTEGRATOR result, including the EIP-191 L1 message required
|
|
79
|
+
* to authorize the integrator approval.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
56
83
|
export interface ApproveIntegratorResult extends LighterSignedBlob {
|
|
57
84
|
/** EIP-191 `L2ApproveIntegrator` L1 body the user's wallet must countersign to authorize the integrator approval. */
|
|
58
85
|
messageToSign: string
|
|
59
86
|
}
|
|
60
87
|
|
|
61
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Lighter-native API keypair generated by the WASM signer. These keys are
|
|
90
|
+
* distinct from an Ethereum wallet keypair.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
62
94
|
export interface ApiKeyPair {
|
|
63
95
|
publicKey: string
|
|
64
96
|
privateKey: string
|
|
@@ -94,7 +126,13 @@ const LIGHTER_ROUTE_BY_DEX: Record<string, number> = {
|
|
|
94
126
|
spot: LT_ROUTE_SPOT,
|
|
95
127
|
}
|
|
96
128
|
|
|
97
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* WASM-backed signer for Lighter API-key transactions and L1-countersigned
|
|
131
|
+
* hybrid flows. The instance memoizes WASM initialization and registered
|
|
132
|
+
* `(apiKeyIndex, accountIndex)` clients.
|
|
133
|
+
*
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
98
136
|
export class LighterSigner {
|
|
99
137
|
private readonly apiUrl: string
|
|
100
138
|
private readonly chainId: number
|
|
@@ -112,6 +150,10 @@ export class LighterSigner {
|
|
|
112
150
|
}
|
|
113
151
|
}
|
|
114
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Load and cache the Go WASM signer exports. Most signing methods initialize
|
|
155
|
+
* lazily, so callers only need this method when they want an explicit warm-up.
|
|
156
|
+
*/
|
|
115
157
|
async initialize(): Promise<void> {
|
|
116
158
|
if (!this.wasm) {
|
|
117
159
|
this.wasm = await loadLighterWasm(this.loaderOptions)
|
|
@@ -5,7 +5,13 @@ import type { LighterSigner } from './LighterSigner.js'
|
|
|
5
5
|
const DEFAULT_LIFETIME_SECONDS = 60 * 60
|
|
6
6
|
const DEFAULT_THRESHOLD_SECONDS = 30 * 86_400
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Inputs for creating a standard Lighter auth token. The signer and API-key
|
|
10
|
+
* fields identify the registered Lighter account; `lifetimeSeconds` is capped
|
|
11
|
+
* by Lighter's token policy and defaults to one hour.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
9
15
|
export interface CreateAuthTokenInputs {
|
|
10
16
|
signer: LighterSigner
|
|
11
17
|
apiKey: Pick<
|
|
@@ -17,7 +23,7 @@ export interface CreateAuthTokenInputs {
|
|
|
17
23
|
* Defaults to 1 hour, matching the previous `PerpsClient` behaviour.
|
|
18
24
|
*/
|
|
19
25
|
lifetimeSeconds?: number
|
|
20
|
-
/** Optional clock injection for tests. */
|
|
26
|
+
/** Optional clock injection for deterministic token-expiry tests. */
|
|
21
27
|
now?: () => number
|
|
22
28
|
}
|
|
23
29
|
|
|
@@ -48,7 +48,13 @@ function defaultAssetUrl(filename: string): URL {
|
|
|
48
48
|
return new URL(`../../wasm/${filename}`, currentModuleUrl())
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Overrides for locating the Lighter Go WASM binary and its runtime loader.
|
|
53
|
+
* Supplying explicit URLs or source is useful when a bundler does not preserve
|
|
54
|
+
* the package's relative asset layout.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
52
58
|
export interface LoadLighterWasmOptions {
|
|
53
59
|
/** Override URL for the `.wasm` binary (browser: fetch; Node: fs). */
|
|
54
60
|
wasmBinaryUrl?: string | URL
|
|
@@ -68,7 +74,13 @@ export interface LoadLighterWasmOptions {
|
|
|
68
74
|
wasmExecJsSource?: string
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Function table installed by the Lighter Go WASM runtime. Methods mirror the
|
|
79
|
+
* venue signer ABI and return a result containing either signed transaction
|
|
80
|
+
* fields or an error; positional argument contracts are documented per method.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
72
84
|
export interface LighterWasmExports {
|
|
73
85
|
GenerateAPIKey: () => {
|
|
74
86
|
publicKey?: string
|
package/src/types/account.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
// Account / balance shapes returned by Lighter's `/api/v1/account` and
|
|
2
2
|
// `/api/v1/accountLimits` endpoints.
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Per-market position row returned by Lighter's account endpoints.
|
|
6
|
+
*
|
|
7
|
+
* Amounts and prices are decimal strings in the market's native precision.
|
|
8
|
+
* `position` is the size magnitude as a decimal string. `sign` is the
|
|
9
|
+
* authoritative side indicator: values greater than or equal to zero represent
|
|
10
|
+
* long positions and values less than zero represent short positions.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
5
14
|
export type LtAccountPosition = {
|
|
6
15
|
market_id: number
|
|
7
16
|
/** Present on REST `/api/v1/account` rows; WS position frames may omit it. */
|
|
@@ -23,7 +32,14 @@ export type LtAccountPosition = {
|
|
|
23
32
|
total_discount: string
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Collateral asset row returned in a Lighter account response. `balance` and
|
|
37
|
+
* `locked_balance` are decimal strings in the asset's native precision.
|
|
38
|
+
* `margin_mode`, when present, is Lighter's cross-margin flag: `0` disables
|
|
39
|
+
* margin use for the asset and `1` enables it.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
27
43
|
export type LtAccountAsset = {
|
|
28
44
|
symbol: string
|
|
29
45
|
asset_id: number
|
|
@@ -46,7 +62,13 @@ export type LtAccountAsset = {
|
|
|
46
62
|
*/
|
|
47
63
|
export type LtDetailedAccountPosition = LtAccountPosition
|
|
48
64
|
|
|
49
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Integrator approval and fee caps attached to a detailed account.
|
|
67
|
+
* Fee values are Lighter's integer fee ticks; `approval_expiry` is a Unix
|
|
68
|
+
* timestamp.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
50
72
|
export interface LtApprovedIntegrator {
|
|
51
73
|
account_index: number
|
|
52
74
|
name: string
|
|
@@ -57,7 +79,14 @@ export interface LtApprovedIntegrator {
|
|
|
57
79
|
approval_expiry: number
|
|
58
80
|
}
|
|
59
81
|
|
|
60
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Detailed account payload returned by Lighter's account endpoint, including
|
|
84
|
+
* account metadata, aggregate collateral values, assets, and positions.
|
|
85
|
+
* Balance and value fields are decimal strings in the relevant asset/quote
|
|
86
|
+
* precision; numeric status and mode fields are Lighter wire enums.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
61
90
|
export interface LtDetailedAccount {
|
|
62
91
|
code: number
|
|
63
92
|
account_type: number
|
|
@@ -85,14 +114,25 @@ export interface LtDetailedAccount {
|
|
|
85
114
|
approved_integrators?: LtApprovedIntegrator[]
|
|
86
115
|
}
|
|
87
116
|
|
|
88
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Response envelope for a detailed-account lookup. `code` is Lighter's
|
|
119
|
+
* endpoint result code and `total` is the number of account rows returned.
|
|
120
|
+
*
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
89
123
|
export interface LtDetailedAccountsResponse {
|
|
90
124
|
code: number
|
|
91
125
|
total: number
|
|
92
126
|
accounts: LtDetailedAccount[]
|
|
93
127
|
}
|
|
94
128
|
|
|
95
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Account-level limits and fee information returned by Lighter's
|
|
131
|
+
* `/api/v1/accountLimits` endpoint. Amount fields are decimal strings;
|
|
132
|
+
* `current_*_fee_tick` values use Lighter's integer fee-tick scale.
|
|
133
|
+
*
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
96
136
|
export interface LtAccountLimits {
|
|
97
137
|
code: number
|
|
98
138
|
message?: string
|
|
@@ -107,7 +147,13 @@ export interface LtAccountLimits {
|
|
|
107
147
|
effective_lit_stakes: string
|
|
108
148
|
}
|
|
109
149
|
|
|
110
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* Sub-account summary returned by Lighter's `accountsByL1Address` endpoint.
|
|
152
|
+
* Balance and collateral values are decimal strings; status and trading-mode
|
|
153
|
+
* fields are Lighter wire values.
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
111
157
|
export interface LtSubAccount {
|
|
112
158
|
code: number
|
|
113
159
|
account_type: number
|
|
@@ -124,7 +170,11 @@ export interface LtSubAccount {
|
|
|
124
170
|
account_trading_mode: number
|
|
125
171
|
}
|
|
126
172
|
|
|
127
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Response envelope for an L1-address sub-account lookup.
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
128
178
|
export interface LtAccountsByL1AddressResponse {
|
|
129
179
|
code: number
|
|
130
180
|
l1_address: string
|
package/src/types/action.ts
CHANGED
|
@@ -109,47 +109,101 @@ export type LtChangePubKeyWasmParams = {
|
|
|
109
109
|
nonce: number
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Lighter wire value for limit orders.
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
113
116
|
export const LT_ORDER_TYPE_LIMIT = 0
|
|
114
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Lighter wire value for market orders.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
115
121
|
export const LT_ORDER_TYPE_MARKET = 1
|
|
116
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* Lighter wire value for stop-loss market orders.
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
117
126
|
export const LT_ORDER_TYPE_STOP_LOSS = 2
|
|
118
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Lighter wire value for stop-loss limit orders.
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
119
131
|
export const LT_ORDER_TYPE_STOP_LOSS_LIMIT = 3
|
|
120
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Lighter wire value for take-profit market orders.
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
121
136
|
export const LT_ORDER_TYPE_TAKE_PROFIT = 4
|
|
122
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Lighter wire value for take-profit limit orders.
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
123
141
|
export const LT_ORDER_TYPE_TAKE_PROFIT_LIMIT = 5
|
|
124
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Lighter wire value for TWAP orders.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
125
146
|
export const LT_ORDER_TYPE_TWAP = 6
|
|
126
147
|
|
|
127
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Lighter wire value for immediate-or-cancel time in force.
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
128
152
|
export const LT_TIME_IN_FORCE_IOC = 0
|
|
129
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Lighter wire value for good-til-cancelled time in force.
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
130
157
|
export const LT_TIME_IN_FORCE_GTC = 1
|
|
131
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Lighter wire value for post-only time in force.
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
132
162
|
export const LT_TIME_IN_FORCE_POST_ONLY = 2
|
|
133
163
|
|
|
134
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Lighter cross-margin mode value.
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
135
168
|
export const LT_MARGIN_MODE_CROSS = 0
|
|
136
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* Lighter isolated-margin mode value.
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
137
173
|
export const LT_MARGIN_MODE_ISOLATED = 1
|
|
138
174
|
|
|
139
|
-
/**
|
|
175
|
+
/**
|
|
176
|
+
* Lighter margin-direction value for removing margin.
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
140
179
|
export const LT_MARGIN_DIRECTION_REMOVE = 0
|
|
141
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* Lighter margin-direction value for adding margin.
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
142
184
|
export const LT_MARGIN_DIRECTION_ADD = 1
|
|
143
185
|
|
|
144
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* Lighter route selector for perpetuals transfers.
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
145
190
|
export const LT_ROUTE_PERP = 0
|
|
146
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Lighter route selector for spot transfers.
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
147
195
|
export const LT_ROUTE_SPOT = 1
|
|
148
196
|
|
|
149
|
-
/**
|
|
197
|
+
/**
|
|
198
|
+
* Lighter spot USDC asset id.
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
150
201
|
export const LT_ASSET_ID_USDC = 3
|
|
151
202
|
|
|
152
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Wire sentinel for an omitted trigger price.
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
153
207
|
export const LT_NIL_TRIGGER_PRICE = 0
|
|
154
208
|
/**
|
|
155
209
|
* Sentinel the lighter-go WASM signer translates to "default 28-day expiry
|
package/src/types/activity.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// Activity history shapes returned by Lighter's REST API
|
|
2
2
|
// (deposits, withdrawals, funding payments, liquidations, transfers).
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Deposit history row returned by Lighter. `amount` is a decimal asset amount,
|
|
6
|
+
* `timestamp` is Unix milliseconds, and `l1_tx_hash` identifies the settlement
|
|
7
|
+
* transaction on the L1 bridge.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
5
11
|
export interface LtDepositHistoryItem {
|
|
6
12
|
id: string
|
|
7
13
|
asset_id: number
|
|
@@ -11,14 +17,25 @@ export interface LtDepositHistoryItem {
|
|
|
11
17
|
l1_tx_hash: string
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Paginated deposit-history response from Lighter. `cursor` is an opaque
|
|
22
|
+
* continuation value for the next page.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
15
26
|
export interface LtDepositHistoryResponse {
|
|
16
27
|
code: number
|
|
17
28
|
deposits: LtDepositHistoryItem[]
|
|
18
29
|
cursor?: string
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Withdrawal history row returned by Lighter. `amount` is a decimal asset
|
|
34
|
+
* amount, `timestamp` is Unix milliseconds, and `l1_tx_hash` identifies the
|
|
35
|
+
* associated L1 transaction.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
22
39
|
export interface LtWithdrawHistoryItem {
|
|
23
40
|
id: string
|
|
24
41
|
asset_id: number
|
|
@@ -29,14 +46,25 @@ export interface LtWithdrawHistoryItem {
|
|
|
29
46
|
l1_tx_hash: string
|
|
30
47
|
}
|
|
31
48
|
|
|
32
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Paginated withdrawal-history response from Lighter. `cursor` is an opaque
|
|
51
|
+
* continuation value for the next page.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
33
55
|
export interface LtWithdrawHistoryResponse {
|
|
34
56
|
code: number
|
|
35
57
|
withdraws: LtWithdrawHistoryItem[]
|
|
36
58
|
cursor?: string
|
|
37
59
|
}
|
|
38
60
|
|
|
39
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Funding-payment history row for one perpetual position. `change`,
|
|
63
|
+
* `position_size`, and `rate` are decimal strings; `timestamp` is a Unix
|
|
64
|
+
* timestamp in seconds and `position_side` is Lighter's side literal.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
40
68
|
export interface LtPositionFunding {
|
|
41
69
|
timestamp: number
|
|
42
70
|
market_id: number
|
|
@@ -47,14 +75,24 @@ export interface LtPositionFunding {
|
|
|
47
75
|
position_side: string
|
|
48
76
|
}
|
|
49
77
|
|
|
50
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Paginated position-funding response from Lighter. `next_cursor` is an opaque
|
|
80
|
+
* continuation value for the next page.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
51
84
|
export interface LtPositionFundingsResponse {
|
|
52
85
|
code: number
|
|
53
86
|
position_fundings: LtPositionFunding[]
|
|
54
87
|
next_cursor?: string
|
|
55
88
|
}
|
|
56
89
|
|
|
57
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Liquidation event row returned by Lighter. `executed_at` is a Unix timestamp
|
|
92
|
+
* in milliseconds.
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
58
96
|
export interface LtLiquidation {
|
|
59
97
|
id: number
|
|
60
98
|
market_id: number
|
|
@@ -62,14 +100,25 @@ export interface LtLiquidation {
|
|
|
62
100
|
executed_at: number
|
|
63
101
|
}
|
|
64
102
|
|
|
65
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Paginated liquidation-history response from Lighter. `next_cursor` is an
|
|
105
|
+
* opaque continuation value for the next page.
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
66
109
|
export interface LtLiquidationsResponse {
|
|
67
110
|
code: number
|
|
68
111
|
liquidations: LtLiquidation[]
|
|
69
112
|
next_cursor?: string
|
|
70
113
|
}
|
|
71
114
|
|
|
72
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Asset transfer-history row returned by Lighter. Amounts and fees are decimal
|
|
117
|
+
* strings in the asset's precision; route literals identify the source and
|
|
118
|
+
* destination account ledger (`spot` or `perps`).
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
73
122
|
export interface LtTransfer {
|
|
74
123
|
id: string
|
|
75
124
|
asset_id: number
|
|
@@ -86,7 +135,12 @@ export interface LtTransfer {
|
|
|
86
135
|
tx_hash: string
|
|
87
136
|
}
|
|
88
137
|
|
|
89
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Paginated transfer-history response from Lighter. `cursor` is an opaque
|
|
140
|
+
* continuation value for the next page.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
90
144
|
export interface LtTransferHistoryResponse {
|
|
91
145
|
code: number
|
|
92
146
|
transfers: LtTransfer[]
|
package/src/types/asset.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// Market / asset / orderbook metadata returned by Lighter's REST API.
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Venue configuration nested in a Lighter perpetual-market descriptor.
|
|
5
|
+
* Numeric fields are Lighter wire mode values; booleans indicate whether the
|
|
6
|
+
* market is currently restricted or hidden.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
4
10
|
export interface LtMarketConfig {
|
|
5
11
|
market_margin_mode: number
|
|
6
12
|
insurance_fund_account_index: number
|
|
@@ -11,7 +17,14 @@ export interface LtMarketConfig {
|
|
|
11
17
|
hidden: boolean
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Perpetual-market metadata returned by Lighter's order-book-details endpoint.
|
|
22
|
+
* Decimal strings use the market's native asset/quote precision. Decimal-count
|
|
23
|
+
* fields describe supported and canonical order precision; fee and margin
|
|
24
|
+
* fractions use Lighter's wire representation.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
15
28
|
export interface LtPerpsOrderBookDetail {
|
|
16
29
|
symbol: string
|
|
17
30
|
market_id: number
|
|
@@ -48,7 +61,13 @@ export interface LtPerpsOrderBookDetail {
|
|
|
48
61
|
strategy_index: number
|
|
49
62
|
}
|
|
50
63
|
|
|
51
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Spot-market metadata returned by Lighter's order-book-details endpoint.
|
|
66
|
+
* Decimal strings use the market's native asset/quote precision; decimal-count
|
|
67
|
+
* fields describe supported order precision.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
52
71
|
export interface LtSpotOrderBookDetail {
|
|
53
72
|
symbol: string
|
|
54
73
|
market_id: number
|
|
@@ -77,14 +96,23 @@ export interface LtSpotOrderBookDetail {
|
|
|
77
96
|
daily_chart: Record<string, unknown>
|
|
78
97
|
}
|
|
79
98
|
|
|
80
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Response envelope containing both perpetual and spot market descriptors.
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
81
104
|
export interface LtOrderBookDetailsResponse {
|
|
82
105
|
code: number
|
|
83
106
|
order_book_details: LtPerpsOrderBookDetail[]
|
|
84
107
|
spot_order_book_details: LtSpotOrderBookDetail[]
|
|
85
108
|
}
|
|
86
109
|
|
|
87
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Token metadata returned by Lighter's token-list endpoint. `market` identifies
|
|
112
|
+
* whether the token is associated with a perpetual or spot market.
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
88
116
|
export interface LtToken {
|
|
89
117
|
symbol: string
|
|
90
118
|
name: string
|
|
@@ -93,13 +121,22 @@ export interface LtToken {
|
|
|
93
121
|
market: 'PERPS' | 'SPOT'
|
|
94
122
|
}
|
|
95
123
|
|
|
96
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* Response envelope for Lighter's token-list endpoint.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
97
129
|
export interface LtTokenListResponse {
|
|
98
130
|
code: number
|
|
99
131
|
tokens: LtToken[]
|
|
100
132
|
}
|
|
101
133
|
|
|
102
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Asset metadata returned by Lighter. `l1_decimals` is the token precision on
|
|
136
|
+
* L1; `decimals` is the Lighter ledger precision.
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
103
140
|
export interface LtAssetDetail {
|
|
104
141
|
asset_id: number
|
|
105
142
|
symbol: string
|
|
@@ -108,13 +145,22 @@ export interface LtAssetDetail {
|
|
|
108
145
|
l1_address: string
|
|
109
146
|
}
|
|
110
147
|
|
|
111
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Response envelope for Lighter's asset-details endpoint.
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
112
153
|
export interface LtAssetDetailsResponse {
|
|
113
154
|
code: number
|
|
114
155
|
asset_details: LtAssetDetail[]
|
|
115
156
|
}
|
|
116
157
|
|
|
117
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* OHLCV candle returned by Lighter. `t` is the candle timestamp in Unix
|
|
160
|
+
* milliseconds; `o`, `h`, `l`, and `c` are prices and `v` is volume.
|
|
161
|
+
*
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
118
164
|
export interface LtCandle {
|
|
119
165
|
t: number
|
|
120
166
|
o: number
|
|
@@ -124,14 +170,24 @@ export interface LtCandle {
|
|
|
124
170
|
v: number
|
|
125
171
|
}
|
|
126
172
|
|
|
127
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Response envelope for a Lighter candle query. `r` is the endpoint's result
|
|
175
|
+
* value and `c` contains the returned candles.
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
128
179
|
export interface LtCandlesResponse {
|
|
129
180
|
code: number
|
|
130
181
|
r: string
|
|
131
182
|
c: LtCandle[]
|
|
132
183
|
}
|
|
133
184
|
|
|
134
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* Funding-rate snapshot for one Lighter perpetual market. `rate` is the
|
|
187
|
+
* venue-provided funding-rate value for the named exchange and market.
|
|
188
|
+
*
|
|
189
|
+
* @public
|
|
190
|
+
*/
|
|
135
191
|
export interface LtFundingRate {
|
|
136
192
|
market_id: number
|
|
137
193
|
exchange: string
|
|
@@ -139,7 +195,11 @@ export interface LtFundingRate {
|
|
|
139
195
|
rate: number
|
|
140
196
|
}
|
|
141
197
|
|
|
142
|
-
/**
|
|
198
|
+
/**
|
|
199
|
+
* Response envelope containing current funding rates by market.
|
|
200
|
+
*
|
|
201
|
+
* @public
|
|
202
|
+
*/
|
|
143
203
|
export interface LtFundingRatesResponse {
|
|
144
204
|
code: number
|
|
145
205
|
funding_rates: LtFundingRate[]
|