@lifi/perps-types 0.1.1-alpha.2 → 0.1.1-alpha.21
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 +24 -7
- package/providers/hyperliquid/package.json +3 -3
- package/src/_cjs/{market.js → action.js} +1 -1
- package/src/_cjs/action.js.map +1 -0
- package/src/_cjs/{trading.js → asset.js} +1 -1
- package/src/_cjs/asset.js.map +1 -0
- package/src/_cjs/enums.js +69 -15
- package/src/_cjs/enums.js.map +1 -1
- package/src/_cjs/index.js +3 -4
- package/src/_cjs/index.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/assetId.js +11 -9
- package/src/_cjs/providers/hyperliquid/assetId.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/mappers/activity.js +66 -0
- package/src/_cjs/providers/hyperliquid/mappers/activity.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/{market.js → asset.js} +9 -9
- package/src/_cjs/providers/hyperliquid/mappers/asset.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/fill.js +64 -0
- package/src/_cjs/providers/hyperliquid/mappers/fill.js.map +1 -0
- package/src/_cjs/providers/hyperliquid/mappers/index.js +12 -7
- package/src/_cjs/providers/hyperliquid/mappers/index.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/mappers/order.js +59 -10
- package/src/_cjs/providers/hyperliquid/mappers/order.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/mappers/position.js +7 -5
- package/src/_cjs/providers/hyperliquid/mappers/position.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/mappers/shared.js +0 -10
- package/src/_cjs/providers/hyperliquid/mappers/shared.js.map +1 -1
- package/src/_cjs/providers/hyperliquid/types.js +7 -0
- package/src/_cjs/providers/hyperliquid/types.js.map +1 -1
- package/src/_cjs/{withdrawal.js → providers.js} +1 -1
- package/src/_cjs/providers.js.map +1 -0
- package/src/_esm/action.js +2 -0
- package/src/_esm/action.js.map +1 -0
- package/src/_esm/asset.js +2 -0
- package/src/_esm/asset.js.map +1 -0
- package/src/_esm/enums.js +68 -14
- package/src/_esm/enums.js.map +1 -1
- package/src/_esm/index.js +3 -4
- package/src/_esm/index.js.map +1 -1
- package/src/_esm/providers/hyperliquid/assetId.js +13 -11
- package/src/_esm/providers/hyperliquid/assetId.js.map +1 -1
- package/src/_esm/providers/hyperliquid/mappers/activity.js +69 -0
- package/src/_esm/providers/hyperliquid/mappers/activity.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/{market.js → asset.js} +7 -7
- package/src/_esm/providers/hyperliquid/mappers/asset.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/fill.js +62 -0
- package/src/_esm/providers/hyperliquid/mappers/fill.js.map +1 -0
- package/src/_esm/providers/hyperliquid/mappers/index.js +4 -4
- package/src/_esm/providers/hyperliquid/mappers/index.js.map +1 -1
- package/src/_esm/providers/hyperliquid/mappers/order.js +56 -9
- package/src/_esm/providers/hyperliquid/mappers/order.js.map +1 -1
- package/src/_esm/providers/hyperliquid/mappers/position.js +7 -5
- package/src/_esm/providers/hyperliquid/mappers/position.js.map +1 -1
- package/src/_esm/providers/hyperliquid/mappers/shared.js +1 -12
- package/src/_esm/providers/hyperliquid/mappers/shared.js.map +1 -1
- package/src/_esm/providers/hyperliquid/types.js +12 -2
- package/src/_esm/providers/hyperliquid/types.js.map +1 -1
- package/src/_esm/providers.js +2 -0
- package/src/_esm/providers.js.map +1 -0
- package/src/_types/account.d.ts +73 -18
- package/src/_types/account.d.ts.map +1 -1
- package/src/_types/action.d.ts +136 -0
- package/src/_types/action.d.ts.map +1 -0
- package/src/_types/{market.d.ts → asset.d.ts} +23 -34
- package/src/_types/asset.d.ts.map +1 -0
- package/src/_types/enums.d.ts +54 -5
- package/src/_types/enums.d.ts.map +1 -1
- package/src/_types/index.d.ts +3 -4
- package/src/_types/index.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/assetId.d.ts +8 -6
- package/src/_types/providers/hyperliquid/assetId.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/mappers/activity.d.ts +13 -0
- package/src/_types/providers/hyperliquid/mappers/activity.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/asset.d.ts +4 -0
- package/src/_types/providers/hyperliquid/mappers/asset.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/fill.d.ts +6 -0
- package/src/_types/providers/hyperliquid/mappers/fill.d.ts.map +1 -0
- package/src/_types/providers/hyperliquid/mappers/index.d.ts +4 -4
- package/src/_types/providers/hyperliquid/mappers/index.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/mappers/order.d.ts +8 -3
- package/src/_types/providers/hyperliquid/mappers/order.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/mappers/position.d.ts +1 -1
- package/src/_types/providers/hyperliquid/mappers/position.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/mappers/shared.d.ts +0 -6
- package/src/_types/providers/hyperliquid/mappers/shared.d.ts.map +1 -1
- package/src/_types/providers/hyperliquid/types.d.ts +55 -11
- package/src/_types/providers/hyperliquid/types.d.ts.map +1 -1
- package/src/_types/providers.d.ts +22 -0
- package/src/_types/providers.d.ts.map +1 -0
- package/src/_types/subscriptions.d.ts +24 -18
- package/src/_types/subscriptions.d.ts.map +1 -1
- package/src/account.ts +94 -18
- package/src/action.ts +182 -0
- package/src/asset.ts +88 -0
- package/src/enums.ts +63 -3
- package/src/index.ts +3 -4
- package/src/providers/hyperliquid/assetId.ts +18 -12
- package/src/providers/hyperliquid/mappers/activity.ts +94 -0
- package/src/providers/hyperliquid/mappers/{market.ts → asset.ts} +9 -12
- package/src/providers/hyperliquid/mappers/fill.ts +77 -0
- package/src/providers/hyperliquid/mappers/index.ts +10 -4
- package/src/providers/hyperliquid/mappers/order.ts +62 -15
- package/src/providers/hyperliquid/mappers/position.ts +7 -10
- package/src/providers/hyperliquid/mappers/shared.ts +0 -15
- package/src/providers/hyperliquid/types.ts +100 -20
- package/src/providers.ts +25 -0
- package/src/subscriptions.ts +22 -20
- package/src/_cjs/authorization.js +0 -3
- package/src/_cjs/authorization.js.map +0 -1
- package/src/_cjs/market.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/history.js +0 -22
- package/src/_cjs/providers/hyperliquid/mappers/history.js.map +0 -1
- package/src/_cjs/providers/hyperliquid/mappers/market.js.map +0 -1
- package/src/_cjs/trading.js.map +0 -1
- package/src/_cjs/withdrawal.js.map +0 -1
- package/src/_esm/authorization.js +0 -2
- package/src/_esm/authorization.js.map +0 -1
- package/src/_esm/market.js +0 -2
- package/src/_esm/market.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/history.js +0 -18
- package/src/_esm/providers/hyperliquid/mappers/history.js.map +0 -1
- package/src/_esm/providers/hyperliquid/mappers/market.js.map +0 -1
- package/src/_esm/trading.js +0 -2
- package/src/_esm/trading.js.map +0 -1
- package/src/_esm/withdrawal.js +0 -2
- package/src/_esm/withdrawal.js.map +0 -1
- package/src/_types/authorization.d.ts +0 -39
- package/src/_types/authorization.d.ts.map +0 -1
- package/src/_types/market.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/history.d.ts +0 -4
- package/src/_types/providers/hyperliquid/mappers/history.d.ts.map +0 -1
- package/src/_types/providers/hyperliquid/mappers/market.d.ts +0 -4
- package/src/_types/providers/hyperliquid/mappers/market.d.ts.map +0 -1
- package/src/_types/trading.d.ts +0 -82
- package/src/_types/trading.d.ts.map +0 -1
- package/src/_types/withdrawal.d.ts +0 -37
- package/src/_types/withdrawal.d.ts.map +0 -1
- package/src/authorization.ts +0 -46
- package/src/market.ts +0 -97
- package/src/providers/hyperliquid/mappers/history.ts +0 -25
- package/src/trading.ts +0 -99
- package/src/withdrawal.ts +0 -44
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Look up an asset ID by symbol, throwing if the symbol is unknown.
|
|
3
|
-
* Asset ID 0 is a valid Hyperliquid asset (BTC-PERP), so a fallback
|
|
4
|
-
* to 0 would silently corrupt data.
|
|
5
|
-
*/
|
|
6
|
-
export const resolveAssetIdFromLookup = (lookup, symbol) => {
|
|
7
|
-
const id = lookup.get(symbol);
|
|
8
|
-
if (id === undefined) {
|
|
9
|
-
throw new Error(`Unknown asset symbol: ${symbol}`);
|
|
10
|
-
}
|
|
11
|
-
return id;
|
|
12
|
-
};
|
|
1
|
+
"use strict";
|
|
13
2
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/shared.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
// ---------------------------------------------------------------------------
|
|
2
|
-
//
|
|
2
|
+
// Hyperliquid /info response types
|
|
3
3
|
// ---------------------------------------------------------------------------
|
|
4
|
-
|
|
4
|
+
// -- abstraction mode -------------------------------------------------------
|
|
5
|
+
/**
|
|
6
|
+
* Possible values returned by the `userAbstraction` info endpoint.
|
|
7
|
+
* `null` means abstraction has never been set (standard mode).
|
|
8
|
+
*/
|
|
9
|
+
export const HlAbstractionMode = {
|
|
10
|
+
DISABLED: 'disabled',
|
|
11
|
+
UNIFIED_ACCOUNT: 'unifiedAccount',
|
|
12
|
+
PORTFOLIO_MARGIN: 'portfolioMargin',
|
|
13
|
+
DEX_ABSTRACTION: 'dexAbstraction',
|
|
14
|
+
};
|
|
5
15
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../providers/hyperliquid/types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../providers/hyperliquid/types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mCAAmC;AACnC,8EAA8E;AA+N9E,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,UAAU;IACpB,eAAe,EAAE,gBAAgB;IACjC,gBAAgB,EAAE,iBAAiB;IACnC,eAAe,EAAE,gBAAgB;CACzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../providers.ts"],"names":[],"mappings":""}
|
package/src/_types/account.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Address } from './typedData.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AssetDisplay } from './asset.js';
|
|
3
|
+
import type { ActivityType, FillClassification, FillStatus, MarginMode, OrderSide, OrderType, PositionSide } from './enums.js';
|
|
3
4
|
export interface FeeTier {
|
|
4
5
|
maker: string;
|
|
5
6
|
taker: string;
|
|
6
7
|
}
|
|
7
8
|
export interface Position {
|
|
8
|
-
|
|
9
|
-
assetId: number;
|
|
10
|
-
dex: string;
|
|
9
|
+
asset: AssetDisplay;
|
|
11
10
|
side: PositionSide;
|
|
12
11
|
size: string;
|
|
13
12
|
entryPrice: string;
|
|
@@ -20,15 +19,14 @@ export interface Position {
|
|
|
20
19
|
}
|
|
21
20
|
export interface OpenOrder {
|
|
22
21
|
id: string;
|
|
23
|
-
|
|
24
|
-
assetId: number;
|
|
25
|
-
dex: string;
|
|
22
|
+
asset: AssetDisplay;
|
|
26
23
|
side: OrderSide;
|
|
27
24
|
type: OrderType;
|
|
28
25
|
size: string;
|
|
29
26
|
price: string;
|
|
30
27
|
filledSize: string;
|
|
31
28
|
reduceOnly: boolean;
|
|
29
|
+
label?: string;
|
|
32
30
|
createdAt: string;
|
|
33
31
|
}
|
|
34
32
|
export interface Balance {
|
|
@@ -36,29 +34,48 @@ export interface Balance {
|
|
|
36
34
|
amount: string;
|
|
37
35
|
}
|
|
38
36
|
export interface AccountResponse {
|
|
39
|
-
|
|
37
|
+
provider: string;
|
|
40
38
|
address: Address;
|
|
41
|
-
balances: Balance[]
|
|
39
|
+
balances: Record<string, Balance[]>;
|
|
42
40
|
marginUsed: string;
|
|
43
41
|
unrealizedPnl: string;
|
|
44
42
|
feeTier: FeeTier;
|
|
43
|
+
config: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export interface TriggerOrder {
|
|
46
|
+
id: string;
|
|
47
|
+
asset: AssetDisplay;
|
|
48
|
+
type: OrderType;
|
|
49
|
+
size: string;
|
|
50
|
+
triggerPrice: string;
|
|
51
|
+
limitPrice?: string;
|
|
52
|
+
label?: string;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
}
|
|
55
|
+
export interface PositionsResponse {
|
|
56
|
+
provider: string;
|
|
45
57
|
positions: Position[];
|
|
58
|
+
pagination: Pagination;
|
|
59
|
+
}
|
|
60
|
+
export interface OrdersResponse {
|
|
61
|
+
provider: string;
|
|
46
62
|
openOrders: OpenOrder[];
|
|
47
|
-
|
|
63
|
+
triggerOrders: TriggerOrder[];
|
|
64
|
+
pagination: Pagination;
|
|
48
65
|
}
|
|
49
|
-
export interface
|
|
66
|
+
export interface Fill {
|
|
50
67
|
id: string;
|
|
51
|
-
|
|
52
|
-
assetId: number;
|
|
53
|
-
dex: string;
|
|
68
|
+
asset: AssetDisplay;
|
|
54
69
|
side: OrderSide;
|
|
55
70
|
type: OrderType;
|
|
56
71
|
size: string;
|
|
57
72
|
price: string;
|
|
58
|
-
status:
|
|
73
|
+
status: FillStatus;
|
|
59
74
|
filledSize?: string;
|
|
60
75
|
fee?: string;
|
|
61
76
|
realizedPnl?: string | null;
|
|
77
|
+
startPosition?: string;
|
|
78
|
+
classification: FillClassification;
|
|
62
79
|
createdAt: string;
|
|
63
80
|
}
|
|
64
81
|
export interface Pagination {
|
|
@@ -67,9 +84,47 @@ export interface Pagination {
|
|
|
67
84
|
cursor?: string;
|
|
68
85
|
nextUrl?: string;
|
|
69
86
|
}
|
|
70
|
-
export interface
|
|
71
|
-
|
|
72
|
-
items:
|
|
87
|
+
export interface FillsResponse {
|
|
88
|
+
provider: string;
|
|
89
|
+
items: Fill[];
|
|
90
|
+
pagination: Pagination;
|
|
91
|
+
}
|
|
92
|
+
export interface BaseActivity {
|
|
93
|
+
id: string;
|
|
94
|
+
provider: string;
|
|
95
|
+
timestamp: string;
|
|
96
|
+
}
|
|
97
|
+
export interface DepositActivity extends BaseActivity {
|
|
98
|
+
type: ActivityType.DEPOSIT;
|
|
99
|
+
amount: string;
|
|
100
|
+
}
|
|
101
|
+
export interface WithdrawalActivity extends BaseActivity {
|
|
102
|
+
type: ActivityType.WITHDRAWAL;
|
|
103
|
+
amount: string;
|
|
104
|
+
fee: string;
|
|
105
|
+
}
|
|
106
|
+
export interface LiquidatedPosition {
|
|
107
|
+
asset: AssetDisplay;
|
|
108
|
+
size: string;
|
|
109
|
+
}
|
|
110
|
+
export interface LiquidationActivity extends BaseActivity {
|
|
111
|
+
type: ActivityType.LIQUIDATION;
|
|
112
|
+
liquidatedNotionalPosition: string;
|
|
113
|
+
accountValue: string;
|
|
114
|
+
leverageType: string;
|
|
115
|
+
liquidatedPositions: LiquidatedPosition[];
|
|
116
|
+
}
|
|
117
|
+
export interface FundingActivity extends BaseActivity {
|
|
118
|
+
type: ActivityType.FUNDING;
|
|
119
|
+
asset: AssetDisplay;
|
|
120
|
+
amount: string;
|
|
121
|
+
positionSize: string;
|
|
122
|
+
fundingRate: string;
|
|
123
|
+
}
|
|
124
|
+
export type ActivityItem = DepositActivity | WithdrawalActivity | LiquidationActivity | FundingActivity;
|
|
125
|
+
export interface ActivitiesResponse {
|
|
126
|
+
provider: string;
|
|
127
|
+
items: ActivityItem[];
|
|
73
128
|
pagination: Pagination;
|
|
74
129
|
}
|
|
75
130
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../account.ts"],"names":[],"mappings":"AAAA,OAAO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AAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,MAAM,YAAY,GACpB,eAAe,GACf,kBAAkB,GAClB,mBAAmB,GACnB,eAAe,CAAA;AAEnB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;CACvB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { OrderType } from './enums.js';
|
|
2
|
+
import { type ActionType, type OrderSide, type OrderStatus, type TimeInForce, type TriggerCondition } from './enums.js';
|
|
3
|
+
import type { Address, Hex, PerpsTypedData } from './typedData.js';
|
|
4
|
+
import type { AssetIdentity, AssetDisplay } from './asset.js';
|
|
5
|
+
export interface ActionStep {
|
|
6
|
+
action: ActionType;
|
|
7
|
+
typedData: PerpsTypedData;
|
|
8
|
+
}
|
|
9
|
+
export interface SignedActionStep {
|
|
10
|
+
action: ActionType;
|
|
11
|
+
typedData: PerpsTypedData;
|
|
12
|
+
signature: Hex;
|
|
13
|
+
}
|
|
14
|
+
export interface ActionResult {
|
|
15
|
+
action: ActionType;
|
|
16
|
+
success: boolean;
|
|
17
|
+
orderId?: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TriggerOrderInput {
|
|
21
|
+
triggerPrice: string;
|
|
22
|
+
limitPrice?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ModifyOrderInput {
|
|
25
|
+
id: string;
|
|
26
|
+
price?: string;
|
|
27
|
+
size?: string;
|
|
28
|
+
triggerPrice?: string;
|
|
29
|
+
limitPrice?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface Order {
|
|
32
|
+
orderId: string;
|
|
33
|
+
asset: AssetDisplay;
|
|
34
|
+
side: OrderSide;
|
|
35
|
+
type: OrderType;
|
|
36
|
+
price?: string;
|
|
37
|
+
originalSize: string;
|
|
38
|
+
remainingSize: string;
|
|
39
|
+
filledSize: string;
|
|
40
|
+
timeInForce?: TimeInForce;
|
|
41
|
+
expiresAt?: string;
|
|
42
|
+
reduceOnly?: boolean;
|
|
43
|
+
isTrigger?: boolean;
|
|
44
|
+
triggerPrice?: string;
|
|
45
|
+
triggerCondition?: TriggerCondition;
|
|
46
|
+
status: OrderStatus;
|
|
47
|
+
averagePrice?: string;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
updatedAt: string;
|
|
50
|
+
}
|
|
51
|
+
export interface PlaceOrderParams {
|
|
52
|
+
asset: AssetIdentity;
|
|
53
|
+
side: OrderSide;
|
|
54
|
+
type?: OrderType;
|
|
55
|
+
size: string;
|
|
56
|
+
price?: string;
|
|
57
|
+
leverage?: number;
|
|
58
|
+
reduceOnly?: boolean;
|
|
59
|
+
timeInForce?: TimeInForce;
|
|
60
|
+
expiresAt?: string;
|
|
61
|
+
takeProfit?: TriggerOrderInput;
|
|
62
|
+
stopLoss?: TriggerOrderInput;
|
|
63
|
+
}
|
|
64
|
+
export interface PlaceTriggerOrderParams {
|
|
65
|
+
asset: AssetIdentity;
|
|
66
|
+
side: OrderSide;
|
|
67
|
+
takeProfit?: TriggerOrderInput;
|
|
68
|
+
stopLoss?: TriggerOrderInput;
|
|
69
|
+
}
|
|
70
|
+
export interface CancelOrderParams {
|
|
71
|
+
ids: string[];
|
|
72
|
+
}
|
|
73
|
+
export interface ModifyOrderParams {
|
|
74
|
+
modifications: ModifyOrderInput[];
|
|
75
|
+
}
|
|
76
|
+
export interface UpdateLeverageParams {
|
|
77
|
+
asset: AssetIdentity;
|
|
78
|
+
leverage: number;
|
|
79
|
+
}
|
|
80
|
+
export interface UpdatePositionMarginParams {
|
|
81
|
+
asset: AssetIdentity;
|
|
82
|
+
action: 'add' | 'remove';
|
|
83
|
+
amount: string;
|
|
84
|
+
}
|
|
85
|
+
export interface WithdrawalParams {
|
|
86
|
+
destination: Address;
|
|
87
|
+
amount: string;
|
|
88
|
+
}
|
|
89
|
+
export interface ApproveAgentParams {
|
|
90
|
+
agentAddress: string;
|
|
91
|
+
agentTtlMs?: number;
|
|
92
|
+
}
|
|
93
|
+
export interface SetAbstractionParams {
|
|
94
|
+
abstraction?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface SendAssetParams {
|
|
97
|
+
collateral: string;
|
|
98
|
+
sourceDex: string;
|
|
99
|
+
destinationDex: string;
|
|
100
|
+
amount: string;
|
|
101
|
+
}
|
|
102
|
+
export interface ActionParamsMap {
|
|
103
|
+
[ActionType.APPROVE_AGENT]: ApproveAgentParams;
|
|
104
|
+
[ActionType.APPROVE_BUILDER_FEE]: Record<string, never>;
|
|
105
|
+
[ActionType.USER_SET_ABSTRACTION]: SetAbstractionParams;
|
|
106
|
+
[ActionType.AGENT_SET_ABSTRACTION]: SetAbstractionParams;
|
|
107
|
+
[ActionType.SEND_ASSET]: SendAssetParams;
|
|
108
|
+
[ActionType.WITHDRAWAL]: WithdrawalParams;
|
|
109
|
+
[ActionType.PLACE_ORDER]: PlaceOrderParams;
|
|
110
|
+
[ActionType.PLACE_TRIGGER_ORDER]: PlaceTriggerOrderParams;
|
|
111
|
+
[ActionType.CANCEL_ORDER]: CancelOrderParams;
|
|
112
|
+
[ActionType.MODIFY_ORDER]: ModifyOrderParams;
|
|
113
|
+
[ActionType.UPDATE_LEVERAGE]: UpdateLeverageParams;
|
|
114
|
+
[ActionType.UPDATE_POSITION_MARGIN]: UpdatePositionMarginParams;
|
|
115
|
+
}
|
|
116
|
+
export interface CreateActionRequest {
|
|
117
|
+
provider: string;
|
|
118
|
+
address: Address;
|
|
119
|
+
signerAddress?: Address;
|
|
120
|
+
action: ActionType;
|
|
121
|
+
params: ActionParamsMap[ActionType];
|
|
122
|
+
}
|
|
123
|
+
export interface CreateActionResponse {
|
|
124
|
+
actions: ActionStep[];
|
|
125
|
+
}
|
|
126
|
+
export interface ExecuteActionRequest {
|
|
127
|
+
provider: string;
|
|
128
|
+
address: Address;
|
|
129
|
+
signerAddress?: Address;
|
|
130
|
+
action: ActionType;
|
|
131
|
+
actions: SignedActionStep[];
|
|
132
|
+
}
|
|
133
|
+
export interface ExecuteActionResponse {
|
|
134
|
+
results: ActionResult[];
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAM7D,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,cAAc,CAAA;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,cAAc,CAAA;IACzB,SAAS,EAAE,GAAG,CAAA;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,UAAU,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAMD,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,M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AU,CAAC,mBAAmB,CAAC,EAAE,uBAAuB,CAAA;IACzD,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAC5C,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAC5C,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,oBAAoB,CAAA;IAClD,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,0BAA0B,CAAA;CAChE;AAMD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,UAAU,CAAA;IAClB,MAAM,EAAE,eAAe,CAAC,UAAU,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,UAAU,EAAE,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,UAAU,CAAA;IAClB,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,YAAY,EAAE,CAAA;CACxB"}
|
|
@@ -1,47 +1,36 @@
|
|
|
1
|
-
export interface AuthorizationParam {
|
|
2
|
-
name: string;
|
|
3
|
-
type: 'string' | 'number' | 'boolean';
|
|
4
|
-
required: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface Authorization {
|
|
7
|
-
key: string;
|
|
8
|
-
name: string;
|
|
9
|
-
params?: AuthorizationParam[];
|
|
10
|
-
}
|
|
11
|
-
export interface Dex {
|
|
12
|
-
key: string;
|
|
13
|
-
name: string;
|
|
14
|
-
logoURI: string;
|
|
15
|
-
authorizations: Authorization[];
|
|
16
|
-
extraData?: Record<string, unknown>;
|
|
17
|
-
wsUrl?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface DexesResponse {
|
|
20
|
-
dexes: Dex[];
|
|
21
|
-
}
|
|
22
1
|
export interface FundingInfo {
|
|
23
2
|
rate: string;
|
|
24
3
|
nextFundingTime: number;
|
|
25
4
|
}
|
|
26
|
-
export interface
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
export interface AssetIdentity {
|
|
6
|
+
assetId: string;
|
|
7
|
+
market: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Asset extends AssetIdentity {
|
|
10
|
+
displaySymbol: string;
|
|
11
|
+
displayQuote: string | null;
|
|
12
|
+
displayName?: string;
|
|
29
13
|
logoURI: string;
|
|
30
|
-
assetId: number;
|
|
31
|
-
dex: string;
|
|
32
14
|
szDecimals: number;
|
|
33
15
|
maxLeverage: number;
|
|
34
16
|
onlyIsolated: boolean;
|
|
17
|
+
isMarginCollateral?: boolean;
|
|
35
18
|
funding: FundingInfo;
|
|
36
19
|
openInterest?: string;
|
|
37
20
|
volume24h?: string;
|
|
21
|
+
prevDayPrice?: string;
|
|
38
22
|
markPrice: string;
|
|
39
23
|
}
|
|
40
|
-
export
|
|
41
|
-
|
|
24
|
+
export type AssetDisplay = Pick<Asset, 'assetId' | 'market' | 'displaySymbol' | 'displayQuote'>;
|
|
25
|
+
export interface AssetPrice {
|
|
26
|
+
assetId: string;
|
|
27
|
+
price: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AssetsResponse {
|
|
30
|
+
assets: Asset[];
|
|
42
31
|
}
|
|
43
32
|
export interface PricesResponse {
|
|
44
|
-
prices:
|
|
33
|
+
prices: AssetPrice[];
|
|
45
34
|
}
|
|
46
35
|
export interface Candle {
|
|
47
36
|
t: number;
|
|
@@ -52,8 +41,8 @@ export interface Candle {
|
|
|
52
41
|
v: string;
|
|
53
42
|
}
|
|
54
43
|
export interface OhlcvResponse {
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
provider: string;
|
|
45
|
+
assetId: string;
|
|
57
46
|
interval: string;
|
|
58
47
|
candles: Candle[];
|
|
59
48
|
}
|
|
@@ -63,10 +52,10 @@ export interface OrderbookLevel {
|
|
|
63
52
|
size: string;
|
|
64
53
|
}
|
|
65
54
|
export interface OrderbookResponse {
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
provider: string;
|
|
56
|
+
assetId: string;
|
|
68
57
|
bids: OrderbookLevel[];
|
|
69
58
|
asks: OrderbookLevel[];
|
|
70
59
|
timestamp: number;
|
|
71
60
|
}
|
|
72
|
-
//# sourceMappingURL=
|
|
61
|
+
//# sourceMappingURL=asset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../asset.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,KAAM,SAAQ,aAAa;IAC1C,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,OAAO,CAAA;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,OAAO,EAAE,WAAW,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,KAAK,EACL,SAAS,GAAG,QAAQ,GAAG,eAAe,GAAG,cAAc,CACxD,CAAA;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,UAAU,EAAE,CAAA;CACrB;AAED,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,MAAM,MAAM,aAAa,GACrB,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,CAAA;AAER,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,cAAc,EAAE,CAAA;IACtB,IAAI,EAAE,cAAc,EAAE,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
package/src/_types/enums.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare enum PerpsErrorCode {
|
|
|
4
4
|
ValidationError = 2002,
|
|
5
5
|
TimeoutError = 2003,
|
|
6
6
|
ThirdPartyError = 2004,
|
|
7
|
+
SDKError = 2005,
|
|
7
8
|
SignatureInvalid = 2010,
|
|
8
9
|
AgentUnauthorized = 2011,
|
|
9
10
|
ExchangeRejected = 2020,
|
|
@@ -24,7 +25,12 @@ export declare enum OrderSide {
|
|
|
24
25
|
}
|
|
25
26
|
export declare enum OrderType {
|
|
26
27
|
MARKET = "MARKET",
|
|
27
|
-
LIMIT = "LIMIT"
|
|
28
|
+
LIMIT = "LIMIT",
|
|
29
|
+
STOP_MARKET = "STOP_MARKET",
|
|
30
|
+
STOP_LIMIT = "STOP_LIMIT",
|
|
31
|
+
TAKE_PROFIT_MARKET = "TAKE_PROFIT_MARKET",
|
|
32
|
+
TAKE_PROFIT_LIMIT = "TAKE_PROFIT_LIMIT",
|
|
33
|
+
TRIGGER_ONLY = "TRIGGER_ONLY"
|
|
28
34
|
}
|
|
29
35
|
export declare enum PositionSide {
|
|
30
36
|
LONG = "LONG",
|
|
@@ -50,17 +56,25 @@ export declare enum OrderStatus {
|
|
|
50
56
|
EXPIRED = "EXPIRED",
|
|
51
57
|
TRIGGERED = "TRIGGERED"
|
|
52
58
|
}
|
|
53
|
-
export declare enum
|
|
59
|
+
export declare enum FillStatus {
|
|
54
60
|
FILLED = "FILLED",
|
|
55
61
|
PARTIALLY_FILLED = "PARTIALLY_FILLED",
|
|
56
62
|
CANCELLED = "CANCELLED",
|
|
57
63
|
REJECTED = "REJECTED"
|
|
58
64
|
}
|
|
59
|
-
export declare enum
|
|
60
|
-
|
|
65
|
+
export declare enum ActionType {
|
|
66
|
+
APPROVE_AGENT = "approveAgent",
|
|
67
|
+
APPROVE_BUILDER_FEE = "approveBuilderFee",
|
|
68
|
+
USER_SET_ABSTRACTION = "userSetAbstraction",
|
|
69
|
+
AGENT_SET_ABSTRACTION = "agentSetAbstraction",
|
|
70
|
+
SEND_ASSET = "sendAsset",
|
|
71
|
+
WITHDRAWAL = "withdrawal",
|
|
61
72
|
PLACE_ORDER = "placeOrder",
|
|
62
73
|
PLACE_TRIGGER_ORDER = "placeTriggerOrder",
|
|
63
|
-
CANCEL_ORDER = "cancelOrder"
|
|
74
|
+
CANCEL_ORDER = "cancelOrder",
|
|
75
|
+
MODIFY_ORDER = "modifyOrder",
|
|
76
|
+
UPDATE_LEVERAGE = "updateLeverage",
|
|
77
|
+
UPDATE_POSITION_MARGIN = "updatePositionMargin"
|
|
64
78
|
}
|
|
65
79
|
export declare enum TriggerCondition {
|
|
66
80
|
ABOVE = "ABOVE",
|
|
@@ -75,4 +89,39 @@ export declare enum TriggerOrderStatus {
|
|
|
75
89
|
TRIGGERED = "TRIGGERED",
|
|
76
90
|
CANCELLED = "CANCELLED"
|
|
77
91
|
}
|
|
92
|
+
export declare enum ActivityType {
|
|
93
|
+
DEPOSIT = "DEPOSIT",
|
|
94
|
+
WITHDRAWAL = "WITHDRAWAL",
|
|
95
|
+
LIQUIDATION = "LIQUIDATION",
|
|
96
|
+
FUNDING = "FUNDING"
|
|
97
|
+
}
|
|
98
|
+
export declare enum FillClassification {
|
|
99
|
+
OPENED_LONG = "Opened Long",
|
|
100
|
+
OPENED_SHORT = "Opened Short",
|
|
101
|
+
INCREASED_LONG = "Increased Long",
|
|
102
|
+
INCREASED_SHORT = "Increased Short",
|
|
103
|
+
REDUCED_LONG = "Reduced Long",
|
|
104
|
+
REDUCED_SHORT = "Reduced Short",
|
|
105
|
+
CLOSED_LONG = "Closed Long",
|
|
106
|
+
CLOSED_SHORT = "Closed Short",
|
|
107
|
+
SWITCHED_LONG = "Switched Long",
|
|
108
|
+
SWITCHED_SHORT = "Switched Short",
|
|
109
|
+
SPOT_BUY = "Spot Buy",
|
|
110
|
+
SPOT_SELL = "Spot Sell"
|
|
111
|
+
}
|
|
112
|
+
export declare enum LiquidationClassification {
|
|
113
|
+
LIQUIDATED = "Liquidated"
|
|
114
|
+
}
|
|
115
|
+
export declare enum FundingClassification {
|
|
116
|
+
FUNDING = "Funding"
|
|
117
|
+
}
|
|
118
|
+
export declare enum TransferClassification {
|
|
119
|
+
DEPOSIT = "Deposit",
|
|
120
|
+
WITHDRAWAL = "Withdrawal"
|
|
121
|
+
}
|
|
122
|
+
export type ActivityClassification = FillClassification | LiquidationClassification | FundingClassification | TransferClassification;
|
|
123
|
+
export declare enum PerpsSigner {
|
|
124
|
+
USER = "USER",
|
|
125
|
+
AGENT = "AGENT"
|
|
126
|
+
}
|
|
78
127
|
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../enums.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IAExB,YAAY,OAAO;IACnB,WAAW,OAAO;IAClB,eAAe,OAAO;IACtB,YAAY,OAAO;IACnB,eAAe,OAAO;
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../enums.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IAExB,YAAY,OAAO;IACnB,WAAW,OAAO;IAClB,eAAe,OAAO;IACtB,YAAY,OAAO;IACnB,eAAe,OAAO;IACtB,QAAQ,OAAO;IAGf,gBAAgB,OAAO;IACvB,iBAAiB,OAAO;IAGxB,gBAAgB,OAAO;IACvB,kBAAkB,OAAO;IACzB,mBAAmB,OAAO;IAC1B,cAAc,OAAO;IACrB,aAAa,OAAO;IACpB,gBAAgB,OAAO;IAGvB,YAAY,OAAO;IACnB,gBAAgB,OAAO;IACvB,YAAY,OAAO;IAGnB,eAAe,OAAO;IAGtB,aAAa,OAAO;CACrB;AAED,oBAAY,SAAS;IACnB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,WAAW,gBAAgB;IAC3B,UAAU,eAAe;IACzB,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;CAC9B;AAED,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,UAAU;IACpB,QAAQ,aAAa;IACrB,KAAK,UAAU;CA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AS,cAAc;CACxB;AAED,oBAAY,yBAAyB;IACnC,UAAU,eAAe;CAC1B;AAED,oBAAY,qBAAqB;IAC/B,OAAO,YAAY;CACpB;AAED,oBAAY,sBAAsB;IAChC,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAED,MAAM,MAAM,sBAAsB,GAC9B,kBAAkB,GAClB,yBAAyB,GACzB,qBAAqB,GACrB,sBAAsB,CAAA;AAE1B,oBAAY,WAAW;IACrB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB"}
|
package/src/_types/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export * from './typedData.js';
|
|
2
2
|
export * from './enums.js';
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
3
|
+
export * from './providers.js';
|
|
4
|
+
export * from './asset.js';
|
|
5
|
+
export * from './action.js';
|
|
5
6
|
export * from './account.js';
|
|
6
|
-
export * from './trading.js';
|
|
7
|
-
export * from './withdrawal.js';
|
|
8
7
|
export * from './errors.js';
|
|
9
8
|
export * from './subscriptions.js';
|
|
10
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
/** Spot asset IDs use the @pairIndex format (e.g. "@230"). */
|
|
2
|
+
export declare const assetIsSpot: (assetId: string) => boolean;
|
|
1
3
|
/**
|
|
2
|
-
* Calculate the asset ID for a given
|
|
4
|
+
* Calculate the asset ID for a given provider index and asset index.
|
|
3
5
|
*
|
|
4
|
-
* Main
|
|
5
|
-
* HIP-3
|
|
6
|
+
* Main provider (provider = ''): assetId = indexInProvider
|
|
7
|
+
* HIP-3 providers (provider = 'xyz'): assetId = 100_000 + perpDexIndex * 10_000 + indexInProvider
|
|
6
8
|
*/
|
|
7
|
-
export declare const calculateAssetId: (
|
|
9
|
+
export declare const calculateAssetId: (providerIndex: number, indexInProvider: number) => number;
|
|
8
10
|
/**
|
|
9
|
-
* Get the
|
|
11
|
+
* Get the provider index from the given list of provider names.
|
|
10
12
|
*/
|
|
11
|
-
export declare const
|
|
13
|
+
export declare const getProviderIndex: (provider: string, providerNames: string[]) => number;
|
|
12
14
|
//# sourceMappingURL=assetId.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetId.d.ts","sourceRoot":"","sources":["../../../providers/hyperliquid/assetId.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,
|
|
1
|
+
{"version":3,"file":"assetId.d.ts","sourceRoot":"","sources":["../../../providers/hyperliquid/assetId.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,OAAkC,CAAA;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,MAAM,EACrB,iBAAiB,MAAM,KACtB,MAKF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,eAAe,MAAM,EAAE,KACtB,MAMF,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ActivityItem, FundingActivity } from '../../../account.js';
|
|
2
|
+
import type { HlLedgerUpdate, HlFundingUpdate } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map a Hyperliquid non-funding ledger entry to an ActivityItem.
|
|
5
|
+
* Returns null for unsupported delta types (accountClassTransfer,
|
|
6
|
+
* internalTransfer, subAccountTransfer, spotTransfer).
|
|
7
|
+
*/
|
|
8
|
+
export declare const mapLedgerEntry: (entry: HlLedgerUpdate, providerKey: string) => ActivityItem | null;
|
|
9
|
+
/**
|
|
10
|
+
* Map a Hyperliquid funding entry to a FundingActivity.
|
|
11
|
+
*/
|
|
12
|
+
export declare const mapFundingActivity: (entry: HlFundingUpdate, providerKey: string) => FundingActivity;
|
|
13
|
+
//# sourceMappingURL=activity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/activity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAIZ,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,cAAc,EACrB,aAAa,MAAM,KAClB,YAAY,GAAG,IAqDjB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,eAAe,EACtB,aAAa,MAAM,KAClB,eAcD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/asset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAI7D,eAAO,MAAM,QAAQ,GACnB,UAAU,cAAc,EACxB,UAAU,UAAU,KACnB,KAuBF,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FillClassification } from '../../../enums.js';
|
|
2
|
+
import type { Fill } from '../../../account.js';
|
|
3
|
+
import type { HlUserFill } from '../types.js';
|
|
4
|
+
export declare function classifyFillFromPosition(startPosition: string, side: string, sz: string): FillClassification;
|
|
5
|
+
export declare const mapFill: (fill: HlUserFill) => Fill;
|
|
6
|
+
//# sourceMappingURL=fill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAInB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,kBAAkB,CAqCpB;AAED,eAAO,MAAM,OAAO,GAAI,MAAM,UAAU,KAAG,IAuBzC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { mapOpenOrder, mapOrder } from './order.js';
|
|
1
|
+
export { mapAsset } from './asset.js';
|
|
2
|
+
export { isTriggerType, mapOpenOrder, mapOrder, mapOrderType, mapTriggerOrder, } from './order.js';
|
|
4
3
|
export { mapPosition } from './position.js';
|
|
5
|
-
export {
|
|
4
|
+
export { classifyFillFromPosition, mapFill } from './fill.js';
|
|
5
|
+
export { mapLedgerEntry, mapFundingActivity } from './activity.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|