@luxfi/dex 1.3.0 → 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.
- package/dist/hooks/index.d.ts +16 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +20 -1
- package/dist/hooks/use-lxbook.d.ts +95 -0
- package/dist/hooks/use-lxbook.d.ts.map +1 -0
- package/dist/hooks/use-lxbook.js +213 -0
- package/dist/hooks/use-lxfeed.d.ts +111 -0
- package/dist/hooks/use-lxfeed.d.ts.map +1 -0
- package/dist/hooks/use-lxfeed.js +152 -0
- package/dist/hooks/use-lxvault.d.ts +137 -0
- package/dist/hooks/use-lxvault.d.ts.map +1 -0
- package/dist/hooks/use-lxvault.js +227 -0
- package/dist/index.d.ts +38 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -26
- package/dist/precompile/abis.d.ts +593 -2
- package/dist/precompile/abis.d.ts.map +1 -1
- package/dist/precompile/abis.js +458 -2
- package/dist/precompile/addresses.d.ts +89 -25
- package/dist/precompile/addresses.d.ts.map +1 -1
- package/dist/precompile/addresses.js +86 -21
- package/dist/precompile/index.d.ts +13 -2
- package/dist/precompile/index.d.ts.map +1 -1
- package/dist/precompile/index.js +13 -2
- package/dist/precompile/types.d.ts +170 -0
- package/dist/precompile/types.d.ts.map +1 -1
- package/dist/precompile/types.js +67 -0
- package/package.json +2 -2
- package/src/hooks/index.ts +24 -1
- package/src/hooks/use-lxbook.ts +343 -0
- package/src/hooks/use-lxfeed.ts +179 -0
- package/src/hooks/use-lxvault.ts +318 -0
- package/src/index.ts +92 -26
- package/src/precompile/abis.ts +466 -2
- package/src/precompile/addresses.ts +109 -28
- package/src/precompile/index.ts +13 -2
- package/src/precompile/types.ts +200 -1
package/dist/precompile/abis.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DEX Precompile ABIs
|
|
3
|
-
* Native Go implementation at
|
|
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
|
* PoolManager ABI (0x0400)
|
|
@@ -285,3 +286,458 @@ export const FLASH_LOAN_ABI = [
|
|
|
285
286
|
stateMutability: 'nonpayable',
|
|
286
287
|
},
|
|
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
|
+
];
|
|
@@ -1,65 +1,129 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* LX Precompile Addresses (LP-Aligned)
|
|
3
3
|
* Native Go implementation at EVM level
|
|
4
4
|
*
|
|
5
|
-
* Lux
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
5
|
+
* LX is the umbrella name for the Lux DEX stack:
|
|
6
|
+
* - AMM (Uniswap v4-style)
|
|
7
|
+
* - CLOB (Hyperliquid-style)
|
|
8
|
+
* - Vaults, Feeds, Routing
|
|
8
9
|
*
|
|
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
|
-
*
|
|
14
|
-
*
|
|
21
|
+
* LX Precompile addresses (LP-9xxx range)
|
|
22
|
+
* LX prefix naming convention for developer-facing contracts
|
|
23
|
+
* Address format: 0x0000000000000000000000000000000000LPNUM
|
|
15
24
|
*/
|
|
16
|
-
export declare const
|
|
25
|
+
export declare const LX: {
|
|
17
26
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
27
|
+
* LXPool (LP-9010)
|
|
28
|
+
* v4 PoolManager-compatible core AMM
|
|
20
29
|
* - Initialize pools
|
|
21
30
|
* - Execute swaps
|
|
22
31
|
* - Modify liquidity
|
|
23
32
|
* - Flash accounting settlement
|
|
24
33
|
*/
|
|
25
|
-
readonly
|
|
34
|
+
readonly LX_POOL: Address;
|
|
26
35
|
/**
|
|
27
|
-
*
|
|
36
|
+
* LXOracle (LP-9011)
|
|
37
|
+
* Multi-source price aggregation
|
|
38
|
+
* - Chainlink, Pyth, TWAP aggregation
|
|
39
|
+
* - Price feed validation
|
|
40
|
+
*/
|
|
41
|
+
readonly LX_ORACLE: Address;
|
|
42
|
+
/**
|
|
43
|
+
* LXRouter (LP-9012)
|
|
28
44
|
* Optimized swap routing
|
|
29
45
|
* - exactInputSingle / exactOutputSingle
|
|
30
46
|
* - Multi-hop swaps
|
|
31
47
|
* - Native LUX support
|
|
32
48
|
*/
|
|
33
|
-
readonly
|
|
49
|
+
readonly LX_ROUTER: Address;
|
|
34
50
|
/**
|
|
35
|
-
*
|
|
51
|
+
* LXHooks (LP-9013)
|
|
36
52
|
* Hook contract registry
|
|
37
53
|
* - Register hook contracts
|
|
38
54
|
* - Query hook permissions
|
|
39
55
|
*/
|
|
40
|
-
readonly
|
|
56
|
+
readonly LX_HOOKS: Address;
|
|
41
57
|
/**
|
|
42
|
-
*
|
|
58
|
+
* LXFlash (LP-9014)
|
|
43
59
|
* Flash loan facility
|
|
44
60
|
* - Borrow any token
|
|
45
61
|
* - Repay in same transaction
|
|
46
62
|
*/
|
|
47
|
-
readonly
|
|
63
|
+
readonly LX_FLASH: Address;
|
|
48
64
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
65
|
+
* LXBook (LP-9020)
|
|
66
|
+
* Permissionless orderbooks + matching + advanced orders
|
|
67
|
+
* - Market factory (createMarket)
|
|
68
|
+
* - Order lifecycle (place/cancel/modify)
|
|
69
|
+
* - Advanced orders (trigger, TWAP)
|
|
70
|
+
* - Book views (L1, order info)
|
|
51
71
|
*/
|
|
52
|
-
readonly
|
|
72
|
+
readonly LX_BOOK: Address;
|
|
53
73
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
74
|
+
* LXVault (LP-9030)
|
|
75
|
+
* Balances, margin, collateral, liquidations
|
|
76
|
+
* - Token custody
|
|
77
|
+
* - Margin requirements
|
|
78
|
+
* - Position liquidations
|
|
56
79
|
*/
|
|
57
|
-
readonly
|
|
80
|
+
readonly LX_VAULT: Address;
|
|
58
81
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
82
|
+
* LXFeed (LP-9040)
|
|
83
|
+
* Price feed aggregator
|
|
84
|
+
*/
|
|
85
|
+
readonly LX_FEED: Address;
|
|
86
|
+
/**
|
|
87
|
+
* Teleport Bridge (LP-6010)
|
|
88
|
+
* Cross-chain asset teleportation
|
|
61
89
|
*/
|
|
62
90
|
readonly TELEPORT: Address;
|
|
63
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Backwards compatibility - old naming convention
|
|
94
|
+
* @deprecated Use LX export instead
|
|
95
|
+
*/
|
|
96
|
+
export declare const DEX_PRECOMPILES: {
|
|
97
|
+
readonly POOL_MANAGER: `0x${string}`;
|
|
98
|
+
readonly ORACLE_HUB: `0x${string}`;
|
|
99
|
+
readonly SWAP_ROUTER: `0x${string}`;
|
|
100
|
+
readonly HOOKS_REGISTRY: `0x${string}`;
|
|
101
|
+
readonly FLASH_LOAN: `0x${string}`;
|
|
102
|
+
readonly CLOB: `0x${string}`;
|
|
103
|
+
readonly VAULT: `0x${string}`;
|
|
104
|
+
readonly PRICE_FEED: `0x${string}`;
|
|
105
|
+
readonly TELEPORT: `0x${string}`;
|
|
106
|
+
};
|
|
107
|
+
export type LxdexPrecompile = keyof typeof LX;
|
|
64
108
|
export type DexPrecompile = keyof typeof DEX_PRECOMPILES;
|
|
109
|
+
/**
|
|
110
|
+
* Generate precompile address from LP number
|
|
111
|
+
* @param lpNumber - The LP number (e.g., 9010)
|
|
112
|
+
* @returns The precompile address
|
|
113
|
+
*/
|
|
114
|
+
export declare function fromLP(lpNumber: number): Address;
|
|
115
|
+
/**
|
|
116
|
+
* Extract LP number from precompile address
|
|
117
|
+
* @param address - The precompile address
|
|
118
|
+
* @returns The LP number
|
|
119
|
+
*/
|
|
120
|
+
export declare function toLP(address: Address): number;
|
|
121
|
+
/**
|
|
122
|
+
* Check if address is a DEX precompile (LP-9xxx range)
|
|
123
|
+
*/
|
|
124
|
+
export declare function isDEXPrecompile(address: Address): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Check if address is a Bridge precompile (LP-6xxx range)
|
|
127
|
+
*/
|
|
128
|
+
export declare function isBridgePrecompile(address: Address): boolean;
|
|
65
129
|
//# sourceMappingURL=addresses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/precompile/addresses.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/precompile/addresses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC;;;;GAIG;AACH,eAAO,MAAM,EAAE;IACb;;;;;;;OAOG;sBACsD,OAAO;IAEhE;;;;;OAKG;wBACwD,OAAO;IAElE;;;;;;OAMG;wBACwD,OAAO;IAElE;;;;;OAKG;uBACuD,OAAO;IAEjE;;;;;OAKG;uBACuD,OAAO;IAEjE;;;;;;;OAOG;sBACsD,OAAO;IAEhE;;;;;;OAMG;uBACuD,OAAO;IAEjE;;;OAGG;sBACsD,OAAO;IAEhE;;;OAGG;uBACuD,OAAO;CACzD,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;CAUlB,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,EAAE,CAAA;AAC7C,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,eAAe,CAAA;AAExD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAGzD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAG5D"}
|