pmxt-core 2.21.2 → 2.22.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/dist/exchanges/kalshi/api.d.ts +1 -1
- package/dist/exchanges/kalshi/api.js +1 -1
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/opinion/api.d.ts +412 -0
- package/dist/exchanges/opinion/api.js +477 -0
- package/dist/exchanges/opinion/auth.d.ts +15 -0
- package/dist/exchanges/opinion/auth.js +107 -0
- package/dist/exchanges/opinion/config.d.ts +5 -0
- package/dist/exchanges/opinion/config.js +9 -0
- package/dist/exchanges/opinion/errors.d.ts +8 -0
- package/dist/exchanges/opinion/errors.js +39 -0
- package/dist/exchanges/opinion/fetcher.d.ts +203 -0
- package/dist/exchanges/opinion/fetcher.js +300 -0
- package/dist/exchanges/opinion/index.d.ts +69 -0
- package/dist/exchanges/opinion/index.js +406 -0
- package/dist/exchanges/opinion/normalizer.d.ts +19 -0
- package/dist/exchanges/opinion/normalizer.js +231 -0
- package/dist/exchanges/opinion/utils.d.ts +23 -0
- package/dist/exchanges/opinion/utils.js +95 -0
- package/dist/exchanges/opinion/websocket.d.ts +83 -0
- package/dist/exchanges/opinion/websocket.js +365 -0
- package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
- package/dist/exchanges/polymarket/api-clob.js +1 -1
- package/dist/exchanges/polymarket/api-data.d.ts +1 -1
- package/dist/exchanges/polymarket/api-data.js +1 -1
- package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
- package/dist/exchanges/polymarket/api-gamma.js +1 -1
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -2
- package/dist/server/app.js +8 -0
- package/package.json +5 -4
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.opinionApiSpec = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
|
|
6
|
+
* Generated at: 2026-03-22T18:41:21.666Z
|
|
7
|
+
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
|
+
*/
|
|
9
|
+
exports.opinionApiSpec = {
|
|
10
|
+
"openapi": "3.0.3",
|
|
11
|
+
"info": {
|
|
12
|
+
"title": "OPINION Prediction Market OpenAPI",
|
|
13
|
+
"version": "1.0.0"
|
|
14
|
+
},
|
|
15
|
+
"servers": [
|
|
16
|
+
{
|
|
17
|
+
"url": "https://openapi.opinion.trade/openapi"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"security": [
|
|
21
|
+
{
|
|
22
|
+
"ApiKeyAuth": []
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"tags": [
|
|
26
|
+
{
|
|
27
|
+
"name": "Market"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "Token"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "QuoteToken"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "Trade"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "Position"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "Order"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"components": {
|
|
46
|
+
"securitySchemes": {
|
|
47
|
+
"ApiKeyAuth": {
|
|
48
|
+
"type": "apiKey",
|
|
49
|
+
"in": "header",
|
|
50
|
+
"name": "apikey",
|
|
51
|
+
"description": "API key for authentication"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"paths": {
|
|
56
|
+
"/market": {
|
|
57
|
+
"get": {
|
|
58
|
+
"tags": [
|
|
59
|
+
"Market"
|
|
60
|
+
],
|
|
61
|
+
"summary": "Get market list",
|
|
62
|
+
"operationId": "getMarketList",
|
|
63
|
+
"parameters": [
|
|
64
|
+
{
|
|
65
|
+
"name": "page",
|
|
66
|
+
"in": "query",
|
|
67
|
+
"schema": {
|
|
68
|
+
"type": "integer",
|
|
69
|
+
"default": 1,
|
|
70
|
+
"minimum": 1
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "limit",
|
|
75
|
+
"in": "query",
|
|
76
|
+
"schema": {
|
|
77
|
+
"type": "integer",
|
|
78
|
+
"default": 10,
|
|
79
|
+
"maximum": 20
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "status",
|
|
84
|
+
"in": "query",
|
|
85
|
+
"schema": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"enum": [
|
|
88
|
+
"activated",
|
|
89
|
+
"resolved"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "marketType",
|
|
95
|
+
"in": "query",
|
|
96
|
+
"schema": {
|
|
97
|
+
"type": "integer",
|
|
98
|
+
"default": 0,
|
|
99
|
+
"enum": [
|
|
100
|
+
0,
|
|
101
|
+
1,
|
|
102
|
+
2
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "sortBy",
|
|
108
|
+
"in": "query",
|
|
109
|
+
"schema": {
|
|
110
|
+
"type": "integer",
|
|
111
|
+
"enum": [
|
|
112
|
+
1,
|
|
113
|
+
2,
|
|
114
|
+
3,
|
|
115
|
+
4,
|
|
116
|
+
5,
|
|
117
|
+
6,
|
|
118
|
+
7,
|
|
119
|
+
8
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "chainId",
|
|
125
|
+
"in": "query",
|
|
126
|
+
"schema": {
|
|
127
|
+
"type": "string"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"/market/{marketId}": {
|
|
134
|
+
"get": {
|
|
135
|
+
"tags": [
|
|
136
|
+
"Market"
|
|
137
|
+
],
|
|
138
|
+
"summary": "Get binary market detail",
|
|
139
|
+
"operationId": "getBinaryMarketDetail",
|
|
140
|
+
"parameters": [
|
|
141
|
+
{
|
|
142
|
+
"name": "marketId",
|
|
143
|
+
"in": "path",
|
|
144
|
+
"required": true,
|
|
145
|
+
"schema": {
|
|
146
|
+
"type": "integer",
|
|
147
|
+
"format": "int64"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"/market/categorical/{marketId}": {
|
|
154
|
+
"get": {
|
|
155
|
+
"tags": [
|
|
156
|
+
"Market"
|
|
157
|
+
],
|
|
158
|
+
"summary": "Get categorical market detail",
|
|
159
|
+
"operationId": "getCategoricalMarketDetail",
|
|
160
|
+
"parameters": [
|
|
161
|
+
{
|
|
162
|
+
"name": "marketId",
|
|
163
|
+
"in": "path",
|
|
164
|
+
"required": true,
|
|
165
|
+
"schema": {
|
|
166
|
+
"type": "integer",
|
|
167
|
+
"format": "int64"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"/token/latest-price": {
|
|
174
|
+
"get": {
|
|
175
|
+
"tags": [
|
|
176
|
+
"Token"
|
|
177
|
+
],
|
|
178
|
+
"summary": "Get latest price",
|
|
179
|
+
"operationId": "getLatestPrice",
|
|
180
|
+
"parameters": [
|
|
181
|
+
{
|
|
182
|
+
"name": "token_id",
|
|
183
|
+
"in": "query",
|
|
184
|
+
"required": true,
|
|
185
|
+
"schema": {
|
|
186
|
+
"type": "string"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"/token/orderbook": {
|
|
193
|
+
"get": {
|
|
194
|
+
"tags": [
|
|
195
|
+
"Token"
|
|
196
|
+
],
|
|
197
|
+
"summary": "Get orderbook",
|
|
198
|
+
"operationId": "getOrderbook",
|
|
199
|
+
"parameters": [
|
|
200
|
+
{
|
|
201
|
+
"name": "token_id",
|
|
202
|
+
"in": "query",
|
|
203
|
+
"required": true,
|
|
204
|
+
"schema": {
|
|
205
|
+
"type": "string"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"/token/price-history": {
|
|
212
|
+
"get": {
|
|
213
|
+
"tags": [
|
|
214
|
+
"Token"
|
|
215
|
+
],
|
|
216
|
+
"summary": "Get price history",
|
|
217
|
+
"operationId": "getPriceHistory",
|
|
218
|
+
"parameters": [
|
|
219
|
+
{
|
|
220
|
+
"name": "token_id",
|
|
221
|
+
"in": "query",
|
|
222
|
+
"required": true,
|
|
223
|
+
"schema": {
|
|
224
|
+
"type": "string"
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"name": "interval",
|
|
229
|
+
"in": "query",
|
|
230
|
+
"schema": {
|
|
231
|
+
"type": "string",
|
|
232
|
+
"default": "1d",
|
|
233
|
+
"enum": [
|
|
234
|
+
"1m",
|
|
235
|
+
"1h",
|
|
236
|
+
"1d",
|
|
237
|
+
"1w",
|
|
238
|
+
"max"
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "start_at",
|
|
244
|
+
"in": "query",
|
|
245
|
+
"schema": {
|
|
246
|
+
"type": "integer",
|
|
247
|
+
"format": "int64"
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"name": "end_at",
|
|
252
|
+
"in": "query",
|
|
253
|
+
"schema": {
|
|
254
|
+
"type": "integer",
|
|
255
|
+
"format": "int64"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
"/quoteToken": {
|
|
262
|
+
"get": {
|
|
263
|
+
"tags": [
|
|
264
|
+
"QuoteToken"
|
|
265
|
+
],
|
|
266
|
+
"summary": "Get quote token list",
|
|
267
|
+
"operationId": "getQuoteTokenList",
|
|
268
|
+
"parameters": [
|
|
269
|
+
{
|
|
270
|
+
"name": "page",
|
|
271
|
+
"in": "query",
|
|
272
|
+
"schema": {
|
|
273
|
+
"type": "integer",
|
|
274
|
+
"default": 1
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "limit",
|
|
279
|
+
"in": "query",
|
|
280
|
+
"schema": {
|
|
281
|
+
"type": "integer",
|
|
282
|
+
"default": 10
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"name": "quoteTokenName",
|
|
287
|
+
"in": "query",
|
|
288
|
+
"schema": {
|
|
289
|
+
"type": "string"
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "chainId",
|
|
294
|
+
"in": "query",
|
|
295
|
+
"schema": {
|
|
296
|
+
"type": "string"
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
"/trade/user/{walletAddress}": {
|
|
303
|
+
"get": {
|
|
304
|
+
"tags": [
|
|
305
|
+
"Trade"
|
|
306
|
+
],
|
|
307
|
+
"summary": "Get user trades",
|
|
308
|
+
"operationId": "getUserTrades",
|
|
309
|
+
"parameters": [
|
|
310
|
+
{
|
|
311
|
+
"name": "walletAddress",
|
|
312
|
+
"in": "path",
|
|
313
|
+
"required": true,
|
|
314
|
+
"schema": {
|
|
315
|
+
"type": "string"
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"name": "page",
|
|
320
|
+
"in": "query",
|
|
321
|
+
"schema": {
|
|
322
|
+
"type": "integer",
|
|
323
|
+
"default": 1,
|
|
324
|
+
"minimum": 1
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"name": "limit",
|
|
329
|
+
"in": "query",
|
|
330
|
+
"schema": {
|
|
331
|
+
"type": "integer",
|
|
332
|
+
"default": 10,
|
|
333
|
+
"maximum": 20
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "marketId",
|
|
338
|
+
"in": "query",
|
|
339
|
+
"schema": {
|
|
340
|
+
"type": "integer",
|
|
341
|
+
"format": "int64"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"name": "chainId",
|
|
346
|
+
"in": "query",
|
|
347
|
+
"schema": {
|
|
348
|
+
"type": "string"
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
"/positions/user/{walletAddress}": {
|
|
355
|
+
"get": {
|
|
356
|
+
"tags": [
|
|
357
|
+
"Position"
|
|
358
|
+
],
|
|
359
|
+
"summary": "Get user positions",
|
|
360
|
+
"operationId": "getUserPositions",
|
|
361
|
+
"parameters": [
|
|
362
|
+
{
|
|
363
|
+
"name": "walletAddress",
|
|
364
|
+
"in": "path",
|
|
365
|
+
"required": true,
|
|
366
|
+
"schema": {
|
|
367
|
+
"type": "string"
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"name": "page",
|
|
372
|
+
"in": "query",
|
|
373
|
+
"schema": {
|
|
374
|
+
"type": "integer",
|
|
375
|
+
"default": 1,
|
|
376
|
+
"minimum": 1
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"name": "limit",
|
|
381
|
+
"in": "query",
|
|
382
|
+
"schema": {
|
|
383
|
+
"type": "integer",
|
|
384
|
+
"default": 10,
|
|
385
|
+
"maximum": 20
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"name": "marketId",
|
|
390
|
+
"in": "query",
|
|
391
|
+
"schema": {
|
|
392
|
+
"type": "integer",
|
|
393
|
+
"format": "int64"
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"name": "chainId",
|
|
398
|
+
"in": "query",
|
|
399
|
+
"schema": {
|
|
400
|
+
"type": "string"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
]
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
"/order": {
|
|
407
|
+
"get": {
|
|
408
|
+
"tags": [
|
|
409
|
+
"Order"
|
|
410
|
+
],
|
|
411
|
+
"summary": "Get orders",
|
|
412
|
+
"operationId": "getOrderList",
|
|
413
|
+
"parameters": [
|
|
414
|
+
{
|
|
415
|
+
"name": "page",
|
|
416
|
+
"in": "query",
|
|
417
|
+
"schema": {
|
|
418
|
+
"type": "integer",
|
|
419
|
+
"default": 1,
|
|
420
|
+
"minimum": 1
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
"name": "limit",
|
|
425
|
+
"in": "query",
|
|
426
|
+
"schema": {
|
|
427
|
+
"type": "integer",
|
|
428
|
+
"default": 10,
|
|
429
|
+
"maximum": 20
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"name": "marketId",
|
|
434
|
+
"in": "query",
|
|
435
|
+
"schema": {
|
|
436
|
+
"type": "integer",
|
|
437
|
+
"format": "int64"
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"name": "chainId",
|
|
442
|
+
"in": "query",
|
|
443
|
+
"schema": {
|
|
444
|
+
"type": "string"
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
"name": "status",
|
|
449
|
+
"in": "query",
|
|
450
|
+
"schema": {
|
|
451
|
+
"type": "string"
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
]
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
"/order/{orderId}": {
|
|
458
|
+
"get": {
|
|
459
|
+
"tags": [
|
|
460
|
+
"Order"
|
|
461
|
+
],
|
|
462
|
+
"summary": "Get order detail",
|
|
463
|
+
"operationId": "getOrderDetail",
|
|
464
|
+
"parameters": [
|
|
465
|
+
{
|
|
466
|
+
"name": "orderId",
|
|
467
|
+
"in": "path",
|
|
468
|
+
"required": true,
|
|
469
|
+
"schema": {
|
|
470
|
+
"type": "string"
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExchangeCredentials } from '../../BaseExchange';
|
|
2
|
+
export declare class OpinionAuth {
|
|
3
|
+
private readonly apiKey;
|
|
4
|
+
private readonly privateKey?;
|
|
5
|
+
private readonly rpcUrl;
|
|
6
|
+
private readonly multiSigAddress?;
|
|
7
|
+
private clobClient?;
|
|
8
|
+
private tradingEnabled;
|
|
9
|
+
constructor(credentials: ExchangeCredentials);
|
|
10
|
+
getHeaders(): Record<string, string>;
|
|
11
|
+
getWsUrl(): string;
|
|
12
|
+
hasTradeCredentials(): boolean;
|
|
13
|
+
getClobClient(): Promise<any>;
|
|
14
|
+
ensureTradingEnabled(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.OpinionAuth = void 0;
|
|
37
|
+
const config_1 = require("./config");
|
|
38
|
+
let sdkPromise;
|
|
39
|
+
function loadSdk() {
|
|
40
|
+
if (!sdkPromise) {
|
|
41
|
+
sdkPromise = Promise.resolve().then(() => __importStar(require('@opinion-labs/opinion-clob-sdk')));
|
|
42
|
+
}
|
|
43
|
+
return sdkPromise;
|
|
44
|
+
}
|
|
45
|
+
class OpinionAuth {
|
|
46
|
+
apiKey;
|
|
47
|
+
privateKey;
|
|
48
|
+
rpcUrl;
|
|
49
|
+
multiSigAddress;
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
clobClient;
|
|
52
|
+
tradingEnabled = false;
|
|
53
|
+
constructor(credentials) {
|
|
54
|
+
if (!credentials.apiKey) {
|
|
55
|
+
throw new Error('Opinion Trade requires an apiKey for authentication');
|
|
56
|
+
}
|
|
57
|
+
this.apiKey = credentials.apiKey;
|
|
58
|
+
this.privateKey = credentials.privateKey;
|
|
59
|
+
this.rpcUrl = config_1.OPINION_DEFAULT_RPC_URL;
|
|
60
|
+
this.multiSigAddress = credentials.funderAddress;
|
|
61
|
+
}
|
|
62
|
+
getHeaders() {
|
|
63
|
+
return {
|
|
64
|
+
'apikey': this.apiKey,
|
|
65
|
+
'Content-Type': 'application/json',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
getWsUrl() {
|
|
69
|
+
return `wss://ws.opinion.trade?apikey=${encodeURIComponent(this.apiKey)}`;
|
|
70
|
+
}
|
|
71
|
+
hasTradeCredentials() {
|
|
72
|
+
return !!this.privateKey;
|
|
73
|
+
}
|
|
74
|
+
async getClobClient() {
|
|
75
|
+
if (this.clobClient) {
|
|
76
|
+
return this.clobClient;
|
|
77
|
+
}
|
|
78
|
+
if (!this.privateKey) {
|
|
79
|
+
throw new Error('Trading requires a privateKey. ' +
|
|
80
|
+
'Initialize OpinionExchange with credentials including privateKey.');
|
|
81
|
+
}
|
|
82
|
+
if (!this.multiSigAddress) {
|
|
83
|
+
throw new Error('Trading requires a funderAddress (multiSigAddress). ' +
|
|
84
|
+
'Initialize OpinionExchange with credentials including funderAddress.');
|
|
85
|
+
}
|
|
86
|
+
const sdk = await loadSdk();
|
|
87
|
+
const config = {
|
|
88
|
+
host: sdk.DEFAULT_API_HOST,
|
|
89
|
+
apiKey: this.apiKey,
|
|
90
|
+
chainId: config_1.OPINION_CHAIN_ID,
|
|
91
|
+
rpcUrl: this.rpcUrl,
|
|
92
|
+
privateKey: this.privateKey,
|
|
93
|
+
multiSigAddress: this.multiSigAddress,
|
|
94
|
+
};
|
|
95
|
+
this.clobClient = new sdk.Client(config);
|
|
96
|
+
return this.clobClient;
|
|
97
|
+
}
|
|
98
|
+
async ensureTradingEnabled() {
|
|
99
|
+
if (this.tradingEnabled) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const client = await this.getClobClient();
|
|
103
|
+
await client.enableTrading();
|
|
104
|
+
this.tradingEnabled = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.OpinionAuth = OpinionAuth;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const OPINION_API_URL = "https://openapi.opinion.trade/openapi";
|
|
2
|
+
export declare const OPINION_WS_URL = "wss://ws.opinion.trade";
|
|
3
|
+
export declare const OPINION_MAX_PAGE_SIZE = 20;
|
|
4
|
+
export declare const OPINION_CHAIN_ID = 56;
|
|
5
|
+
export declare const OPINION_DEFAULT_RPC_URL = "https://bsc-dataseed.binance.org";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OPINION_DEFAULT_RPC_URL = exports.OPINION_CHAIN_ID = exports.OPINION_MAX_PAGE_SIZE = exports.OPINION_WS_URL = exports.OPINION_API_URL = void 0;
|
|
4
|
+
exports.OPINION_API_URL = "https://openapi.opinion.trade/openapi";
|
|
5
|
+
exports.OPINION_WS_URL = "wss://ws.opinion.trade";
|
|
6
|
+
exports.OPINION_MAX_PAGE_SIZE = 20;
|
|
7
|
+
// CLOB SDK chain constants
|
|
8
|
+
exports.OPINION_CHAIN_ID = 56;
|
|
9
|
+
exports.OPINION_DEFAULT_RPC_URL = 'https://bsc-dataseed.binance.org';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ErrorMapper } from '../../utils/error-mapper';
|
|
2
|
+
import { BadRequest } from '../../errors';
|
|
3
|
+
export declare class OpinionErrorMapper extends ErrorMapper {
|
|
4
|
+
constructor();
|
|
5
|
+
protected extractErrorMessage(error: any): string;
|
|
6
|
+
protected mapBadRequestError(message: string, data: any): BadRequest;
|
|
7
|
+
}
|
|
8
|
+
export declare const opinionErrorMapper: OpinionErrorMapper;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.opinionErrorMapper = exports.OpinionErrorMapper = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const error_mapper_1 = require("../../utils/error-mapper");
|
|
9
|
+
const errors_1 = require("../../errors");
|
|
10
|
+
class OpinionErrorMapper extends error_mapper_1.ErrorMapper {
|
|
11
|
+
constructor() {
|
|
12
|
+
super('Opinion');
|
|
13
|
+
}
|
|
14
|
+
extractErrorMessage(error) {
|
|
15
|
+
if (axios_1.default.isAxiosError(error) && error.response?.data) {
|
|
16
|
+
const data = error.response.data;
|
|
17
|
+
// OpenAPI format uses "msg", SDK format uses "errmsg"
|
|
18
|
+
const message = data.msg || data.errmsg;
|
|
19
|
+
if (message) {
|
|
20
|
+
return `[${error.response.status}] ${message}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return super.extractErrorMessage(error);
|
|
24
|
+
}
|
|
25
|
+
mapBadRequestError(message, data) {
|
|
26
|
+
if (data && typeof data === 'object') {
|
|
27
|
+
// OpenAPI format: { code: number, msg: string }
|
|
28
|
+
// SDK format: { errno: number, errmsg: string }
|
|
29
|
+
const errorCode = data.code ?? data.errno;
|
|
30
|
+
const errorMsg = data.msg || data.errmsg || message;
|
|
31
|
+
if (errorCode !== undefined && errorCode !== 0) {
|
|
32
|
+
return new errors_1.BadRequest(`Opinion API error (code ${errorCode}): ${errorMsg}`, this.exchangeName);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return super.mapBadRequestError(message, data);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.OpinionErrorMapper = OpinionErrorMapper;
|
|
39
|
+
exports.opinionErrorMapper = new OpinionErrorMapper();
|