@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.
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 +95 -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 +111 -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 +137 -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 +170 -0
  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
@@ -0,0 +1,137 @@
1
+ import type { Address } from 'viem';
2
+ import type { LXPosition, LXMarginInfo } from '../precompile/types';
3
+ /**
4
+ * Hook to get token balance in vault
5
+ */
6
+ export declare function useLXVaultBalance(token: Address, subaccountId?: number): {
7
+ balance: bigint | undefined;
8
+ isLoading: boolean;
9
+ error: import("viem").ReadContractErrorType | null;
10
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<bigint, import("viem").ReadContractErrorType>>;
11
+ };
12
+ /**
13
+ * Hook to get position for a market
14
+ */
15
+ export declare function useLXVaultPosition(marketId: number, subaccountId?: number): {
16
+ position: LXPosition | undefined;
17
+ isLoading: boolean;
18
+ error: import("viem").ReadContractErrorType | null;
19
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
20
+ marketId: number;
21
+ side: number;
22
+ sizeX18: bigint;
23
+ entryPxX18: bigint;
24
+ unrealizedPnlX18: bigint;
25
+ accumulatedFundingX18: bigint;
26
+ lastFundingTime: bigint;
27
+ }, import("viem").ReadContractErrorType>>;
28
+ };
29
+ /**
30
+ * Hook to get margin info (free margin, used margin, etc.)
31
+ */
32
+ export declare function useLXVaultMargin(subaccountId?: number): {
33
+ margin: LXMarginInfo | undefined;
34
+ isLoading: boolean;
35
+ error: import("viem").ReadContractErrorType | null;
36
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
37
+ totalCollateralX18: bigint;
38
+ usedMarginX18: bigint;
39
+ freeMarginX18: bigint;
40
+ marginRatioX18: bigint;
41
+ maintenanceMarginX18: bigint;
42
+ liquidatable: boolean;
43
+ }, import("viem").ReadContractErrorType>>;
44
+ };
45
+ /**
46
+ * Hook to check if account is liquidatable
47
+ */
48
+ export declare function useLXVaultLiquidatable(account?: Address, subaccountId?: number): {
49
+ liquidatable: boolean | undefined;
50
+ shortfall: bigint | undefined;
51
+ isLoading: boolean;
52
+ error: import("viem").ReadContractErrorType | null;
53
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<readonly [boolean, bigint], import("viem").ReadContractErrorType>>;
54
+ };
55
+ /**
56
+ * Hook to get funding rate for a market
57
+ */
58
+ export declare function useLXVaultFundingRate(marketId: number): {
59
+ rateX18: bigint | undefined;
60
+ nextFundingTime: bigint | undefined;
61
+ isLoading: boolean;
62
+ error: import("viem").ReadContractErrorType | null;
63
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<readonly [bigint, bigint], import("viem").ReadContractErrorType>>;
64
+ };
65
+ interface UseLXVaultDepositResult {
66
+ deposit: (token: Address, amount: bigint, subaccountId?: number) => void;
67
+ hash: `0x${string}` | undefined;
68
+ isPending: boolean;
69
+ isConfirming: boolean;
70
+ isSuccess: boolean;
71
+ error: Error | null;
72
+ }
73
+ /**
74
+ * Hook for depositing tokens into vault
75
+ */
76
+ export declare function useLXVaultDeposit(): UseLXVaultDepositResult;
77
+ interface UseLXVaultWithdrawResult {
78
+ withdraw: (token: Address, amount: bigint, subaccountId?: number) => void;
79
+ hash: `0x${string}` | undefined;
80
+ isPending: boolean;
81
+ isConfirming: boolean;
82
+ isSuccess: boolean;
83
+ error: Error | null;
84
+ }
85
+ /**
86
+ * Hook for withdrawing tokens from vault
87
+ */
88
+ export declare function useLXVaultWithdraw(): UseLXVaultWithdrawResult;
89
+ interface UseLXVaultTransferResult {
90
+ transfer: (token: Address, amount: bigint, fromSubaccount: number, toSubaccount: number) => void;
91
+ hash: `0x${string}` | undefined;
92
+ isPending: boolean;
93
+ isConfirming: boolean;
94
+ isSuccess: boolean;
95
+ error: Error | null;
96
+ }
97
+ /**
98
+ * Hook for transferring between subaccounts
99
+ */
100
+ export declare function useLXVaultTransfer(): UseLXVaultTransferResult;
101
+ interface UseLXVaultLiquidateResult {
102
+ liquidate: (targetAccount: Address, targetSubaccount: number, marketId: number, sizeX18: bigint) => void;
103
+ hash: `0x${string}` | undefined;
104
+ isPending: boolean;
105
+ isConfirming: boolean;
106
+ isSuccess: boolean;
107
+ error: Error | null;
108
+ }
109
+ /**
110
+ * Hook for liquidating underwater positions
111
+ */
112
+ export declare function useLXVaultLiquidate(): UseLXVaultLiquidateResult;
113
+ /**
114
+ * Combined hook for common vault operations
115
+ */
116
+ export declare function useLXVault(subaccountId?: number): {
117
+ address: `0x${string}` | undefined;
118
+ subaccountId: number;
119
+ margin: LXMarginInfo | undefined;
120
+ isLoadingMargin: boolean;
121
+ deposit: (token: Address, amount: bigint, subaccountId?: number) => void;
122
+ withdraw: (token: Address, amount: bigint, subaccountId?: number) => void;
123
+ transfer: (token: Address, amount: bigint, fromSubaccount: number, toSubaccount: number) => void;
124
+ isDepositing: boolean;
125
+ isWithdrawing: boolean;
126
+ isTransferring: boolean;
127
+ refetchMargin: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
128
+ totalCollateralX18: bigint;
129
+ usedMarginX18: bigint;
130
+ freeMarginX18: bigint;
131
+ marginRatioX18: bigint;
132
+ maintenanceMarginX18: bigint;
133
+ liquidatable: boolean;
134
+ }, import("viem").ReadContractErrorType>>;
135
+ };
136
+ export {};
137
+ //# sourceMappingURL=use-lxvault.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-lxvault.d.ts","sourceRoot":"","sources":["../../src/hooks/use-lxvault.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,KAAK,EAAa,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAS9E;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,GAAE,MAAU;aAYrD,MAAM,GAAG,SAAS;;;;EAKtC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,GAAE,MAA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AAK,IAAI,CAAA;IAChG,IAAI,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS,CAAA;IAC/B,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CACpB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,wBAAwB,CA6B7D;AAED,UAAU,yBAAyB;IACjC,SAAS,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACxG,IAAI,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS,CAAA;IAC/B,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CACpB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,yBAAyB,CA6B/D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,YAAY,GAAE,MAAU;;;;;qBApKhC,OAAO,UAAU,MAAM,iBAAiB,MAAM,KAAK,IAAI;sBAsCtD,OAAO,UAAU,MAAM,iBAAiB,MAAM,KAAK,IAAI;sBAsCvD,OAAO,UAAU,MAAM,kBAAkB,MAAM,gBAAgB,MAAM,KAAK,IAAI;;;;;;;;;;;;EA4GjG"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * LXVault Hooks (LP-9030)
3
+ * React hooks for custody, margin, and positions via LXVault precompile
4
+ */
5
+ import { useCallback } from 'react';
6
+ import { useReadContract, useWriteContract, useWaitForTransactionReceipt, useAccount } from 'wagmi';
7
+ import { LX } from '../precompile/addresses';
8
+ import { LX_VAULT_ABI } from '../precompile/abis';
9
+ /**
10
+ * Build account tuple from address and subaccount
11
+ */
12
+ function buildAccount(main, subaccountId = 0) {
13
+ return { main, subaccountId };
14
+ }
15
+ /**
16
+ * Hook to get token balance in vault
17
+ */
18
+ export function useLXVaultBalance(token, subaccountId = 0) {
19
+ const { address } = useAccount();
20
+ const { data, isLoading, error, refetch } = useReadContract({
21
+ address: LX.LX_VAULT,
22
+ abi: LX_VAULT_ABI,
23
+ functionName: 'getBalance',
24
+ args: address ? [buildAccount(address, subaccountId), token] : undefined,
25
+ query: { enabled: !!address },
26
+ });
27
+ return {
28
+ balance: data,
29
+ isLoading,
30
+ error,
31
+ refetch,
32
+ };
33
+ }
34
+ /**
35
+ * Hook to get position for a market
36
+ */
37
+ export function useLXVaultPosition(marketId, subaccountId = 0) {
38
+ const { address } = useAccount();
39
+ const { data, isLoading, error, refetch } = useReadContract({
40
+ address: LX.LX_VAULT,
41
+ abi: LX_VAULT_ABI,
42
+ functionName: 'getPosition',
43
+ args: address ? [buildAccount(address, subaccountId), marketId] : undefined,
44
+ query: { enabled: !!address },
45
+ });
46
+ return {
47
+ position: data,
48
+ isLoading,
49
+ error,
50
+ refetch,
51
+ };
52
+ }
53
+ /**
54
+ * Hook to get margin info (free margin, used margin, etc.)
55
+ */
56
+ export function useLXVaultMargin(subaccountId = 0) {
57
+ const { address } = useAccount();
58
+ const { data, isLoading, error, refetch } = useReadContract({
59
+ address: LX.LX_VAULT,
60
+ abi: LX_VAULT_ABI,
61
+ functionName: 'getMargin',
62
+ args: address ? [buildAccount(address, subaccountId)] : undefined,
63
+ query: { enabled: !!address },
64
+ });
65
+ return {
66
+ margin: data,
67
+ isLoading,
68
+ error,
69
+ refetch,
70
+ };
71
+ }
72
+ /**
73
+ * Hook to check if account is liquidatable
74
+ */
75
+ export function useLXVaultLiquidatable(account, subaccountId = 0) {
76
+ const { address: connectedAddress } = useAccount();
77
+ const targetAddress = account ?? connectedAddress;
78
+ const { data, isLoading, error, refetch } = useReadContract({
79
+ address: LX.LX_VAULT,
80
+ abi: LX_VAULT_ABI,
81
+ functionName: 'isLiquidatable',
82
+ args: targetAddress ? [buildAccount(targetAddress, subaccountId)] : undefined,
83
+ query: { enabled: !!targetAddress },
84
+ });
85
+ const result = data;
86
+ return {
87
+ liquidatable: result?.[0],
88
+ shortfall: result?.[1],
89
+ isLoading,
90
+ error,
91
+ refetch,
92
+ };
93
+ }
94
+ /**
95
+ * Hook to get funding rate for a market
96
+ */
97
+ export function useLXVaultFundingRate(marketId) {
98
+ const { data, isLoading, error, refetch } = useReadContract({
99
+ address: LX.LX_VAULT,
100
+ abi: LX_VAULT_ABI,
101
+ functionName: 'getFundingRate',
102
+ args: [marketId],
103
+ });
104
+ const result = data;
105
+ return {
106
+ rateX18: result?.[0],
107
+ nextFundingTime: result?.[1],
108
+ isLoading,
109
+ error,
110
+ refetch,
111
+ };
112
+ }
113
+ /**
114
+ * Hook for depositing tokens into vault
115
+ */
116
+ export function useLXVaultDeposit() {
117
+ const { writeContract, data: hash, isPending, error } = useWriteContract();
118
+ const { isLoading: isConfirming, isSuccess } = useWaitForTransactionReceipt({ hash });
119
+ const deposit = useCallback((token, amount, subaccountId = 0) => {
120
+ writeContract({
121
+ address: LX.LX_VAULT,
122
+ abi: LX_VAULT_ABI,
123
+ functionName: 'deposit',
124
+ args: [token, amount, subaccountId],
125
+ });
126
+ }, [writeContract]);
127
+ return {
128
+ deposit,
129
+ hash,
130
+ isPending,
131
+ isConfirming,
132
+ isSuccess,
133
+ error,
134
+ };
135
+ }
136
+ /**
137
+ * Hook for withdrawing tokens from vault
138
+ */
139
+ export function useLXVaultWithdraw() {
140
+ const { writeContract, data: hash, isPending, error } = useWriteContract();
141
+ const { isLoading: isConfirming, isSuccess } = useWaitForTransactionReceipt({ hash });
142
+ const withdraw = useCallback((token, amount, subaccountId = 0) => {
143
+ writeContract({
144
+ address: LX.LX_VAULT,
145
+ abi: LX_VAULT_ABI,
146
+ functionName: 'withdraw',
147
+ args: [token, amount, subaccountId],
148
+ });
149
+ }, [writeContract]);
150
+ return {
151
+ withdraw,
152
+ hash,
153
+ isPending,
154
+ isConfirming,
155
+ isSuccess,
156
+ error,
157
+ };
158
+ }
159
+ /**
160
+ * Hook for transferring between subaccounts
161
+ */
162
+ export function useLXVaultTransfer() {
163
+ const { writeContract, data: hash, isPending, error } = useWriteContract();
164
+ const { isLoading: isConfirming, isSuccess } = useWaitForTransactionReceipt({ hash });
165
+ const transfer = useCallback((token, amount, fromSubaccount, toSubaccount) => {
166
+ writeContract({
167
+ address: LX.LX_VAULT,
168
+ abi: LX_VAULT_ABI,
169
+ functionName: 'transfer',
170
+ args: [token, amount, fromSubaccount, toSubaccount],
171
+ });
172
+ }, [writeContract]);
173
+ return {
174
+ transfer,
175
+ hash,
176
+ isPending,
177
+ isConfirming,
178
+ isSuccess,
179
+ error,
180
+ };
181
+ }
182
+ /**
183
+ * Hook for liquidating underwater positions
184
+ */
185
+ export function useLXVaultLiquidate() {
186
+ const { writeContract, data: hash, isPending, error } = useWriteContract();
187
+ const { isLoading: isConfirming, isSuccess } = useWaitForTransactionReceipt({ hash });
188
+ const liquidate = useCallback((targetAccount, targetSubaccount, marketId, sizeX18) => {
189
+ writeContract({
190
+ address: LX.LX_VAULT,
191
+ abi: LX_VAULT_ABI,
192
+ functionName: 'liquidate',
193
+ args: [buildAccount(targetAccount, targetSubaccount), marketId, sizeX18],
194
+ });
195
+ }, [writeContract]);
196
+ return {
197
+ liquidate,
198
+ hash,
199
+ isPending,
200
+ isConfirming,
201
+ isSuccess,
202
+ error,
203
+ };
204
+ }
205
+ /**
206
+ * Combined hook for common vault operations
207
+ */
208
+ export function useLXVault(subaccountId = 0) {
209
+ const { address } = useAccount();
210
+ const margin = useLXVaultMargin(subaccountId);
211
+ const { deposit, isPending: isDepositing } = useLXVaultDeposit();
212
+ const { withdraw, isPending: isWithdrawing } = useLXVaultWithdraw();
213
+ const { transfer, isPending: isTransferring } = useLXVaultTransfer();
214
+ return {
215
+ address,
216
+ subaccountId,
217
+ margin: margin.margin,
218
+ isLoadingMargin: margin.isLoading,
219
+ deposit,
220
+ withdraw,
221
+ transfer,
222
+ isDepositing,
223
+ isWithdrawing,
224
+ isTransferring,
225
+ refetchMargin: margin.refetch,
226
+ };
227
+ }
package/dist/index.d.ts CHANGED
@@ -1,33 +1,50 @@
1
1
  /**
2
2
  * @luxfi/dex
3
3
  *
4
- * DEX Integration Package
4
+ * LX Integration Package
5
5
  *
6
- * Provides routing between:
7
- * - CLOB (Central Limit Order Book) via ~/work/lux/dex
8
- * - AMM Precompiles (0x0400-0x0403) for native swaps
6
+ * Native precompile integration for Lux DEX stack:
7
+ * - LXPool (LP-9010): v4-style AMM PoolManager
8
+ * - LXOracle (LP-9011): Multi-source price aggregation
9
+ * - LXRouter (LP-9012): Optimized swap routing
10
+ * - LXHooks (LP-9013): Hook contract registry
11
+ * - LXFlash (LP-9014): Flash loan facility
12
+ * - LXBook (LP-9020): CLOB matching engine
13
+ * - LXVault (LP-9030): Custody and margin engine
14
+ * - LXFeed (LP-9040): Mark price and funding feeds
9
15
  *
10
16
  * Architecture:
11
17
  * ```
12
- * ┌────────────────────────────────────────┐
13
- * │ Omnichain Router
14
- * │ Best execution between CLOB & AMM
15
- * └─────────────────┬──────────────────────┘
16
- *
17
- * ┌─────────────┴─────────────┐
18
- *
19
- *
20
- * ┌─────────┐ ┌───────────────┐
21
- * │ CLOB AMM Precompile
22
- * │ Client (0x0400)
23
- * │
24
- * │ • Limit │ • Swap
25
- * │ • HFT │ • Liquidity
26
- * │ • Perps │ • Flash │
27
- * └─────────┘ └───────────────┘
18
+ * ┌─────────────────────────────────────────────────────────────┐
19
+ * │ Omnichain Router
20
+ * │ Best execution between CLOB & AMM
21
+ * └─────────────────────────┬───────────────────────────────────┘
22
+ *
23
+ * ┌───────────────────┼───────────────────┐
24
+ *
25
+ *
26
+ * ┌───────────┐ ┌───────────┐ ┌───────────┐
27
+ * │ LXBook LXPool │ LXVault │
28
+ * │ (LP-9020) (LP-9010) │ (LP-9030) │
29
+ * │ │ │
30
+ * │ • Orders │ │ • Swaps │ • Custody
31
+ * │ • CLOB │ • AMM │ • Margin │
32
+ * │ • Perps │ • Flash • Liq. │
33
+ * └───────────┘ └───────────┘ └───────────┘
34
+ * │ │ │
35
+ * └───────────────────┴───────────────────┘
36
+ * │
37
+ * ┌──────┴──────┐
38
+ * │ LXFeed │
39
+ * │ (LP-9040) │
40
+ * │ │
41
+ * │ • Mark Px │
42
+ * │ • Index Px │
43
+ * │ • Funding │
44
+ * └─────────────┘
28
45
  * ```
29
46
  */
30
- export { type Currency, type PoolKey, type BalanceDelta, type SwapParams, type ModifyLiquidityParams, type PoolState, type Position as AMMPosition, NATIVE_LUX, sortCurrencies, createPoolKey, POOL_MANAGER_ABI, SWAP_ROUTER_ABI, HOOKS_REGISTRY_ABI, FLASH_LOAN_ABI, DEX_PRECOMPILES, type DexPrecompile, } from './precompile';
47
+ export { type Currency, type PoolKey, type BalanceDelta, type SwapParams, type ModifyLiquidityParams, type PoolState, type Position as AMMPosition, NATIVE_LUX, sortCurrencies, createPoolKey, TIF, OrderKind, GroupType, ActionType, type LXOrder, type LXAction, type LXPlaceResult, type LXL1, MarginMode, PositionSide, type LXAccount, type LXPosition, type LXMarginInfo, type LXSettlement, type LXLiquidationResult, type LXMarkPrice, type LXFundingRate, POOL_MANAGER_ABI, SWAP_ROUTER_ABI, HOOKS_REGISTRY_ABI, FLASH_LOAN_ABI, LX_BOOK_ABI, LX_VAULT_ABI, LX_FEED_ABI, LX_ORACLE_ABI, LX, DEX_PRECOMPILES, type LxdexPrecompile, type DexPrecompile, fromLP, toLP, isDEXPrecompile, isBridgePrecompile, } from './precompile';
31
48
  export { type OrderSide, type OrderType, type OrderStatus, type TimeInForce, type OrderRequest, type Order, type OrderBookEntry, type OrderBook, type Trade, type Position as CLOBPosition, type Balance, type ICLOBClient, CLOBClient, createCLOBClient, } from './client';
32
49
  export * from './router';
33
50
  export * from './hooks';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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B,KAAK,aAAa,EAGlB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,cAAc,EAGd,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EAGb,EAAE,EACF,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,MAAM,EACN,IAAI,EACJ,eAAe,EACf,kBAAkB,GACnB,MAAM,cAAc,CAAA;AAMrB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,QAAQ,IAAI,YAAY,EAC7B,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,UAAU,EACV,gBAAgB,GACjB,MAAM,UAAU,CAAA;AAMjB,cAAc,UAAU,CAAA;AAMxB,cAAc,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -1,41 +1,72 @@
1
1
  /**
2
2
  * @luxfi/dex
3
3
  *
4
- * DEX Integration Package
4
+ * LX Integration Package
5
5
  *
6
- * Provides routing between:
7
- * - CLOB (Central Limit Order Book) via ~/work/lux/dex
8
- * - AMM Precompiles (0x0400-0x0403) for native swaps
6
+ * Native precompile integration for Lux DEX stack:
7
+ * - LXPool (LP-9010): v4-style AMM PoolManager
8
+ * - LXOracle (LP-9011): Multi-source price aggregation
9
+ * - LXRouter (LP-9012): Optimized swap routing
10
+ * - LXHooks (LP-9013): Hook contract registry
11
+ * - LXFlash (LP-9014): Flash loan facility
12
+ * - LXBook (LP-9020): CLOB matching engine
13
+ * - LXVault (LP-9030): Custody and margin engine
14
+ * - LXFeed (LP-9040): Mark price and funding feeds
9
15
  *
10
16
  * Architecture:
11
17
  * ```
12
- * ┌────────────────────────────────────────┐
13
- * │ Omnichain Router
14
- * │ Best execution between CLOB & AMM
15
- * └─────────────────┬──────────────────────┘
16
- *
17
- * ┌─────────────┴─────────────┐
18
- *
19
- *
20
- * ┌─────────┐ ┌───────────────┐
21
- * │ CLOB AMM Precompile
22
- * │ Client (0x0400)
23
- * │
24
- * │ • Limit │ • Swap
25
- * │ • HFT │ • Liquidity
26
- * │ • Perps │ • Flash │
27
- * └─────────┘ └───────────────┘
18
+ * ┌─────────────────────────────────────────────────────────────┐
19
+ * │ Omnichain Router
20
+ * │ Best execution between CLOB & AMM
21
+ * └─────────────────────────┬───────────────────────────────────┘
22
+ *
23
+ * ┌───────────────────┼───────────────────┐
24
+ *
25
+ *
26
+ * ┌───────────┐ ┌───────────┐ ┌───────────┐
27
+ * │ LXBook LXPool │ LXVault │
28
+ * │ (LP-9020) (LP-9010) │ (LP-9030) │
29
+ * │ │ │
30
+ * │ • Orders │ │ • Swaps │ • Custody
31
+ * │ • CLOB │ • AMM │ • Margin │
32
+ * │ • Perps │ • Flash • Liq. │
33
+ * └───────────┘ └───────────┘ └───────────┘
34
+ * │ │ │
35
+ * └───────────────────┴───────────────────┘
36
+ * │
37
+ * ┌──────┴──────┐
38
+ * │ LXFeed │
39
+ * │ (LP-9040) │
40
+ * │ │
41
+ * │ • Mark Px │
42
+ * │ • Index Px │
43
+ * │ • Funding │
44
+ * └─────────────┘
28
45
  * ```
29
46
  */
30
- // Precompile types and ABIs (AMM)
47
+ // =============================================================================
48
+ // Precompile Types, ABIs, and Addresses
49
+ // =============================================================================
31
50
  export { NATIVE_LUX, sortCurrencies, createPoolKey,
32
- // ABIs
51
+ // LXBook Types (LP-9020)
52
+ TIF, OrderKind, GroupType, ActionType,
53
+ // LXVault Types (LP-9030)
54
+ MarginMode, PositionSide,
55
+ // AMM ABIs
33
56
  POOL_MANAGER_ABI, SWAP_ROUTER_ABI, HOOKS_REGISTRY_ABI, FLASH_LOAN_ABI,
57
+ // LX* ABIs
58
+ LX_BOOK_ABI, LX_VAULT_ABI, LX_FEED_ABI, LX_ORACLE_ABI,
34
59
  // Addresses
35
- DEX_PRECOMPILES, } from './precompile';
36
- // CLOB client (exports Position as CLOBPosition to avoid conflict)
60
+ LX, DEX_PRECOMPILES, fromLP, toLP, isDEXPrecompile, isBridgePrecompile, } from './precompile';
61
+ // =============================================================================
62
+ // CLOB Client (External ~/work/lux/dex integration)
63
+ // =============================================================================
37
64
  export { CLOBClient, createCLOBClient, } from './client';
38
- // Omnichain router
65
+ // =============================================================================
66
+ // Omnichain Router
67
+ // =============================================================================
39
68
  export * from './router';
40
- // React hooks
69
+ // =============================================================================
70
+ // React Hooks
71
+ // =============================================================================
41
72
  export * from './hooks';