@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,eAAe,GAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { OrderType } from '../../../enums.js';
|
|
2
|
+
import type { OpenOrder, TriggerOrder } from '../../../account.js';
|
|
3
|
+
import type { Order } from '../../../action.js';
|
|
3
4
|
import type { HlFrontendOpenOrder, HlOrderDetail } from '../types.js';
|
|
4
|
-
|
|
5
|
+
/** Map a Hyperliquid orderType string to the OrderType enum. */
|
|
6
|
+
export declare const mapOrderType: (orderType: string) => OrderType;
|
|
7
|
+
export declare const isTriggerType: (type: OrderType) => boolean;
|
|
8
|
+
export declare const mapOpenOrder: (o: HlFrontendOpenOrder) => OpenOrder;
|
|
9
|
+
export declare const mapTriggerOrder: (o: HlFrontendOpenOrder) => TriggerOrder;
|
|
5
10
|
export declare const mapOrder: (detail: HlOrderDetail) => Order;
|
|
6
11
|
//# sourceMappingURL=order.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/order.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/order.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAEV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAErE,gEAAgE;AAChE,eAAO,MAAM,YAAY,GAAI,WAAW,MAAM,KAAG,SAehD,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,KAAG,OAIjB,CAAA;AAE/B,eAAO,MAAM,YAAY,GAAI,GAAG,mBAAmB,KAAG,SAkBpD,CAAA;AAEF,eAAO,MAAM,eAAe,GAAI,GAAG,mBAAmB,KAAG,YAmBxD,CAAA;AAoCD,eAAO,MAAM,QAAQ,GAAI,QAAQ,aAAa,KAAG,KA0BhD,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Position } from '../../../account.js';
|
|
2
2
|
import type { HlAssetPosition } from '../types.js';
|
|
3
|
-
export declare const mapPosition: (ap: HlAssetPosition
|
|
3
|
+
export declare const mapPosition: (ap: HlAssetPosition) => Position;
|
|
4
4
|
//# sourceMappingURL=position.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/position.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/position.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,WAAW,GAAI,IAAI,eAAe,KAAG,QA2BjD,CAAA"}
|
|
@@ -1,7 +1 @@
|
|
|
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 declare const resolveAssetIdFromLookup: (lookup: Map<string, number>, symbol: string) => number;
|
|
7
1
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../providers/hyperliquid/mappers/shared.ts"],"names":[],"mappings":""}
|
|
@@ -2,8 +2,8 @@ export type HlUniverseItem = {
|
|
|
2
2
|
name: string;
|
|
3
3
|
szDecimals: number;
|
|
4
4
|
maxLeverage: number;
|
|
5
|
-
onlyIsolated
|
|
6
|
-
isDelisted
|
|
5
|
+
onlyIsolated?: boolean;
|
|
6
|
+
isDelisted?: boolean;
|
|
7
7
|
};
|
|
8
8
|
export type HlMeta = {
|
|
9
9
|
universe: HlUniverseItem[];
|
|
@@ -12,6 +12,7 @@ export type HlAssetCtx = {
|
|
|
12
12
|
funding: string;
|
|
13
13
|
openInterest: string;
|
|
14
14
|
dayNtlVlm: string;
|
|
15
|
+
prevDayPx: string;
|
|
15
16
|
markPx: string;
|
|
16
17
|
};
|
|
17
18
|
export type HlMetaAndAssetCtxs = [HlMeta, HlAssetCtx[]];
|
|
@@ -87,9 +88,16 @@ export type HlFrontendOpenOrder = {
|
|
|
87
88
|
origSz: string;
|
|
88
89
|
reduceOnly: boolean;
|
|
89
90
|
timestamp: number;
|
|
91
|
+
isTrigger: boolean;
|
|
92
|
+
isPositionTpsl: boolean;
|
|
93
|
+
triggerCondition: string;
|
|
94
|
+
triggerPx: string;
|
|
95
|
+
children: HlFrontendOpenOrder[];
|
|
96
|
+
tif: string | null;
|
|
97
|
+
cloid: string | null;
|
|
90
98
|
};
|
|
91
99
|
export type HlFrontendOpenOrders = HlFrontendOpenOrder[];
|
|
92
|
-
export type HlExtraAgents =
|
|
100
|
+
export type HlExtraAgents = Record<string, unknown>[];
|
|
93
101
|
export type HlUserFill = {
|
|
94
102
|
tid: number;
|
|
95
103
|
coin: string;
|
|
@@ -100,13 +108,10 @@ export type HlUserFill = {
|
|
|
100
108
|
fee: string;
|
|
101
109
|
closedPnl: string;
|
|
102
110
|
time: number;
|
|
111
|
+
startPosition: string;
|
|
103
112
|
};
|
|
104
113
|
export type HlUserFills = HlUserFill[];
|
|
105
114
|
export type HlUserFillsByTime = HlUserFill[];
|
|
106
|
-
export type HlOrderStatusFound = {
|
|
107
|
-
status: 'order';
|
|
108
|
-
order: HlOrderDetail;
|
|
109
|
-
};
|
|
110
115
|
export type HlOrderDetail = {
|
|
111
116
|
order: {
|
|
112
117
|
oid: number;
|
|
@@ -126,12 +131,51 @@ export type HlOrderDetail = {
|
|
|
126
131
|
status: string;
|
|
127
132
|
statusTimestamp: number;
|
|
128
133
|
};
|
|
134
|
+
export type HlOrderStatusFound = {
|
|
135
|
+
status: 'order';
|
|
136
|
+
order: HlOrderDetail;
|
|
137
|
+
};
|
|
129
138
|
export type HlOrderStatusResponse = HlOrderStatusFound | {
|
|
130
139
|
status: 'unknownOid';
|
|
131
140
|
};
|
|
132
|
-
export type
|
|
141
|
+
export type HlLedgerDelta = {
|
|
142
|
+
type: string;
|
|
143
|
+
usdc?: string;
|
|
144
|
+
[key: string]: unknown;
|
|
145
|
+
};
|
|
146
|
+
export type HlLedgerUpdate = {
|
|
147
|
+
time: number;
|
|
148
|
+
hash: string;
|
|
149
|
+
delta: HlLedgerDelta;
|
|
150
|
+
};
|
|
151
|
+
export type HlUserNonFundingLedgerUpdates = HlLedgerUpdate[];
|
|
152
|
+
export type HlFundingDelta = {
|
|
153
|
+
type: 'funding';
|
|
154
|
+
coin: string;
|
|
155
|
+
usdc: string;
|
|
156
|
+
szi: string;
|
|
157
|
+
fundingRate: string;
|
|
158
|
+
};
|
|
159
|
+
export type HlFundingUpdate = {
|
|
160
|
+
time: number;
|
|
161
|
+
hash: string;
|
|
162
|
+
delta: HlFundingDelta;
|
|
163
|
+
};
|
|
164
|
+
export type HlUserFunding = HlFundingUpdate[];
|
|
165
|
+
/**
|
|
166
|
+
* Possible values returned by the `userAbstraction` info endpoint.
|
|
167
|
+
* `null` means abstraction has never been set (standard mode).
|
|
168
|
+
*/
|
|
169
|
+
export declare const HlAbstractionMode: {
|
|
170
|
+
readonly DISABLED: "disabled";
|
|
171
|
+
readonly UNIFIED_ACCOUNT: "unifiedAccount";
|
|
172
|
+
readonly PORTFOLIO_MARGIN: "portfolioMargin";
|
|
173
|
+
readonly DEX_ABSTRACTION: "dexAbstraction";
|
|
174
|
+
};
|
|
175
|
+
export type HlAbstractionMode = (typeof HlAbstractionMode)[keyof typeof HlAbstractionMode];
|
|
176
|
+
export type HlPerpDexs = (null | {
|
|
133
177
|
name: string;
|
|
134
|
-
}
|
|
178
|
+
})[];
|
|
135
179
|
export type HlExchangeRequest = {
|
|
136
180
|
action: Record<string, unknown>;
|
|
137
181
|
signature: {
|
|
@@ -147,7 +191,7 @@ export type HlExchangeResponse = {
|
|
|
147
191
|
response?: string | {
|
|
148
192
|
type: string;
|
|
149
193
|
data?: {
|
|
150
|
-
statuses?:
|
|
194
|
+
statuses?: (string | {
|
|
151
195
|
filled: {
|
|
152
196
|
totalSz: string;
|
|
153
197
|
avgPx: string;
|
|
@@ -169,7 +213,7 @@ export type HlExchangeResponse = {
|
|
|
169
213
|
success: true;
|
|
170
214
|
} | {
|
|
171
215
|
error: string;
|
|
172
|
-
}
|
|
216
|
+
})[];
|
|
173
217
|
status?: unknown;
|
|
174
218
|
};
|
|
175
219
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../providers/hyperliquid/types.ts"],"names":[],"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GACnC;gBAAE,iBAAiB,EAAE;oBAAE,GAAG,EAAE,MAAM,CAAA;iBAAE,CAAA;aAAE,GACtC;gBAAE,OAAO,EAAE,IAAI,CAAA;aAAE,GACjB;gBAAE,KAAK,EAAE,MAAM,CAAA;aAAE,CACpB,EAAE,CAAA;YACH,MAAM,CAAC,EAAE,OAAO,CAAA;SACjB,CAAA;KACF,CAAA;CACN,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ActionType, PerpsSigner } from './enums.js';
|
|
2
|
+
export interface ActionDescriptor {
|
|
3
|
+
type: ActionType;
|
|
4
|
+
signers: PerpsSigner[];
|
|
5
|
+
}
|
|
6
|
+
export interface ProviderMarketInfo {
|
|
7
|
+
id: string;
|
|
8
|
+
quoteAsset: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface Provider {
|
|
11
|
+
key: string;
|
|
12
|
+
name: string;
|
|
13
|
+
logoURI: string;
|
|
14
|
+
prepareAccountActions: ActionDescriptor[];
|
|
15
|
+
actions: ActionDescriptor[];
|
|
16
|
+
markets: ProviderMarketInfo[];
|
|
17
|
+
wsUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ProvidersResponse {
|
|
20
|
+
providers: Provider[];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +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;AAEzD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,WAAW,EAAE,CAAA;CACvB;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,qBAAqB,EAAE,gBAAgB,EAAE,CAAA;IACzC,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,7 +1,7 @@
|
|
|
1
1
|
import type { Address } from './typedData.js';
|
|
2
|
-
import type { Candle, OhlcvInterval, OrderbookResponse
|
|
3
|
-
import type {
|
|
4
|
-
import type { Order } from './
|
|
2
|
+
import type { Candle, OhlcvInterval, OrderbookResponse } from './asset.js';
|
|
3
|
+
import type { Fill, Position } from './account.js';
|
|
4
|
+
import type { Order } from './action.js';
|
|
5
5
|
export type PricesSubscription = {
|
|
6
6
|
channel: 'prices';
|
|
7
7
|
dex: string;
|
|
@@ -9,17 +9,13 @@ export type PricesSubscription = {
|
|
|
9
9
|
export type OrderbookSubscription = {
|
|
10
10
|
channel: 'orderbook';
|
|
11
11
|
dex: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export type TradesSubscription = {
|
|
15
|
-
channel: 'trades';
|
|
16
|
-
dex: string;
|
|
17
|
-
symbol: string;
|
|
12
|
+
assetId: string;
|
|
13
|
+
depth?: number;
|
|
18
14
|
};
|
|
19
15
|
export type CandleSubscription = {
|
|
20
16
|
channel: 'candle';
|
|
21
17
|
dex: string;
|
|
22
|
-
|
|
18
|
+
assetId: string;
|
|
23
19
|
interval: OhlcvInterval;
|
|
24
20
|
};
|
|
25
21
|
export type OrderUpdatesSubscription = {
|
|
@@ -37,19 +33,25 @@ export type PositionsSubscription = {
|
|
|
37
33
|
dex: string;
|
|
38
34
|
address: Address;
|
|
39
35
|
};
|
|
40
|
-
export type
|
|
36
|
+
export type SpotBalancesSubscription = {
|
|
37
|
+
channel: 'spotBalances';
|
|
38
|
+
dex: string;
|
|
39
|
+
address: Address;
|
|
40
|
+
};
|
|
41
|
+
export type Subscription = PricesSubscription | OrderbookSubscription | CandleSubscription | OrderUpdatesSubscription | FillsSubscription | PositionsSubscription | SpotBalancesSubscription;
|
|
42
|
+
export interface SpotBalance {
|
|
43
|
+
coin: string;
|
|
44
|
+
total: string;
|
|
45
|
+
hold: string;
|
|
46
|
+
}
|
|
41
47
|
export type PricesEvent = {
|
|
42
48
|
channel: 'prices';
|
|
43
|
-
data:
|
|
49
|
+
data: Record<string, string>;
|
|
44
50
|
};
|
|
45
51
|
export type OrderbookEvent = {
|
|
46
52
|
channel: 'orderbook';
|
|
47
53
|
data: OrderbookResponse;
|
|
48
54
|
};
|
|
49
|
-
export type TradesEvent = {
|
|
50
|
-
channel: 'trades';
|
|
51
|
-
data: HistoryItem[];
|
|
52
|
-
};
|
|
53
55
|
export type CandleEvent = {
|
|
54
56
|
channel: 'candle';
|
|
55
57
|
data: Candle;
|
|
@@ -60,11 +62,15 @@ export type OrderUpdatesEvent = {
|
|
|
60
62
|
};
|
|
61
63
|
export type FillsEvent = {
|
|
62
64
|
channel: 'fills';
|
|
63
|
-
data:
|
|
65
|
+
data: Fill[];
|
|
64
66
|
};
|
|
65
67
|
export type PositionsEvent = {
|
|
66
68
|
channel: 'positions';
|
|
67
69
|
data: Position[];
|
|
68
70
|
};
|
|
69
|
-
export type
|
|
71
|
+
export type SpotBalancesEvent = {
|
|
72
|
+
channel: 'spotBalances';
|
|
73
|
+
data: SpotBalance[];
|
|
74
|
+
};
|
|
75
|
+
export type SubscriptionEvent = PricesEvent | OrderbookEvent | CandleEvent | OrderUpdatesEvent | FillsEvent | PositionsEvent | SpotBalancesEvent;
|
|
70
76
|
//# sourceMappingURL=subscriptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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AAW,GACX,iBAAiB,GACjB,UAAU,GACV,cAAc,GACd,iBAAiB,CAAA"}
|
package/src/account.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Address } from './typedData.js'
|
|
2
|
+
import type { AssetDisplay } from './asset.js'
|
|
2
3
|
import type {
|
|
3
|
-
|
|
4
|
+
ActivityType,
|
|
5
|
+
FillClassification,
|
|
6
|
+
FillStatus,
|
|
4
7
|
MarginMode,
|
|
5
8
|
OrderSide,
|
|
6
9
|
OrderType,
|
|
@@ -13,9 +16,7 @@ export interface FeeTier {
|
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export interface Position {
|
|
16
|
-
|
|
17
|
-
assetId: number
|
|
18
|
-
dex: string
|
|
19
|
+
asset: AssetDisplay
|
|
19
20
|
side: PositionSide
|
|
20
21
|
size: string
|
|
21
22
|
entryPrice: string
|
|
@@ -29,15 +30,14 @@ export interface Position {
|
|
|
29
30
|
|
|
30
31
|
export interface OpenOrder {
|
|
31
32
|
id: string
|
|
32
|
-
|
|
33
|
-
assetId: number
|
|
34
|
-
dex: string
|
|
33
|
+
asset: AssetDisplay
|
|
35
34
|
side: OrderSide
|
|
36
35
|
type: OrderType
|
|
37
36
|
size: string
|
|
38
37
|
price: string
|
|
39
38
|
filledSize: string
|
|
40
39
|
reduceOnly: boolean
|
|
40
|
+
label?: string
|
|
41
41
|
createdAt: string
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -47,30 +47,52 @@ export interface Balance {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export interface AccountResponse {
|
|
50
|
-
|
|
50
|
+
provider: string
|
|
51
51
|
address: Address
|
|
52
|
-
balances: Balance[]
|
|
52
|
+
balances: Record<string, Balance[]>
|
|
53
53
|
marginUsed: string
|
|
54
54
|
unrealizedPnl: string
|
|
55
55
|
feeTier: FeeTier
|
|
56
|
+
config: Record<string, unknown>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface TriggerOrder {
|
|
60
|
+
id: string
|
|
61
|
+
asset: AssetDisplay
|
|
62
|
+
type: OrderType
|
|
63
|
+
size: string
|
|
64
|
+
triggerPrice: string
|
|
65
|
+
limitPrice?: string
|
|
66
|
+
label?: string
|
|
67
|
+
createdAt: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface PositionsResponse {
|
|
71
|
+
provider: string
|
|
56
72
|
positions: Position[]
|
|
73
|
+
pagination: Pagination
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface OrdersResponse {
|
|
77
|
+
provider: string
|
|
57
78
|
openOrders: OpenOrder[]
|
|
58
|
-
|
|
79
|
+
triggerOrders: TriggerOrder[]
|
|
80
|
+
pagination: Pagination
|
|
59
81
|
}
|
|
60
82
|
|
|
61
|
-
export interface
|
|
83
|
+
export interface Fill {
|
|
62
84
|
id: string
|
|
63
|
-
|
|
64
|
-
assetId: number
|
|
65
|
-
dex: string
|
|
85
|
+
asset: AssetDisplay
|
|
66
86
|
side: OrderSide
|
|
67
87
|
type: OrderType
|
|
68
88
|
size: string
|
|
69
89
|
price: string
|
|
70
|
-
status:
|
|
90
|
+
status: FillStatus
|
|
71
91
|
filledSize?: string
|
|
72
92
|
fee?: string
|
|
73
93
|
realizedPnl?: string | null
|
|
94
|
+
startPosition?: string
|
|
95
|
+
classification: FillClassification
|
|
74
96
|
createdAt: string
|
|
75
97
|
}
|
|
76
98
|
|
|
@@ -81,8 +103,62 @@ export interface Pagination {
|
|
|
81
103
|
nextUrl?: string
|
|
82
104
|
}
|
|
83
105
|
|
|
84
|
-
export interface
|
|
85
|
-
|
|
86
|
-
items:
|
|
106
|
+
export interface FillsResponse {
|
|
107
|
+
provider: string
|
|
108
|
+
items: Fill[]
|
|
109
|
+
pagination: Pagination
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Activities
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
|
|
116
|
+
export interface BaseActivity {
|
|
117
|
+
id: string
|
|
118
|
+
provider: string
|
|
119
|
+
timestamp: string
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface DepositActivity extends BaseActivity {
|
|
123
|
+
type: ActivityType.DEPOSIT
|
|
124
|
+
amount: string
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface WithdrawalActivity extends BaseActivity {
|
|
128
|
+
type: ActivityType.WITHDRAWAL
|
|
129
|
+
amount: string
|
|
130
|
+
fee: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface LiquidatedPosition {
|
|
134
|
+
asset: AssetDisplay
|
|
135
|
+
size: string
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface LiquidationActivity extends BaseActivity {
|
|
139
|
+
type: ActivityType.LIQUIDATION
|
|
140
|
+
liquidatedNotionalPosition: string
|
|
141
|
+
accountValue: string
|
|
142
|
+
leverageType: string
|
|
143
|
+
liquidatedPositions: LiquidatedPosition[]
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface FundingActivity extends BaseActivity {
|
|
147
|
+
type: ActivityType.FUNDING
|
|
148
|
+
asset: AssetDisplay
|
|
149
|
+
amount: string
|
|
150
|
+
positionSize: string
|
|
151
|
+
fundingRate: string
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type ActivityItem =
|
|
155
|
+
| DepositActivity
|
|
156
|
+
| WithdrawalActivity
|
|
157
|
+
| LiquidationActivity
|
|
158
|
+
| FundingActivity
|
|
159
|
+
|
|
160
|
+
export interface ActivitiesResponse {
|
|
161
|
+
provider: string
|
|
162
|
+
items: ActivityItem[]
|
|
87
163
|
pagination: Pagination
|
|
88
164
|
}
|
package/src/action.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { OrderType } from './enums.js'
|
|
2
|
+
import {
|
|
3
|
+
type ActionType,
|
|
4
|
+
type OrderSide,
|
|
5
|
+
type OrderStatus,
|
|
6
|
+
type TimeInForce,
|
|
7
|
+
type TriggerCondition,
|
|
8
|
+
} from './enums.js'
|
|
9
|
+
import type { Address, Hex, PerpsTypedData } from './typedData.js'
|
|
10
|
+
import type { AssetIdentity, AssetDisplay } from './asset.js'
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Action step types (create → sign → execute flow)
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
export interface ActionStep {
|
|
17
|
+
action: ActionType
|
|
18
|
+
typedData: PerpsTypedData
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SignedActionStep {
|
|
22
|
+
action: ActionType
|
|
23
|
+
typedData: PerpsTypedData
|
|
24
|
+
signature: Hex
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ActionResult {
|
|
28
|
+
action: ActionType
|
|
29
|
+
success: boolean
|
|
30
|
+
orderId?: string
|
|
31
|
+
error?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Shared data types
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
export interface TriggerOrderInput {
|
|
39
|
+
triggerPrice: string
|
|
40
|
+
limitPrice?: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ModifyOrderInput {
|
|
44
|
+
id: string
|
|
45
|
+
price?: string
|
|
46
|
+
size?: string
|
|
47
|
+
triggerPrice?: string
|
|
48
|
+
limitPrice?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface Order {
|
|
52
|
+
orderId: string
|
|
53
|
+
asset: AssetDisplay
|
|
54
|
+
side: OrderSide
|
|
55
|
+
type: OrderType
|
|
56
|
+
price?: string
|
|
57
|
+
originalSize: string
|
|
58
|
+
remainingSize: string
|
|
59
|
+
filledSize: string
|
|
60
|
+
timeInForce?: TimeInForce
|
|
61
|
+
expiresAt?: string
|
|
62
|
+
reduceOnly?: boolean
|
|
63
|
+
isTrigger?: boolean
|
|
64
|
+
triggerPrice?: string
|
|
65
|
+
triggerCondition?: TriggerCondition
|
|
66
|
+
status: OrderStatus
|
|
67
|
+
averagePrice?: string
|
|
68
|
+
createdAt: string
|
|
69
|
+
updatedAt: string
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Per-action param types
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
export interface PlaceOrderParams {
|
|
77
|
+
asset: AssetIdentity
|
|
78
|
+
side: OrderSide
|
|
79
|
+
type?: OrderType
|
|
80
|
+
size: string
|
|
81
|
+
price?: string
|
|
82
|
+
leverage?: number
|
|
83
|
+
reduceOnly?: boolean
|
|
84
|
+
timeInForce?: TimeInForce
|
|
85
|
+
expiresAt?: string
|
|
86
|
+
takeProfit?: TriggerOrderInput
|
|
87
|
+
stopLoss?: TriggerOrderInput
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface PlaceTriggerOrderParams {
|
|
91
|
+
asset: AssetIdentity
|
|
92
|
+
side: OrderSide
|
|
93
|
+
takeProfit?: TriggerOrderInput
|
|
94
|
+
stopLoss?: TriggerOrderInput
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface CancelOrderParams {
|
|
98
|
+
ids: string[]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface ModifyOrderParams {
|
|
102
|
+
modifications: ModifyOrderInput[]
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface UpdateLeverageParams {
|
|
106
|
+
asset: AssetIdentity
|
|
107
|
+
leverage: number
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface UpdatePositionMarginParams {
|
|
111
|
+
asset: AssetIdentity
|
|
112
|
+
action: 'add' | 'remove'
|
|
113
|
+
amount: string
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface WithdrawalParams {
|
|
117
|
+
destination: Address
|
|
118
|
+
amount: string
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface ApproveAgentParams {
|
|
122
|
+
agentAddress: string
|
|
123
|
+
agentTtlMs?: number
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface SetAbstractionParams {
|
|
127
|
+
abstraction?: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface SendAssetParams {
|
|
131
|
+
collateral: string
|
|
132
|
+
sourceDex: string
|
|
133
|
+
destinationDex: string
|
|
134
|
+
amount: string
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// ActionParamsMap — compile-time type resolution for SDK
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
|
|
141
|
+
export interface ActionParamsMap {
|
|
142
|
+
[ActionType.APPROVE_AGENT]: ApproveAgentParams
|
|
143
|
+
[ActionType.APPROVE_BUILDER_FEE]: Record<string, never>
|
|
144
|
+
[ActionType.USER_SET_ABSTRACTION]: SetAbstractionParams
|
|
145
|
+
[ActionType.AGENT_SET_ABSTRACTION]: SetAbstractionParams
|
|
146
|
+
[ActionType.SEND_ASSET]: SendAssetParams
|
|
147
|
+
[ActionType.WITHDRAWAL]: WithdrawalParams
|
|
148
|
+
[ActionType.PLACE_ORDER]: PlaceOrderParams
|
|
149
|
+
[ActionType.PLACE_TRIGGER_ORDER]: PlaceTriggerOrderParams
|
|
150
|
+
[ActionType.CANCEL_ORDER]: CancelOrderParams
|
|
151
|
+
[ActionType.MODIFY_ORDER]: ModifyOrderParams
|
|
152
|
+
[ActionType.UPDATE_LEVERAGE]: UpdateLeverageParams
|
|
153
|
+
[ActionType.UPDATE_POSITION_MARGIN]: UpdatePositionMarginParams
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// Request / Response types
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
|
|
160
|
+
export interface CreateActionRequest {
|
|
161
|
+
provider: string
|
|
162
|
+
address: Address
|
|
163
|
+
signerAddress?: Address
|
|
164
|
+
action: ActionType
|
|
165
|
+
params: ActionParamsMap[ActionType]
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface CreateActionResponse {
|
|
169
|
+
actions: ActionStep[]
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface ExecuteActionRequest {
|
|
173
|
+
provider: string
|
|
174
|
+
address: Address
|
|
175
|
+
signerAddress?: Address
|
|
176
|
+
action: ActionType
|
|
177
|
+
actions: SignedActionStep[]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface ExecuteActionResponse {
|
|
181
|
+
results: ActionResult[]
|
|
182
|
+
}
|