@pear-protocol/types 2.21.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +1 -0
- package/dist/fee/entities.d.ts +1 -0
- package/dist/fee/responses.d.ts +26 -0
- package/dist/index.js +7355 -3
- package/dist/rewards/entities.d.ts +28 -0
- package/dist/rewards/payloads.d.ts +7 -0
- package/dist/rewards/responses.d.ts +73 -0
- package/dist/users/entities.d.ts +4 -0
- package/dist/users/response.d.ts +2 -0
- package/package.json +3 -2
- package/dist/auth/api-keys.js +0 -44
- package/dist/auth/entities.js +0 -25
- package/dist/auth/index.js +0 -4
- package/dist/auth/payloads.js +0 -84
- package/dist/auth/response.js +0 -82
- package/dist/baskets/recommended/entities.js +0 -22
- package/dist/baskets/recommended/index.js +0 -2
- package/dist/baskets/recommended/responses.js +0 -8
- package/dist/baskets/saved/entities.js +0 -23
- package/dist/baskets/saved/payloads.js +0 -18
- package/dist/baskets/saved/responses.js +0 -14
- package/dist/bundle.js +0 -36
- package/dist/common/address.js +0 -5
- package/dist/common/array.js +0 -17
- package/dist/common/client-id.js +0 -5
- package/dist/common/hex-string.js +0 -5
- package/dist/common/index.js +0 -4
- package/dist/common/refinement.js +0 -64
- package/dist/common/request.js +0 -24
- package/dist/common/response.js +0 -28
- package/dist/common/schema.js +0 -18
- package/dist/common/trade-legs.js +0 -50
- package/dist/connector/index.js +0 -12
- package/dist/copy/entities.js +0 -151
- package/dist/copy/index.js +0 -5
- package/dist/copy/payloads.js +0 -8
- package/dist/copy/performance.js +0 -63
- package/dist/copy/queries.js +0 -20
- package/dist/copy/responses.js +0 -89
- package/dist/execution/entities.js +0 -196
- package/dist/execution/index.js +0 -3
- package/dist/execution/queries.js +0 -18
- package/dist/execution/responses.js +0 -12
- package/dist/fee/entities.js +0 -34
- package/dist/fee/index.js +0 -3
- package/dist/fee/queries.js +0 -12
- package/dist/fee/responses.js +0 -29
- package/dist/fill/entities.js +0 -82
- package/dist/fill/index.js +0 -3
- package/dist/fill/queries.js +0 -14
- package/dist/fill/responses.js +0 -23
- package/dist/funding/entities.js +0 -16
- package/dist/funding/index.js +0 -3
- package/dist/funding/queries.js +0 -8
- package/dist/funding/responses.js +0 -11
- package/dist/instrument/entities.js +0 -102
- package/dist/instrument/index.js +0 -3
- package/dist/instrument/queries.js +0 -15
- package/dist/instrument/responses.js +0 -20
- package/dist/instrument-precision/index.js +0 -56
- package/dist/ladder/entities.js +0 -24
- package/dist/ladder/index.js +0 -4
- package/dist/ladder/payloads.js +0 -96
- package/dist/ladder/queries.js +0 -12
- package/dist/ladder/responses.js +0 -18
- package/dist/leverage/index.js +0 -2
- package/dist/leverage/payloads.js +0 -14
- package/dist/leverage/response.js +0 -5
- package/dist/margin/index.js +0 -2
- package/dist/margin/payloads.js +0 -20
- package/dist/margin/response.js +0 -11
- package/dist/market/entities.js +0 -52
- package/dist/market/index.js +0 -4
- package/dist/market/payloads.js +0 -11
- package/dist/market/queries.js +0 -19
- package/dist/market/responses.js +0 -18
- package/dist/misc/index.js +0 -2
- package/dist/misc/payloads.js +0 -99
- package/dist/misc/responses.js +0 -85
- package/dist/notification/entities.js +0 -274
- package/dist/notification/index.js +0 -4
- package/dist/notification/payloads.js +0 -15
- package/dist/notification/queries.js +0 -29
- package/dist/notification/responses.js +0 -20
- package/dist/order/entities.js +0 -81
- package/dist/order/index.js +0 -1
- package/dist/portfolio/entities.js +0 -77
- package/dist/portfolio/index.js +0 -3
- package/dist/portfolio/queries.js +0 -34
- package/dist/portfolio/responses.js +0 -33
- package/dist/position/entities.js +0 -433
- package/dist/position/index.js +0 -3
- package/dist/position/queries.js +0 -109
- package/dist/position/responses.js +0 -41
- package/dist/price/entities.js +0 -10
- package/dist/price/index.js +0 -3
- package/dist/price/queries.js +0 -8
- package/dist/price/responses.js +0 -15
- package/dist/realtime/channels.js +0 -16
- package/dist/realtime/frames.js +0 -140
- package/dist/realtime/index.js +0 -6
- package/dist/realtime/messages.js +0 -118
- package/dist/realtime/public-events.js +0 -92
- package/dist/realtime/user-events.js +0 -32
- package/dist/realtime/vault-events.js +0 -42
- package/dist/rebalance/entities.js +0 -86
- package/dist/rebalance/index.js +0 -4
- package/dist/rebalance/payloads.js +0 -56
- package/dist/rebalance/queries.js +0 -14
- package/dist/rebalance/responses.js +0 -41
- package/dist/schedule/entities.js +0 -239
- package/dist/schedule/index.js +0 -5
- package/dist/schedule/payloads.js +0 -85
- package/dist/schedule/queries.js +0 -30
- package/dist/schedule/randomization.js +0 -15
- package/dist/schedule/responses.js +0 -22
- package/dist/schedule/twap-config.js +0 -29
- package/dist/statistics/entities.js +0 -105
- package/dist/statistics/index.js +0 -3
- package/dist/statistics/queries.js +0 -111
- package/dist/statistics/responses.js +0 -67
- package/dist/sync/index.js +0 -2
- package/dist/sync/payloads.js +0 -136
- package/dist/sync/responses.js +0 -28
- package/dist/tca/entities.js +0 -9
- package/dist/tca/index.js +0 -3
- package/dist/tca/queries.js +0 -14
- package/dist/tca/responses.js +0 -126
- package/dist/trade/entities.js +0 -101
- package/dist/trade/index.js +0 -4
- package/dist/trade/payloads.js +0 -84
- package/dist/trade/queries.js +0 -9
- package/dist/trade/responses.js +0 -25
- package/dist/trade-accounts/entities.js +0 -61
- package/dist/trade-accounts/index.js +0 -4
- package/dist/trade-accounts/payloads.js +0 -132
- package/dist/trade-accounts/queries.js +0 -7
- package/dist/trade-accounts/response.js +0 -79
- package/dist/traders/index.js +0 -2
- package/dist/traders/performance.js +0 -21
- package/dist/traders/public.js +0 -192
- package/dist/trigger/common/index.js +0 -39
- package/dist/trigger/entities/conditions.js +0 -174
- package/dist/trigger/entities/index.js +0 -257
- package/dist/trigger/index.js +0 -9
- package/dist/trigger/oracle.js +0 -22
- package/dist/trigger/payloads/conditions.js +0 -213
- package/dist/trigger/payloads/config.js +0 -3
- package/dist/trigger/payloads/index.js +0 -173
- package/dist/trigger/queries.js +0 -16
- package/dist/trigger/refinement/index.js +0 -2
- package/dist/trigger/refinement/static.refinement.js +0 -50
- package/dist/trigger/refinement/trailing.refinement.js +0 -83
- package/dist/trigger/responses.js +0 -18
- package/dist/triggers/entities.js +0 -27
- package/dist/triggers/index.js +0 -3
- package/dist/triggers/queries.js +0 -10
- package/dist/triggers/responses.js +0 -9
- package/dist/users/entities.js +0 -45
- package/dist/users/index.js +0 -4
- package/dist/users/payloads.js +0 -33
- package/dist/users/queries.js +0 -8
- package/dist/users/response.js +0 -28
- package/dist/vaults/entities.js +0 -96
- package/dist/vaults/index.js +0 -4
- package/dist/vaults/payloads.js +0 -65
- package/dist/vaults/queries.js +0 -66
- package/dist/vaults/responses.js +0 -368
- /package/dist/{baskets/saved/index.js → rewards/index.d.ts} +0 -0
package/dist/position/queries.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { normalizeArray, CursorFindParams } from '../common';
|
|
3
|
-
import { Connector } from '../connector';
|
|
4
|
-
|
|
5
|
-
const OrderBy = z.union([
|
|
6
|
-
z.literal("createdAt"),
|
|
7
|
-
z.literal("-createdAt"),
|
|
8
|
-
z.literal("updatedAt"),
|
|
9
|
-
z.literal("-updatedAt")
|
|
10
|
-
]);
|
|
11
|
-
const StatusEnum = z.enum([
|
|
12
|
-
"OPEN",
|
|
13
|
-
"CLOSED"
|
|
14
|
-
]);
|
|
15
|
-
const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(StatusEnum));
|
|
16
|
-
const PositionListParams = CursorFindParams.extend({
|
|
17
|
-
/**
|
|
18
|
-
* Connector filter
|
|
19
|
-
*/
|
|
20
|
-
connector: Connector.optional(),
|
|
21
|
-
/**
|
|
22
|
-
* Status filter
|
|
23
|
-
*/
|
|
24
|
-
status: StatusArray.optional(),
|
|
25
|
-
/**
|
|
26
|
-
* Order by field
|
|
27
|
-
*/
|
|
28
|
-
orderBy: OrderBy.default("-createdAt")
|
|
29
|
-
});
|
|
30
|
-
const ClosedPositionListParams = CursorFindParams.extend({
|
|
31
|
-
/**
|
|
32
|
-
* Capped below the shared 2000 because every row drags its fills along — 2000
|
|
33
|
-
* closed positions could pull tens of thousands of fill rows into one response.
|
|
34
|
-
*/
|
|
35
|
-
limit: z.coerce.number().int().positive().max(200).optional().default(20),
|
|
36
|
-
/**
|
|
37
|
-
* Inclusive bounds on the close time. They filter the same
|
|
38
|
-
* `coalesce(closed_at, updated_at)` expression the ordering and cursor use, so
|
|
39
|
-
* filtering and paging cannot disagree. Absent means unbounded.
|
|
40
|
-
*/
|
|
41
|
-
startDate: z.string().optional(),
|
|
42
|
-
endDate: z.string().optional(),
|
|
43
|
-
/**
|
|
44
|
-
* Narrows the page to one closed position. The only scope `includeSteps` may be
|
|
45
|
-
* asked at — see the refinement below.
|
|
46
|
-
*/
|
|
47
|
-
positionId: z.uuid().optional(),
|
|
48
|
-
/**
|
|
49
|
-
* Whether to return each position's `steps` timeline. Off by default because the array
|
|
50
|
-
* is unbounded, and a caller listing history rarely needs every recorded action of
|
|
51
|
-
* every row. `openedAt` is always present, so omitting steps costs no timestamp.
|
|
52
|
-
*
|
|
53
|
-
* Accepts a real boolean from an SDK caller and its text form from a query string.
|
|
54
|
-
* Deliberately not `z.coerce.boolean()`, which reads the string "false" as true and
|
|
55
|
-
* so cannot be switched off from a URL at all.
|
|
56
|
-
*/
|
|
57
|
-
includeSteps: z.union([
|
|
58
|
-
z.boolean(),
|
|
59
|
-
z.stringbool()
|
|
60
|
-
]).optional().default(false)
|
|
61
|
-
}).refine((params) => !params.includeSteps || params.positionId !== void 0, {
|
|
62
|
-
path: [
|
|
63
|
-
"includeSteps"
|
|
64
|
-
],
|
|
65
|
-
message: "includeSteps requires positionId"
|
|
66
|
-
});
|
|
67
|
-
const OpenPositionListParams = CursorFindParams.extend({
|
|
68
|
-
/**
|
|
69
|
-
* Capped below the shared 2000 because every row drags its fills along — one page
|
|
70
|
-
* of open positions can pull thousands of fill rows into one response.
|
|
71
|
-
*/
|
|
72
|
-
limit: z.coerce.number().int().positive().max(200).optional().default(20),
|
|
73
|
-
/**
|
|
74
|
-
* Narrows the page to one open position. The only scope `includeSteps` may be
|
|
75
|
-
* asked at — see the refinement below.
|
|
76
|
-
*/
|
|
77
|
-
positionId: z.uuid().optional(),
|
|
78
|
-
/**
|
|
79
|
-
* Whether to return each position's `steps` timeline. Off by default because the array
|
|
80
|
-
* is unbounded, and a caller listing history rarely needs every recorded action of
|
|
81
|
-
* every row. `openedAt` is always present, so omitting steps costs no timestamp.
|
|
82
|
-
*
|
|
83
|
-
* Accepts a real boolean from an SDK caller and its text form from a query string.
|
|
84
|
-
* Deliberately not `z.coerce.boolean()`, which reads the string "false" as true and
|
|
85
|
-
* so cannot be switched off from a URL at all.
|
|
86
|
-
*/
|
|
87
|
-
includeSteps: z.union([
|
|
88
|
-
z.boolean(),
|
|
89
|
-
z.stringbool()
|
|
90
|
-
]).optional().default(false)
|
|
91
|
-
}).refine((params) => !params.includeSteps || params.positionId !== void 0, {
|
|
92
|
-
path: [
|
|
93
|
-
"includeSteps"
|
|
94
|
-
],
|
|
95
|
-
message: "includeSteps requires positionId"
|
|
96
|
-
});
|
|
97
|
-
const VaultOpenPositionListParams = CursorFindParams.extend({
|
|
98
|
-
/** Same cap as the private open history: every row drags its fills along. */
|
|
99
|
-
limit: z.coerce.number().int().positive().max(200).optional().default(20)
|
|
100
|
-
}).strict();
|
|
101
|
-
const VaultClosedPositionListParams = CursorFindParams.extend({
|
|
102
|
-
/** Same cap as the private closed history: every row drags its fills along. */
|
|
103
|
-
limit: z.coerce.number().int().positive().max(200).optional().default(20),
|
|
104
|
-
/** Inclusive bounds on the close time, exactly as `ClosedPositionListParams` defines them. */
|
|
105
|
-
startDate: z.string().optional(),
|
|
106
|
-
endDate: z.string().optional()
|
|
107
|
-
}).strict();
|
|
108
|
-
|
|
109
|
-
export { ClosedPositionListParams, OpenPositionListParams, PositionListParams, VaultClosedPositionListParams, VaultOpenPositionListParams };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { CursorResponse } from '../common';
|
|
3
|
-
import { EthereumAddress } from '../common/address';
|
|
4
|
-
import { SignedDecimalString } from '../common/schema';
|
|
5
|
-
import { Connector } from '../connector';
|
|
6
|
-
import { InstrumentId } from '../instrument';
|
|
7
|
-
import { Position, PositionOrigin, ClosedPosition, OpenPosition, VaultOpenPosition, VaultClosedPosition } from './entities';
|
|
8
|
-
|
|
9
|
-
const PositionListResponse = CursorResponse.extend({
|
|
10
|
-
positions: z.array(Position)
|
|
11
|
-
});
|
|
12
|
-
const OpenPositionLite = z.object({
|
|
13
|
-
id: z.uuid(),
|
|
14
|
-
/** The subscription that opened the position is identified only in this authenticated read. */
|
|
15
|
-
copySubscriptionId: z.uuid().optional(),
|
|
16
|
-
positionKey: z.string().trim().min(1, "positionKey must be non-empty"),
|
|
17
|
-
createdAt: z.iso.datetime(),
|
|
18
|
-
exposure: z.record(InstrumentId, SignedDecimalString),
|
|
19
|
-
status: z.literal("OPEN"),
|
|
20
|
-
origin: PositionOrigin,
|
|
21
|
-
connector: Connector
|
|
22
|
-
});
|
|
23
|
-
const OpenPositionLiteListResponse = z.object({
|
|
24
|
-
positions: z.array(OpenPositionLite)
|
|
25
|
-
});
|
|
26
|
-
const ClosedPositionListResponse = CursorResponse.extend({
|
|
27
|
-
positions: z.array(ClosedPosition)
|
|
28
|
-
});
|
|
29
|
-
const OpenPositionListResponse = CursorResponse.extend({
|
|
30
|
-
positions: z.array(OpenPosition)
|
|
31
|
-
});
|
|
32
|
-
const VaultOpenPositionListResponse = CursorResponse.extend({
|
|
33
|
-
vaultAddress: EthereumAddress,
|
|
34
|
-
positions: z.array(VaultOpenPosition)
|
|
35
|
-
});
|
|
36
|
-
const VaultClosedPositionListResponse = CursorResponse.extend({
|
|
37
|
-
vaultAddress: EthereumAddress,
|
|
38
|
-
positions: z.array(VaultClosedPosition)
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export { ClosedPositionListResponse, OpenPositionListResponse, OpenPositionLite, OpenPositionLiteListResponse, PositionListResponse, VaultClosedPositionListResponse, VaultOpenPositionListResponse };
|
package/dist/price/entities.js
DELETED
package/dist/price/index.js
DELETED
package/dist/price/queries.js
DELETED
package/dist/price/responses.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { InstrumentPriceMap } from './entities';
|
|
3
|
-
|
|
4
|
-
const PricesResponse = z.object({
|
|
5
|
-
/**
|
|
6
|
-
* Mid prices for instruments
|
|
7
|
-
*/
|
|
8
|
-
mid: InstrumentPriceMap,
|
|
9
|
-
/**
|
|
10
|
-
* Mark prices for instruments
|
|
11
|
-
*/
|
|
12
|
-
mark: InstrumentPriceMap
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export { PricesResponse };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
const WebsocketPublicChannel = z.enum([
|
|
4
|
-
"prices",
|
|
5
|
-
"funding",
|
|
6
|
-
"trades"
|
|
7
|
-
]);
|
|
8
|
-
const WebsocketChannel = z.enum([
|
|
9
|
-
...WebsocketPublicChannel.options,
|
|
10
|
-
"trigger_events",
|
|
11
|
-
"user_events",
|
|
12
|
-
"vault_events",
|
|
13
|
-
"vault_management"
|
|
14
|
-
]);
|
|
15
|
-
|
|
16
|
-
export { WebsocketChannel, WebsocketPublicChannel };
|
package/dist/realtime/frames.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { EthereumAddress } from '../common/address';
|
|
3
|
-
import { WebsocketChannel } from './channels';
|
|
4
|
-
import { PriceUpdatedData, FundingUpdatedData, TradeExecutedData, TriggerTriggeredPublicData } from './public-events';
|
|
5
|
-
import { UserEventData, UserEventTopic } from './user-events';
|
|
6
|
-
import { PublicVaultInvalidatedData, ManagementVaultInvalidatedData } from './vault-events';
|
|
7
|
-
|
|
8
|
-
const FrameRequestId = z.string().optional();
|
|
9
|
-
const WebsocketWelcomeFrame = z.object({
|
|
10
|
-
type: z.literal("welcome"),
|
|
11
|
-
connectionId: z.string(),
|
|
12
|
-
heartbeatIntervalMs: z.number(),
|
|
13
|
-
resubscribeRequired: z.literal(true)
|
|
14
|
-
});
|
|
15
|
-
const AuthAckFrame = z.object({
|
|
16
|
-
id: FrameRequestId,
|
|
17
|
-
type: z.literal("ack"),
|
|
18
|
-
method: z.literal("auth"),
|
|
19
|
-
ok: z.literal(true)
|
|
20
|
-
});
|
|
21
|
-
const SubscriptionAckFrame = z.object({
|
|
22
|
-
id: FrameRequestId,
|
|
23
|
-
type: z.literal("ack"),
|
|
24
|
-
method: z.enum([
|
|
25
|
-
"subscribe",
|
|
26
|
-
"unsubscribe"
|
|
27
|
-
]),
|
|
28
|
-
channel: WebsocketChannel,
|
|
29
|
-
ok: z.literal(true)
|
|
30
|
-
});
|
|
31
|
-
const WebsocketAckFrame = z.discriminatedUnion("method", [
|
|
32
|
-
AuthAckFrame,
|
|
33
|
-
SubscriptionAckFrame
|
|
34
|
-
]);
|
|
35
|
-
const WebsocketVaultErrorCode = z.enum([
|
|
36
|
-
"FORBIDDEN",
|
|
37
|
-
"SUBSCRIPTION_REVOKED"
|
|
38
|
-
]);
|
|
39
|
-
const WebsocketRequestErrorCode = z.enum([
|
|
40
|
-
"AUTH_EXPIRED",
|
|
41
|
-
"CAPACITY_UNAVAILABLE",
|
|
42
|
-
"INTERNAL_ERROR",
|
|
43
|
-
"INVALID_FRAME",
|
|
44
|
-
"INVALID_JSON",
|
|
45
|
-
"INVALID_MESSAGE",
|
|
46
|
-
"INVALID_SUBSCRIPTION",
|
|
47
|
-
"RATE_LIMITED",
|
|
48
|
-
"TOO_MANY_SUBSCRIPTIONS",
|
|
49
|
-
"UNAUTHENTICATED"
|
|
50
|
-
]);
|
|
51
|
-
const WebsocketErrorCode = z.enum([
|
|
52
|
-
...WebsocketRequestErrorCode.options,
|
|
53
|
-
...WebsocketVaultErrorCode.options
|
|
54
|
-
]);
|
|
55
|
-
const RequestErrorFrame = z.object({
|
|
56
|
-
id: FrameRequestId,
|
|
57
|
-
type: z.literal("error"),
|
|
58
|
-
code: WebsocketRequestErrorCode,
|
|
59
|
-
message: z.string()
|
|
60
|
-
});
|
|
61
|
-
const VaultErrorFrame = z.object({
|
|
62
|
-
id: FrameRequestId,
|
|
63
|
-
type: z.literal("error"),
|
|
64
|
-
code: WebsocketVaultErrorCode,
|
|
65
|
-
message: z.string(),
|
|
66
|
-
// Vaults a FORBIDDEN refusal or SUBSCRIPTION_REVOKED notice applies to.
|
|
67
|
-
vaults: z.array(EthereumAddress)
|
|
68
|
-
});
|
|
69
|
-
const WebsocketErrorFrame = z.discriminatedUnion("code", [
|
|
70
|
-
RequestErrorFrame,
|
|
71
|
-
VaultErrorFrame
|
|
72
|
-
]);
|
|
73
|
-
const PriceUpdatedFrame = z.object({
|
|
74
|
-
type: z.literal("event"),
|
|
75
|
-
channel: z.literal("prices"),
|
|
76
|
-
topic: z.literal("price.updated"),
|
|
77
|
-
data: PriceUpdatedData
|
|
78
|
-
});
|
|
79
|
-
const FundingUpdatedFrame = z.object({
|
|
80
|
-
type: z.literal("event"),
|
|
81
|
-
channel: z.literal("funding"),
|
|
82
|
-
topic: z.literal("funding.updated"),
|
|
83
|
-
data: FundingUpdatedData
|
|
84
|
-
});
|
|
85
|
-
const TradeExecutedFrame = z.object({
|
|
86
|
-
type: z.literal("event"),
|
|
87
|
-
channel: z.literal("trades"),
|
|
88
|
-
topic: z.literal("trade.executed"),
|
|
89
|
-
data: TradeExecutedData
|
|
90
|
-
});
|
|
91
|
-
const TriggerTriggeredPublicFrame = z.object({
|
|
92
|
-
type: z.literal("event"),
|
|
93
|
-
channel: z.literal("trigger_events"),
|
|
94
|
-
topic: z.literal("trigger.triggered.public"),
|
|
95
|
-
data: TriggerTriggeredPublicData
|
|
96
|
-
});
|
|
97
|
-
const UserEventFrame = z.object({
|
|
98
|
-
type: z.literal("event"),
|
|
99
|
-
channel: z.literal("user_events"),
|
|
100
|
-
topic: UserEventTopic,
|
|
101
|
-
data: UserEventData
|
|
102
|
-
});
|
|
103
|
-
const VaultEventsInvalidatedFrame = z.object({
|
|
104
|
-
type: z.literal("event"),
|
|
105
|
-
channel: z.literal("vault_events"),
|
|
106
|
-
topic: z.literal("vault.invalidated"),
|
|
107
|
-
data: PublicVaultInvalidatedData
|
|
108
|
-
});
|
|
109
|
-
const VaultManagementInvalidatedFrame = z.object({
|
|
110
|
-
type: z.literal("event"),
|
|
111
|
-
channel: z.literal("vault_management"),
|
|
112
|
-
topic: z.literal("vault.invalidated"),
|
|
113
|
-
data: ManagementVaultInvalidatedData
|
|
114
|
-
});
|
|
115
|
-
const VaultInvalidatedFrame = z.discriminatedUnion("channel", [
|
|
116
|
-
VaultEventsInvalidatedFrame,
|
|
117
|
-
VaultManagementInvalidatedFrame
|
|
118
|
-
]);
|
|
119
|
-
const WebsocketEventFrame = z.discriminatedUnion("topic", [
|
|
120
|
-
PriceUpdatedFrame,
|
|
121
|
-
FundingUpdatedFrame,
|
|
122
|
-
TradeExecutedFrame,
|
|
123
|
-
TriggerTriggeredPublicFrame,
|
|
124
|
-
UserEventFrame,
|
|
125
|
-
VaultInvalidatedFrame
|
|
126
|
-
]);
|
|
127
|
-
const WebsocketPongFrame = z.object({
|
|
128
|
-
id: FrameRequestId,
|
|
129
|
-
type: z.literal("pong"),
|
|
130
|
-
timestamp: z.iso.datetime()
|
|
131
|
-
});
|
|
132
|
-
const WebsocketFrame = z.discriminatedUnion("type", [
|
|
133
|
-
WebsocketWelcomeFrame,
|
|
134
|
-
WebsocketAckFrame,
|
|
135
|
-
WebsocketErrorFrame,
|
|
136
|
-
WebsocketEventFrame,
|
|
137
|
-
WebsocketPongFrame
|
|
138
|
-
]);
|
|
139
|
-
|
|
140
|
-
export { WebsocketAckFrame, WebsocketErrorCode, WebsocketErrorFrame, WebsocketEventFrame, WebsocketFrame, WebsocketPongFrame, WebsocketRequestErrorCode, WebsocketVaultErrorCode, WebsocketWelcomeFrame };
|
package/dist/realtime/index.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { EthereumAddress } from '../common/address';
|
|
3
|
-
import { Connector } from '../connector';
|
|
4
|
-
import { WebsocketPublicChannel } from './channels';
|
|
5
|
-
import { UserEventTopic } from './user-events';
|
|
6
|
-
|
|
7
|
-
const MAX_VAULTS_PER_CONNECTION = 20;
|
|
8
|
-
const WebsocketRequestId = z.union([
|
|
9
|
-
z.string(),
|
|
10
|
-
z.number()
|
|
11
|
-
]).transform(String).optional();
|
|
12
|
-
const WebsocketPublicParams = z.object({
|
|
13
|
-
connectors: z.array(Connector).optional(),
|
|
14
|
-
instrumentIds: z.array(z.string()).optional()
|
|
15
|
-
}).strict();
|
|
16
|
-
const WebsocketUserEventsParams = z.object({
|
|
17
|
-
topics: z.array(UserEventTopic).optional()
|
|
18
|
-
}).strict();
|
|
19
|
-
const WebsocketTriggerEventsParams = z.object({
|
|
20
|
-
connectors: z.array(Connector).optional(),
|
|
21
|
-
accountIds: z.array(z.string()).optional()
|
|
22
|
-
}).strict();
|
|
23
|
-
const WebsocketVaultEventsParams = z.object({
|
|
24
|
-
vaults: z.array(EthereumAddress).min(1)
|
|
25
|
-
}).strict();
|
|
26
|
-
const PingMessage = z.object({
|
|
27
|
-
id: WebsocketRequestId,
|
|
28
|
-
method: z.literal("ping")
|
|
29
|
-
});
|
|
30
|
-
const AuthMessage = z.object({
|
|
31
|
-
id: WebsocketRequestId,
|
|
32
|
-
method: z.literal("auth"),
|
|
33
|
-
params: z.object({
|
|
34
|
-
accessToken: z.string().min(1)
|
|
35
|
-
}).strict()
|
|
36
|
-
});
|
|
37
|
-
const SubscribePublicMessage = z.object({
|
|
38
|
-
id: WebsocketRequestId,
|
|
39
|
-
method: z.literal("subscribe"),
|
|
40
|
-
channel: WebsocketPublicChannel,
|
|
41
|
-
params: WebsocketPublicParams.optional()
|
|
42
|
-
});
|
|
43
|
-
const SubscribeUserEventsMessage = z.object({
|
|
44
|
-
id: WebsocketRequestId,
|
|
45
|
-
method: z.literal("subscribe"),
|
|
46
|
-
channel: z.literal("user_events"),
|
|
47
|
-
params: WebsocketUserEventsParams.optional()
|
|
48
|
-
});
|
|
49
|
-
const SubscribeTriggerEventsMessage = z.object({
|
|
50
|
-
id: WebsocketRequestId,
|
|
51
|
-
method: z.literal("subscribe"),
|
|
52
|
-
channel: z.literal("trigger_events"),
|
|
53
|
-
params: WebsocketTriggerEventsParams.optional()
|
|
54
|
-
});
|
|
55
|
-
const SubscribeVaultEventsMessage = z.object({
|
|
56
|
-
id: WebsocketRequestId,
|
|
57
|
-
method: z.literal("subscribe"),
|
|
58
|
-
channel: z.literal("vault_events"),
|
|
59
|
-
params: WebsocketVaultEventsParams
|
|
60
|
-
});
|
|
61
|
-
const SubscribeVaultManagementMessage = z.object({
|
|
62
|
-
id: WebsocketRequestId,
|
|
63
|
-
method: z.literal("subscribe"),
|
|
64
|
-
channel: z.literal("vault_management"),
|
|
65
|
-
params: WebsocketVaultEventsParams
|
|
66
|
-
});
|
|
67
|
-
const UnsubscribePublicMessage = z.object({
|
|
68
|
-
id: WebsocketRequestId,
|
|
69
|
-
method: z.literal("unsubscribe"),
|
|
70
|
-
channel: WebsocketPublicChannel,
|
|
71
|
-
params: WebsocketPublicParams.optional()
|
|
72
|
-
});
|
|
73
|
-
const UnsubscribeUserEventsMessage = z.object({
|
|
74
|
-
id: WebsocketRequestId,
|
|
75
|
-
method: z.literal("unsubscribe"),
|
|
76
|
-
channel: z.literal("user_events"),
|
|
77
|
-
params: WebsocketUserEventsParams.optional()
|
|
78
|
-
});
|
|
79
|
-
const UnsubscribeTriggerEventsMessage = z.object({
|
|
80
|
-
id: WebsocketRequestId,
|
|
81
|
-
method: z.literal("unsubscribe"),
|
|
82
|
-
channel: z.literal("trigger_events"),
|
|
83
|
-
params: WebsocketTriggerEventsParams.optional()
|
|
84
|
-
});
|
|
85
|
-
const UnsubscribeVaultEventsMessage = z.object({
|
|
86
|
-
id: WebsocketRequestId,
|
|
87
|
-
method: z.literal("unsubscribe"),
|
|
88
|
-
channel: z.literal("vault_events"),
|
|
89
|
-
params: WebsocketVaultEventsParams.optional()
|
|
90
|
-
});
|
|
91
|
-
const UnsubscribeVaultManagementMessage = z.object({
|
|
92
|
-
id: WebsocketRequestId,
|
|
93
|
-
method: z.literal("unsubscribe"),
|
|
94
|
-
channel: z.literal("vault_management"),
|
|
95
|
-
params: WebsocketVaultEventsParams.optional()
|
|
96
|
-
});
|
|
97
|
-
const SubscribeMessage = z.discriminatedUnion("channel", [
|
|
98
|
-
SubscribePublicMessage,
|
|
99
|
-
SubscribeUserEventsMessage,
|
|
100
|
-
SubscribeTriggerEventsMessage,
|
|
101
|
-
SubscribeVaultEventsMessage,
|
|
102
|
-
SubscribeVaultManagementMessage
|
|
103
|
-
]);
|
|
104
|
-
const UnsubscribeMessage = z.discriminatedUnion("channel", [
|
|
105
|
-
UnsubscribePublicMessage,
|
|
106
|
-
UnsubscribeUserEventsMessage,
|
|
107
|
-
UnsubscribeTriggerEventsMessage,
|
|
108
|
-
UnsubscribeVaultEventsMessage,
|
|
109
|
-
UnsubscribeVaultManagementMessage
|
|
110
|
-
]);
|
|
111
|
-
const WebsocketControlMessage = z.discriminatedUnion("method", [
|
|
112
|
-
AuthMessage,
|
|
113
|
-
PingMessage,
|
|
114
|
-
SubscribeMessage,
|
|
115
|
-
UnsubscribeMessage
|
|
116
|
-
]);
|
|
117
|
-
|
|
118
|
-
export { MAX_VAULTS_PER_CONNECTION, WebsocketControlMessage, WebsocketPublicParams, WebsocketRequestId, WebsocketTriggerEventsParams, WebsocketUserEventsParams, WebsocketVaultEventsParams };
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ClientIdCode } from '../common/client-id';
|
|
3
|
-
import { Connector } from '../connector';
|
|
4
|
-
import { PriceSource } from '../price';
|
|
5
|
-
import { TriggerConditionClose, TpSlBracketType } from '../trigger';
|
|
6
|
-
|
|
7
|
-
const RealtimePrice = z.object({
|
|
8
|
-
// Connector-native instrument id.
|
|
9
|
-
id: z.string(),
|
|
10
|
-
// The price for the subscribed source (mid or mark).
|
|
11
|
-
p: z.string(),
|
|
12
|
-
// Best bid, when the venue reports one.
|
|
13
|
-
bid: z.string().nullable(),
|
|
14
|
-
// Best ask, when the venue reports one.
|
|
15
|
-
ask: z.string().nullable(),
|
|
16
|
-
// Epoch milliseconds of the tick.
|
|
17
|
-
t: z.number()
|
|
18
|
-
});
|
|
19
|
-
const RealtimeFunding = z.object({
|
|
20
|
-
// Connector-native instrument id.
|
|
21
|
-
id: z.string(),
|
|
22
|
-
// Funding rate.
|
|
23
|
-
r: z.string(),
|
|
24
|
-
// Epoch milliseconds of the tick.
|
|
25
|
-
t: z.number(),
|
|
26
|
-
// Next funding time in epoch milliseconds.
|
|
27
|
-
nft: z.number()
|
|
28
|
-
});
|
|
29
|
-
const PublicTradeLeg = z.object({
|
|
30
|
-
// SYMBOL-MIGRATION switch-to-id: optional while old producers still drain; becomes required once every producer stamps it.
|
|
31
|
-
id: z.string().optional().describe("Connector-native instrument id"),
|
|
32
|
-
symbol: z.string(),
|
|
33
|
-
side: z.enum([
|
|
34
|
-
"BUY",
|
|
35
|
-
"SELL"
|
|
36
|
-
]),
|
|
37
|
-
reduceOnly: z.boolean(),
|
|
38
|
-
quantity: z.string(),
|
|
39
|
-
price: z.string()
|
|
40
|
-
});
|
|
41
|
-
const PriceUpdatedData = z.object({
|
|
42
|
-
connector: Connector,
|
|
43
|
-
source: PriceSource,
|
|
44
|
-
prices: z.record(z.string(), RealtimePrice)
|
|
45
|
-
});
|
|
46
|
-
const FundingUpdatedData = z.object({
|
|
47
|
-
connector: Connector,
|
|
48
|
-
funding: z.record(z.string(), RealtimeFunding)
|
|
49
|
-
});
|
|
50
|
-
const TradeExecutedData = z.object({
|
|
51
|
-
connector: Connector,
|
|
52
|
-
source: z.enum([
|
|
53
|
-
"DIRECT",
|
|
54
|
-
"TWAP",
|
|
55
|
-
"TRIGGER"
|
|
56
|
-
]),
|
|
57
|
-
intent: z.enum([
|
|
58
|
-
"OPEN",
|
|
59
|
-
"ADJUST",
|
|
60
|
-
"CLOSE",
|
|
61
|
-
"REVERSE"
|
|
62
|
-
]),
|
|
63
|
-
orderType: z.enum([
|
|
64
|
-
"MARKET"
|
|
65
|
-
]),
|
|
66
|
-
timestamp: z.iso.datetime(),
|
|
67
|
-
clientId: ClientIdCode,
|
|
68
|
-
legs: z.array(PublicTradeLeg).min(1)
|
|
69
|
-
});
|
|
70
|
-
const TriggerTriggeredPublicData = z.object({
|
|
71
|
-
connector: Connector,
|
|
72
|
-
accountId: z.string(),
|
|
73
|
-
triggerId: z.string(),
|
|
74
|
-
bracketType: z.enum([
|
|
75
|
-
"STOP_LOSS",
|
|
76
|
-
"TAKE_PROFIT"
|
|
77
|
-
]),
|
|
78
|
-
// User-facing bracket semantics; `bracketType` is the crossing encoding (wire-flipped
|
|
79
|
-
// for a price bracket on a short watched leg). Always stated.
|
|
80
|
-
semanticBracketType: TpSlBracketType,
|
|
81
|
-
intent: z.enum([
|
|
82
|
-
"OPEN",
|
|
83
|
-
"ADJUST",
|
|
84
|
-
"CLOSE"
|
|
85
|
-
]),
|
|
86
|
-
condition: TriggerConditionClose,
|
|
87
|
-
triggerLevel: z.number().nullable(),
|
|
88
|
-
timestamp: z.iso.datetime(),
|
|
89
|
-
legs: z.array(PublicTradeLeg).min(1)
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export { FundingUpdatedData, PriceUpdatedData, PublicTradeLeg, RealtimeFunding, RealtimePrice, TradeExecutedData, TriggerTriggeredPublicData };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
const UserEventTopic = z.enum([
|
|
4
|
-
"execution.failed",
|
|
5
|
-
"execution.completed",
|
|
6
|
-
"position.created",
|
|
7
|
-
"position.updated",
|
|
8
|
-
"position.closed",
|
|
9
|
-
"schedule.created",
|
|
10
|
-
"schedule.completed",
|
|
11
|
-
"schedule.failed",
|
|
12
|
-
"schedule.cancelled",
|
|
13
|
-
"ladder.created",
|
|
14
|
-
"ladder.updated",
|
|
15
|
-
"ladder.cancelled",
|
|
16
|
-
"trigger.created",
|
|
17
|
-
"trigger.triggered",
|
|
18
|
-
"trigger.cancelled",
|
|
19
|
-
"trigger.converted",
|
|
20
|
-
"rebalance.created",
|
|
21
|
-
"rebalance.updated",
|
|
22
|
-
"rebalance.executed",
|
|
23
|
-
"rebalance.paused",
|
|
24
|
-
"rebalance.cancelled",
|
|
25
|
-
"notification.created"
|
|
26
|
-
]);
|
|
27
|
-
const UserEventData = z.object({
|
|
28
|
-
// The changed entity (execution, position, schedule, ladder, trigger, rebalance or notification id).
|
|
29
|
-
entityId: z.string()
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export { UserEventData, UserEventTopic };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { EthereumAddress } from '../common/address';
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
const PublicVaultDataset = z.enum([
|
|
7
|
-
"positions",
|
|
8
|
-
"detail",
|
|
9
|
-
"nav",
|
|
10
|
-
"ledger"
|
|
11
|
-
]);
|
|
12
|
-
const ManagementVaultDataset = z.enum([
|
|
13
|
-
"orders",
|
|
14
|
-
"schedules",
|
|
15
|
-
"private_history"
|
|
16
|
-
]);
|
|
17
|
-
const VaultDataset = z.enum([
|
|
18
|
-
...PublicVaultDataset.options,
|
|
19
|
-
...ManagementVaultDataset.options
|
|
20
|
-
]);
|
|
21
|
-
function isPublicVaultDataset(dataset) {
|
|
22
|
-
return PublicVaultDataset.safeParse(dataset).success;
|
|
23
|
-
}
|
|
24
|
-
__name(isPublicVaultDataset, "isPublicVaultDataset");
|
|
25
|
-
const VaultInvalidatedData = z.object({
|
|
26
|
-
// The vault whose dataset changed, lowercased.
|
|
27
|
-
vaultAddress: EthereumAddress,
|
|
28
|
-
// The read model to refetch; its visibility decides which channel carries the notice.
|
|
29
|
-
dataset: VaultDataset,
|
|
30
|
-
// Unique per emitted invalidation so clients can dedupe redeliveries.
|
|
31
|
-
eventId: z.uuid(),
|
|
32
|
-
// Epoch milliseconds when realtime emitted the invalidation.
|
|
33
|
-
emittedAt: z.number().int().nonnegative()
|
|
34
|
-
});
|
|
35
|
-
const PublicVaultInvalidatedData = VaultInvalidatedData.extend({
|
|
36
|
-
dataset: PublicVaultDataset
|
|
37
|
-
});
|
|
38
|
-
const ManagementVaultInvalidatedData = VaultInvalidatedData.extend({
|
|
39
|
-
dataset: ManagementVaultDataset
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export { ManagementVaultDataset, ManagementVaultInvalidatedData, PublicVaultDataset, PublicVaultInvalidatedData, VaultDataset, VaultInvalidatedData, isPublicVaultDataset };
|