@lifi/perps-types 0.1.1-alpha.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 (61) hide show
  1. package/LICENSE.md +201 -0
  2. package/README.md +48 -0
  3. package/package.json +40 -0
  4. package/src/_cjs/account.js +3 -0
  5. package/src/_cjs/account.js.map +1 -0
  6. package/src/_cjs/authorization.js +3 -0
  7. package/src/_cjs/authorization.js.map +1 -0
  8. package/src/_cjs/enums.js +93 -0
  9. package/src/_cjs/enums.js.map +1 -0
  10. package/src/_cjs/errors.js +3 -0
  11. package/src/_cjs/errors.js.map +1 -0
  12. package/src/_cjs/index.js +24 -0
  13. package/src/_cjs/index.js.map +1 -0
  14. package/src/_cjs/market.js +3 -0
  15. package/src/_cjs/market.js.map +1 -0
  16. package/src/_cjs/package.json +1 -0
  17. package/src/_cjs/trading.js +3 -0
  18. package/src/_cjs/trading.js.map +1 -0
  19. package/src/_cjs/typedData.js +3 -0
  20. package/src/_cjs/typedData.js.map +1 -0
  21. package/src/_esm/account.js +2 -0
  22. package/src/_esm/account.js.map +1 -0
  23. package/src/_esm/authorization.js +2 -0
  24. package/src/_esm/authorization.js.map +1 -0
  25. package/src/_esm/enums.js +96 -0
  26. package/src/_esm/enums.js.map +1 -0
  27. package/src/_esm/errors.js +2 -0
  28. package/src/_esm/errors.js.map +1 -0
  29. package/src/_esm/index.js +8 -0
  30. package/src/_esm/index.js.map +1 -0
  31. package/src/_esm/market.js +2 -0
  32. package/src/_esm/market.js.map +1 -0
  33. package/src/_esm/package.json +1 -0
  34. package/src/_esm/trading.js +2 -0
  35. package/src/_esm/trading.js.map +1 -0
  36. package/src/_esm/typedData.js +2 -0
  37. package/src/_esm/typedData.js.map +1 -0
  38. package/src/_types/account.d.ts +75 -0
  39. package/src/_types/account.d.ts.map +1 -0
  40. package/src/_types/authorization.d.ts +39 -0
  41. package/src/_types/authorization.d.ts.map +1 -0
  42. package/src/_types/enums.d.ts +78 -0
  43. package/src/_types/enums.d.ts.map +1 -0
  44. package/src/_types/errors.d.ts +7 -0
  45. package/src/_types/errors.d.ts.map +1 -0
  46. package/src/_types/index.d.ts +8 -0
  47. package/src/_types/index.d.ts.map +1 -0
  48. package/src/_types/market.d.ts +71 -0
  49. package/src/_types/market.d.ts.map +1 -0
  50. package/src/_types/trading.d.ts +82 -0
  51. package/src/_types/trading.d.ts.map +1 -0
  52. package/src/_types/typedData.d.ts +11 -0
  53. package/src/_types/typedData.d.ts.map +1 -0
  54. package/src/account.ts +88 -0
  55. package/src/authorization.ts +46 -0
  56. package/src/enums.ts +99 -0
  57. package/src/errors.ts +7 -0
  58. package/src/index.ts +7 -0
  59. package/src/market.ts +96 -0
  60. package/src/trading.ts +99 -0
  61. package/src/typedData.ts +19 -0
package/src/market.ts ADDED
@@ -0,0 +1,96 @@
1
+ export interface AuthorizationParam {
2
+ name: string
3
+ type: 'string' | 'number' | 'boolean'
4
+ required: boolean
5
+ }
6
+
7
+ export interface Authorization {
8
+ key: string
9
+ name: string
10
+ params?: AuthorizationParam[]
11
+ }
12
+
13
+ export interface Dex {
14
+ key: string
15
+ name: string
16
+ logoURI: string
17
+ authorizations: Authorization[]
18
+ extraData?: Record<string, unknown>
19
+ }
20
+
21
+ export interface DexesResponse {
22
+ dexes: Dex[]
23
+ }
24
+
25
+ export interface FundingInfo {
26
+ rate: string
27
+ nextFundingTime: number
28
+ }
29
+
30
+ export interface Market {
31
+ symbol: string
32
+ name: string
33
+ logoURI: string
34
+ assetId: number
35
+ dex: string
36
+ szDecimals: number
37
+ maxLeverage: number
38
+ onlyIsolated: boolean
39
+ funding: FundingInfo
40
+ openInterest?: string
41
+ volume24h?: string
42
+ markPrice: string
43
+ }
44
+
45
+ export interface MarketsResponse {
46
+ markets: Market[]
47
+ }
48
+
49
+ export interface PricesResponse {
50
+ prices: Record<string, string>
51
+ }
52
+
53
+ export interface Candle {
54
+ t: number
55
+ o: string
56
+ h: string
57
+ l: string
58
+ c: string
59
+ v: string
60
+ }
61
+
62
+ export interface OhlcvResponse {
63
+ dex: string
64
+ symbol: string
65
+ interval: string
66
+ candles: Candle[]
67
+ }
68
+
69
+ export type OhlcvInterval =
70
+ | '1m'
71
+ | '3m'
72
+ | '5m'
73
+ | '15m'
74
+ | '30m'
75
+ | '1h'
76
+ | '2h'
77
+ | '4h'
78
+ | '8h'
79
+ | '12h'
80
+ | '1d'
81
+ | '3d'
82
+ | '1w'
83
+ | '1M'
84
+
85
+ export interface OrderbookLevel {
86
+ price: string
87
+ size: string
88
+ }
89
+
90
+ export interface OrderbookResponse {
91
+ dex: string
92
+ symbol: string
93
+ bids: OrderbookLevel[]
94
+ asks: OrderbookLevel[]
95
+ timestamp: number
96
+ }
package/src/trading.ts ADDED
@@ -0,0 +1,99 @@
1
+ import type { Address, Hex, PerpsTypedData } from './typedData.js'
2
+ import type {
3
+ OrderActionType,
4
+ OrderSide,
5
+ OrderStatus,
6
+ OrderType,
7
+ TimeInForce,
8
+ TriggerCondition,
9
+ } from './enums.js'
10
+
11
+ export interface TriggerOrderInput {
12
+ triggerPrice: string
13
+ limitPrice?: string
14
+ }
15
+
16
+ export interface CreateOrderRequest {
17
+ dex: string
18
+ address: Address
19
+ signerAddress?: Address
20
+ clientOrderId?: string
21
+ symbol: string
22
+ side: OrderSide
23
+ type: OrderType
24
+ size: string
25
+ price: string
26
+ leverage?: number
27
+ reduceOnly?: boolean
28
+ timeInForce?: TimeInForce
29
+ expiresAt?: string
30
+ takeProfit?: TriggerOrderInput
31
+ stopLoss?: TriggerOrderInput
32
+ }
33
+
34
+ export interface OrderAction {
35
+ action: OrderActionType
36
+ description?: string
37
+ typedData: PerpsTypedData
38
+ }
39
+
40
+ export interface CreateOrderResponse {
41
+ actions: OrderAction[]
42
+ }
43
+
44
+ export interface CancelOrderRequest {
45
+ dex: string
46
+ address: Address
47
+ signerAddress?: Address
48
+ ids: string[]
49
+ }
50
+
51
+ export interface CancelOrderPayloadResponse {
52
+ actions: OrderAction[]
53
+ }
54
+
55
+ export interface SignedOrderAction {
56
+ action: OrderActionType
57
+ typedData: PerpsTypedData
58
+ signature: Hex
59
+ }
60
+
61
+ export interface SubmitOrderRequest {
62
+ dex: string
63
+ address: Address
64
+ signerAddress?: Address
65
+ actions: SignedOrderAction[]
66
+ }
67
+
68
+ export interface OrderActionResult {
69
+ action: OrderActionType
70
+ success: boolean
71
+ orderId?: string
72
+ error?: string
73
+ }
74
+
75
+ export interface SubmitOrderResponse {
76
+ results: OrderActionResult[]
77
+ }
78
+
79
+ export interface Order {
80
+ orderId: string
81
+ clientOrderId?: string
82
+ symbol: string
83
+ side: OrderSide
84
+ type: OrderType
85
+ price?: string
86
+ originalSize: string
87
+ remainingSize: string
88
+ filledSize: string
89
+ timeInForce?: TimeInForce
90
+ expiresAt?: string
91
+ reduceOnly?: boolean
92
+ isTrigger?: boolean
93
+ triggerPrice?: string
94
+ triggerCondition?: TriggerCondition
95
+ status: OrderStatus
96
+ averagePrice?: string
97
+ createdAt: string
98
+ updatedAt: string
99
+ }
@@ -0,0 +1,19 @@
1
+ import type { TypedData, SignedTypedData } from '@lifi/types'
2
+ import type { Address, Hex, TypedDataDomain, TypedDataParameter } from 'viem'
3
+
4
+ export type PerpsTypedDataPrimaryType =
5
+ | 'HyperliquidTransaction:ApproveAgent'
6
+ | 'HyperliquidTransaction:ApproveBuilderFee'
7
+ | 'HyperliquidTransaction:UserSetAbstraction'
8
+ | 'Agent'
9
+
10
+ export type PerpsTypedData = Omit<TypedData, 'primaryType'> & {
11
+ primaryType: PerpsTypedDataPrimaryType
12
+ }
13
+
14
+ export type PerpsSignedTypedData = Omit<SignedTypedData, 'primaryType'> & {
15
+ primaryType: PerpsTypedDataPrimaryType
16
+ }
17
+
18
+ // Re-export viem primitives used across perps types
19
+ export type { Address, Hex, TypedDataDomain, TypedDataParameter }