@pear-protocol/types 2.11.0 → 2.12.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/auth/payloads.d.ts +3 -3
- package/dist/auth/payloads.js +1 -1
- package/dist/baskets/saved/entities.js +1 -1
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.js +2 -0
- package/dist/common/refinement.d.ts +3 -3
- package/dist/common/trade-legs.js +1 -1
- package/dist/copy/entities.d.ts +186 -0
- package/dist/copy/entities.js +113 -0
- package/dist/copy/index.d.ts +4 -0
- package/dist/copy/index.js +4 -0
- package/dist/copy/payloads.d.ts +14 -0
- package/dist/copy/payloads.js +8 -0
- package/dist/copy/queries.d.ts +13 -0
- package/dist/copy/queries.js +16 -0
- package/dist/copy/responses.d.ts +332 -0
- package/dist/copy/responses.js +91 -0
- package/dist/execution/entities.d.ts +71 -71
- package/dist/execution/entities.js +1 -1
- package/dist/execution/queries.d.ts +2 -2
- package/dist/execution/responses.d.ts +40 -40
- package/dist/ladder/entities.d.ts +22 -17
- package/dist/ladder/queries.d.ts +5 -0
- package/dist/ladder/queries.js +6 -2
- package/dist/ladder/responses.d.ts +63 -48
- package/dist/misc/payloads.d.ts +26 -0
- package/dist/misc/payloads.js +27 -1
- package/dist/misc/responses.d.ts +8 -0
- package/dist/misc/responses.js +7 -1
- package/dist/notification/entities.d.ts +120 -0
- package/dist/notification/entities.js +59 -3
- package/dist/notification/responses.d.ts +60 -0
- package/dist/order/entities.d.ts +3 -3
- package/dist/position/entities.d.ts +1 -1
- package/dist/position/responses.d.ts +3 -1
- package/dist/position/responses.js +2 -0
- package/dist/schedule/entities.d.ts +18 -12
- package/dist/schedule/entities.js +2 -1
- package/dist/schedule/queries.d.ts +2 -2
- package/dist/schedule/responses.d.ts +12 -8
- package/dist/schedule/twap-config.js +1 -1
- package/dist/statistics/entities.d.ts +10 -0
- package/dist/statistics/entities.js +4 -0
- package/dist/statistics/responses.d.ts +10 -0
- package/dist/sync/payloads.d.ts +12 -0
- package/dist/sync/payloads.js +31 -3
- package/dist/tca/responses.d.ts +12 -12
- package/dist/trade/responses.d.ts +100 -100
- package/dist/trade-accounts/entities.d.ts +136 -12
- package/dist/trade-accounts/entities.js +41 -9
- package/dist/trade-accounts/payloads.d.ts +12 -0
- package/dist/trade-accounts/payloads.js +7 -1
- package/dist/trade-accounts/response.d.ts +963 -223
- package/dist/traders/index.d.ts +1 -0
- package/dist/traders/index.js +1 -0
- package/dist/traders/public.d.ts +4967 -0
- package/dist/traders/public.js +128 -0
- package/dist/trigger/common/index.d.ts +3 -2
- package/dist/trigger/common/index.js +1 -0
- package/dist/trigger/entities/index.d.ts +64 -48
- package/dist/trigger/entities/index.js +3 -3
- package/dist/trigger/queries.d.ts +2 -2
- package/dist/trigger/responses.d.ts +40 -30
- package/dist/vaults/entities.d.ts +1 -1
- package/dist/vaults/responses.d.ts +2 -2
- package/package.json +2 -2
package/dist/auth/payloads.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const LinkEmailRequest: z.ZodObject<{
|
|
|
13
13
|
export declare const LinkWalletRequest: z.ZodObject<{
|
|
14
14
|
address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
15
15
|
signature: z.ZodString;
|
|
16
|
-
nonce: z.
|
|
16
|
+
nonce: z.ZodString;
|
|
17
17
|
}, z.core.$strip>;
|
|
18
18
|
export declare const StartXLinkRequest: z.ZodObject<{
|
|
19
19
|
returnTo: z.ZodOptional<z.ZodString>;
|
|
@@ -34,7 +34,7 @@ export declare const WalletLoginRequest: z.ZodObject<{
|
|
|
34
34
|
method: z.ZodLiteral<"wallet">;
|
|
35
35
|
address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
36
36
|
signature: z.ZodString;
|
|
37
|
-
nonce: z.
|
|
37
|
+
nonce: z.ZodString;
|
|
38
38
|
accessCode: z.ZodOptional<z.ZodString>;
|
|
39
39
|
}, z.core.$strip>;
|
|
40
40
|
export declare const EmailLoginRequest: z.ZodObject<{
|
|
@@ -61,7 +61,7 @@ export declare const LoginRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
61
61
|
method: z.ZodLiteral<"wallet">;
|
|
62
62
|
address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
63
63
|
signature: z.ZodString;
|
|
64
|
-
nonce: z.
|
|
64
|
+
nonce: z.ZodString;
|
|
65
65
|
accessCode: z.ZodOptional<z.ZodString>;
|
|
66
66
|
}, z.core.$strip>, z.ZodObject<{
|
|
67
67
|
method: z.ZodLiteral<"email">;
|
package/dist/auth/payloads.js
CHANGED
|
@@ -4,7 +4,7 @@ const EthereumAddress = z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereu
|
|
|
4
4
|
const Email = z.email("Invalid email address").transform((val) => val.toLowerCase()).describe("Email address (lowercase)");
|
|
5
5
|
const Password = z.string().min(8, "Password must be at least 8 characters").max(128, "Password must be at most 128 characters").describe("Password for authentication");
|
|
6
6
|
const AccessCode = z.string().trim().max(64).optional().describe("Optional beta access code");
|
|
7
|
-
const SignedNonce = z.string().min(1).max(128).
|
|
7
|
+
const SignedNonce = z.string().min(1).max(128).describe("Nonce of the signed challenge, as returned by the nonce endpoint");
|
|
8
8
|
const RequestNonceRequest = z.object({
|
|
9
9
|
address: EthereumAddress
|
|
10
10
|
}).describe("Request a nonce for wallet authentication");
|
|
@@ -4,7 +4,7 @@ import { Side, AssetWeight } from '../../common/schema';
|
|
|
4
4
|
import { InstrumentId } from '../../instrument';
|
|
5
5
|
|
|
6
6
|
const SavedBasketLeg = z.object({
|
|
7
|
-
//
|
|
7
|
+
// SYMBOL-MIGRATION switch-to-id: mirrors `symbol` today; becomes required once requests always carry `id`.
|
|
8
8
|
id: InstrumentId.optional().describe("Connector-native instrument id"),
|
|
9
9
|
symbol: InstrumentId,
|
|
10
10
|
side: Side,
|
package/dist/bundle.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './baskets/saved';
|
|
|
4
4
|
export * from './common/address';
|
|
5
5
|
export * from './common/trade-legs';
|
|
6
6
|
export * from './connector';
|
|
7
|
+
export * from './copy';
|
|
7
8
|
export * from './execution';
|
|
8
9
|
export * from './fee';
|
|
9
10
|
export * from './fill';
|
|
@@ -27,6 +28,7 @@ export * from './sync';
|
|
|
27
28
|
export * from './tca';
|
|
28
29
|
export * from './trade';
|
|
29
30
|
export * from './trade-accounts';
|
|
31
|
+
export * from './traders';
|
|
30
32
|
export * from './trigger';
|
|
31
33
|
export * from './triggers';
|
|
32
34
|
export * from './users';
|
package/dist/bundle.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from './baskets/saved';
|
|
|
4
4
|
export * from './common/address';
|
|
5
5
|
export * from './common/trade-legs';
|
|
6
6
|
export * from './connector';
|
|
7
|
+
export * from './copy';
|
|
7
8
|
export * from './execution';
|
|
8
9
|
export * from './fee';
|
|
9
10
|
export * from './fill';
|
|
@@ -27,6 +28,7 @@ export * from './sync';
|
|
|
27
28
|
export * from './tca';
|
|
28
29
|
export * from './trade';
|
|
29
30
|
export * from './trade-accounts';
|
|
31
|
+
export * from './traders';
|
|
30
32
|
export * from './trigger';
|
|
31
33
|
export * from './triggers';
|
|
32
34
|
export * from './users';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* `id ?? symbol` before clients start sending `id` (
|
|
3
|
+
* SYMBOL-MIGRATION switch-to-id: these refinements key on `symbol` only. Re-key them on
|
|
4
|
+
* `id ?? symbol` before clients start sending `id` (the ticker track's external switch to `id`).
|
|
5
5
|
*/
|
|
6
6
|
export declare const RefineMinimumOneSymbol: <T extends {
|
|
7
7
|
symbol: string;
|
|
@@ -16,7 +16,7 @@ export declare const RefineTwoUniqueSymbols: <T extends {
|
|
|
16
16
|
export declare const RefineUniqueSymbols: <T extends {
|
|
17
17
|
symbol: string;
|
|
18
18
|
}[]>(basket: T, ctx: z.RefinementCtx) => void;
|
|
19
|
-
/**
|
|
19
|
+
/** SYMBOL-MIGRATION drop-symbol: a request's `id` must name the same instrument as `symbol`. Delete when `symbol` leaves the request. */
|
|
20
20
|
export declare const RefineLegIdMatchesSymbol: <T extends {
|
|
21
21
|
id?: string;
|
|
22
22
|
symbol: string;
|
|
@@ -8,7 +8,7 @@ const TradeLegMode = z.enum([
|
|
|
8
8
|
"USD"
|
|
9
9
|
]);
|
|
10
10
|
const TradeLegShape = z.object({
|
|
11
|
-
/**
|
|
11
|
+
/** SYMBOL-MIGRATION switch-to-id: mirrors `symbol` today; becomes required once requests always carry `id`. */
|
|
12
12
|
id: InstrumentId.optional(),
|
|
13
13
|
/**
|
|
14
14
|
* Instrument ID
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CopySubscriptionStatus: z.ZodEnum<{
|
|
3
|
+
ACTIVE: "ACTIVE";
|
|
4
|
+
ENDED: "ENDED";
|
|
5
|
+
}>;
|
|
6
|
+
export type CopySubscriptionStatus = z.infer<typeof CopySubscriptionStatus>;
|
|
7
|
+
/**
|
|
8
|
+
* How a subscription is sized.
|
|
9
|
+
*
|
|
10
|
+
* A tagged union with one member. The tag is the point: a second sizing mode becomes another variant
|
|
11
|
+
* rather than a breaking change to a field every client already reads.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CopySizing: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
14
|
+
mode: z.ZodLiteral<"LEADER_EQUITY_FRACTION">;
|
|
15
|
+
}, z.core.$strip>], "mode">;
|
|
16
|
+
export type CopySizing = z.infer<typeof CopySizing>;
|
|
17
|
+
export declare const CopySubscription: z.ZodObject<{
|
|
18
|
+
id: z.ZodUUID;
|
|
19
|
+
leaderTradeAccountId: z.ZodUUID;
|
|
20
|
+
followerTradeAccountId: z.ZodUUID;
|
|
21
|
+
connector: z.ZodEnum<{
|
|
22
|
+
hyperliquid: "hyperliquid";
|
|
23
|
+
binance: "binance";
|
|
24
|
+
bybit: "bybit";
|
|
25
|
+
okx: "okx";
|
|
26
|
+
lighter: "lighter";
|
|
27
|
+
lighter_rhc: "lighter_rhc";
|
|
28
|
+
}>;
|
|
29
|
+
status: z.ZodEnum<{
|
|
30
|
+
ACTIVE: "ACTIVE";
|
|
31
|
+
ENDED: "ENDED";
|
|
32
|
+
}>;
|
|
33
|
+
sizing: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
|
+
mode: z.ZodLiteral<"LEADER_EQUITY_FRACTION">;
|
|
35
|
+
}, z.core.$strip>], "mode">;
|
|
36
|
+
createdAt: z.ZodString;
|
|
37
|
+
endedAt: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type CopySubscription = z.infer<typeof CopySubscription>;
|
|
40
|
+
export declare const CopyActivityOutcome: z.ZodEnum<{
|
|
41
|
+
COPIED: "COPIED";
|
|
42
|
+
PARTIAL: "PARTIAL";
|
|
43
|
+
SKIPPED: "SKIPPED";
|
|
44
|
+
FAILED: "FAILED";
|
|
45
|
+
}>;
|
|
46
|
+
export type CopyActivityOutcome = z.infer<typeof CopyActivityOutcome>;
|
|
47
|
+
export declare const CopyActivityState: z.ZodEnum<{
|
|
48
|
+
RECORDED: "RECORDED";
|
|
49
|
+
DISPATCHED: "DISPATCHED";
|
|
50
|
+
SETTLED: "SETTLED";
|
|
51
|
+
}>;
|
|
52
|
+
export type CopyActivityState = z.infer<typeof CopyActivityState>;
|
|
53
|
+
/** One actual fill-derived change on the follower account. */
|
|
54
|
+
export declare const CopyActivityLeg: z.ZodObject<{
|
|
55
|
+
symbol: z.ZodString;
|
|
56
|
+
targetQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
57
|
+
deltaQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export type CopyActivityLeg = z.infer<typeof CopyActivityLeg>;
|
|
60
|
+
export declare const CopySkipReason: z.ZodEnum<{
|
|
61
|
+
SUBSCRIPTION_NOT_ACTIVE: "SUBSCRIPTION_NOT_ACTIVE";
|
|
62
|
+
POSITION_EXCLUDED: "POSITION_EXCLUDED";
|
|
63
|
+
INCLUDED_IN_JOIN: "INCLUDED_IN_JOIN";
|
|
64
|
+
VENUE_MISMATCH: "VENUE_MISMATCH";
|
|
65
|
+
BELOW_VENUE_MINIMUM: "BELOW_VENUE_MINIMUM";
|
|
66
|
+
PAIR_ALREADY_ENTERED: "PAIR_ALREADY_ENTERED";
|
|
67
|
+
ENTRY_EXPIRED: "ENTRY_EXPIRED";
|
|
68
|
+
FOLLOWER_LEG_ABSENT: "FOLLOWER_LEG_ABSENT";
|
|
69
|
+
LEADER_LEG_REOPENED: "LEADER_LEG_REOPENED";
|
|
70
|
+
NO_FOLLOWER_DELTA: "NO_FOLLOWER_DELTA";
|
|
71
|
+
LEADER_EQUITY_UNREADABLE: "LEADER_EQUITY_UNREADABLE";
|
|
72
|
+
FOLLOWER_EQUITY_UNREADABLE: "FOLLOWER_EQUITY_UNREADABLE";
|
|
73
|
+
PRICE_UNAVAILABLE: "PRICE_UNAVAILABLE";
|
|
74
|
+
LEVERAGE_NOT_APPLIED: "LEVERAGE_NOT_APPLIED";
|
|
75
|
+
}>;
|
|
76
|
+
export type CopySkipReason = z.infer<typeof CopySkipReason>;
|
|
77
|
+
export declare const CopyLeaderAction: z.ZodEnum<{
|
|
78
|
+
OPEN: "OPEN";
|
|
79
|
+
ADJUST: "ADJUST";
|
|
80
|
+
CLOSE: "CLOSE";
|
|
81
|
+
REVERSE: "REVERSE";
|
|
82
|
+
}>;
|
|
83
|
+
export type CopyLeaderAction = z.infer<typeof CopyLeaderAction>;
|
|
84
|
+
/** Leader execution provenance; these resources are never installed on the follower. */
|
|
85
|
+
export declare const CopyExecutionSource: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
86
|
+
origin: z.ZodLiteral<"DIRECT">;
|
|
87
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
88
|
+
origin: z.ZodLiteral<"SCHEDULE">;
|
|
89
|
+
scheduleId: z.ZodString;
|
|
90
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
91
|
+
origin: z.ZodLiteral<"TRIGGER">;
|
|
92
|
+
triggerId: z.ZodString;
|
|
93
|
+
triggerIntent: z.ZodEnum<{
|
|
94
|
+
OPEN: "OPEN";
|
|
95
|
+
ADJUST: "ADJUST";
|
|
96
|
+
CLOSE: "CLOSE";
|
|
97
|
+
}>;
|
|
98
|
+
bracketType: z.ZodOptional<z.ZodString>;
|
|
99
|
+
ladderId: z.ZodOptional<z.ZodString>;
|
|
100
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
101
|
+
origin: z.ZodLiteral<"AUTO_REBALANCE">;
|
|
102
|
+
configId: z.ZodString;
|
|
103
|
+
}, z.core.$strip>], "origin">;
|
|
104
|
+
export type CopyExecutionSource = z.infer<typeof CopyExecutionSource>;
|
|
105
|
+
/**
|
|
106
|
+
* One leader action, and what it meant for this follower.
|
|
107
|
+
*
|
|
108
|
+
* Every leader action writes one of these, including the ones that produced no order at all — at a
|
|
109
|
+
* small size most actions resolve to nothing, and those are precisely the ones the follower most
|
|
110
|
+
* needs to see.
|
|
111
|
+
*/
|
|
112
|
+
export declare const CopyActivity: z.ZodObject<{
|
|
113
|
+
id: z.ZodUUID;
|
|
114
|
+
leaderAction: z.ZodEnum<{
|
|
115
|
+
OPEN: "OPEN";
|
|
116
|
+
ADJUST: "ADJUST";
|
|
117
|
+
CLOSE: "CLOSE";
|
|
118
|
+
REVERSE: "REVERSE";
|
|
119
|
+
}>;
|
|
120
|
+
executionSource: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
121
|
+
origin: z.ZodLiteral<"DIRECT">;
|
|
122
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
123
|
+
origin: z.ZodLiteral<"SCHEDULE">;
|
|
124
|
+
scheduleId: z.ZodString;
|
|
125
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
126
|
+
origin: z.ZodLiteral<"TRIGGER">;
|
|
127
|
+
triggerId: z.ZodString;
|
|
128
|
+
triggerIntent: z.ZodEnum<{
|
|
129
|
+
OPEN: "OPEN";
|
|
130
|
+
ADJUST: "ADJUST";
|
|
131
|
+
CLOSE: "CLOSE";
|
|
132
|
+
}>;
|
|
133
|
+
bracketType: z.ZodOptional<z.ZodString>;
|
|
134
|
+
ladderId: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
136
|
+
origin: z.ZodLiteral<"AUTO_REBALANCE">;
|
|
137
|
+
configId: z.ZodString;
|
|
138
|
+
}, z.core.$strip>], "origin">>;
|
|
139
|
+
state: z.ZodEnum<{
|
|
140
|
+
RECORDED: "RECORDED";
|
|
141
|
+
DISPATCHED: "DISPATCHED";
|
|
142
|
+
SETTLED: "SETTLED";
|
|
143
|
+
}>;
|
|
144
|
+
outcome: z.ZodOptional<z.ZodEnum<{
|
|
145
|
+
COPIED: "COPIED";
|
|
146
|
+
PARTIAL: "PARTIAL";
|
|
147
|
+
SKIPPED: "SKIPPED";
|
|
148
|
+
FAILED: "FAILED";
|
|
149
|
+
}>>;
|
|
150
|
+
skipReason: z.ZodOptional<z.ZodEnum<{
|
|
151
|
+
SUBSCRIPTION_NOT_ACTIVE: "SUBSCRIPTION_NOT_ACTIVE";
|
|
152
|
+
POSITION_EXCLUDED: "POSITION_EXCLUDED";
|
|
153
|
+
INCLUDED_IN_JOIN: "INCLUDED_IN_JOIN";
|
|
154
|
+
VENUE_MISMATCH: "VENUE_MISMATCH";
|
|
155
|
+
BELOW_VENUE_MINIMUM: "BELOW_VENUE_MINIMUM";
|
|
156
|
+
PAIR_ALREADY_ENTERED: "PAIR_ALREADY_ENTERED";
|
|
157
|
+
ENTRY_EXPIRED: "ENTRY_EXPIRED";
|
|
158
|
+
FOLLOWER_LEG_ABSENT: "FOLLOWER_LEG_ABSENT";
|
|
159
|
+
LEADER_LEG_REOPENED: "LEADER_LEG_REOPENED";
|
|
160
|
+
NO_FOLLOWER_DELTA: "NO_FOLLOWER_DELTA";
|
|
161
|
+
LEADER_EQUITY_UNREADABLE: "LEADER_EQUITY_UNREADABLE";
|
|
162
|
+
FOLLOWER_EQUITY_UNREADABLE: "FOLLOWER_EQUITY_UNREADABLE";
|
|
163
|
+
PRICE_UNAVAILABLE: "PRICE_UNAVAILABLE";
|
|
164
|
+
LEVERAGE_NOT_APPLIED: "LEVERAGE_NOT_APPLIED";
|
|
165
|
+
}>>;
|
|
166
|
+
failureReason: z.ZodOptional<z.ZodString>;
|
|
167
|
+
followerLegs: z.ZodArray<z.ZodObject<{
|
|
168
|
+
symbol: z.ZodString;
|
|
169
|
+
targetQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
170
|
+
deltaQuantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
leaderEquityFraction: z.ZodOptional<z.ZodString>;
|
|
173
|
+
createdAt: z.ZodString;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
export type CopyActivity = z.infer<typeof CopyActivity>;
|
|
176
|
+
/** A current follower account with only its owner's publishable X identity. */
|
|
177
|
+
export declare const CopyFollower: z.ZodObject<{
|
|
178
|
+
tradeAccountId: z.ZodUUID;
|
|
179
|
+
status: z.ZodLiteral<"ACTIVE">;
|
|
180
|
+
followedAt: z.ZodString;
|
|
181
|
+
xUserId: z.ZodOptional<z.ZodString>;
|
|
182
|
+
xHandle: z.ZodOptional<z.ZodString>;
|
|
183
|
+
xName: z.ZodOptional<z.ZodString>;
|
|
184
|
+
xAvatarUrl: z.ZodOptional<z.ZodString>;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
export type CopyFollower = z.output<typeof CopyFollower>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SignedDecimalString } from '../common/schema';
|
|
3
|
+
import { Connector } from '../connector';
|
|
4
|
+
import { InstrumentId } from '../instrument';
|
|
5
|
+
|
|
6
|
+
const CopySubscriptionStatus = z.enum([
|
|
7
|
+
"ACTIVE",
|
|
8
|
+
"ENDED"
|
|
9
|
+
]);
|
|
10
|
+
const CopySizing = z.discriminatedUnion("mode", [
|
|
11
|
+
z.object({
|
|
12
|
+
/**
|
|
13
|
+
* Entry is the leader's own notional-over-equity fraction applied to the follower's equity, taken
|
|
14
|
+
* at the moment of entry. There is nothing for the follower to size.
|
|
15
|
+
*/
|
|
16
|
+
mode: z.literal("LEADER_EQUITY_FRACTION")
|
|
17
|
+
})
|
|
18
|
+
]);
|
|
19
|
+
const CopySubscription = z.object({
|
|
20
|
+
id: z.uuid(),
|
|
21
|
+
leaderTradeAccountId: z.uuid().describe("The account being copied"),
|
|
22
|
+
followerTradeAccountId: z.uuid().describe("The account copies land in"),
|
|
23
|
+
connector: Connector,
|
|
24
|
+
status: CopySubscriptionStatus,
|
|
25
|
+
sizing: CopySizing,
|
|
26
|
+
createdAt: z.string().describe("ISO 8601"),
|
|
27
|
+
endedAt: z.string().optional().describe("ISO 8601; set once the follower unsubscribed")
|
|
28
|
+
});
|
|
29
|
+
const CopyActivityOutcome = z.enum([
|
|
30
|
+
"COPIED",
|
|
31
|
+
"PARTIAL",
|
|
32
|
+
"SKIPPED",
|
|
33
|
+
"FAILED"
|
|
34
|
+
]);
|
|
35
|
+
const CopyActivityState = z.enum([
|
|
36
|
+
"RECORDED",
|
|
37
|
+
"DISPATCHED",
|
|
38
|
+
"SETTLED"
|
|
39
|
+
]);
|
|
40
|
+
const CopyActivityLeg = z.object({
|
|
41
|
+
symbol: InstrumentId,
|
|
42
|
+
targetQuantity: SignedDecimalString,
|
|
43
|
+
deltaQuantity: SignedDecimalString
|
|
44
|
+
});
|
|
45
|
+
const CopySkipReason = z.enum([
|
|
46
|
+
"SUBSCRIPTION_NOT_ACTIVE",
|
|
47
|
+
"POSITION_EXCLUDED",
|
|
48
|
+
"INCLUDED_IN_JOIN",
|
|
49
|
+
"VENUE_MISMATCH",
|
|
50
|
+
"BELOW_VENUE_MINIMUM",
|
|
51
|
+
"PAIR_ALREADY_ENTERED",
|
|
52
|
+
"ENTRY_EXPIRED",
|
|
53
|
+
"FOLLOWER_LEG_ABSENT",
|
|
54
|
+
"LEADER_LEG_REOPENED",
|
|
55
|
+
"NO_FOLLOWER_DELTA",
|
|
56
|
+
"LEADER_EQUITY_UNREADABLE",
|
|
57
|
+
"FOLLOWER_EQUITY_UNREADABLE",
|
|
58
|
+
"PRICE_UNAVAILABLE",
|
|
59
|
+
"LEVERAGE_NOT_APPLIED"
|
|
60
|
+
]);
|
|
61
|
+
const CopyLeaderAction = z.enum([
|
|
62
|
+
"OPEN",
|
|
63
|
+
"ADJUST",
|
|
64
|
+
"CLOSE",
|
|
65
|
+
"REVERSE"
|
|
66
|
+
]);
|
|
67
|
+
const CopyExecutionSource = z.discriminatedUnion("origin", [
|
|
68
|
+
z.object({
|
|
69
|
+
origin: z.literal("DIRECT")
|
|
70
|
+
}),
|
|
71
|
+
z.object({
|
|
72
|
+
origin: z.literal("SCHEDULE"),
|
|
73
|
+
scheduleId: z.string()
|
|
74
|
+
}),
|
|
75
|
+
z.object({
|
|
76
|
+
origin: z.literal("TRIGGER"),
|
|
77
|
+
triggerId: z.string(),
|
|
78
|
+
triggerIntent: z.enum([
|
|
79
|
+
"OPEN",
|
|
80
|
+
"ADJUST",
|
|
81
|
+
"CLOSE"
|
|
82
|
+
]),
|
|
83
|
+
bracketType: z.string().optional(),
|
|
84
|
+
ladderId: z.string().optional()
|
|
85
|
+
}),
|
|
86
|
+
z.object({
|
|
87
|
+
origin: z.literal("AUTO_REBALANCE"),
|
|
88
|
+
configId: z.string()
|
|
89
|
+
})
|
|
90
|
+
]);
|
|
91
|
+
const CopyActivity = z.object({
|
|
92
|
+
id: z.uuid(),
|
|
93
|
+
leaderAction: CopyLeaderAction.describe("What the leader did"),
|
|
94
|
+
executionSource: CopyExecutionSource.optional().describe("Leader source; absent for admission position joins"),
|
|
95
|
+
state: CopyActivityState,
|
|
96
|
+
outcome: CopyActivityOutcome.optional().describe("Absent until dispatch work settles"),
|
|
97
|
+
skipReason: CopySkipReason.optional().describe("Why nothing was placed; set when the outcome is SKIPPED"),
|
|
98
|
+
failureReason: z.string().optional().describe("Why execution stopped; set when the outcome is FAILED or PARTIAL"),
|
|
99
|
+
followerLegs: z.array(CopyActivityLeg).describe("Actual fills received by the follower"),
|
|
100
|
+
leaderEquityFraction: z.string().optional().describe("The leader position notional over their equity at that moment; absent when unvaluable"),
|
|
101
|
+
createdAt: z.string().describe("ISO 8601")
|
|
102
|
+
});
|
|
103
|
+
const CopyFollower = z.object({
|
|
104
|
+
tradeAccountId: z.uuid(),
|
|
105
|
+
status: z.literal("ACTIVE"),
|
|
106
|
+
followedAt: z.string().describe("ISO 8601 subscription creation time"),
|
|
107
|
+
xUserId: z.string().optional(),
|
|
108
|
+
xHandle: z.string().optional(),
|
|
109
|
+
xName: z.string().optional(),
|
|
110
|
+
xAvatarUrl: z.string().optional()
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export { CopyActivity, CopyActivityLeg, CopyActivityOutcome, CopyActivityState, CopyExecutionSource, CopyFollower, CopyLeaderAction, CopySizing, CopySkipReason, CopySubscription, CopySubscriptionStatus };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Start copying a leader into the account selected by the x-trade-account-id header.
|
|
4
|
+
*
|
|
5
|
+
* There is no size to set. Entry is the leader's own equity fraction applied to the follower's
|
|
6
|
+
* equity. Existing eligible positions are attempted by default; set syncExistingPositions to false
|
|
7
|
+
* to start without copying them.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CreateCopySubscription: z.ZodObject<{
|
|
10
|
+
leaderTradeAccountId: z.ZodUUID;
|
|
11
|
+
syncExistingPositions: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type CreateCopySubscriptionInput = z.input<typeof CreateCopySubscription>;
|
|
14
|
+
export type CreateCopySubscription = z.output<typeof CreateCopySubscription>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const CreateCopySubscription = z.object({
|
|
4
|
+
leaderTradeAccountId: z.uuid().describe("The account to copy"),
|
|
5
|
+
syncExistingPositions: z.boolean().default(true).describe("Copy existing leader positions when subscribing")
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export { CreateCopySubscription };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CopyActivityListParams: z.ZodObject<{
|
|
3
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export type CopyActivityListParamsInput = z.input<typeof CopyActivityListParams>;
|
|
6
|
+
export type CopyActivityListParams = z.output<typeof CopyActivityListParams>;
|
|
7
|
+
/** Fill timestamps use an inclusive start and exclusive end; counts remain current/lifetime. */
|
|
8
|
+
export declare const CopyStatsParams: z.ZodObject<{
|
|
9
|
+
startDate: z.ZodOptional<z.ZodCoercedDate<Date>>;
|
|
10
|
+
endDate: z.ZodOptional<z.ZodCoercedDate<Date>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type CopyStatsParamsInput = z.input<typeof CopyStatsParams>;
|
|
13
|
+
export type CopyStatsParams = z.output<typeof CopyStatsParams>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const CopyActivityListParams = z.object({
|
|
4
|
+
limit: z.coerce.number().int().min(1).max(200).default(50)
|
|
5
|
+
});
|
|
6
|
+
const CopyStatsParams = z.object({
|
|
7
|
+
startDate: z.coerce.date().optional(),
|
|
8
|
+
endDate: z.coerce.date().optional()
|
|
9
|
+
}).refine((params) => !params.startDate || !params.endDate || params.startDate < params.endDate, {
|
|
10
|
+
message: "startDate must be before endDate",
|
|
11
|
+
path: [
|
|
12
|
+
"startDate"
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { CopyActivityListParams, CopyStatsParams };
|