zklighter-perps 1.0.301 → 1.0.303

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/README.md CHANGED
@@ -1,86 +1,50 @@
1
- # zklighter-perps-ts
1
+ # zklighter-perps
2
2
 
3
- Auto-generated TypeScript SDK for the Lighter Perps API, published to npm as
3
+ TypeScript client for the Lighter Perps REST API, published to npm as
4
4
  [`zklighter-perps`](https://www.npmjs.com/package/zklighter-perps).
5
5
 
6
- The SDK source (`index.ts`, `runtime.ts`, `apis/`, `models/`) is **generated** by
7
- the [OpenAPI Generator](https://openapi-generator.tech) from the backend's
8
- OpenAPI spec. Do not edit the generated files by hand they are overwritten on
9
- every regeneration. The package ships raw `.ts` (`"main": "index.ts"`), so
10
- consumers compile it themselves.
6
+ The client is generated from the backend's OpenAPI spec with
7
+ [OpenAPI Generator](https://openapi-generator.tech) (`typescript-fetch`). It
8
+ ships raw `.ts` (`"main": "index.ts"`), so your bundler or `tsc` compiles it
9
+ along with your own code.
11
10
 
12
- ## Generation pipeline (CircleCI)
11
+ ## Install
13
12
 
14
- Defined in [`.circleci/config.yml`](.circleci/config.yml). The `update_ts_sdk`
15
- workflow (manually triggered) runs three jobs in sequence:
16
-
17
- 1. **`update_openapi`** — clones `zklighter-perps`, runs `goctl-swagger` to emit
18
- the raw `openapi.json`, and persists it. This job no longer transforms the
19
- spec; it only generates and persists it.
20
- 2. **`openapi_postprocess`** — runs
21
- [`.circleci/openapi_postprocess.py`](.circleci/openapi_postprocess.py), the
22
- **single source of truth** for all spec fixups (see below).
23
- 3. **`update_ts_sdk`** — runs the OpenAPI Generator on the post-processed spec,
24
- bumps the package version, and opens a PR.
25
-
26
- The `update_npm_package` workflow runs on `main`:
13
+ ```bash
14
+ npm install zklighter-perps
15
+ ```
27
16
 
28
- - **`typecheck`** — `npm install && npm run typecheck` (`tsc --noEmit` using
29
- [`tsconfig.json`](tsconfig.json)). Runs on every branch, including the
30
- timestamped branches opened by `update_ts_sdk`, so a regenerated SDK that
31
- would fail to compile in a consumer (e.g. `perps-fe`) is caught on its PR.
32
- - **`update_npm_package`** — publishes to npm (requires `typecheck` to pass;
33
- `main` only).
34
- - **`publish_prerelease`** — on non-`main` branches with an open PR, publishes
35
- a prerelease version (`0.<PR>.0-<actor>.<sha>.<branch>`, npm dist-tag =
36
- branch name) and posts/updates a PR comment with the exact version to drop
37
- into a consumer's `package.json`, mirroring the prerelease flow in
38
- `zklighter-react-store`.
17
+ ## Usage
39
18
 
40
- ## OpenAPI post-processing
19
+ ```ts
20
+ import { Configuration, OrderApi } from 'zklighter-perps'
41
21
 
42
- The spec emitted by `goctl-swagger` has quirks that either break the OpenAPI
43
- Generator or produce an awkward SDK, so we post-process it before generation.
44
- All of this lives in **one place** — `.circleci/openapi_postprocess.py`.
45
- (Historically some of these fixes were inline `jq`/`sed` commands in the
46
- `update_openapi` job; they have been consolidated into the script so the logic
47
- is in a single, testable file.)
22
+ const orderApi = new OrderApi(
23
+ new Configuration({ basePath: 'https://mainnet.zklighter.elliot.ai' }),
24
+ )
48
25
 
49
- Why each transform exists:
26
+ const orderBooks = await orderApi.orderBooks()
27
+ ```
50
28
 
51
- 1. **Drop internal endpoints/definitions** (`/api/v1/feedback`,
52
- `/api/v1/ws_status`, `/stream`, `/api/v1/permission`, `ReqSendFeedback`)
53
- not part of the public SDK surface.
54
- 2. **Strip empty-string keys** the generator emits `""` keys the OpenAPI
55
- Generator cannot process.
56
- 3. **Mirror `summary` into `description`** — preserves the original
57
- human-readable text as the generated doc comment before `summary` is
58
- overwritten in step 8.
59
- 4. **Seed `summary` from `operationId`** — normalizes naming before step 8.
60
- 5. **Add a documented `400` response** referencing `ResultCode` to every
61
- operation, so the SDK models the standard error shape.
62
- 6. **Model the `types` parameter as a byte array** (`array` of `uint8`) instead
63
- of the non-standard scalar the spec declares.
64
- 7. **Remove placeholder `"-"` enum/array values** that aren't real values.
65
- 8. **Derive stable, path-based `operationId`/`summary`** (e.g.
66
- `/api/v1/account` → `account`) so generated method names are predictable.
67
- 9. **Inline non-standard `int16`/`float64`/map `$ref`s** (`int16`, `float64`,
68
- `mapint16string`, `mapstringfloat64`) — these are not standard OpenAPI and
69
- make the generator emit broken model references.
70
- 10. **Move array-level `enum` into `items`** — correct placement for array
71
- schemas.
72
- 11. **Make the `transfer/history` `type` param an array** of enum strings.
73
- 12. **Trim over-eager `required` fields** — the backend marks fields required
74
- that are actually optional in responses; we relax them so deserialization
75
- doesn't reject valid payloads.
29
+ Every API group has a class in [`apis/`](apis) (`AccountApi`, `OrderApi`,
30
+ `TransactionApi`, ...) and every request/response type lives in
31
+ [`models/`](models). `basePath` defaults to mainnet; pass the testnet URL to
32
+ target testnet. Endpoints that need authentication take an `auth` parameter.
76
33
 
77
- ## Local development
34
+ ## Development
78
35
 
79
36
  ```bash
80
- npm install # installs TypeScript (the only dependency)
81
- npm run typecheck # same check CI runs: tsc --noEmit
37
+ npm install # also wires the git hooks (.githooks)
38
+ npm run typecheck # tsc --noEmit, the same check CI runs
39
+ npm run scan:secrets
82
40
  ```
83
41
 
84
- To test the post-processing script against a spec locally, place an
85
- `openapi.json` next to the script and run `python3 openapi_postprocess.py`
86
- (it reads/writes `./openapi.json`).
42
+ `index.ts`, `runtime.ts`, `apis/` and `models/` are generated. Do not edit
43
+ them by hand; they are overwritten on the next regeneration. Regeneration,
44
+ spec post-processing and npm publishing all run in CircleCI and are documented
45
+ in [`.circleci/README.md`](.circleci/README.md).
46
+
47
+ A pre-commit hook scans staged files for secrets, and `npm publish` runs the
48
+ same scan over the whole package before uploading. Both use
49
+ [secretlint](https://github.com/secretlint/secretlint) with the recommended
50
+ preset; exclusions go in `.secretlintignore`.
@@ -31,6 +31,12 @@ export interface OrderBook {
31
31
  * @memberof OrderBook
32
32
  */
33
33
  market_id: number;
34
+ /**
35
+ * internal only: the reusable tree slot backing this market; never serialized, users only know market_id (the public market index)
36
+ * @type {number}
37
+ * @memberof OrderBook
38
+ */
39
+ marketSlotId: number;
34
40
  /**
35
41
  *
36
42
  * @type {string}
@@ -161,6 +167,7 @@ export type OrderBookStatusEnum = typeof OrderBookStatusEnum[keyof typeof OrderB
161
167
  export function instanceOfOrderBook(value: object): value is OrderBook {
162
168
  if (!('symbol' in value) || value['symbol'] === undefined) return false;
163
169
  if (!('market_id' in value) || value['market_id'] === undefined) return false;
170
+ if (!('marketSlotId' in value) || value['marketSlotId'] === undefined) return false;
164
171
  if (!('market_type' in value) || value['market_type'] === undefined) return false;
165
172
  if (!('base_asset_id' in value) || value['base_asset_id'] === undefined) return false;
166
173
  if (!('quote_asset_id' in value) || value['quote_asset_id'] === undefined) return false;
@@ -193,6 +200,7 @@ export function OrderBookFromJSONTyped(json: any, ignoreDiscriminator: boolean):
193
200
 
194
201
  'symbol': json['symbol'],
195
202
  'market_id': json['market_id'],
203
+ 'marketSlotId': json['marketSlotId'],
196
204
  'market_type': json['market_type'],
197
205
  'base_asset_id': json['base_asset_id'],
198
206
  'quote_asset_id': json['quote_asset_id'],
@@ -221,6 +229,7 @@ export function OrderBookToJSON(value?: OrderBook | null): any {
221
229
 
222
230
  'symbol': value['symbol'],
223
231
  'market_id': value['market_id'],
232
+ 'marketSlotId': value['marketSlotId'],
224
233
  'market_type': value['market_type'],
225
234
  'base_asset_id': value['base_asset_id'],
226
235
  'quote_asset_id': value['quote_asset_id'],
@@ -38,6 +38,12 @@ export interface PerpsOrderBookDetail {
38
38
  * @memberof PerpsOrderBookDetail
39
39
  */
40
40
  market_id: number;
41
+ /**
42
+ * internal only: the reusable tree slot backing this market; never serialized, users only know market_id (the public market index)
43
+ * @type {number}
44
+ * @memberof PerpsOrderBookDetail
45
+ */
46
+ marketSlotId: number;
41
47
  /**
42
48
  *
43
49
  * @type {string}
@@ -318,6 +324,7 @@ export type PerpsOrderBookDetailStatusEnum = typeof PerpsOrderBookDetailStatusEn
318
324
  export function instanceOfPerpsOrderBookDetail(value: object): value is PerpsOrderBookDetail {
319
325
  if (!('symbol' in value) || value['symbol'] === undefined) return false;
320
326
  if (!('market_id' in value) || value['market_id'] === undefined) return false;
327
+ if (!('marketSlotId' in value) || value['marketSlotId'] === undefined) return false;
321
328
  if (!('market_type' in value) || value['market_type'] === undefined) return false;
322
329
  if (!('base_asset_id' in value) || value['base_asset_id'] === undefined) return false;
323
330
  if (!('quote_asset_id' in value) || value['quote_asset_id'] === undefined) return false;
@@ -375,6 +382,7 @@ export function PerpsOrderBookDetailFromJSONTyped(json: any, ignoreDiscriminator
375
382
 
376
383
  'symbol': json['symbol'],
377
384
  'market_id': json['market_id'],
385
+ 'marketSlotId': json['marketSlotId'],
378
386
  'market_type': json['market_type'],
379
387
  'base_asset_id': json['base_asset_id'],
380
388
  'quote_asset_id': json['quote_asset_id'],
@@ -428,6 +436,7 @@ export function PerpsOrderBookDetailToJSON(value?: PerpsOrderBookDetail | null):
428
436
 
429
437
  'symbol': value['symbol'],
430
438
  'market_id': value['market_id'],
439
+ 'marketSlotId': value['marketSlotId'],
431
440
  'market_type': value['market_type'],
432
441
  'base_asset_id': value['base_asset_id'],
433
442
  'quote_asset_id': value['quote_asset_id'],
@@ -73,7 +73,7 @@ export interface RFQEntry {
73
73
  * @type {string}
74
74
  * @memberof RFQEntry
75
75
  */
76
- status: string;
76
+ status: RFQEntryStatusEnum;
77
77
  /**
78
78
  *
79
79
  * @type {RFQMetadata}
@@ -100,6 +100,18 @@ export interface RFQEntry {
100
100
  updated_at: number;
101
101
  }
102
102
 
103
+
104
+ /**
105
+ * @export
106
+ */
107
+ export const RFQEntryStatusEnum = {
108
+ Opened: 'opened',
109
+ OrderCreated: 'order_created',
110
+ Closed: 'closed'
111
+ } as const;
112
+ export type RFQEntryStatusEnum = typeof RFQEntryStatusEnum[keyof typeof RFQEntryStatusEnum];
113
+
114
+
103
115
  /**
104
116
  * Check if a given object implements the RFQEntry interface.
105
117
  */
@@ -85,7 +85,7 @@ export interface RespCreateRFQ {
85
85
  * @type {string}
86
86
  * @memberof RespCreateRFQ
87
87
  */
88
- status: string;
88
+ status: RespCreateRFQStatusEnum;
89
89
  /**
90
90
  *
91
91
  * @type {RFQMetadata}
@@ -112,6 +112,18 @@ export interface RespCreateRFQ {
112
112
  updated_at: number;
113
113
  }
114
114
 
115
+
116
+ /**
117
+ * @export
118
+ */
119
+ export const RespCreateRFQStatusEnum = {
120
+ Opened: 'opened',
121
+ OrderCreated: 'order_created',
122
+ Closed: 'closed'
123
+ } as const;
124
+ export type RespCreateRFQStatusEnum = typeof RespCreateRFQStatusEnum[keyof typeof RespCreateRFQStatusEnum];
125
+
126
+
115
127
  /**
116
128
  * Check if a given object implements the RespCreateRFQ interface.
117
129
  */
@@ -85,7 +85,7 @@ export interface RespGetRFQ {
85
85
  * @type {string}
86
86
  * @memberof RespGetRFQ
87
87
  */
88
- status: string;
88
+ status: RespGetRFQStatusEnum;
89
89
  /**
90
90
  *
91
91
  * @type {RFQMetadata}
@@ -112,6 +112,18 @@ export interface RespGetRFQ {
112
112
  updated_at: number;
113
113
  }
114
114
 
115
+
116
+ /**
117
+ * @export
118
+ */
119
+ export const RespGetRFQStatusEnum = {
120
+ Opened: 'opened',
121
+ OrderCreated: 'order_created',
122
+ Closed: 'closed'
123
+ } as const;
124
+ export type RespGetRFQStatusEnum = typeof RespGetRFQStatusEnum[keyof typeof RespGetRFQStatusEnum];
125
+
126
+
115
127
  /**
116
128
  * Check if a given object implements the RespGetRFQ interface.
117
129
  */
@@ -85,7 +85,7 @@ export interface RespRespondToRFQ {
85
85
  * @type {string}
86
86
  * @memberof RespRespondToRFQ
87
87
  */
88
- status: string;
88
+ status: RespRespondToRFQStatusEnum;
89
89
  /**
90
90
  *
91
91
  * @type {RFQMetadata}
@@ -112,6 +112,18 @@ export interface RespRespondToRFQ {
112
112
  updated_at: number;
113
113
  }
114
114
 
115
+
116
+ /**
117
+ * @export
118
+ */
119
+ export const RespRespondToRFQStatusEnum = {
120
+ Opened: 'opened',
121
+ OrderCreated: 'order_created',
122
+ Closed: 'closed'
123
+ } as const;
124
+ export type RespRespondToRFQStatusEnum = typeof RespRespondToRFQStatusEnum[keyof typeof RespRespondToRFQStatusEnum];
125
+
126
+
115
127
  /**
116
128
  * Check if a given object implements the RespRespondToRFQ interface.
117
129
  */
@@ -85,7 +85,7 @@ export interface RespUpdateRFQ {
85
85
  * @type {string}
86
86
  * @memberof RespUpdateRFQ
87
87
  */
88
- status: string;
88
+ status: RespUpdateRFQStatusEnum;
89
89
  /**
90
90
  *
91
91
  * @type {RFQMetadata}
@@ -112,6 +112,18 @@ export interface RespUpdateRFQ {
112
112
  updated_at: number;
113
113
  }
114
114
 
115
+
116
+ /**
117
+ * @export
118
+ */
119
+ export const RespUpdateRFQStatusEnum = {
120
+ Opened: 'opened',
121
+ OrderCreated: 'order_created',
122
+ Closed: 'closed'
123
+ } as const;
124
+ export type RespUpdateRFQStatusEnum = typeof RespUpdateRFQStatusEnum[keyof typeof RespUpdateRFQStatusEnum];
125
+
126
+
115
127
  /**
116
128
  * Check if a given object implements the RespUpdateRFQ interface.
117
129
  */
@@ -31,6 +31,12 @@ export interface SpotOrderBookDetail {
31
31
  * @memberof SpotOrderBookDetail
32
32
  */
33
33
  market_id: number;
34
+ /**
35
+ * internal only: the reusable tree slot backing this market; never serialized, users only know market_id (the public market index)
36
+ * @type {number}
37
+ * @memberof SpotOrderBookDetail
38
+ */
39
+ marketSlotId: number;
34
40
  /**
35
41
  *
36
42
  * @type {string}
@@ -221,6 +227,7 @@ export type SpotOrderBookDetailStatusEnum = typeof SpotOrderBookDetailStatusEnum
221
227
  export function instanceOfSpotOrderBookDetail(value: object): value is SpotOrderBookDetail {
222
228
  if (!('symbol' in value) || value['symbol'] === undefined) return false;
223
229
  if (!('market_id' in value) || value['market_id'] === undefined) return false;
230
+ if (!('marketSlotId' in value) || value['marketSlotId'] === undefined) return false;
224
231
  if (!('market_type' in value) || value['market_type'] === undefined) return false;
225
232
  if (!('base_asset_id' in value) || value['base_asset_id'] === undefined) return false;
226
233
  if (!('quote_asset_id' in value) || value['quote_asset_id'] === undefined) return false;
@@ -263,6 +270,7 @@ export function SpotOrderBookDetailFromJSONTyped(json: any, ignoreDiscriminator:
263
270
 
264
271
  'symbol': json['symbol'],
265
272
  'market_id': json['market_id'],
273
+ 'marketSlotId': json['marketSlotId'],
266
274
  'market_type': json['market_type'],
267
275
  'base_asset_id': json['base_asset_id'],
268
276
  'quote_asset_id': json['quote_asset_id'],
@@ -301,6 +309,7 @@ export function SpotOrderBookDetailToJSON(value?: SpotOrderBookDetail | null): a
301
309
 
302
310
  'symbol': value['symbol'],
303
311
  'market_id': value['market_id'],
312
+ 'marketSlotId': value['marketSlotId'],
304
313
  'market_type': value['market_type'],
305
314
  'base_asset_id': value['base_asset_id'],
306
315
  'quote_asset_id': value['quote_asset_id'],