@luxfi/dex 1.3.0 → 2.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.
Files changed (37) hide show
  1. package/dist/hooks/index.d.ts +16 -1
  2. package/dist/hooks/index.d.ts.map +1 -1
  3. package/dist/hooks/index.js +20 -1
  4. package/dist/hooks/use-lxbook.d.ts +84 -0
  5. package/dist/hooks/use-lxbook.d.ts.map +1 -0
  6. package/dist/hooks/use-lxbook.js +213 -0
  7. package/dist/hooks/use-lxfeed.d.ts +42 -0
  8. package/dist/hooks/use-lxfeed.d.ts.map +1 -0
  9. package/dist/hooks/use-lxfeed.js +152 -0
  10. package/dist/hooks/use-lxvault.d.ts +75 -0
  11. package/dist/hooks/use-lxvault.d.ts.map +1 -0
  12. package/dist/hooks/use-lxvault.js +227 -0
  13. package/dist/index.d.ts +38 -21
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +57 -26
  16. package/dist/precompile/abis.d.ts +593 -2
  17. package/dist/precompile/abis.d.ts.map +1 -1
  18. package/dist/precompile/abis.js +458 -2
  19. package/dist/precompile/addresses.d.ts +89 -25
  20. package/dist/precompile/addresses.d.ts.map +1 -1
  21. package/dist/precompile/addresses.js +86 -21
  22. package/dist/precompile/index.d.ts +13 -2
  23. package/dist/precompile/index.d.ts.map +1 -1
  24. package/dist/precompile/index.js +13 -2
  25. package/dist/precompile/types.d.ts +171 -1
  26. package/dist/precompile/types.d.ts.map +1 -1
  27. package/dist/precompile/types.js +67 -0
  28. package/package.json +2 -2
  29. package/src/hooks/index.ts +24 -1
  30. package/src/hooks/use-lxbook.ts +343 -0
  31. package/src/hooks/use-lxfeed.ts +179 -0
  32. package/src/hooks/use-lxvault.ts +318 -0
  33. package/src/index.ts +92 -26
  34. package/src/precompile/abis.ts +466 -2
  35. package/src/precompile/addresses.ts +109 -28
  36. package/src/precompile/index.ts +13 -2
  37. package/src/precompile/types.ts +200 -1
@@ -1,6 +1,7 @@
1
1
  /**
2
- * DEX Precompile ABIs
3
- * Native Go implementation at 0x0400-0x0403
2
+ * DEX Precompile ABIs (LP-Aligned)
3
+ * Native Go implementation at LP-9010 to LP-9040
4
+ * Address format: 0x0000000000000000000000000000000000LPNUM
4
5
  */
5
6
 
6
7
  /**
@@ -289,3 +290,466 @@ export const FLASH_LOAN_ABI = [
289
290
  stateMutability: 'nonpayable',
290
291
  },
291
292
  ] as const
293
+
294
+ // ============================================================================
295
+ // LXBook ABI (LP-9020) - CLOB Matching Engine
296
+ // ============================================================================
297
+
298
+ /**
299
+ * LXBook ABI (LP-9020)
300
+ * Permissionless orderbooks with Hyperliquid-style execute() endpoint
301
+ */
302
+ export const LX_BOOK_ABI = [
303
+ // Hyperliquid-style execute endpoint
304
+ {
305
+ type: 'function',
306
+ name: 'execute',
307
+ inputs: [
308
+ {
309
+ name: 'action',
310
+ type: 'tuple',
311
+ components: [
312
+ { name: 'actionType', type: 'uint8' },
313
+ { name: 'nonce', type: 'uint64' },
314
+ { name: 'expiresAfter', type: 'uint64' },
315
+ { name: 'data', type: 'bytes' },
316
+ ],
317
+ },
318
+ ],
319
+ outputs: [{ name: 'result', type: 'bytes' }],
320
+ stateMutability: 'nonpayable',
321
+ },
322
+ // Batch execute
323
+ {
324
+ type: 'function',
325
+ name: 'executeBatch',
326
+ inputs: [
327
+ {
328
+ name: 'actions',
329
+ type: 'tuple[]',
330
+ components: [
331
+ { name: 'actionType', type: 'uint8' },
332
+ { name: 'nonce', type: 'uint64' },
333
+ { name: 'expiresAfter', type: 'uint64' },
334
+ { name: 'data', type: 'bytes' },
335
+ ],
336
+ },
337
+ ],
338
+ outputs: [{ name: 'results', type: 'bytes[]' }],
339
+ stateMutability: 'nonpayable',
340
+ },
341
+ // Create market
342
+ {
343
+ type: 'function',
344
+ name: 'createMarket',
345
+ inputs: [
346
+ {
347
+ name: 'cfg',
348
+ type: 'tuple',
349
+ components: [
350
+ { name: 'baseAsset', type: 'bytes32' },
351
+ { name: 'quoteAsset', type: 'bytes32' },
352
+ { name: 'tickSizeX18', type: 'uint128' },
353
+ { name: 'lotSizeX18', type: 'uint128' },
354
+ { name: 'makerFeePpm', type: 'uint32' },
355
+ { name: 'takerFeePpm', type: 'uint32' },
356
+ { name: 'feedId', type: 'bytes32' },
357
+ { name: 'initialStatus', type: 'uint8' },
358
+ ],
359
+ },
360
+ ],
361
+ outputs: [{ name: 'marketId', type: 'uint32' }],
362
+ stateMutability: 'nonpayable',
363
+ },
364
+ // Get L1 (best bid/ask)
365
+ {
366
+ type: 'function',
367
+ name: 'getL1',
368
+ inputs: [{ name: 'marketId', type: 'uint32' }],
369
+ outputs: [
370
+ {
371
+ name: 'l1',
372
+ type: 'tuple',
373
+ components: [
374
+ { name: 'bestBidPxX18', type: 'uint128' },
375
+ { name: 'bestBidSzX18', type: 'uint128' },
376
+ { name: 'bestAskPxX18', type: 'uint128' },
377
+ { name: 'bestAskSzX18', type: 'uint128' },
378
+ { name: 'lastTradePxX18', type: 'uint128' },
379
+ ],
380
+ },
381
+ ],
382
+ stateMutability: 'view',
383
+ },
384
+ // Get market config
385
+ {
386
+ type: 'function',
387
+ name: 'getMarketConfig',
388
+ inputs: [{ name: 'marketId', type: 'uint32' }],
389
+ outputs: [
390
+ {
391
+ name: 'cfg',
392
+ type: 'tuple',
393
+ components: [
394
+ { name: 'baseAsset', type: 'bytes32' },
395
+ { name: 'quoteAsset', type: 'bytes32' },
396
+ { name: 'tickSizeX18', type: 'uint128' },
397
+ { name: 'lotSizeX18', type: 'uint128' },
398
+ { name: 'makerFeePpm', type: 'uint32' },
399
+ { name: 'takerFeePpm', type: 'uint32' },
400
+ { name: 'feedId', type: 'bytes32' },
401
+ { name: 'initialStatus', type: 'uint8' },
402
+ ],
403
+ },
404
+ ],
405
+ stateMutability: 'view',
406
+ },
407
+ // Get market status
408
+ {
409
+ type: 'function',
410
+ name: 'getMarketStatus',
411
+ inputs: [{ name: 'marketId', type: 'uint32' }],
412
+ outputs: [{ name: 'status', type: 'uint8' }],
413
+ stateMutability: 'view',
414
+ },
415
+ ] as const
416
+
417
+ // ============================================================================
418
+ // LXVault ABI (LP-9030) - Custody and Risk Engine
419
+ // ============================================================================
420
+
421
+ /**
422
+ * LXVault ABI (LP-9030)
423
+ * Balances, margin, collateral, liquidations
424
+ */
425
+ export const LX_VAULT_ABI = [
426
+ // Deposit
427
+ {
428
+ type: 'function',
429
+ name: 'deposit',
430
+ inputs: [
431
+ { name: 'token', type: 'address' },
432
+ { name: 'amount', type: 'uint128' },
433
+ { name: 'subaccountId', type: 'uint8' },
434
+ ],
435
+ outputs: [],
436
+ stateMutability: 'nonpayable',
437
+ },
438
+ // Withdraw
439
+ {
440
+ type: 'function',
441
+ name: 'withdraw',
442
+ inputs: [
443
+ { name: 'token', type: 'address' },
444
+ { name: 'amount', type: 'uint128' },
445
+ { name: 'subaccountId', type: 'uint8' },
446
+ ],
447
+ outputs: [],
448
+ stateMutability: 'nonpayable',
449
+ },
450
+ // Transfer between subaccounts
451
+ {
452
+ type: 'function',
453
+ name: 'transfer',
454
+ inputs: [
455
+ { name: 'token', type: 'address' },
456
+ { name: 'amount', type: 'uint128' },
457
+ { name: 'fromSubaccount', type: 'uint8' },
458
+ { name: 'toSubaccount', type: 'uint8' },
459
+ ],
460
+ outputs: [],
461
+ stateMutability: 'nonpayable',
462
+ },
463
+ // Get balance
464
+ {
465
+ type: 'function',
466
+ name: 'getBalance',
467
+ inputs: [
468
+ {
469
+ name: 'account',
470
+ type: 'tuple',
471
+ components: [
472
+ { name: 'main', type: 'address' },
473
+ { name: 'subaccountId', type: 'uint8' },
474
+ ],
475
+ },
476
+ { name: 'token', type: 'address' },
477
+ ],
478
+ outputs: [{ name: 'balance', type: 'uint128' }],
479
+ stateMutability: 'view',
480
+ },
481
+ // Get position
482
+ {
483
+ type: 'function',
484
+ name: 'getPosition',
485
+ inputs: [
486
+ {
487
+ name: 'account',
488
+ type: 'tuple',
489
+ components: [
490
+ { name: 'main', type: 'address' },
491
+ { name: 'subaccountId', type: 'uint8' },
492
+ ],
493
+ },
494
+ { name: 'marketId', type: 'uint32' },
495
+ ],
496
+ outputs: [
497
+ {
498
+ name: 'position',
499
+ type: 'tuple',
500
+ components: [
501
+ { name: 'marketId', type: 'uint32' },
502
+ { name: 'side', type: 'uint8' },
503
+ { name: 'sizeX18', type: 'uint128' },
504
+ { name: 'entryPxX18', type: 'uint128' },
505
+ { name: 'unrealizedPnlX18', type: 'uint128' },
506
+ { name: 'accumulatedFundingX18', type: 'int128' },
507
+ { name: 'lastFundingTime', type: 'uint64' },
508
+ ],
509
+ },
510
+ ],
511
+ stateMutability: 'view',
512
+ },
513
+ // Get margin info
514
+ {
515
+ type: 'function',
516
+ name: 'getMargin',
517
+ inputs: [
518
+ {
519
+ name: 'account',
520
+ type: 'tuple',
521
+ components: [
522
+ { name: 'main', type: 'address' },
523
+ { name: 'subaccountId', type: 'uint8' },
524
+ ],
525
+ },
526
+ ],
527
+ outputs: [
528
+ {
529
+ name: 'info',
530
+ type: 'tuple',
531
+ components: [
532
+ { name: 'totalCollateralX18', type: 'uint128' },
533
+ { name: 'usedMarginX18', type: 'uint128' },
534
+ { name: 'freeMarginX18', type: 'uint128' },
535
+ { name: 'marginRatioX18', type: 'uint128' },
536
+ { name: 'maintenanceMarginX18', type: 'uint128' },
537
+ { name: 'liquidatable', type: 'bool' },
538
+ ],
539
+ },
540
+ ],
541
+ stateMutability: 'view',
542
+ },
543
+ // Check if liquidatable
544
+ {
545
+ type: 'function',
546
+ name: 'isLiquidatable',
547
+ inputs: [
548
+ {
549
+ name: 'account',
550
+ type: 'tuple',
551
+ components: [
552
+ { name: 'main', type: 'address' },
553
+ { name: 'subaccountId', type: 'uint8' },
554
+ ],
555
+ },
556
+ ],
557
+ outputs: [
558
+ { name: 'liquidatable', type: 'bool' },
559
+ { name: 'shortfall', type: 'uint128' },
560
+ ],
561
+ stateMutability: 'view',
562
+ },
563
+ // Liquidate
564
+ {
565
+ type: 'function',
566
+ name: 'liquidate',
567
+ inputs: [
568
+ {
569
+ name: 'account',
570
+ type: 'tuple',
571
+ components: [
572
+ { name: 'main', type: 'address' },
573
+ { name: 'subaccountId', type: 'uint8' },
574
+ ],
575
+ },
576
+ { name: 'marketId', type: 'uint32' },
577
+ { name: 'sizeX18', type: 'uint128' },
578
+ ],
579
+ outputs: [
580
+ {
581
+ name: 'result',
582
+ type: 'tuple',
583
+ components: [
584
+ {
585
+ name: 'liquidated',
586
+ type: 'tuple',
587
+ components: [
588
+ { name: 'main', type: 'address' },
589
+ { name: 'subaccountId', type: 'uint8' },
590
+ ],
591
+ },
592
+ {
593
+ name: 'liquidator',
594
+ type: 'tuple',
595
+ components: [
596
+ { name: 'main', type: 'address' },
597
+ { name: 'subaccountId', type: 'uint8' },
598
+ ],
599
+ },
600
+ { name: 'marketId', type: 'uint32' },
601
+ { name: 'sizeX18', type: 'uint128' },
602
+ { name: 'priceX18', type: 'uint128' },
603
+ { name: 'penaltyX18', type: 'uint128' },
604
+ { name: 'adlTriggered', type: 'bool' },
605
+ ],
606
+ },
607
+ ],
608
+ stateMutability: 'nonpayable',
609
+ },
610
+ // Get funding rate
611
+ {
612
+ type: 'function',
613
+ name: 'getFundingRate',
614
+ inputs: [{ name: 'marketId', type: 'uint32' }],
615
+ outputs: [
616
+ { name: 'rateX18', type: 'int128' },
617
+ { name: 'nextFundingTime', type: 'uint64' },
618
+ ],
619
+ stateMutability: 'view',
620
+ },
621
+ ] as const
622
+
623
+ // ============================================================================
624
+ // LXFeed ABI (LP-9040) - Price Feeds
625
+ // ============================================================================
626
+
627
+ /**
628
+ * LXFeed ABI (LP-9040)
629
+ * Mark price, index price, funding calculations
630
+ */
631
+ export const LX_FEED_ABI = [
632
+ // Get mark price
633
+ {
634
+ type: 'function',
635
+ name: 'getMarkPrice',
636
+ inputs: [{ name: 'marketId', type: 'uint32' }],
637
+ outputs: [
638
+ {
639
+ name: 'mark',
640
+ type: 'tuple',
641
+ components: [
642
+ { name: 'indexPxX18', type: 'uint128' },
643
+ { name: 'markPxX18', type: 'uint128' },
644
+ { name: 'premiumX18', type: 'int128' },
645
+ { name: 'timestamp', type: 'uint64' },
646
+ ],
647
+ },
648
+ ],
649
+ stateMutability: 'view',
650
+ },
651
+ // Get index price
652
+ {
653
+ type: 'function',
654
+ name: 'getIndexPrice',
655
+ inputs: [{ name: 'marketId', type: 'uint32' }],
656
+ outputs: [
657
+ { name: 'priceX18', type: 'uint128' },
658
+ { name: 'timestamp', type: 'uint64' },
659
+ ],
660
+ stateMutability: 'view',
661
+ },
662
+ // Get funding rate
663
+ {
664
+ type: 'function',
665
+ name: 'getFundingRate',
666
+ inputs: [{ name: 'marketId', type: 'uint32' }],
667
+ outputs: [
668
+ { name: 'rateX18', type: 'int128' },
669
+ { name: 'nextFundingTime', type: 'uint64' },
670
+ ],
671
+ stateMutability: 'view',
672
+ },
673
+ // Get trigger price for order
674
+ {
675
+ type: 'function',
676
+ name: 'getTriggerPrice',
677
+ inputs: [
678
+ { name: 'marketId', type: 'uint32' },
679
+ { name: 'isBuy', type: 'bool' },
680
+ ],
681
+ outputs: [{ name: 'priceX18', type: 'uint128' }],
682
+ stateMutability: 'view',
683
+ },
684
+ ] as const
685
+
686
+ // ============================================================================
687
+ // LXOracle ABI (LP-9011) - Price Oracle
688
+ // ============================================================================
689
+
690
+ /**
691
+ * LXOracle ABI (LP-9011)
692
+ * Multi-source price aggregation
693
+ */
694
+ export const LX_ORACLE_ABI = [
695
+ // Get price
696
+ {
697
+ type: 'function',
698
+ name: 'getPrice',
699
+ inputs: [
700
+ { name: 'baseToken', type: 'address' },
701
+ { name: 'quoteToken', type: 'address' },
702
+ ],
703
+ outputs: [
704
+ {
705
+ name: 'price',
706
+ type: 'tuple',
707
+ components: [
708
+ { name: 'price', type: 'uint256' },
709
+ { name: 'confidence', type: 'uint256' },
710
+ { name: 'timestamp', type: 'uint256' },
711
+ { name: 'source', type: 'uint8' },
712
+ { name: 'expo', type: 'int32' },
713
+ ],
714
+ },
715
+ ],
716
+ stateMutability: 'view',
717
+ },
718
+ // Get aggregated price
719
+ {
720
+ type: 'function',
721
+ name: 'getAggregatedPrice',
722
+ inputs: [
723
+ { name: 'baseToken', type: 'address' },
724
+ { name: 'quoteToken', type: 'address' },
725
+ { name: 'maxStaleness', type: 'uint256' },
726
+ ],
727
+ outputs: [
728
+ {
729
+ name: 'aggregated',
730
+ type: 'tuple',
731
+ components: [
732
+ { name: 'price', type: 'uint256' },
733
+ { name: 'minPrice', type: 'uint256' },
734
+ { name: 'maxPrice', type: 'uint256' },
735
+ { name: 'deviation', type: 'uint256' },
736
+ { name: 'numSources', type: 'uint256' },
737
+ { name: 'timestamp', type: 'uint256' },
738
+ ],
739
+ },
740
+ ],
741
+ stateMutability: 'view',
742
+ },
743
+ // Check if price is fresh
744
+ {
745
+ type: 'function',
746
+ name: 'isPriceFresh',
747
+ inputs: [
748
+ { name: 'baseToken', type: 'address' },
749
+ { name: 'quoteToken', type: 'address' },
750
+ { name: 'maxStaleness', type: 'uint256' },
751
+ ],
752
+ outputs: [{ name: 'fresh', type: 'bool' }],
753
+ stateMutability: 'view',
754
+ },
755
+ ] as const
@@ -1,72 +1,153 @@
1
1
  /**
2
- * DEX Precompile Addresses
2
+ * LX Precompile Addresses (LP-Aligned)
3
3
  * Native Go implementation at EVM level
4
- *
5
- * Lux Precompile Address Standard:
6
- * - Prefix format: 0xNNNN000000000000000000000000000000000000
7
- * - Range 0x0400-0x04FF is reserved for DEX precompiles
8
- *
9
- * @see ~/work/lux/precompile/dex/module.go for implementation
4
+ *
5
+ * LX is the umbrella name for the Lux DEX stack:
6
+ * - AMM (Lux v4-style)
7
+ * - CLOB (Hyperliquid-style)
8
+ * - Vaults, Feeds, Routing
9
+ *
10
+ * LP-Aligned Address Format (LP-9015):
11
+ * - Address = 0x0000000000000000000000000000000000LPNUM
12
+ * - LP number directly visible as trailing hex digits
13
+ * - Example: LP-9010 → 0x0000...009010
14
+ *
15
+ * @see LP-9015 (Precompile Registry) for canonical spec
16
+ * @see ~/work/lux/precompile/dex/module.go for Go implementation
17
+ * @see ~/work/lux/lps/LPs/lp-9015-precompile-registry.md
10
18
  */
11
19
  import type { Address } from 'viem'
12
20
 
13
21
  /**
14
- * DEX Precompile contract addresses
15
- * These are native precompiles, not deployed contracts
22
+ * LX Precompile addresses (LP-9xxx range)
23
+ * LX prefix naming convention for developer-facing contracts
24
+ * Address format: 0x0000000000000000000000000000000000LPNUM
16
25
  */
17
- export const DEX_PRECOMPILES = {
26
+ export const LX = {
18
27
  /**
19
- * PoolManager (0x0400)
20
- * Singleton managing all liquidity pools
28
+ * LXPool (LP-9010)
29
+ * v4 PoolManager-compatible core AMM
21
30
  * - Initialize pools
22
31
  * - Execute swaps
23
32
  * - Modify liquidity
24
33
  * - Flash accounting settlement
25
34
  */
26
- POOL_MANAGER: '0x0400000000000000000000000000000000000000' as Address,
35
+ LX_POOL: '0x0000000000000000000000000000000000009010' as Address,
36
+
37
+ /**
38
+ * LXOracle (LP-9011)
39
+ * Multi-source price aggregation
40
+ * - Chainlink, Pyth, TWAP aggregation
41
+ * - Price feed validation
42
+ */
43
+ LX_ORACLE: '0x0000000000000000000000000000000000009011' as Address,
27
44
 
28
45
  /**
29
- * SwapRouter (0x0401)
46
+ * LXRouter (LP-9012)
30
47
  * Optimized swap routing
31
48
  * - exactInputSingle / exactOutputSingle
32
49
  * - Multi-hop swaps
33
50
  * - Native LUX support
34
51
  */
35
- SWAP_ROUTER: '0x0401000000000000000000000000000000000000' as Address,
52
+ LX_ROUTER: '0x0000000000000000000000000000000000009012' as Address,
36
53
 
37
54
  /**
38
- * HooksRegistry (0x0402)
55
+ * LXHooks (LP-9013)
39
56
  * Hook contract registry
40
57
  * - Register hook contracts
41
58
  * - Query hook permissions
42
59
  */
43
- HOOKS_REGISTRY: '0x0402000000000000000000000000000000000000' as Address,
60
+ LX_HOOKS: '0x0000000000000000000000000000000000009013' as Address,
44
61
 
45
62
  /**
46
- * FlashLoan (0x0403)
63
+ * LXFlash (LP-9014)
47
64
  * Flash loan facility
48
65
  * - Borrow any token
49
66
  * - Repay in same transaction
50
67
  */
51
- FLASH_LOAN: '0x0403000000000000000000000000000000000000' as Address,
68
+ LX_FLASH: '0x0000000000000000000000000000000000009014' as Address,
69
+
70
+ /**
71
+ * LXBook (LP-9020)
72
+ * Permissionless orderbooks + matching + advanced orders
73
+ * - Market factory (createMarket)
74
+ * - Order lifecycle (place/cancel/modify)
75
+ * - Advanced orders (trigger, TWAP)
76
+ * - Book views (L1, order info)
77
+ */
78
+ LX_BOOK: '0x0000000000000000000000000000000000009020' as Address,
52
79
 
53
80
  /**
54
- * Lending (0x0410)
55
- * Lending protocol
81
+ * LXVault (LP-9030)
82
+ * Balances, margin, collateral, liquidations
83
+ * - Token custody
84
+ * - Margin requirements
85
+ * - Position liquidations
56
86
  */
57
- LENDING: '0x0410000000000000000000000000000000000000' as Address,
87
+ LX_VAULT: '0x0000000000000000000000000000000000009030' as Address,
58
88
 
59
89
  /**
60
- * Liquid (0x0430)
61
- * Liquid staking vaults
90
+ * LXFeed (LP-9040)
91
+ * Price feed aggregator
62
92
  */
63
- LIQUID: '0x0430000000000000000000000000000000000000' as Address,
93
+ LX_FEED: '0x0000000000000000000000000000000000009040' as Address,
64
94
 
65
95
  /**
66
- * Teleport (0x0440)
67
- * Cross-chain bridge
96
+ * Teleport Bridge (LP-6010)
97
+ * Cross-chain asset teleportation
68
98
  */
69
- TELEPORT: '0x0440000000000000000000000000000000000000' as Address,
99
+ TELEPORT: '0x0000000000000000000000000000000000006010' as Address,
100
+ } as const
101
+
102
+ /**
103
+ * Backwards compatibility - old naming convention
104
+ * @deprecated Use LX export instead
105
+ */
106
+ export const DEX_PRECOMPILES = {
107
+ POOL_MANAGER: LX.LX_POOL,
108
+ ORACLE_HUB: LX.LX_ORACLE,
109
+ SWAP_ROUTER: LX.LX_ROUTER,
110
+ HOOKS_REGISTRY: LX.LX_HOOKS,
111
+ FLASH_LOAN: LX.LX_FLASH,
112
+ CLOB: LX.LX_BOOK,
113
+ VAULT: LX.LX_VAULT,
114
+ PRICE_FEED: LX.LX_FEED,
115
+ TELEPORT: LX.TELEPORT,
70
116
  } as const
71
117
 
118
+ export type LxdexPrecompile = keyof typeof LX
72
119
  export type DexPrecompile = keyof typeof DEX_PRECOMPILES
120
+
121
+ /**
122
+ * Generate precompile address from LP number
123
+ * @param lpNumber - The LP number (e.g., 9010)
124
+ * @returns The precompile address
125
+ */
126
+ export function fromLP(lpNumber: number): Address {
127
+ return `0x${lpNumber.toString(16).padStart(40, '0')}` as Address
128
+ }
129
+
130
+ /**
131
+ * Extract LP number from precompile address
132
+ * @param address - The precompile address
133
+ * @returns The LP number
134
+ */
135
+ export function toLP(address: Address): number {
136
+ return parseInt(address.slice(-4), 16)
137
+ }
138
+
139
+ /**
140
+ * Check if address is a DEX precompile (LP-9xxx range)
141
+ */
142
+ export function isDEXPrecompile(address: Address): boolean {
143
+ const lp = toLP(address)
144
+ return lp >= 9000 && lp < 10000
145
+ }
146
+
147
+ /**
148
+ * Check if address is a Bridge precompile (LP-6xxx range)
149
+ */
150
+ export function isBridgePrecompile(address: Address): boolean {
151
+ const lp = toLP(address)
152
+ return lp >= 6000 && lp < 7000
153
+ }
@@ -1,6 +1,17 @@
1
1
  /**
2
- * DEX Precompile Exports
3
- * Native Uniswap v4-style AMM at 0x0400-0x0403
2
+ * LX Precompile Exports (LP-Aligned)
3
+ *
4
+ * Native precompiles for Lux DEX stack:
5
+ * - LXPool (LP-9010): v4-style AMM PoolManager
6
+ * - LXOracle (LP-9011): Multi-source price aggregation
7
+ * - LXRouter (LP-9012): Optimized swap routing
8
+ * - LXHooks (LP-9013): Hook contract registry
9
+ * - LXFlash (LP-9014): Flash loan facility
10
+ * - LXBook (LP-9020): CLOB matching engine
11
+ * - LXVault (LP-9030): Custody and margin engine
12
+ * - LXFeed (LP-9040): Mark price and funding feeds
13
+ *
14
+ * Address format: 0x0000000000000000000000000000000000LPNUM
4
15
  */
5
16
  export * from './types'
6
17
  export * from './abis'