@lifi/perps-types 0.1.1-alpha.21 → 0.1.1-alpha.23
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/package.json +18 -4
- package/providers/lighter/package.json +5 -0
- package/src/_cjs/enums.js +19 -1
- package/src/_cjs/enums.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/mappers/fill.js +2 -0
- package/src/_cjs/providers/hyperliquid/mappers/fill.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/types.js +8 -1
- package/src/_cjs/providers/hyperliquid/types.js.map +1 -1
- package/src/_cjs/providers/lighter/apiTypes.js +3 -0
- package/src/_cjs/providers/lighter/apiTypes.js.map +1 -0
- package/src/_cjs/providers/lighter/index.js +20 -0
- package/src/_cjs/providers/lighter/index.js.map +1 -0
- package/src/_cjs/providers/lighter/mappers/fill.js +30 -0
- package/src/_cjs/providers/lighter/mappers/fill.js.map +1 -0
- package/src/_cjs/providers/lighter/mappers/index.js +11 -0
- package/src/_cjs/providers/lighter/mappers/index.js.map +1 -0
- package/src/_cjs/providers/lighter/mappers/order.js +84 -0
- package/src/_cjs/providers/lighter/mappers/order.js.map +1 -0
- package/src/_cjs/providers/lighter/mappers/position.js +33 -0
- package/src/_cjs/providers/lighter/mappers/position.js.map +1 -0
- package/src/_cjs/providers/lighter/types.js +23 -0
- package/src/_cjs/providers/lighter/types.js.map +1 -0
- package/src/_esm/enums.js +18 -0
- package/src/_esm/enums.js.map +1 -1
- package/src/_esm/providers/hyperliquid/mappers/fill.js +3 -1
- package/src/_esm/providers/hyperliquid/mappers/fill.js.map +1 -1
- package/src/_esm/providers/hyperliquid/types.js +10 -0
- package/src/_esm/providers/hyperliquid/types.js.map +1 -1
- package/src/_esm/providers/lighter/apiTypes.js +5 -0
- package/src/_esm/providers/lighter/apiTypes.js.map +1 -0
- package/src/_esm/providers/lighter/index.js +4 -0
- package/src/_esm/providers/lighter/index.js.map +1 -0
- package/src/_esm/providers/lighter/mappers/fill.js +32 -0
- package/src/_esm/providers/lighter/mappers/fill.js.map +1 -0
- package/src/_esm/providers/lighter/mappers/index.js +4 -0
- package/src/_esm/providers/lighter/mappers/index.js.map +1 -0
- package/src/_esm/providers/lighter/mappers/order.js +91 -0
- package/src/_esm/providers/lighter/mappers/order.js.map +1 -0
- package/src/_esm/providers/lighter/mappers/position.js +34 -0
- package/src/_esm/providers/lighter/mappers/position.js.map +1 -0
- package/src/_esm/providers/lighter/types.js +30 -0
- package/src/_esm/providers/lighter/types.js.map +1 -0
- package/src/_types/account.d.ts +17 -2
- package/src/_types/account.d.ts.map +1 -1
- package/src/_types/action.d.ts +61 -3
- package/src/_types/action.d.ts.map +1 -1
- package/src/_types/enums.d.ts +19 -3
- package/src/_types/enums.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/mappers/fill.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/types.d.ts +10 -0
- package/src/_types/providers/hyperliquid/types.d.ts.map +1 -1
- package/src/_types/providers/lighter/apiTypes.d.ts +74 -0
- package/src/_types/providers/lighter/apiTypes.d.ts.map +1 -0
- package/src/_types/providers/lighter/index.d.ts +4 -0
- package/src/_types/providers/lighter/index.d.ts.map +1 -0
- package/src/_types/providers/lighter/mappers/fill.d.ts +10 -0
- package/src/_types/providers/lighter/mappers/fill.d.ts.map +1 -0
- package/src/_types/providers/lighter/mappers/index.d.ts +4 -0
- package/src/_types/providers/lighter/mappers/index.d.ts.map +1 -0
- package/src/_types/providers/lighter/mappers/order.d.ts +15 -0
- package/src/_types/providers/lighter/mappers/order.d.ts.map +1 -0
- package/src/_types/providers/lighter/mappers/position.d.ts +9 -0
- package/src/_types/providers/lighter/mappers/position.d.ts.map +1 -0
- package/src/_types/providers/lighter/types.d.ts +90 -0
- package/src/_types/providers/lighter/types.d.ts.map +1 -0
- package/src/_types/providers.d.ts +40 -2
- package/src/_types/providers.d.ts.map +1 -1
- package/src/_types/typedData.d.ts +13 -5
- package/src/_types/typedData.d.ts.map +1 -1
- package/src/account.ts +18 -0
- package/src/action.ts +80 -3
- package/src/enums.ts +18 -0
- package/src/providers/hyperliquid/mappers/fill.ts +3 -0
- package/src/providers/hyperliquid/types.ts +29 -0
- package/src/providers/lighter/apiTypes.ts +84 -0
- package/src/providers/lighter/index.ts +3 -0
- package/src/providers/lighter/mappers/fill.ts +48 -0
- package/src/providers/lighter/mappers/index.ts +3 -0
- package/src/providers/lighter/mappers/order.ts +105 -0
- package/src/providers/lighter/mappers/position.ts +43 -0
- package/src/providers/lighter/types.ts +115 -0
- package/src/providers.ts +41 -2
- package/src/typedData.ts +15 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../providers/lighter/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Fill } from '../../../account.js';
|
|
2
|
+
import type { LtTrade } from '../apiTypes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map a raw Lighter trade to the generic Fill type.
|
|
5
|
+
* @param trade - Raw trade from REST or WS
|
|
6
|
+
* @param accountIndex - The viewer's Lighter account index (to determine buy/sell side)
|
|
7
|
+
* @param symbol - Resolved symbol (market_id → symbol lookup)
|
|
8
|
+
*/
|
|
9
|
+
export declare const mapFill: (trade: LtTrade, accountIndex: number, symbol: string) => Fill;
|
|
10
|
+
//# sourceMappingURL=fill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../../../providers/lighter/mappers/fill.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAK7C;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAClB,OAAO,OAAO,EACd,cAAc,MAAM,EACpB,QAAQ,MAAM,KACb,IAwBF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../providers/lighter/mappers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OpenOrder } from '../../../account.js';
|
|
2
|
+
import type { Order } from '../../../action.js';
|
|
3
|
+
import type { LtOrder } from '../apiTypes.js';
|
|
4
|
+
/**
|
|
5
|
+
* Map a raw Lighter order to the generic OpenOrder type.
|
|
6
|
+
* @param order - Raw order from REST or WS
|
|
7
|
+
* @param symbol - Resolved symbol (market_index → symbol lookup)
|
|
8
|
+
*/
|
|
9
|
+
export declare const mapOrder: (order: LtOrder, symbol: string) => OpenOrder;
|
|
10
|
+
/**
|
|
11
|
+
* Map a raw Lighter order to the rich Order type used by getOrder.
|
|
12
|
+
* Includes status, time-in-force, and remaining/filled sizes.
|
|
13
|
+
*/
|
|
14
|
+
export declare const mapOrderDetail: (order: LtOrder, symbol: string) => Order;
|
|
15
|
+
//# sourceMappingURL=order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../../providers/lighter/mappers/order.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAmD7C;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,EAAE,QAAQ,MAAM,KAAG,SAexD,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,EAAE,QAAQ,MAAM,KAAG,KAmB9D,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Position } from '../../../account.js';
|
|
2
|
+
import type { LtAccountPosition } from '../apiTypes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map a raw Lighter account position to the generic Position type.
|
|
5
|
+
* @param pos - Raw position from REST or WS
|
|
6
|
+
* @param symbol - Resolved symbol (market_id → symbol lookup, or pos.symbol)
|
|
7
|
+
*/
|
|
8
|
+
export declare const mapPosition: (pos: LtAccountPosition, symbol: string) => Position;
|
|
9
|
+
//# sourceMappingURL=position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../../providers/lighter/mappers/position.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,KAAK,iBAAiB,EACtB,QAAQ,MAAM,KACb,QA6BF,CAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** Backend-provided params for SignCreateOrder. */
|
|
2
|
+
export type LtCreateOrderWasmParams = {
|
|
3
|
+
market_index: number;
|
|
4
|
+
client_order_index: number;
|
|
5
|
+
base_amount: number;
|
|
6
|
+
price: number;
|
|
7
|
+
is_ask: number;
|
|
8
|
+
order_type: number;
|
|
9
|
+
time_in_force: number;
|
|
10
|
+
reduce_only: boolean;
|
|
11
|
+
trigger_price: number;
|
|
12
|
+
order_expiry: number;
|
|
13
|
+
integrator_account_index: number;
|
|
14
|
+
integrator_taker_fee: number;
|
|
15
|
+
integrator_maker_fee: number;
|
|
16
|
+
};
|
|
17
|
+
/** Backend-provided params for SignCancelOrder. */
|
|
18
|
+
export type LtCancelOrderWasmParams = {
|
|
19
|
+
market_index: number;
|
|
20
|
+
order_index: number;
|
|
21
|
+
};
|
|
22
|
+
/** Backend-provided params for SignModifyOrder. */
|
|
23
|
+
export type LtModifyOrderWasmParams = {
|
|
24
|
+
market_index: number;
|
|
25
|
+
order_index: number;
|
|
26
|
+
base_amount: number;
|
|
27
|
+
price: number;
|
|
28
|
+
trigger_price: number;
|
|
29
|
+
integrator_account_index: number;
|
|
30
|
+
integrator_taker_fee: number;
|
|
31
|
+
integrator_maker_fee: number;
|
|
32
|
+
};
|
|
33
|
+
/** Backend-provided params for SignUpdateLeverage. */
|
|
34
|
+
export type LtUpdateLeverageWasmParams = {
|
|
35
|
+
market_index: number;
|
|
36
|
+
fraction: number;
|
|
37
|
+
margin_mode: number;
|
|
38
|
+
};
|
|
39
|
+
/** Backend-provided params for SignUpdateMargin. */
|
|
40
|
+
export type LtUpdateMarginWasmParams = {
|
|
41
|
+
market_index: number;
|
|
42
|
+
usdc_amount: number;
|
|
43
|
+
direction: number;
|
|
44
|
+
};
|
|
45
|
+
/** Backend-provided params for SignWithdraw. */
|
|
46
|
+
export type LtWithdrawWasmParams = {
|
|
47
|
+
asset_index: number;
|
|
48
|
+
route_type: number;
|
|
49
|
+
amount: number;
|
|
50
|
+
};
|
|
51
|
+
/** Backend-provided params for SignCancelAllOrders. */
|
|
52
|
+
export type LtCancelAllOrdersWasmParams = {
|
|
53
|
+
/** 0=immediate (cancel GTC), 1=scheduled, 2=abort scheduled */
|
|
54
|
+
time_in_force: number;
|
|
55
|
+
/** Unix timestamp in milliseconds. Use Date.now() for immediate cancels. */
|
|
56
|
+
timestamp_ms: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Backend-provided params for SignChangePubKey (REGISTER_API_KEY).
|
|
60
|
+
*
|
|
61
|
+
* NOTE: `new_public_key` is a placeholder here — the SDK generates the actual
|
|
62
|
+
* keypair via the WASM signer and fills this in before calling SignChangePubKey.
|
|
63
|
+
* This action also requires an L1 Ethereum signature (the user's wallet signs
|
|
64
|
+
* the ChangePubKey message), so it is a hybrid: WASM blob + EIP-191 eth_sign.
|
|
65
|
+
*/
|
|
66
|
+
export type LtChangePubKeyWasmParams = {
|
|
67
|
+
/** API key slot index to register (0-255). SDK fills in the generated public key. */
|
|
68
|
+
api_key_index: number;
|
|
69
|
+
nonce: number;
|
|
70
|
+
};
|
|
71
|
+
export declare const LT_ORDER_TYPE_LIMIT = 0;
|
|
72
|
+
export declare const LT_ORDER_TYPE_MARKET = 1;
|
|
73
|
+
export declare const LT_ORDER_TYPE_STOP_LOSS = 2;
|
|
74
|
+
export declare const LT_ORDER_TYPE_STOP_LOSS_LIMIT = 3;
|
|
75
|
+
export declare const LT_ORDER_TYPE_TAKE_PROFIT = 4;
|
|
76
|
+
export declare const LT_ORDER_TYPE_TAKE_PROFIT_LIMIT = 5;
|
|
77
|
+
export declare const LT_ORDER_TYPE_TWAP = 6;
|
|
78
|
+
export declare const LT_TIME_IN_FORCE_IOC = 0;
|
|
79
|
+
export declare const LT_TIME_IN_FORCE_GTC = 1;
|
|
80
|
+
export declare const LT_TIME_IN_FORCE_POST_ONLY = 2;
|
|
81
|
+
export declare const LT_MARGIN_MODE_CROSS = 0;
|
|
82
|
+
export declare const LT_MARGIN_MODE_ISOLATED = 1;
|
|
83
|
+
export declare const LT_MARGIN_DIRECTION_REMOVE = 0;
|
|
84
|
+
export declare const LT_MARGIN_DIRECTION_ADD = 1;
|
|
85
|
+
export declare const LT_ROUTE_PERP = 0;
|
|
86
|
+
export declare const LT_ROUTE_SPOT = 1;
|
|
87
|
+
export declare const LT_ASSET_ID_USDC = 3;
|
|
88
|
+
export declare const LT_NIL_TRIGGER_PRICE = 0;
|
|
89
|
+
export declare const LT_DEFAULT_ORDER_EXPIRY = -1;
|
|
90
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../providers/lighter/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,38 @@
|
|
|
1
|
-
import type { ActionType, PerpsSigner } from './enums.js';
|
|
1
|
+
import type { ActionType, PerpsSigner, SigningMethod } from './enums.js';
|
|
2
2
|
export interface ActionDescriptor {
|
|
3
3
|
type: ActionType;
|
|
4
4
|
signers: PerpsSigner[];
|
|
5
|
+
/**
|
|
6
|
+
* How the SDK must sign this specific action. Most actions match the
|
|
7
|
+
* provider's dominant pattern (Hyperliquid: EIP712, Lighter: WASM_BLOB),
|
|
8
|
+
* but on-chain bridge actions like DEPOSIT are EVM_TX regardless of
|
|
9
|
+
* provider — the SDK dispatches by this field rather than by
|
|
10
|
+
* `Provider.signingMethod`.
|
|
11
|
+
*/
|
|
12
|
+
signingMethod: SigningMethod;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Self-documenting account-setup step the user must (or may) fulfill before
|
|
16
|
+
* trading with a given provider. Mirrors a single entry of the `config`
|
|
17
|
+
* object returned by `GET /perps/account` — that endpoint reports the
|
|
18
|
+
* *state* of these items, while `Provider.accountConfiguration` declares
|
|
19
|
+
* what items exist and how to fulfill them.
|
|
20
|
+
*
|
|
21
|
+
* Extends `ActionDescriptor` because each item resolves to exactly one
|
|
22
|
+
* action the SDK dispatches when the user proceeds; the additional fields
|
|
23
|
+
* are the presentation and gating metadata the widget needs to render the
|
|
24
|
+
* onboarding overlay without hardcoded labels.
|
|
25
|
+
*
|
|
26
|
+
* `optional: false` means the item must be fulfilled before the user can
|
|
27
|
+
* proceed; `optional: true` means the user may skip it.
|
|
28
|
+
*/
|
|
29
|
+
export interface AccountConfigurationItem extends ActionDescriptor {
|
|
30
|
+
/** User-facing row title rendered in the onboarding overlay. */
|
|
31
|
+
title: string;
|
|
32
|
+
/** User-facing description rendered in the onboarding overlay. */
|
|
33
|
+
description: string;
|
|
34
|
+
/** When true the user may skip the item; when false it gates the trade flow. */
|
|
35
|
+
optional: boolean;
|
|
5
36
|
}
|
|
6
37
|
export interface ProviderMarketInfo {
|
|
7
38
|
id: string;
|
|
@@ -11,7 +42,14 @@ export interface Provider {
|
|
|
11
42
|
key: string;
|
|
12
43
|
name: string;
|
|
13
44
|
logoURI: string;
|
|
14
|
-
|
|
45
|
+
signingMethod: SigningMethod;
|
|
46
|
+
/**
|
|
47
|
+
* Account-setup items required (or optional) for trading with this
|
|
48
|
+
* provider. Replaces the previous `prepareAccountActions: ActionDescriptor[]`:
|
|
49
|
+
* same operational fields, plus the user-facing metadata the widget needs.
|
|
50
|
+
* An empty array is valid and indicates the provider has no setup gates.
|
|
51
|
+
*/
|
|
52
|
+
accountConfiguration: AccountConfigurationItem[];
|
|
15
53
|
actions: ActionDescriptor[];
|
|
16
54
|
markets: ProviderMarketInfo[];
|
|
17
55
|
wsUrl?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAExE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB;;;;;;OAMG;IACH,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAA;IACb,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAA;IACnB,gFAAgF;IAChF,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,aAAa,CAAA;IAC5B;;;;;OAKG;IACH,oBAAoB,EAAE,wBAAwB,EAAE,CAAA;IAChD,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,QAAQ,EAAE,CAAA;CACtB"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import type { TypedData, SignedTypedData } from '@lifi/types';
|
|
2
1
|
import type { Address, Hex, TypedDataDomain, TypedDataParameter } from 'viem';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { HlPrimaryType } from './providers/hyperliquid/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* All known EIP-712 primaryType values across supported providers.
|
|
5
|
+
* Extend this union when adding a new EIP-712 provider.
|
|
6
|
+
*/
|
|
7
|
+
export type PerpsPrimaryType = HlPrimaryType;
|
|
8
|
+
export type PerpsTypedData = {
|
|
9
|
+
domain: TypedDataDomain;
|
|
10
|
+
types: Record<string, readonly TypedDataParameter[]>;
|
|
11
|
+
primaryType: PerpsPrimaryType;
|
|
12
|
+
message: Record<string, any>;
|
|
5
13
|
};
|
|
6
|
-
export type PerpsSignedTypedData =
|
|
7
|
-
|
|
14
|
+
export type PerpsSignedTypedData = PerpsTypedData & {
|
|
15
|
+
signature: Hex;
|
|
8
16
|
};
|
|
9
17
|
export type { Address, Hex, TypedDataDomain, TypedDataParameter };
|
|
10
18
|
//# sourceMappingURL=typedData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typedData.d.ts","sourceRoot":"","sources":["../typedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"typedData.d.ts","sourceRoot":"","sources":["../typedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAErE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAA;AAE5C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC,CAAA;IACpD,WAAW,EAAE,gBAAgB,CAAA;IAE7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG;IAClD,SAAS,EAAE,GAAG,CAAA;CACf,CAAA;AAGD,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAA"}
|
package/src/account.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ActivityType,
|
|
5
5
|
FillClassification,
|
|
6
6
|
FillStatus,
|
|
7
|
+
LiquidityRole,
|
|
7
8
|
MarginMode,
|
|
8
9
|
OrderSide,
|
|
9
10
|
OrderType,
|
|
@@ -82,12 +83,14 @@ export interface OrdersResponse {
|
|
|
82
83
|
|
|
83
84
|
export interface Fill {
|
|
84
85
|
id: string
|
|
86
|
+
orderId: string
|
|
85
87
|
asset: AssetDisplay
|
|
86
88
|
side: OrderSide
|
|
87
89
|
type: OrderType
|
|
88
90
|
size: string
|
|
89
91
|
price: string
|
|
90
92
|
status: FillStatus
|
|
93
|
+
liquidity: LiquidityRole
|
|
91
94
|
filledSize?: string
|
|
92
95
|
fee?: string
|
|
93
96
|
realizedPnl?: string | null
|
|
@@ -151,11 +154,26 @@ export interface FundingActivity extends BaseActivity {
|
|
|
151
154
|
fundingRate: string
|
|
152
155
|
}
|
|
153
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Internal transfer between two accounts on the same L2 (e.g. Lighter
|
|
159
|
+
* `/api/v1/transfer/history`). Direction is relative to the queried
|
|
160
|
+
* account; `counterpartyAccountIndex` identifies the other side.
|
|
161
|
+
*/
|
|
162
|
+
export interface TransferActivity extends BaseActivity {
|
|
163
|
+
type: ActivityType.TRANSFER
|
|
164
|
+
direction: 'IN' | 'OUT'
|
|
165
|
+
counterpartyAccountIndex: number
|
|
166
|
+
asset: string
|
|
167
|
+
amount: string
|
|
168
|
+
meta?: Record<string, unknown>
|
|
169
|
+
}
|
|
170
|
+
|
|
154
171
|
export type ActivityItem =
|
|
155
172
|
| DepositActivity
|
|
156
173
|
| WithdrawalActivity
|
|
157
174
|
| LiquidationActivity
|
|
158
175
|
| FundingActivity
|
|
176
|
+
| TransferActivity
|
|
159
177
|
|
|
160
178
|
export interface ActivitiesResponse {
|
|
161
179
|
provider: string
|
package/src/action.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OrderType } from './enums.js'
|
|
1
|
+
import type { MarginMode, OrderType } from './enums.js'
|
|
2
2
|
import {
|
|
3
3
|
type ActionType,
|
|
4
4
|
type OrderSide,
|
|
@@ -11,19 +11,59 @@ import type { AssetIdentity, AssetDisplay } from './asset.js'
|
|
|
11
11
|
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
// Action step types (create → sign → execute flow)
|
|
14
|
+
//
|
|
15
|
+
// Union by structural shape — the SDK knows which variant to expect based
|
|
16
|
+
// on the provider's `signingMethod` from the /providers response.
|
|
17
|
+
//
|
|
18
|
+
// Eip712 – Hyperliquid and future EVM dexes (EIP-712 typed data + ECDSA sig)
|
|
19
|
+
// WasmBlob – Lighter and zk-rollup dexes (WASM signer → {txType, txInfo, txHash})
|
|
20
|
+
// EvmTx – plain EVM transaction (reserved for future use)
|
|
14
21
|
// ---------------------------------------------------------------------------
|
|
15
22
|
|
|
16
|
-
export interface
|
|
23
|
+
export interface Eip712ActionStep {
|
|
17
24
|
action: ActionType
|
|
18
25
|
typedData: PerpsTypedData
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
export interface
|
|
28
|
+
export interface WasmBlobActionStep {
|
|
29
|
+
action: ActionType
|
|
30
|
+
wasmSignParams: Record<string, unknown>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface EvmTxActionStep {
|
|
34
|
+
action: ActionType
|
|
35
|
+
txParams: Record<string, unknown>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type ActionStep = Eip712ActionStep | WasmBlobActionStep | EvmTxActionStep
|
|
39
|
+
|
|
40
|
+
export interface Eip712SignedActionStep {
|
|
22
41
|
action: ActionType
|
|
23
42
|
typedData: PerpsTypedData
|
|
24
43
|
signature: Hex
|
|
25
44
|
}
|
|
26
45
|
|
|
46
|
+
export interface WasmBlobSignedActionStep {
|
|
47
|
+
action: ActionType
|
|
48
|
+
wasmSignParams: Record<string, unknown>
|
|
49
|
+
signedTx: {
|
|
50
|
+
txType: number
|
|
51
|
+
txInfo: string
|
|
52
|
+
txHash: string
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface EvmTxSignedActionStep {
|
|
57
|
+
action: ActionType
|
|
58
|
+
txParams: Record<string, unknown>
|
|
59
|
+
txHash: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type SignedActionStep =
|
|
63
|
+
| Eip712SignedActionStep
|
|
64
|
+
| WasmBlobSignedActionStep
|
|
65
|
+
| EvmTxSignedActionStep
|
|
66
|
+
|
|
27
67
|
export interface ActionResult {
|
|
28
68
|
action: ActionType
|
|
29
69
|
success: boolean
|
|
@@ -80,6 +120,12 @@ export interface PlaceOrderParams {
|
|
|
80
120
|
size: string
|
|
81
121
|
price?: string
|
|
82
122
|
leverage?: number
|
|
123
|
+
/**
|
|
124
|
+
* Margin mode to use for the position. When omitted, the backend falls back
|
|
125
|
+
* to the provider's default (currently CROSS for both Hyperliquid and
|
|
126
|
+
* Lighter). Callers should set this explicitly when they need ISOLATED.
|
|
127
|
+
*/
|
|
128
|
+
marginMode?: MarginMode
|
|
83
129
|
reduceOnly?: boolean
|
|
84
130
|
timeInForce?: TimeInForce
|
|
85
131
|
expiresAt?: string
|
|
@@ -105,6 +151,12 @@ export interface ModifyOrderParams {
|
|
|
105
151
|
export interface UpdateLeverageParams {
|
|
106
152
|
asset: AssetIdentity
|
|
107
153
|
leverage: number
|
|
154
|
+
/**
|
|
155
|
+
* Margin mode to use for the position. When omitted, the backend falls back
|
|
156
|
+
* to the provider's default (currently CROSS for both Hyperliquid and
|
|
157
|
+
* Lighter). Callers should set this explicitly when they need ISOLATED.
|
|
158
|
+
*/
|
|
159
|
+
marginMode?: MarginMode
|
|
108
160
|
}
|
|
109
161
|
|
|
110
162
|
export interface UpdatePositionMarginParams {
|
|
@@ -118,6 +170,15 @@ export interface WithdrawalParams {
|
|
|
118
170
|
amount: string
|
|
119
171
|
}
|
|
120
172
|
|
|
173
|
+
export interface DepositParams {
|
|
174
|
+
/** Amount of the token to deposit (human-readable, e.g. "100.5"). */
|
|
175
|
+
amount: string
|
|
176
|
+
/** ERC-20 token address on the source chain. */
|
|
177
|
+
tokenAddress: Address
|
|
178
|
+
/** Chain ID of the source chain (e.g. 1 for Ethereum, 42161 for Arbitrum). */
|
|
179
|
+
chainId: number
|
|
180
|
+
}
|
|
181
|
+
|
|
121
182
|
export interface ApproveAgentParams {
|
|
122
183
|
agentAddress: string
|
|
123
184
|
agentTtlMs?: number
|
|
@@ -138,6 +199,18 @@ export interface SendAssetParams {
|
|
|
138
199
|
// ActionParamsMap — compile-time type resolution for SDK
|
|
139
200
|
// ---------------------------------------------------------------------------
|
|
140
201
|
|
|
202
|
+
export interface CancelAllOrdersParams {
|
|
203
|
+
/** 0=immediate (cancel GTC), 1=scheduled, 2=abort scheduled */
|
|
204
|
+
timeInForce: number
|
|
205
|
+
/** Unix timestamp in milliseconds (required for scheduled cancels) */
|
|
206
|
+
timestampMs?: number
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface RegisterApiKeyParams {
|
|
210
|
+
/** The API key slot index to register (0-255). Reusing a fixed slot overwrites the old key. */
|
|
211
|
+
apiKeyIndex: number
|
|
212
|
+
}
|
|
213
|
+
|
|
141
214
|
export interface ActionParamsMap {
|
|
142
215
|
[ActionType.APPROVE_AGENT]: ApproveAgentParams
|
|
143
216
|
[ActionType.APPROVE_BUILDER_FEE]: Record<string, never>
|
|
@@ -145,12 +218,16 @@ export interface ActionParamsMap {
|
|
|
145
218
|
[ActionType.AGENT_SET_ABSTRACTION]: SetAbstractionParams
|
|
146
219
|
[ActionType.SEND_ASSET]: SendAssetParams
|
|
147
220
|
[ActionType.WITHDRAWAL]: WithdrawalParams
|
|
221
|
+
[ActionType.TRANSFER]: Record<string, never>
|
|
148
222
|
[ActionType.PLACE_ORDER]: PlaceOrderParams
|
|
149
223
|
[ActionType.PLACE_TRIGGER_ORDER]: PlaceTriggerOrderParams
|
|
150
224
|
[ActionType.CANCEL_ORDER]: CancelOrderParams
|
|
225
|
+
[ActionType.CANCEL_ALL_ORDERS]: CancelAllOrdersParams
|
|
151
226
|
[ActionType.MODIFY_ORDER]: ModifyOrderParams
|
|
152
227
|
[ActionType.UPDATE_LEVERAGE]: UpdateLeverageParams
|
|
153
228
|
[ActionType.UPDATE_POSITION_MARGIN]: UpdatePositionMarginParams
|
|
229
|
+
[ActionType.REGISTER_API_KEY]: RegisterApiKeyParams
|
|
230
|
+
[ActionType.DEPOSIT]: DepositParams
|
|
154
231
|
}
|
|
155
232
|
|
|
156
233
|
// ---------------------------------------------------------------------------
|
package/src/enums.ts
CHANGED
|
@@ -18,6 +18,7 @@ export enum PerpsErrorCode {
|
|
|
18
18
|
MarketNotFound = 2023,
|
|
19
19
|
OrderNotFound = 2024,
|
|
20
20
|
PositionNotFound = 2025,
|
|
21
|
+
AccountNotFound = 2026,
|
|
21
22
|
|
|
22
23
|
// Nonce errors (2040-2049)
|
|
23
24
|
InvalidNonce = 2040,
|
|
@@ -81,6 +82,11 @@ export enum FillStatus {
|
|
|
81
82
|
REJECTED = 'REJECTED',
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
export enum LiquidityRole {
|
|
86
|
+
MAKER = 'maker',
|
|
87
|
+
TAKER = 'taker',
|
|
88
|
+
}
|
|
89
|
+
|
|
84
90
|
export enum ActionType {
|
|
85
91
|
APPROVE_AGENT = 'approveAgent',
|
|
86
92
|
APPROVE_BUILDER_FEE = 'approveBuilderFee',
|
|
@@ -88,12 +94,16 @@ export enum ActionType {
|
|
|
88
94
|
AGENT_SET_ABSTRACTION = 'agentSetAbstraction',
|
|
89
95
|
SEND_ASSET = 'sendAsset',
|
|
90
96
|
WITHDRAWAL = 'withdrawal',
|
|
97
|
+
TRANSFER = 'transfer',
|
|
91
98
|
PLACE_ORDER = 'placeOrder',
|
|
92
99
|
PLACE_TRIGGER_ORDER = 'placeTriggerOrder',
|
|
93
100
|
CANCEL_ORDER = 'cancelOrder',
|
|
101
|
+
CANCEL_ALL_ORDERS = 'cancelAllOrders',
|
|
94
102
|
MODIFY_ORDER = 'modifyOrder',
|
|
95
103
|
UPDATE_LEVERAGE = 'updateLeverage',
|
|
96
104
|
UPDATE_POSITION_MARGIN = 'updatePositionMargin',
|
|
105
|
+
REGISTER_API_KEY = 'registerApiKey',
|
|
106
|
+
DEPOSIT = 'deposit',
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
export enum TriggerCondition {
|
|
@@ -117,6 +127,7 @@ export enum ActivityType {
|
|
|
117
127
|
WITHDRAWAL = 'WITHDRAWAL',
|
|
118
128
|
LIQUIDATION = 'LIQUIDATION',
|
|
119
129
|
FUNDING = 'FUNDING',
|
|
130
|
+
TRANSFER = 'TRANSFER',
|
|
120
131
|
}
|
|
121
132
|
|
|
122
133
|
export enum FillClassification {
|
|
@@ -156,4 +167,11 @@ export type ActivityClassification =
|
|
|
156
167
|
export enum PerpsSigner {
|
|
157
168
|
USER = 'USER',
|
|
158
169
|
AGENT = 'AGENT',
|
|
170
|
+
API_KEY = 'API_KEY',
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export enum SigningMethod {
|
|
174
|
+
EIP712 = 'eip712',
|
|
175
|
+
WASM_BLOB = 'wasmBlob',
|
|
176
|
+
EVM_TX = 'evmTx',
|
|
159
177
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FillClassification,
|
|
3
3
|
FillStatus,
|
|
4
|
+
LiquidityRole,
|
|
4
5
|
OrderSide,
|
|
5
6
|
OrderType,
|
|
6
7
|
} from '../../../enums.js'
|
|
@@ -53,6 +54,7 @@ export function classifyFillFromPosition(
|
|
|
53
54
|
|
|
54
55
|
export const mapFill = (fill: HlUserFill): Fill => ({
|
|
55
56
|
id: String(fill.tid),
|
|
57
|
+
orderId: String(fill.oid),
|
|
56
58
|
asset: {
|
|
57
59
|
assetId: fill.coin,
|
|
58
60
|
market: '',
|
|
@@ -64,6 +66,7 @@ export const mapFill = (fill: HlUserFill): Fill => ({
|
|
|
64
66
|
size: fill.sz,
|
|
65
67
|
price: fill.px,
|
|
66
68
|
status: FillStatus.FILLED,
|
|
69
|
+
liquidity: fill.crossed ? LiquidityRole.TAKER : LiquidityRole.MAKER,
|
|
67
70
|
filledSize: fill.sz,
|
|
68
71
|
fee: fill.fee,
|
|
69
72
|
realizedPnl: fill.closedPnl === '0' ? null : fill.closedPnl,
|
|
@@ -143,6 +143,7 @@ export type HlExtraAgents = Record<string, unknown>[]
|
|
|
143
143
|
|
|
144
144
|
export type HlUserFill = {
|
|
145
145
|
tid: number
|
|
146
|
+
oid: number
|
|
146
147
|
coin: string
|
|
147
148
|
side: string
|
|
148
149
|
sz: string
|
|
@@ -150,6 +151,7 @@ export type HlUserFill = {
|
|
|
150
151
|
dir: string
|
|
151
152
|
fee: string
|
|
152
153
|
closedPnl: string
|
|
154
|
+
crossed: boolean
|
|
153
155
|
time: number
|
|
154
156
|
startPosition: string
|
|
155
157
|
}
|
|
@@ -278,3 +280,30 @@ export type HlExchangeResponse = {
|
|
|
278
280
|
}
|
|
279
281
|
}
|
|
280
282
|
}
|
|
283
|
+
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
285
|
+
// Hyperliquid EIP-712 primary type constants
|
|
286
|
+
// ---------------------------------------------------------------------------
|
|
287
|
+
|
|
288
|
+
export const HL_PRIMARY_TYPE_APPROVE_AGENT =
|
|
289
|
+
'HyperliquidTransaction:ApproveAgent' as const
|
|
290
|
+
export const HL_PRIMARY_TYPE_APPROVE_BUILDER_FEE =
|
|
291
|
+
'HyperliquidTransaction:ApproveBuilderFee' as const
|
|
292
|
+
export const HL_PRIMARY_TYPE_USER_SET_ABSTRACTION =
|
|
293
|
+
'HyperliquidTransaction:UserSetAbstraction' as const
|
|
294
|
+
export const HL_PRIMARY_TYPE_AGENT_SET_ABSTRACTION =
|
|
295
|
+
'HyperliquidTransaction:AgentSetAbstraction' as const
|
|
296
|
+
export const HL_PRIMARY_TYPE_WITHDRAW =
|
|
297
|
+
'HyperliquidTransaction:Withdraw' as const
|
|
298
|
+
export const HL_PRIMARY_TYPE_SEND_ASSET =
|
|
299
|
+
'HyperliquidTransaction:SendAsset' as const
|
|
300
|
+
export const HL_PRIMARY_TYPE_AGENT = 'Agent' as const
|
|
301
|
+
|
|
302
|
+
export type HlPrimaryType =
|
|
303
|
+
| typeof HL_PRIMARY_TYPE_APPROVE_AGENT
|
|
304
|
+
| typeof HL_PRIMARY_TYPE_APPROVE_BUILDER_FEE
|
|
305
|
+
| typeof HL_PRIMARY_TYPE_USER_SET_ABSTRACTION
|
|
306
|
+
| typeof HL_PRIMARY_TYPE_AGENT_SET_ABSTRACTION
|
|
307
|
+
| typeof HL_PRIMARY_TYPE_WITHDRAW
|
|
308
|
+
| typeof HL_PRIMARY_TYPE_SEND_ASSET
|
|
309
|
+
| typeof HL_PRIMARY_TYPE_AGENT
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Lighter raw API response types — shared between backend (REST) and SDK (WS)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
export type LtAccountPosition = {
|
|
6
|
+
market_id: number
|
|
7
|
+
symbol: string
|
|
8
|
+
initial_margin_fraction: string
|
|
9
|
+
open_order_count: number
|
|
10
|
+
pending_order_count: number
|
|
11
|
+
position_tied_order_count: number
|
|
12
|
+
sign: number
|
|
13
|
+
position: string
|
|
14
|
+
avg_entry_price: string
|
|
15
|
+
position_value: string
|
|
16
|
+
unrealized_pnl: string
|
|
17
|
+
realized_pnl: string
|
|
18
|
+
liquidation_price: string
|
|
19
|
+
total_funding_paid_out: string
|
|
20
|
+
margin_mode: number
|
|
21
|
+
allocated_margin: string
|
|
22
|
+
total_discount: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type LtAccountAsset = {
|
|
26
|
+
symbol: string
|
|
27
|
+
asset_id: number
|
|
28
|
+
balance: string
|
|
29
|
+
locked_balance: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type LtTrade = {
|
|
33
|
+
trade_id: number
|
|
34
|
+
tx_hash: string
|
|
35
|
+
type: string
|
|
36
|
+
market_id: number
|
|
37
|
+
size: string
|
|
38
|
+
price: string
|
|
39
|
+
usd_amount: string
|
|
40
|
+
ask_id: number
|
|
41
|
+
bid_id: number
|
|
42
|
+
ask_account_id: number
|
|
43
|
+
bid_account_id: number
|
|
44
|
+
is_maker_ask: boolean
|
|
45
|
+
block_height: number
|
|
46
|
+
timestamp: number
|
|
47
|
+
// Lighter's OpenAPI spec marks these as required `StrictInt`, but the live
|
|
48
|
+
// /api/v1/trades endpoint omits them on some `type: "trade"` rows (observed
|
|
49
|
+
// on older trades). Treat as optional and let the mapper produce `undefined`
|
|
50
|
+
// for Fill.fee (already optional) when missing.
|
|
51
|
+
taker_fee?: number
|
|
52
|
+
maker_fee?: number
|
|
53
|
+
transaction_time: number
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type LtOrder = {
|
|
57
|
+
order_index: number
|
|
58
|
+
client_order_index: number
|
|
59
|
+
order_id: string
|
|
60
|
+
client_order_id: string
|
|
61
|
+
market_index: number
|
|
62
|
+
owner_account_index: number
|
|
63
|
+
initial_base_amount: string
|
|
64
|
+
price: string
|
|
65
|
+
nonce: number
|
|
66
|
+
remaining_base_amount: string
|
|
67
|
+
is_ask: boolean
|
|
68
|
+
filled_base_amount: string
|
|
69
|
+
filled_quote_amount: string
|
|
70
|
+
side: string
|
|
71
|
+
type: string
|
|
72
|
+
time_in_force: string
|
|
73
|
+
reduce_only: boolean
|
|
74
|
+
trigger_price: string
|
|
75
|
+
order_expiry: number
|
|
76
|
+
status: string
|
|
77
|
+
trigger_status: string
|
|
78
|
+
trigger_time: number
|
|
79
|
+
block_height: number
|
|
80
|
+
timestamp: number
|
|
81
|
+
created_at: number
|
|
82
|
+
updated_at: number
|
|
83
|
+
transaction_time: number
|
|
84
|
+
}
|