@luxfi/dex 1.2.1 → 2.0.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.
Files changed (74) hide show
  1. package/dist/client/clob.d.ts +52 -0
  2. package/dist/client/clob.d.ts.map +1 -0
  3. package/dist/client/clob.js +196 -0
  4. package/dist/client/index.d.ts +7 -0
  5. package/dist/client/index.d.ts.map +1 -0
  6. package/dist/client/index.js +6 -0
  7. package/dist/client/types.d.ts +126 -0
  8. package/dist/client/types.d.ts.map +1 -0
  9. package/dist/client/types.js +5 -0
  10. package/dist/hooks/index.d.ts +22 -0
  11. package/dist/hooks/index.d.ts.map +1 -0
  12. package/dist/hooks/index.js +25 -0
  13. package/dist/hooks/use-lxbook.d.ts +95 -0
  14. package/dist/hooks/use-lxbook.d.ts.map +1 -0
  15. package/dist/hooks/use-lxbook.js +213 -0
  16. package/dist/hooks/use-lxfeed.d.ts +111 -0
  17. package/dist/hooks/use-lxfeed.d.ts.map +1 -0
  18. package/dist/hooks/use-lxfeed.js +152 -0
  19. package/dist/hooks/use-lxvault.d.ts +137 -0
  20. package/dist/hooks/use-lxvault.d.ts.map +1 -0
  21. package/dist/hooks/use-lxvault.js +227 -0
  22. package/dist/hooks/use-quote.d.ts +18 -0
  23. package/dist/hooks/use-quote.d.ts.map +1 -0
  24. package/dist/hooks/use-quote.js +65 -0
  25. package/dist/hooks/use-swap.d.ts +17 -0
  26. package/dist/hooks/use-swap.d.ts.map +1 -0
  27. package/dist/hooks/use-swap.js +75 -0
  28. package/dist/index.d.ts +50 -115
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +72 -225
  31. package/dist/precompile/abis.d.ts +991 -0
  32. package/dist/precompile/abis.d.ts.map +1 -0
  33. package/dist/precompile/abis.js +743 -0
  34. package/dist/precompile/addresses.d.ts +129 -0
  35. package/dist/precompile/addresses.d.ts.map +1 -0
  36. package/dist/precompile/addresses.js +117 -0
  37. package/dist/precompile/index.d.ts +19 -0
  38. package/dist/precompile/index.d.ts.map +1 -0
  39. package/dist/precompile/index.js +18 -0
  40. package/dist/precompile/types.d.ts +246 -0
  41. package/dist/precompile/types.d.ts.map +1 -0
  42. package/dist/precompile/types.js +84 -0
  43. package/dist/router/index.d.ts +7 -0
  44. package/dist/router/index.d.ts.map +1 -0
  45. package/dist/router/index.js +6 -0
  46. package/dist/router/router.d.ts +58 -0
  47. package/dist/router/router.d.ts.map +1 -0
  48. package/dist/router/router.js +272 -0
  49. package/dist/router/types.d.ts +76 -0
  50. package/dist/router/types.d.ts.map +1 -0
  51. package/dist/router/types.js +1 -0
  52. package/package.json +55 -29
  53. package/src/client/clob.ts +256 -0
  54. package/src/client/index.ts +6 -0
  55. package/src/client/types.ts +148 -0
  56. package/src/hooks/index.ts +29 -0
  57. package/src/hooks/use-lxbook.ts +343 -0
  58. package/src/hooks/use-lxfeed.ts +179 -0
  59. package/src/hooks/use-lxvault.ts +318 -0
  60. package/src/hooks/use-quote.ts +92 -0
  61. package/src/hooks/use-swap.ts +103 -0
  62. package/src/index.ts +142 -309
  63. package/src/precompile/abis.ts +755 -0
  64. package/src/precompile/addresses.ts +153 -0
  65. package/src/precompile/index.ts +18 -0
  66. package/src/precompile/types.ts +295 -0
  67. package/src/router/index.ts +6 -0
  68. package/src/router/router.ts +338 -0
  69. package/src/router/types.ts +87 -0
  70. package/dist/marketData.d.ts +0 -152
  71. package/dist/marketData.d.ts.map +0 -1
  72. package/dist/marketData.js +0 -253
  73. package/src/marketData.ts +0 -351
  74. package/tsconfig.json +0 -19
@@ -0,0 +1,743 @@
1
+ /**
2
+ * DEX Precompile ABIs (LP-Aligned)
3
+ * Native Go implementation at LP-9010 to LP-9040
4
+ * Address format: 0x0000000000000000000000000000000000LPNUM
5
+ */
6
+ /**
7
+ * PoolManager ABI (0x0400)
8
+ * Singleton contract managing all pools
9
+ */
10
+ export const POOL_MANAGER_ABI = [
11
+ // Initialize a new pool
12
+ {
13
+ type: 'function',
14
+ name: 'initialize',
15
+ inputs: [
16
+ {
17
+ name: 'key',
18
+ type: 'tuple',
19
+ components: [
20
+ { name: 'currency0', type: 'address' },
21
+ { name: 'currency1', type: 'address' },
22
+ { name: 'fee', type: 'uint24' },
23
+ { name: 'tickSpacing', type: 'int24' },
24
+ { name: 'hooks', type: 'address' },
25
+ ],
26
+ },
27
+ { name: 'sqrtPriceX96', type: 'uint160' },
28
+ ],
29
+ outputs: [{ name: 'tick', type: 'int24' }],
30
+ stateMutability: 'nonpayable',
31
+ },
32
+ // Execute a swap
33
+ {
34
+ type: 'function',
35
+ name: 'swap',
36
+ inputs: [
37
+ {
38
+ name: 'key',
39
+ type: 'tuple',
40
+ components: [
41
+ { name: 'currency0', type: 'address' },
42
+ { name: 'currency1', type: 'address' },
43
+ { name: 'fee', type: 'uint24' },
44
+ { name: 'tickSpacing', type: 'int24' },
45
+ { name: 'hooks', type: 'address' },
46
+ ],
47
+ },
48
+ {
49
+ name: 'params',
50
+ type: 'tuple',
51
+ components: [
52
+ { name: 'zeroForOne', type: 'bool' },
53
+ { name: 'amountSpecified', type: 'int256' },
54
+ { name: 'sqrtPriceLimitX96', type: 'uint160' },
55
+ ],
56
+ },
57
+ { name: 'hookData', type: 'bytes' },
58
+ ],
59
+ outputs: [{ name: 'delta', type: 'int256' }],
60
+ stateMutability: 'nonpayable',
61
+ },
62
+ // Modify liquidity
63
+ {
64
+ type: 'function',
65
+ name: 'modifyLiquidity',
66
+ inputs: [
67
+ {
68
+ name: 'key',
69
+ type: 'tuple',
70
+ components: [
71
+ { name: 'currency0', type: 'address' },
72
+ { name: 'currency1', type: 'address' },
73
+ { name: 'fee', type: 'uint24' },
74
+ { name: 'tickSpacing', type: 'int24' },
75
+ { name: 'hooks', type: 'address' },
76
+ ],
77
+ },
78
+ {
79
+ name: 'params',
80
+ type: 'tuple',
81
+ components: [
82
+ { name: 'tickLower', type: 'int24' },
83
+ { name: 'tickUpper', type: 'int24' },
84
+ { name: 'liquidityDelta', type: 'int256' },
85
+ { name: 'salt', type: 'bytes32' },
86
+ ],
87
+ },
88
+ { name: 'hookData', type: 'bytes' },
89
+ ],
90
+ outputs: [
91
+ { name: 'callerDelta', type: 'int256' },
92
+ { name: 'feesAccrued', type: 'int256' },
93
+ ],
94
+ stateMutability: 'nonpayable',
95
+ },
96
+ // Settle outstanding balance
97
+ {
98
+ type: 'function',
99
+ name: 'settle',
100
+ inputs: [{ name: 'currency', type: 'address' }],
101
+ outputs: [{ name: 'amount', type: 'uint256' }],
102
+ stateMutability: 'payable',
103
+ },
104
+ // Take tokens from pool
105
+ {
106
+ type: 'function',
107
+ name: 'take',
108
+ inputs: [
109
+ { name: 'currency', type: 'address' },
110
+ { name: 'to', type: 'address' },
111
+ { name: 'amount', type: 'uint256' },
112
+ ],
113
+ outputs: [],
114
+ stateMutability: 'nonpayable',
115
+ },
116
+ // Get pool state
117
+ {
118
+ type: 'function',
119
+ name: 'getSlot0',
120
+ inputs: [
121
+ {
122
+ name: 'key',
123
+ type: 'tuple',
124
+ components: [
125
+ { name: 'currency0', type: 'address' },
126
+ { name: 'currency1', type: 'address' },
127
+ { name: 'fee', type: 'uint24' },
128
+ { name: 'tickSpacing', type: 'int24' },
129
+ { name: 'hooks', type: 'address' },
130
+ ],
131
+ },
132
+ ],
133
+ outputs: [
134
+ { name: 'sqrtPriceX96', type: 'uint160' },
135
+ { name: 'tick', type: 'int24' },
136
+ { name: 'protocolFee', type: 'uint24' },
137
+ { name: 'lpFee', type: 'uint24' },
138
+ ],
139
+ stateMutability: 'view',
140
+ },
141
+ // Get liquidity
142
+ {
143
+ type: 'function',
144
+ name: 'getLiquidity',
145
+ inputs: [
146
+ {
147
+ name: 'key',
148
+ type: 'tuple',
149
+ components: [
150
+ { name: 'currency0', type: 'address' },
151
+ { name: 'currency1', type: 'address' },
152
+ { name: 'fee', type: 'uint24' },
153
+ { name: 'tickSpacing', type: 'int24' },
154
+ { name: 'hooks', type: 'address' },
155
+ ],
156
+ },
157
+ ],
158
+ outputs: [{ name: 'liquidity', type: 'uint128' }],
159
+ stateMutability: 'view',
160
+ },
161
+ ];
162
+ /**
163
+ * SwapRouter ABI (0x0401)
164
+ * Optimized swap routing
165
+ */
166
+ export const SWAP_ROUTER_ABI = [
167
+ // Single swap (exact input)
168
+ {
169
+ type: 'function',
170
+ name: 'exactInputSingle',
171
+ inputs: [
172
+ {
173
+ name: 'params',
174
+ type: 'tuple',
175
+ components: [
176
+ {
177
+ name: 'poolKey',
178
+ type: 'tuple',
179
+ components: [
180
+ { name: 'currency0', type: 'address' },
181
+ { name: 'currency1', type: 'address' },
182
+ { name: 'fee', type: 'uint24' },
183
+ { name: 'tickSpacing', type: 'int24' },
184
+ { name: 'hooks', type: 'address' },
185
+ ],
186
+ },
187
+ { name: 'zeroForOne', type: 'bool' },
188
+ { name: 'amountIn', type: 'uint256' },
189
+ { name: 'amountOutMinimum', type: 'uint256' },
190
+ { name: 'sqrtPriceLimitX96', type: 'uint160' },
191
+ { name: 'hookData', type: 'bytes' },
192
+ ],
193
+ },
194
+ ],
195
+ outputs: [{ name: 'amountOut', type: 'uint256' }],
196
+ stateMutability: 'payable',
197
+ },
198
+ // Single swap (exact output)
199
+ {
200
+ type: 'function',
201
+ name: 'exactOutputSingle',
202
+ inputs: [
203
+ {
204
+ name: 'params',
205
+ type: 'tuple',
206
+ components: [
207
+ {
208
+ name: 'poolKey',
209
+ type: 'tuple',
210
+ components: [
211
+ { name: 'currency0', type: 'address' },
212
+ { name: 'currency1', type: 'address' },
213
+ { name: 'fee', type: 'uint24' },
214
+ { name: 'tickSpacing', type: 'int24' },
215
+ { name: 'hooks', type: 'address' },
216
+ ],
217
+ },
218
+ { name: 'zeroForOne', type: 'bool' },
219
+ { name: 'amountOut', type: 'uint256' },
220
+ { name: 'amountInMaximum', type: 'uint256' },
221
+ { name: 'sqrtPriceLimitX96', type: 'uint160' },
222
+ { name: 'hookData', type: 'bytes' },
223
+ ],
224
+ },
225
+ ],
226
+ outputs: [{ name: 'amountIn', type: 'uint256' }],
227
+ stateMutability: 'payable',
228
+ },
229
+ // Multi-hop swap
230
+ {
231
+ type: 'function',
232
+ name: 'exactInput',
233
+ inputs: [
234
+ {
235
+ name: 'params',
236
+ type: 'tuple',
237
+ components: [
238
+ { name: 'path', type: 'bytes' },
239
+ { name: 'amountIn', type: 'uint256' },
240
+ { name: 'amountOutMinimum', type: 'uint256' },
241
+ ],
242
+ },
243
+ ],
244
+ outputs: [{ name: 'amountOut', type: 'uint256' }],
245
+ stateMutability: 'payable',
246
+ },
247
+ ];
248
+ /**
249
+ * HooksRegistry ABI (0x0402)
250
+ * Registry for hook contracts
251
+ */
252
+ export const HOOKS_REGISTRY_ABI = [
253
+ {
254
+ type: 'function',
255
+ name: 'registerHook',
256
+ inputs: [
257
+ { name: 'hook', type: 'address' },
258
+ { name: 'permissions', type: 'uint256' },
259
+ ],
260
+ outputs: [],
261
+ stateMutability: 'nonpayable',
262
+ },
263
+ {
264
+ type: 'function',
265
+ name: 'getHookPermissions',
266
+ inputs: [{ name: 'hook', type: 'address' }],
267
+ outputs: [{ name: 'permissions', type: 'uint256' }],
268
+ stateMutability: 'view',
269
+ },
270
+ ];
271
+ /**
272
+ * FlashLoan ABI (0x0403)
273
+ * Flash loan facility
274
+ */
275
+ export const FLASH_LOAN_ABI = [
276
+ {
277
+ type: 'function',
278
+ name: 'flash',
279
+ inputs: [
280
+ { name: 'recipient', type: 'address' },
281
+ { name: 'currency', type: 'address' },
282
+ { name: 'amount', type: 'uint256' },
283
+ { name: 'data', type: 'bytes' },
284
+ ],
285
+ outputs: [],
286
+ stateMutability: 'nonpayable',
287
+ },
288
+ ];
289
+ // ============================================================================
290
+ // LXBook ABI (LP-9020) - CLOB Matching Engine
291
+ // ============================================================================
292
+ /**
293
+ * LXBook ABI (LP-9020)
294
+ * Permissionless orderbooks with Hyperliquid-style execute() endpoint
295
+ */
296
+ export const LX_BOOK_ABI = [
297
+ // Hyperliquid-style execute endpoint
298
+ {
299
+ type: 'function',
300
+ name: 'execute',
301
+ inputs: [
302
+ {
303
+ name: 'action',
304
+ type: 'tuple',
305
+ components: [
306
+ { name: 'actionType', type: 'uint8' },
307
+ { name: 'nonce', type: 'uint64' },
308
+ { name: 'expiresAfter', type: 'uint64' },
309
+ { name: 'data', type: 'bytes' },
310
+ ],
311
+ },
312
+ ],
313
+ outputs: [{ name: 'result', type: 'bytes' }],
314
+ stateMutability: 'nonpayable',
315
+ },
316
+ // Batch execute
317
+ {
318
+ type: 'function',
319
+ name: 'executeBatch',
320
+ inputs: [
321
+ {
322
+ name: 'actions',
323
+ type: 'tuple[]',
324
+ components: [
325
+ { name: 'actionType', type: 'uint8' },
326
+ { name: 'nonce', type: 'uint64' },
327
+ { name: 'expiresAfter', type: 'uint64' },
328
+ { name: 'data', type: 'bytes' },
329
+ ],
330
+ },
331
+ ],
332
+ outputs: [{ name: 'results', type: 'bytes[]' }],
333
+ stateMutability: 'nonpayable',
334
+ },
335
+ // Create market
336
+ {
337
+ type: 'function',
338
+ name: 'createMarket',
339
+ inputs: [
340
+ {
341
+ name: 'cfg',
342
+ type: 'tuple',
343
+ components: [
344
+ { name: 'baseAsset', type: 'bytes32' },
345
+ { name: 'quoteAsset', type: 'bytes32' },
346
+ { name: 'tickSizeX18', type: 'uint128' },
347
+ { name: 'lotSizeX18', type: 'uint128' },
348
+ { name: 'makerFeePpm', type: 'uint32' },
349
+ { name: 'takerFeePpm', type: 'uint32' },
350
+ { name: 'feedId', type: 'bytes32' },
351
+ { name: 'initialStatus', type: 'uint8' },
352
+ ],
353
+ },
354
+ ],
355
+ outputs: [{ name: 'marketId', type: 'uint32' }],
356
+ stateMutability: 'nonpayable',
357
+ },
358
+ // Get L1 (best bid/ask)
359
+ {
360
+ type: 'function',
361
+ name: 'getL1',
362
+ inputs: [{ name: 'marketId', type: 'uint32' }],
363
+ outputs: [
364
+ {
365
+ name: 'l1',
366
+ type: 'tuple',
367
+ components: [
368
+ { name: 'bestBidPxX18', type: 'uint128' },
369
+ { name: 'bestBidSzX18', type: 'uint128' },
370
+ { name: 'bestAskPxX18', type: 'uint128' },
371
+ { name: 'bestAskSzX18', type: 'uint128' },
372
+ { name: 'lastTradePxX18', type: 'uint128' },
373
+ ],
374
+ },
375
+ ],
376
+ stateMutability: 'view',
377
+ },
378
+ // Get market config
379
+ {
380
+ type: 'function',
381
+ name: 'getMarketConfig',
382
+ inputs: [{ name: 'marketId', type: 'uint32' }],
383
+ outputs: [
384
+ {
385
+ name: 'cfg',
386
+ type: 'tuple',
387
+ components: [
388
+ { name: 'baseAsset', type: 'bytes32' },
389
+ { name: 'quoteAsset', type: 'bytes32' },
390
+ { name: 'tickSizeX18', type: 'uint128' },
391
+ { name: 'lotSizeX18', type: 'uint128' },
392
+ { name: 'makerFeePpm', type: 'uint32' },
393
+ { name: 'takerFeePpm', type: 'uint32' },
394
+ { name: 'feedId', type: 'bytes32' },
395
+ { name: 'initialStatus', type: 'uint8' },
396
+ ],
397
+ },
398
+ ],
399
+ stateMutability: 'view',
400
+ },
401
+ // Get market status
402
+ {
403
+ type: 'function',
404
+ name: 'getMarketStatus',
405
+ inputs: [{ name: 'marketId', type: 'uint32' }],
406
+ outputs: [{ name: 'status', type: 'uint8' }],
407
+ stateMutability: 'view',
408
+ },
409
+ ];
410
+ // ============================================================================
411
+ // LXVault ABI (LP-9030) - Custody and Risk Engine
412
+ // ============================================================================
413
+ /**
414
+ * LXVault ABI (LP-9030)
415
+ * Balances, margin, collateral, liquidations
416
+ */
417
+ export const LX_VAULT_ABI = [
418
+ // Deposit
419
+ {
420
+ type: 'function',
421
+ name: 'deposit',
422
+ inputs: [
423
+ { name: 'token', type: 'address' },
424
+ { name: 'amount', type: 'uint128' },
425
+ { name: 'subaccountId', type: 'uint8' },
426
+ ],
427
+ outputs: [],
428
+ stateMutability: 'nonpayable',
429
+ },
430
+ // Withdraw
431
+ {
432
+ type: 'function',
433
+ name: 'withdraw',
434
+ inputs: [
435
+ { name: 'token', type: 'address' },
436
+ { name: 'amount', type: 'uint128' },
437
+ { name: 'subaccountId', type: 'uint8' },
438
+ ],
439
+ outputs: [],
440
+ stateMutability: 'nonpayable',
441
+ },
442
+ // Transfer between subaccounts
443
+ {
444
+ type: 'function',
445
+ name: 'transfer',
446
+ inputs: [
447
+ { name: 'token', type: 'address' },
448
+ { name: 'amount', type: 'uint128' },
449
+ { name: 'fromSubaccount', type: 'uint8' },
450
+ { name: 'toSubaccount', type: 'uint8' },
451
+ ],
452
+ outputs: [],
453
+ stateMutability: 'nonpayable',
454
+ },
455
+ // Get balance
456
+ {
457
+ type: 'function',
458
+ name: 'getBalance',
459
+ inputs: [
460
+ {
461
+ name: 'account',
462
+ type: 'tuple',
463
+ components: [
464
+ { name: 'main', type: 'address' },
465
+ { name: 'subaccountId', type: 'uint8' },
466
+ ],
467
+ },
468
+ { name: 'token', type: 'address' },
469
+ ],
470
+ outputs: [{ name: 'balance', type: 'uint128' }],
471
+ stateMutability: 'view',
472
+ },
473
+ // Get position
474
+ {
475
+ type: 'function',
476
+ name: 'getPosition',
477
+ inputs: [
478
+ {
479
+ name: 'account',
480
+ type: 'tuple',
481
+ components: [
482
+ { name: 'main', type: 'address' },
483
+ { name: 'subaccountId', type: 'uint8' },
484
+ ],
485
+ },
486
+ { name: 'marketId', type: 'uint32' },
487
+ ],
488
+ outputs: [
489
+ {
490
+ name: 'position',
491
+ type: 'tuple',
492
+ components: [
493
+ { name: 'marketId', type: 'uint32' },
494
+ { name: 'side', type: 'uint8' },
495
+ { name: 'sizeX18', type: 'uint128' },
496
+ { name: 'entryPxX18', type: 'uint128' },
497
+ { name: 'unrealizedPnlX18', type: 'uint128' },
498
+ { name: 'accumulatedFundingX18', type: 'int128' },
499
+ { name: 'lastFundingTime', type: 'uint64' },
500
+ ],
501
+ },
502
+ ],
503
+ stateMutability: 'view',
504
+ },
505
+ // Get margin info
506
+ {
507
+ type: 'function',
508
+ name: 'getMargin',
509
+ inputs: [
510
+ {
511
+ name: 'account',
512
+ type: 'tuple',
513
+ components: [
514
+ { name: 'main', type: 'address' },
515
+ { name: 'subaccountId', type: 'uint8' },
516
+ ],
517
+ },
518
+ ],
519
+ outputs: [
520
+ {
521
+ name: 'info',
522
+ type: 'tuple',
523
+ components: [
524
+ { name: 'totalCollateralX18', type: 'uint128' },
525
+ { name: 'usedMarginX18', type: 'uint128' },
526
+ { name: 'freeMarginX18', type: 'uint128' },
527
+ { name: 'marginRatioX18', type: 'uint128' },
528
+ { name: 'maintenanceMarginX18', type: 'uint128' },
529
+ { name: 'liquidatable', type: 'bool' },
530
+ ],
531
+ },
532
+ ],
533
+ stateMutability: 'view',
534
+ },
535
+ // Check if liquidatable
536
+ {
537
+ type: 'function',
538
+ name: 'isLiquidatable',
539
+ inputs: [
540
+ {
541
+ name: 'account',
542
+ type: 'tuple',
543
+ components: [
544
+ { name: 'main', type: 'address' },
545
+ { name: 'subaccountId', type: 'uint8' },
546
+ ],
547
+ },
548
+ ],
549
+ outputs: [
550
+ { name: 'liquidatable', type: 'bool' },
551
+ { name: 'shortfall', type: 'uint128' },
552
+ ],
553
+ stateMutability: 'view',
554
+ },
555
+ // Liquidate
556
+ {
557
+ type: 'function',
558
+ name: 'liquidate',
559
+ inputs: [
560
+ {
561
+ name: 'account',
562
+ type: 'tuple',
563
+ components: [
564
+ { name: 'main', type: 'address' },
565
+ { name: 'subaccountId', type: 'uint8' },
566
+ ],
567
+ },
568
+ { name: 'marketId', type: 'uint32' },
569
+ { name: 'sizeX18', type: 'uint128' },
570
+ ],
571
+ outputs: [
572
+ {
573
+ name: 'result',
574
+ type: 'tuple',
575
+ components: [
576
+ {
577
+ name: 'liquidated',
578
+ type: 'tuple',
579
+ components: [
580
+ { name: 'main', type: 'address' },
581
+ { name: 'subaccountId', type: 'uint8' },
582
+ ],
583
+ },
584
+ {
585
+ name: 'liquidator',
586
+ type: 'tuple',
587
+ components: [
588
+ { name: 'main', type: 'address' },
589
+ { name: 'subaccountId', type: 'uint8' },
590
+ ],
591
+ },
592
+ { name: 'marketId', type: 'uint32' },
593
+ { name: 'sizeX18', type: 'uint128' },
594
+ { name: 'priceX18', type: 'uint128' },
595
+ { name: 'penaltyX18', type: 'uint128' },
596
+ { name: 'adlTriggered', type: 'bool' },
597
+ ],
598
+ },
599
+ ],
600
+ stateMutability: 'nonpayable',
601
+ },
602
+ // Get funding rate
603
+ {
604
+ type: 'function',
605
+ name: 'getFundingRate',
606
+ inputs: [{ name: 'marketId', type: 'uint32' }],
607
+ outputs: [
608
+ { name: 'rateX18', type: 'int128' },
609
+ { name: 'nextFundingTime', type: 'uint64' },
610
+ ],
611
+ stateMutability: 'view',
612
+ },
613
+ ];
614
+ // ============================================================================
615
+ // LXFeed ABI (LP-9040) - Price Feeds
616
+ // ============================================================================
617
+ /**
618
+ * LXFeed ABI (LP-9040)
619
+ * Mark price, index price, funding calculations
620
+ */
621
+ export const LX_FEED_ABI = [
622
+ // Get mark price
623
+ {
624
+ type: 'function',
625
+ name: 'getMarkPrice',
626
+ inputs: [{ name: 'marketId', type: 'uint32' }],
627
+ outputs: [
628
+ {
629
+ name: 'mark',
630
+ type: 'tuple',
631
+ components: [
632
+ { name: 'indexPxX18', type: 'uint128' },
633
+ { name: 'markPxX18', type: 'uint128' },
634
+ { name: 'premiumX18', type: 'int128' },
635
+ { name: 'timestamp', type: 'uint64' },
636
+ ],
637
+ },
638
+ ],
639
+ stateMutability: 'view',
640
+ },
641
+ // Get index price
642
+ {
643
+ type: 'function',
644
+ name: 'getIndexPrice',
645
+ inputs: [{ name: 'marketId', type: 'uint32' }],
646
+ outputs: [
647
+ { name: 'priceX18', type: 'uint128' },
648
+ { name: 'timestamp', type: 'uint64' },
649
+ ],
650
+ stateMutability: 'view',
651
+ },
652
+ // Get funding rate
653
+ {
654
+ type: 'function',
655
+ name: 'getFundingRate',
656
+ inputs: [{ name: 'marketId', type: 'uint32' }],
657
+ outputs: [
658
+ { name: 'rateX18', type: 'int128' },
659
+ { name: 'nextFundingTime', type: 'uint64' },
660
+ ],
661
+ stateMutability: 'view',
662
+ },
663
+ // Get trigger price for order
664
+ {
665
+ type: 'function',
666
+ name: 'getTriggerPrice',
667
+ inputs: [
668
+ { name: 'marketId', type: 'uint32' },
669
+ { name: 'isBuy', type: 'bool' },
670
+ ],
671
+ outputs: [{ name: 'priceX18', type: 'uint128' }],
672
+ stateMutability: 'view',
673
+ },
674
+ ];
675
+ // ============================================================================
676
+ // LXOracle ABI (LP-9011) - Price Oracle
677
+ // ============================================================================
678
+ /**
679
+ * LXOracle ABI (LP-9011)
680
+ * Multi-source price aggregation
681
+ */
682
+ export const LX_ORACLE_ABI = [
683
+ // Get price
684
+ {
685
+ type: 'function',
686
+ name: 'getPrice',
687
+ inputs: [
688
+ { name: 'baseToken', type: 'address' },
689
+ { name: 'quoteToken', type: 'address' },
690
+ ],
691
+ outputs: [
692
+ {
693
+ name: 'price',
694
+ type: 'tuple',
695
+ components: [
696
+ { name: 'price', type: 'uint256' },
697
+ { name: 'confidence', type: 'uint256' },
698
+ { name: 'timestamp', type: 'uint256' },
699
+ { name: 'source', type: 'uint8' },
700
+ { name: 'expo', type: 'int32' },
701
+ ],
702
+ },
703
+ ],
704
+ stateMutability: 'view',
705
+ },
706
+ // Get aggregated price
707
+ {
708
+ type: 'function',
709
+ name: 'getAggregatedPrice',
710
+ inputs: [
711
+ { name: 'baseToken', type: 'address' },
712
+ { name: 'quoteToken', type: 'address' },
713
+ { name: 'maxStaleness', type: 'uint256' },
714
+ ],
715
+ outputs: [
716
+ {
717
+ name: 'aggregated',
718
+ type: 'tuple',
719
+ components: [
720
+ { name: 'price', type: 'uint256' },
721
+ { name: 'minPrice', type: 'uint256' },
722
+ { name: 'maxPrice', type: 'uint256' },
723
+ { name: 'deviation', type: 'uint256' },
724
+ { name: 'numSources', type: 'uint256' },
725
+ { name: 'timestamp', type: 'uint256' },
726
+ ],
727
+ },
728
+ ],
729
+ stateMutability: 'view',
730
+ },
731
+ // Check if price is fresh
732
+ {
733
+ type: 'function',
734
+ name: 'isPriceFresh',
735
+ inputs: [
736
+ { name: 'baseToken', type: 'address' },
737
+ { name: 'quoteToken', type: 'address' },
738
+ { name: 'maxStaleness', type: 'uint256' },
739
+ ],
740
+ outputs: [{ name: 'fresh', type: 'bool' }],
741
+ stateMutability: 'view',
742
+ },
743
+ ];