@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.
- 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 +84 -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 +42 -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 +75 -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 +171 -1
- 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/src/precompile/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DEX Precompile Types
|
|
3
|
-
* Native
|
|
3
|
+
* Native Lux v4-style AMM implementation
|
|
4
4
|
*/
|
|
5
5
|
import type { Address } from 'viem'
|
|
6
6
|
|
|
@@ -94,3 +94,202 @@ export function createPoolKey(
|
|
|
94
94
|
const [currency0, currency1] = sortCurrencies(tokenA, tokenB)
|
|
95
95
|
return { currency0, currency1, fee, tickSpacing, hooks }
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// LXBook Types (LP-9020) - CLOB Matching Engine
|
|
100
|
+
// ============================================================================
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Order time-in-force
|
|
104
|
+
*/
|
|
105
|
+
export enum TIF {
|
|
106
|
+
GTC = 0, // Good-til-canceled (resting)
|
|
107
|
+
IOC = 1, // Immediate-or-cancel
|
|
108
|
+
ALO = 2, // Add-liquidity-only (post-only)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Order kind
|
|
113
|
+
*/
|
|
114
|
+
export enum OrderKind {
|
|
115
|
+
LIMIT = 0,
|
|
116
|
+
MARKET = 1,
|
|
117
|
+
STOP_MARKET = 2,
|
|
118
|
+
STOP_LIMIT = 3,
|
|
119
|
+
TAKE_MARKET = 4,
|
|
120
|
+
TAKE_LIMIT = 5,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Order group type
|
|
125
|
+
*/
|
|
126
|
+
export enum GroupType {
|
|
127
|
+
NONE = 0,
|
|
128
|
+
OCO = 1, // One-cancels-other
|
|
129
|
+
BRACKET = 2, // Bracket order
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Action type for execute() endpoint
|
|
134
|
+
*/
|
|
135
|
+
export enum ActionType {
|
|
136
|
+
PLACE = 0,
|
|
137
|
+
CANCEL = 1,
|
|
138
|
+
CANCEL_BY_CLOID = 2,
|
|
139
|
+
MODIFY = 3,
|
|
140
|
+
TWAP_CREATE = 4,
|
|
141
|
+
TWAP_CANCEL = 5,
|
|
142
|
+
SCHEDULE_CANCEL = 6,
|
|
143
|
+
NOOP = 7,
|
|
144
|
+
RESERVE_WEIGHT = 8,
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* LXBook Order (LP-9020)
|
|
149
|
+
*/
|
|
150
|
+
export interface LXOrder {
|
|
151
|
+
marketId: number
|
|
152
|
+
isBuy: boolean
|
|
153
|
+
kind: OrderKind
|
|
154
|
+
sizeX18: bigint
|
|
155
|
+
limitPxX18: bigint
|
|
156
|
+
triggerPxX18: bigint
|
|
157
|
+
reduceOnly: boolean
|
|
158
|
+
tif: TIF
|
|
159
|
+
cloid: `0x${string}`
|
|
160
|
+
groupId: `0x${string}`
|
|
161
|
+
groupType: GroupType
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* LXBook Action (execute() payload)
|
|
166
|
+
*/
|
|
167
|
+
export interface LXAction {
|
|
168
|
+
actionType: ActionType
|
|
169
|
+
nonce: bigint
|
|
170
|
+
expiresAfter: bigint
|
|
171
|
+
data: `0x${string}`
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* LXBook PlaceResult
|
|
176
|
+
*/
|
|
177
|
+
export interface LXPlaceResult {
|
|
178
|
+
oid: bigint
|
|
179
|
+
status: number // 0=rejected, 1=filled, 2=resting, 3=partial
|
|
180
|
+
filledSizeX18: bigint
|
|
181
|
+
avgPxX18: bigint
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* LXBook L1 (best bid/ask)
|
|
186
|
+
*/
|
|
187
|
+
export interface LXL1 {
|
|
188
|
+
bestBidPxX18: bigint
|
|
189
|
+
bestBidSzX18: bigint
|
|
190
|
+
bestAskPxX18: bigint
|
|
191
|
+
bestAskSzX18: bigint
|
|
192
|
+
lastTradePxX18: bigint
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// LXVault Types (LP-9030) - Custody and Risk Engine
|
|
197
|
+
// ============================================================================
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Margin mode
|
|
201
|
+
*/
|
|
202
|
+
export enum MarginMode {
|
|
203
|
+
CROSS = 0,
|
|
204
|
+
ISOLATED = 1,
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Position side
|
|
209
|
+
*/
|
|
210
|
+
export enum PositionSide {
|
|
211
|
+
LONG = 0,
|
|
212
|
+
SHORT = 1,
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* LXVault Account identifier
|
|
217
|
+
*/
|
|
218
|
+
export interface LXAccount {
|
|
219
|
+
main: Address
|
|
220
|
+
subaccountId: number
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* LXVault Position (LP-9030)
|
|
225
|
+
*/
|
|
226
|
+
export interface LXPosition {
|
|
227
|
+
marketId: number
|
|
228
|
+
side: PositionSide
|
|
229
|
+
sizeX18: bigint
|
|
230
|
+
entryPxX18: bigint
|
|
231
|
+
unrealizedPnlX18: bigint
|
|
232
|
+
accumulatedFundingX18: bigint
|
|
233
|
+
lastFundingTime: bigint
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* LXVault MarginInfo
|
|
238
|
+
*/
|
|
239
|
+
export interface LXMarginInfo {
|
|
240
|
+
totalCollateralX18: bigint
|
|
241
|
+
usedMarginX18: bigint
|
|
242
|
+
freeMarginX18: bigint
|
|
243
|
+
marginRatioX18: bigint
|
|
244
|
+
maintenanceMarginX18: bigint
|
|
245
|
+
liquidatable: boolean
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* LXVault Settlement (LXBook → LXVault)
|
|
250
|
+
*/
|
|
251
|
+
export interface LXSettlement {
|
|
252
|
+
maker: LXAccount
|
|
253
|
+
taker: LXAccount
|
|
254
|
+
marketId: number
|
|
255
|
+
takerIsBuy: boolean
|
|
256
|
+
sizeX18: bigint
|
|
257
|
+
priceX18: bigint
|
|
258
|
+
makerFeeX18: bigint
|
|
259
|
+
takerFeeX18: bigint
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* LXVault LiquidationResult
|
|
264
|
+
*/
|
|
265
|
+
export interface LXLiquidationResult {
|
|
266
|
+
liquidated: LXAccount
|
|
267
|
+
liquidator: LXAccount
|
|
268
|
+
marketId: number
|
|
269
|
+
sizeX18: bigint
|
|
270
|
+
priceX18: bigint
|
|
271
|
+
penaltyX18: bigint
|
|
272
|
+
adlTriggered: boolean
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// ============================================================================
|
|
276
|
+
// LXFeed Types (LP-9040) - Price Feeds
|
|
277
|
+
// ============================================================================
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* LXFeed Mark price
|
|
281
|
+
*/
|
|
282
|
+
export interface LXMarkPrice {
|
|
283
|
+
indexPxX18: bigint
|
|
284
|
+
markPxX18: bigint
|
|
285
|
+
premiumX18: bigint
|
|
286
|
+
timestamp: bigint
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* LXFeed Funding rate
|
|
291
|
+
*/
|
|
292
|
+
export interface LXFundingRate {
|
|
293
|
+
rateX18: bigint
|
|
294
|
+
nextFundingTime: bigint
|
|
295
|
+
}
|