@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.
Files changed (169) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/fee/entities.d.ts +1 -0
  3. package/dist/fee/responses.d.ts +26 -0
  4. package/dist/index.js +7355 -3
  5. package/dist/rewards/entities.d.ts +28 -0
  6. package/dist/rewards/payloads.d.ts +7 -0
  7. package/dist/rewards/responses.d.ts +73 -0
  8. package/dist/users/entities.d.ts +4 -0
  9. package/dist/users/response.d.ts +2 -0
  10. package/package.json +3 -2
  11. package/dist/auth/api-keys.js +0 -44
  12. package/dist/auth/entities.js +0 -25
  13. package/dist/auth/index.js +0 -4
  14. package/dist/auth/payloads.js +0 -84
  15. package/dist/auth/response.js +0 -82
  16. package/dist/baskets/recommended/entities.js +0 -22
  17. package/dist/baskets/recommended/index.js +0 -2
  18. package/dist/baskets/recommended/responses.js +0 -8
  19. package/dist/baskets/saved/entities.js +0 -23
  20. package/dist/baskets/saved/payloads.js +0 -18
  21. package/dist/baskets/saved/responses.js +0 -14
  22. package/dist/bundle.js +0 -36
  23. package/dist/common/address.js +0 -5
  24. package/dist/common/array.js +0 -17
  25. package/dist/common/client-id.js +0 -5
  26. package/dist/common/hex-string.js +0 -5
  27. package/dist/common/index.js +0 -4
  28. package/dist/common/refinement.js +0 -64
  29. package/dist/common/request.js +0 -24
  30. package/dist/common/response.js +0 -28
  31. package/dist/common/schema.js +0 -18
  32. package/dist/common/trade-legs.js +0 -50
  33. package/dist/connector/index.js +0 -12
  34. package/dist/copy/entities.js +0 -151
  35. package/dist/copy/index.js +0 -5
  36. package/dist/copy/payloads.js +0 -8
  37. package/dist/copy/performance.js +0 -63
  38. package/dist/copy/queries.js +0 -20
  39. package/dist/copy/responses.js +0 -89
  40. package/dist/execution/entities.js +0 -196
  41. package/dist/execution/index.js +0 -3
  42. package/dist/execution/queries.js +0 -18
  43. package/dist/execution/responses.js +0 -12
  44. package/dist/fee/entities.js +0 -34
  45. package/dist/fee/index.js +0 -3
  46. package/dist/fee/queries.js +0 -12
  47. package/dist/fee/responses.js +0 -29
  48. package/dist/fill/entities.js +0 -82
  49. package/dist/fill/index.js +0 -3
  50. package/dist/fill/queries.js +0 -14
  51. package/dist/fill/responses.js +0 -23
  52. package/dist/funding/entities.js +0 -16
  53. package/dist/funding/index.js +0 -3
  54. package/dist/funding/queries.js +0 -8
  55. package/dist/funding/responses.js +0 -11
  56. package/dist/instrument/entities.js +0 -102
  57. package/dist/instrument/index.js +0 -3
  58. package/dist/instrument/queries.js +0 -15
  59. package/dist/instrument/responses.js +0 -20
  60. package/dist/instrument-precision/index.js +0 -56
  61. package/dist/ladder/entities.js +0 -24
  62. package/dist/ladder/index.js +0 -4
  63. package/dist/ladder/payloads.js +0 -96
  64. package/dist/ladder/queries.js +0 -12
  65. package/dist/ladder/responses.js +0 -18
  66. package/dist/leverage/index.js +0 -2
  67. package/dist/leverage/payloads.js +0 -14
  68. package/dist/leverage/response.js +0 -5
  69. package/dist/margin/index.js +0 -2
  70. package/dist/margin/payloads.js +0 -20
  71. package/dist/margin/response.js +0 -11
  72. package/dist/market/entities.js +0 -52
  73. package/dist/market/index.js +0 -4
  74. package/dist/market/payloads.js +0 -11
  75. package/dist/market/queries.js +0 -19
  76. package/dist/market/responses.js +0 -18
  77. package/dist/misc/index.js +0 -2
  78. package/dist/misc/payloads.js +0 -99
  79. package/dist/misc/responses.js +0 -85
  80. package/dist/notification/entities.js +0 -274
  81. package/dist/notification/index.js +0 -4
  82. package/dist/notification/payloads.js +0 -15
  83. package/dist/notification/queries.js +0 -29
  84. package/dist/notification/responses.js +0 -20
  85. package/dist/order/entities.js +0 -81
  86. package/dist/order/index.js +0 -1
  87. package/dist/portfolio/entities.js +0 -77
  88. package/dist/portfolio/index.js +0 -3
  89. package/dist/portfolio/queries.js +0 -34
  90. package/dist/portfolio/responses.js +0 -33
  91. package/dist/position/entities.js +0 -433
  92. package/dist/position/index.js +0 -3
  93. package/dist/position/queries.js +0 -109
  94. package/dist/position/responses.js +0 -41
  95. package/dist/price/entities.js +0 -10
  96. package/dist/price/index.js +0 -3
  97. package/dist/price/queries.js +0 -8
  98. package/dist/price/responses.js +0 -15
  99. package/dist/realtime/channels.js +0 -16
  100. package/dist/realtime/frames.js +0 -140
  101. package/dist/realtime/index.js +0 -6
  102. package/dist/realtime/messages.js +0 -118
  103. package/dist/realtime/public-events.js +0 -92
  104. package/dist/realtime/user-events.js +0 -32
  105. package/dist/realtime/vault-events.js +0 -42
  106. package/dist/rebalance/entities.js +0 -86
  107. package/dist/rebalance/index.js +0 -4
  108. package/dist/rebalance/payloads.js +0 -56
  109. package/dist/rebalance/queries.js +0 -14
  110. package/dist/rebalance/responses.js +0 -41
  111. package/dist/schedule/entities.js +0 -239
  112. package/dist/schedule/index.js +0 -5
  113. package/dist/schedule/payloads.js +0 -85
  114. package/dist/schedule/queries.js +0 -30
  115. package/dist/schedule/randomization.js +0 -15
  116. package/dist/schedule/responses.js +0 -22
  117. package/dist/schedule/twap-config.js +0 -29
  118. package/dist/statistics/entities.js +0 -105
  119. package/dist/statistics/index.js +0 -3
  120. package/dist/statistics/queries.js +0 -111
  121. package/dist/statistics/responses.js +0 -67
  122. package/dist/sync/index.js +0 -2
  123. package/dist/sync/payloads.js +0 -136
  124. package/dist/sync/responses.js +0 -28
  125. package/dist/tca/entities.js +0 -9
  126. package/dist/tca/index.js +0 -3
  127. package/dist/tca/queries.js +0 -14
  128. package/dist/tca/responses.js +0 -126
  129. package/dist/trade/entities.js +0 -101
  130. package/dist/trade/index.js +0 -4
  131. package/dist/trade/payloads.js +0 -84
  132. package/dist/trade/queries.js +0 -9
  133. package/dist/trade/responses.js +0 -25
  134. package/dist/trade-accounts/entities.js +0 -61
  135. package/dist/trade-accounts/index.js +0 -4
  136. package/dist/trade-accounts/payloads.js +0 -132
  137. package/dist/trade-accounts/queries.js +0 -7
  138. package/dist/trade-accounts/response.js +0 -79
  139. package/dist/traders/index.js +0 -2
  140. package/dist/traders/performance.js +0 -21
  141. package/dist/traders/public.js +0 -192
  142. package/dist/trigger/common/index.js +0 -39
  143. package/dist/trigger/entities/conditions.js +0 -174
  144. package/dist/trigger/entities/index.js +0 -257
  145. package/dist/trigger/index.js +0 -9
  146. package/dist/trigger/oracle.js +0 -22
  147. package/dist/trigger/payloads/conditions.js +0 -213
  148. package/dist/trigger/payloads/config.js +0 -3
  149. package/dist/trigger/payloads/index.js +0 -173
  150. package/dist/trigger/queries.js +0 -16
  151. package/dist/trigger/refinement/index.js +0 -2
  152. package/dist/trigger/refinement/static.refinement.js +0 -50
  153. package/dist/trigger/refinement/trailing.refinement.js +0 -83
  154. package/dist/trigger/responses.js +0 -18
  155. package/dist/triggers/entities.js +0 -27
  156. package/dist/triggers/index.js +0 -3
  157. package/dist/triggers/queries.js +0 -10
  158. package/dist/triggers/responses.js +0 -9
  159. package/dist/users/entities.js +0 -45
  160. package/dist/users/index.js +0 -4
  161. package/dist/users/payloads.js +0 -33
  162. package/dist/users/queries.js +0 -8
  163. package/dist/users/response.js +0 -28
  164. package/dist/vaults/entities.js +0 -96
  165. package/dist/vaults/index.js +0 -4
  166. package/dist/vaults/payloads.js +0 -65
  167. package/dist/vaults/queries.js +0 -66
  168. package/dist/vaults/responses.js +0 -368
  169. /package/dist/{baskets/saved/index.js → rewards/index.d.ts} +0 -0
@@ -1,86 +0,0 @@
1
- import { z } from 'zod';
2
- import { UnsignedDecimalString } from '../common/schema';
3
- import { InstrumentId } from '../instrument';
4
-
5
- const AutoRebalanceStatus = z.enum([
6
- "ACTIVE",
7
- "PAUSED"
8
- ]);
9
- const AutoRebalancePausedReason = z.enum([
10
- "USER",
11
- "POSITION_CHANGED",
12
- "REPEATED_FAILURES",
13
- "INVALID_LIVE_BETA_EXPOSURE"
14
- ]);
15
- const AutoRebalanceWeightSource = z.enum([
16
- "INITIAL_WEIGHT",
17
- "LIVE_BETA"
18
- ]);
19
- const AutoRebalanceTimeframe = z.enum([
20
- "1h",
21
- "4h",
22
- "1d"
23
- ]);
24
- const RebalanceEventStatus = z.enum([
25
- "SUCCESS",
26
- "FAILED"
27
- ]);
28
- const WeightMap = z.record(InstrumentId, z.number());
29
- const AutoRebalanceConfigBase = z.object({
30
- id: z.uuid(),
31
- positionId: z.uuid(),
32
- status: AutoRebalanceStatus,
33
- pausedReason: AutoRebalancePausedReason.optional(),
34
- minimumDriftPct: UnsignedDecimalString,
35
- createdAt: z.iso.datetime(),
36
- updatedAt: z.iso.datetime()
37
- });
38
- const AutoRebalanceBetaState = z.discriminatedUnion("state", [
39
- z.object({
40
- state: z.literal("PENDING")
41
- }),
42
- z.object({
43
- state: z.literal("BASELINED"),
44
- // The frozen drift baseline: implied beta of the achieved leg split at entry, re-snapshotted after
45
- // every rebalance.
46
- impliedEntryBeta: UnsignedDecimalString
47
- }),
48
- z.object({
49
- state: z.literal("TRACKING"),
50
- // The frozen drift baseline: implied beta of the achieved leg split at entry, re-snapshotted after
51
- // every rebalance.
52
- impliedEntryBeta: UnsignedDecimalString,
53
- // Kalman beta of the last candle this config processed — the moving side of the drift comparison.
54
- lastDerivedBeta: UnsignedDecimalString,
55
- // Bar time lastDerivedBeta was read at, so a client can judge how fresh that beta is.
56
- lastProcessedBetaTime: z.iso.datetime(),
57
- // How far lastDerivedBeta sits from impliedEntryBeta, as a fraction (0.05 = 5%) directly comparable
58
- // to minimumDriftPct. Derived from the two betas above; absent on a degenerate (zero) baseline.
59
- driftPct: UnsignedDecimalString.optional()
60
- })
61
- ]);
62
- const AutoRebalanceConfig = z.discriminatedUnion("weightSource", [
63
- AutoRebalanceConfigBase.extend({
64
- weightSource: z.literal("INITIAL_WEIGHT")
65
- }),
66
- AutoRebalanceConfigBase.extend({
67
- weightSource: z.literal("LIVE_BETA"),
68
- // Stat-arb bar timeframe selecting which realtime candle feed drives the drift comparison.
69
- timeframe: AutoRebalanceTimeframe,
70
- beta: AutoRebalanceBetaState
71
- })
72
- ]);
73
- const RebalanceEvent = z.object({
74
- id: z.uuid(),
75
- autoRebalanceConfigId: z.uuid(),
76
- positionId: z.uuid(),
77
- weightSource: AutoRebalanceWeightSource,
78
- driftPct: UnsignedDecimalString,
79
- currentWeights: WeightMap,
80
- targetWeights: WeightMap,
81
- status: RebalanceEventStatus,
82
- error: z.string().optional(),
83
- createdAt: z.iso.datetime()
84
- });
85
-
86
- export { AutoRebalanceBetaState, AutoRebalanceConfig, AutoRebalancePausedReason, AutoRebalanceStatus, AutoRebalanceTimeframe, AutoRebalanceWeightSource, RebalanceEvent, RebalanceEventStatus, WeightMap };
@@ -1,4 +0,0 @@
1
- export * from './entities';
2
- export * from './payloads';
3
- export * from './queries';
4
- export * from './responses';
@@ -1,56 +0,0 @@
1
- import { z } from 'zod';
2
- import { ClientIdCode } from '../common/client-id';
3
- import { RefineWeightingSum, RefineUniqueSymbols } from '../common/refinement';
4
- import { UnsignedDecimalString } from '../common/schema';
5
- import { ExecutionOrderType } from '../execution';
6
- import { InstrumentId } from '../instrument';
7
- import { AutoRebalanceTimeframe, AutoRebalanceStatus } from './entities';
8
-
9
- const RebalanceManual = z.object({
10
- orderType: ExecutionOrderType,
11
- weightings: z.array(z.object({
12
- symbol: InstrumentId,
13
- weight: z.number().positive({
14
- message: "Weight must be greater than 0"
15
- }).max(1, {
16
- message: "Weight must be less than 1"
17
- })
18
- })).superRefine(RefineWeightingSum).superRefine(RefineUniqueSymbols).describe("Array of weightings to rebalance the position"),
19
- /**
20
- * Attribution route code (client_ids.code)
21
- */
22
- clientId: ClientIdCode
23
- });
24
- const MinimumDriftPct = UnsignedDecimalString.refine((value) => Number(value) > 0 && Number(value) <= 1, {
25
- message: "minimumDriftPct must be greater than 0 and at most 1"
26
- });
27
- const InitialWeightConfig = z.object({
28
- weightSource: z.literal("INITIAL_WEIGHT"),
29
- minimumDriftPct: MinimumDriftPct
30
- });
31
- const LiveBetaConfig = z.object({
32
- weightSource: z.literal("LIVE_BETA"),
33
- minimumDriftPct: MinimumDriftPct,
34
- timeframe: AutoRebalanceTimeframe
35
- });
36
- const CreateInitialWeight = InitialWeightConfig.extend({
37
- positionId: z.uuid()
38
- });
39
- const CreateLiveBeta = LiveBetaConfig.extend({
40
- positionId: z.uuid()
41
- });
42
- const CreateAutoRebalanceConfig = z.discriminatedUnion("weightSource", [
43
- CreateInitialWeight,
44
- CreateLiveBeta
45
- ]);
46
- const ReplaceAutoRebalanceConfig = z.discriminatedUnion("weightSource", [
47
- InitialWeightConfig,
48
- LiveBetaConfig
49
- ]);
50
- const UpdateAutoRebalanceConfig = z.object({
51
- minimumDriftPct: MinimumDriftPct.optional(),
52
- timeframe: AutoRebalanceTimeframe.optional(),
53
- status: AutoRebalanceStatus.optional()
54
- });
55
-
56
- export { CreateAutoRebalanceConfig, RebalanceManual, ReplaceAutoRebalanceConfig, UpdateAutoRebalanceConfig };
@@ -1,14 +0,0 @@
1
- import { z } from 'zod';
2
- import { normalizeArray, CursorFindParams } from '../common';
3
- import { AutoRebalanceStatus, AutoRebalanceWeightSource } from './entities';
4
-
5
- const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(AutoRebalanceStatus));
6
- const WeightSourceArray = z.preprocess((arg) => normalizeArray(arg), z.array(AutoRebalanceWeightSource));
7
- const AutoRebalanceListParams = CursorFindParams.extend({
8
- status: StatusArray.optional(),
9
- weightSource: WeightSourceArray.optional(),
10
- positionId: z.uuid().optional()
11
- });
12
- const RebalanceEventListParams = CursorFindParams.extend({});
13
-
14
- export { AutoRebalanceListParams, RebalanceEventListParams };
@@ -1,41 +0,0 @@
1
- import { z } from 'zod';
2
- import { CursorResponse } from '../common';
3
- import { AutoRebalanceConfig, RebalanceEvent } from './entities';
4
-
5
- const RebalanceManualResponse = z.object({
6
- plan: z.discriminatedUnion("outcome", [
7
- z.object({
8
- outcome: z.literal("full_rebalance")
9
- }),
10
- z.object({
11
- outcome: z.literal("partial_rebalance"),
12
- messages: z.tuple([
13
- z.string()
14
- ]).rest(z.string())
15
- }),
16
- z.object({
17
- outcome: z.literal("no_rebalance"),
18
- messages: z.tuple([
19
- z.string()
20
- ]).rest(z.string())
21
- }),
22
- // `failed` only occurs on background runs (dispatch/cron); MANUAL execution errors throw and surface as HTTP errors instead.
23
- z.object({
24
- outcome: z.literal("failed"),
25
- messages: z.tuple([
26
- z.string()
27
- ]).rest(z.string())
28
- })
29
- ])
30
- });
31
- const AutoRebalanceListResponse = CursorResponse.extend({
32
- items: z.array(AutoRebalanceConfig)
33
- });
34
- const CreateAutoRebalanceResponse = z.object({
35
- config: AutoRebalanceConfig
36
- });
37
- const RebalanceEventListResponse = CursorResponse.extend({
38
- items: z.array(RebalanceEvent)
39
- });
40
-
41
- export { AutoRebalanceListResponse, CreateAutoRebalanceResponse, RebalanceEventListResponse, RebalanceManualResponse };
@@ -1,239 +0,0 @@
1
- import { z } from 'zod';
2
- import { AssetWeight, Side, UnsignedDecimalString, SignedDecimalString } from '../common/schema';
3
- import { Connector } from '../connector';
4
- import { Fill } from '../fill/entities';
5
- import { InstrumentId } from '../instrument';
6
- import { TWAPRandomization } from './randomization';
7
-
8
- const ScheduleStrategy = z.enum([
9
- "TWAP",
10
- "VWAP"
11
- ]);
12
- const ScheduleStatus = z.enum([
13
- "ACTIVE",
14
- "COMPLETED",
15
- "FAILED",
16
- "CANCELLED"
17
- ]);
18
- const ScheduleIntent = z.enum([
19
- "OPEN",
20
- "CLOSE"
21
- ]);
22
- const ScheduleExecutionType = z.enum([
23
- "MARKET"
24
- ]);
25
- const ScheduleCancelledReason = z.enum([
26
- "POSITION_CLOSED",
27
- "USER",
28
- "SYSTEM",
29
- "POSITION_NETTED",
30
- "POSITION_LIQUIDATED",
31
- "POSITION_REVERSED"
32
- ]);
33
- const TWAPOpenLeg = z.object({
34
- /** SYMBOL-MIGRATION switch-to-id: mirrors `symbol` today; becomes required once requests always carry `id`. */
35
- id: InstrumentId.optional(),
36
- /**
37
- * Instrument ID
38
- */
39
- symbol: InstrumentId,
40
- /**
41
- * Side
42
- */
43
- side: Side,
44
- /**
45
- * Share of the parent target notional allocated to this leg
46
- */
47
- weight: AssetWeight
48
- });
49
- const BaseSchedule = z.object({
50
- /**
51
- * Schedule UUID
52
- */
53
- id: z.uuid(),
54
- /**
55
- * Connector
56
- */
57
- connector: Connector,
58
- /**
59
- * Schedule strategy
60
- */
61
- strategy: ScheduleStrategy,
62
- /**
63
- * Schedule status
64
- */
65
- status: ScheduleStatus,
66
- /**
67
- * Intent
68
- */
69
- intent: ScheduleIntent,
70
- /**
71
- * Position key
72
- */
73
- positionKey: z.string(),
74
- /**
75
- * Execution type
76
- */
77
- executionType: ScheduleExecutionType,
78
- /**
79
- * Last slice at timestamp
80
- */
81
- lastSliceAt: z.string().optional(),
82
- /**
83
- * Start at timestamp
84
- */
85
- startAt: z.string(),
86
- /**
87
- * End at timestamp
88
- */
89
- endAt: z.string(),
90
- /**
91
- * When the schedule was cancelled
92
- */
93
- cancelledAt: z.string().optional(),
94
- /**
95
- * Reason for the schedule being cancelled
96
- */
97
- cancelledReason: ScheduleCancelledReason.optional(),
98
- /**
99
- * Created at timestamp
100
- */
101
- createdAt: z.string(),
102
- /**
103
- * Updated at timestamp
104
- */
105
- updatedAt: z.string(),
106
- /**
107
- * Slices that produced live fills
108
- */
109
- executedSliceCount: z.number().int().nonnegative(),
110
- /**
111
- * Absolute USD filled across every slice
112
- */
113
- filledUsd: UnsignedDecimalString,
114
- /**
115
- * Absolute base quantity filled, per instrument
116
- */
117
- filledQuantities: z.record(InstrumentId, UnsignedDecimalString),
118
- /**
119
- * Overall progress from 0 to 1: notional filled for OPEN, the slowest leg for CLOSE
120
- */
121
- progress: z.number().min(0).max(1),
122
- /**
123
- * Progress of each leg from 0 to 1, capped at 1 when a leg overfills
124
- */
125
- legProgress: z.record(InstrumentId, z.number().min(0).max(1))
126
- });
127
- const TWAPOpen = BaseSchedule.extend({
128
- /**
129
- * Strategy
130
- */
131
- strategy: z.literal("TWAP"),
132
- /**
133
- * Intent
134
- */
135
- intent: z.literal("OPEN"),
136
- /**
137
- * Slice interval in seconds
138
- */
139
- sliceIntervalSec: z.number(),
140
- /**
141
- * Number of slices planned inside the execution window
142
- */
143
- sliceCount: z.number().int().positive(),
144
- /**
145
- * Bounded timing and basket-size randomization
146
- */
147
- randomization: TWAPRandomization,
148
- /**
149
- * Parent-order leg allocation
150
- */
151
- legs: z.array(TWAPOpenLeg),
152
- /**
153
- * Target notional
154
- */
155
- targetNotional: UnsignedDecimalString,
156
- /**
157
- * Remaining notional
158
- */
159
- remainingNotional: UnsignedDecimalString
160
- });
161
- const TWAPClose = BaseSchedule.extend({
162
- /**
163
- * Strategy
164
- */
165
- strategy: z.literal("TWAP"),
166
- /**
167
- * Intent
168
- */
169
- intent: z.literal("CLOSE"),
170
- /**
171
- * Slice interval in seconds
172
- */
173
- sliceIntervalSec: z.number(),
174
- /**
175
- * Number of slices planned inside the execution window
176
- */
177
- sliceCount: z.number().int().positive(),
178
- /**
179
- * Bounded timing and basket-size randomization
180
- */
181
- randomization: TWAPRandomization,
182
- /**
183
- * Position UUID
184
- */
185
- positionId: z.uuid(),
186
- /**
187
- * Initial exposure
188
- */
189
- initialExposure: z.record(InstrumentId, SignedDecimalString)
190
- });
191
- const Schedule = z.discriminatedUnion("intent", [
192
- TWAPOpen,
193
- TWAPClose
194
- ]);
195
- const ScheduleSlicePosition = z.object({
196
- /**
197
- * Grid index of the slice inside the execution window
198
- */
199
- index: z.number().int().nonnegative(),
200
- /**
201
- * Grid time the slice is planned around, before timing jitter
202
- */
203
- scheduledAt: z.string()
204
- });
205
- const ScheduleSlice = z.discriminatedUnion("status", [
206
- ScheduleSlicePosition.extend({
207
- status: z.literal("EXECUTED"),
208
- /**
209
- * Absolute USD filled by the slice
210
- */
211
- usd: UnsignedDecimalString,
212
- /**
213
- * Absolute base quantity filled by the slice, per instrument
214
- */
215
- quantities: z.record(InstrumentId, UnsignedDecimalString),
216
- /**
217
- * Timestamp of the slice's latest fill
218
- */
219
- lastFilledAt: z.string(),
220
- /**
221
- * The slice's live fills in time order, present when requested with include=fills
222
- */
223
- fills: z.array(Fill).optional()
224
- }),
225
- ScheduleSlicePosition.extend({
226
- /**
227
- * Not yet reached on an active schedule
228
- */
229
- status: z.literal("PENDING")
230
- }),
231
- ScheduleSlicePosition.extend({
232
- /**
233
- * Passed without fills: skipped by catch-up, or before a finished schedule's last executed slice
234
- */
235
- status: z.literal("MISSED")
236
- })
237
- ]);
238
-
239
- export { Schedule, ScheduleCancelledReason, ScheduleExecutionType, ScheduleIntent, ScheduleSlice, ScheduleStatus, ScheduleStrategy, TWAPClose, TWAPOpen };
@@ -1,5 +0,0 @@
1
- export * from './entities';
2
- export * from './payloads';
3
- export * from './queries';
4
- export * from './randomization';
5
- export * from './responses';
@@ -1,85 +0,0 @@
1
- import { z } from 'zod';
2
- import { ClientIdCode } from '../common/client-id';
3
- import { TWAPRandomization, DEFAULT_TWAP_RANDOMIZATION } from './randomization';
4
- import { FINAL_TWAP_SLICE_START_HEADROOM_SEC, TWAPSliceIntervalSec, TWAPTargetNotional, TWAPOpenLegs } from './twap-config';
5
-
6
- const BaseSchedule = z.object({
7
- /**
8
- * Start at date
9
- */
10
- startAt: z.coerce.date(),
11
- /**
12
- * End at date
13
- */
14
- endAt: z.coerce.date(),
15
- /**
16
- * Optional bounded timing and basket-size randomization
17
- */
18
- randomization: TWAPRandomization.optional().default(DEFAULT_TWAP_RANDOMIZATION)
19
- }).refine((data) => data.startAt && data.endAt && data.startAt < data.endAt, {
20
- message: "Start at date must be before end at date"
21
- }).refine((data) => data.endAt.getTime() - data.startAt.getTime() >= FINAL_TWAP_SLICE_START_HEADROOM_SEC * 1e3, {
22
- message: `TWAP execution window must be at least ${FINAL_TWAP_SLICE_START_HEADROOM_SEC} seconds`
23
- });
24
- const CreateTWAPOpen = BaseSchedule.safeExtend({
25
- /**
26
- * Strategy
27
- */
28
- strategy: z.literal("TWAP"),
29
- /**
30
- * Intent
31
- */
32
- intent: z.literal("OPEN"),
33
- /**
34
- * Execution type
35
- */
36
- executionType: z.literal("MARKET"),
37
- /**
38
- * Parent-order allocation for each leg
39
- */
40
- legs: TWAPOpenLegs,
41
- /**
42
- * Target notional
43
- */
44
- targetNotional: TWAPTargetNotional,
45
- /**
46
- * Slice interval in seconds
47
- */
48
- sliceIntervalSec: TWAPSliceIntervalSec,
49
- /**
50
- * Attribution route code (client_ids.code)
51
- */
52
- clientId: ClientIdCode
53
- });
54
- const CreateTWAPClose = BaseSchedule.safeExtend({
55
- /**
56
- * Strategy
57
- */
58
- strategy: z.literal("TWAP"),
59
- /**
60
- * Intent
61
- */
62
- intent: z.literal("CLOSE"),
63
- /**
64
- * Execution type
65
- */
66
- executionType: z.literal("MARKET"),
67
- /**
68
- * Position UUID
69
- */
70
- positionId: z.uuid(),
71
- /**
72
- * Slice interval in seconds
73
- */
74
- sliceIntervalSec: TWAPSliceIntervalSec,
75
- /**
76
- * Attribution route code (client_ids.code)
77
- */
78
- clientId: ClientIdCode
79
- });
80
- const CreateSchedule = z.discriminatedUnion("intent", [
81
- CreateTWAPOpen,
82
- CreateTWAPClose
83
- ]);
84
-
85
- export { CreateSchedule, CreateTWAPClose, CreateTWAPOpen };
@@ -1,30 +0,0 @@
1
- import { z } from 'zod';
2
- import { normalizeArray, CursorFindParams } from '../common';
3
- import { Connector } from '../connector';
4
-
5
- const StatusEnum = z.enum([
6
- "ACTIVE",
7
- "COMPLETED",
8
- "CANCELLED"
9
- ]);
10
- const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(StatusEnum));
11
- const ScheduleListParams = CursorFindParams.extend({
12
- connector: Connector.optional(),
13
- status: StatusArray.optional()
14
- });
15
- const ScheduleDetailParams = z.object({
16
- /**
17
- * Slices per page; kept small so a page with fills stays bounded
18
- */
19
- limit: z.coerce.number().int().positive().max(100).optional().default(20),
20
- /**
21
- * Slice index the page starts at; pass the previous page's nextCursor as-is
22
- */
23
- cursor: z.coerce.number().int().nonnegative().optional(),
24
- /**
25
- * Nest each executed slice's live fills
26
- */
27
- include: z.literal("fills").optional()
28
- });
29
-
30
- export { ScheduleDetailParams, ScheduleListParams };
@@ -1,15 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const MAX_JITTER_BPS = 5e3;
4
- const DEFAULT_TWAP_RANDOMIZATION = {
5
- timingJitterBps: 0,
6
- sizeJitterBps: 0
7
- };
8
- const TWAPRandomization = z.object({
9
- /** Maximum symmetric timing variation in basis points, capped at ±50%. */
10
- timingJitterBps: z.int().min(0).max(MAX_JITTER_BPS),
11
- /** Maximum symmetric basket-size variation in basis points, capped at ±50%. */
12
- sizeJitterBps: z.int().min(0).max(MAX_JITTER_BPS)
13
- });
14
-
15
- export { DEFAULT_TWAP_RANDOMIZATION, TWAPRandomization };
@@ -1,22 +0,0 @@
1
- import { z } from 'zod';
2
- import { CursorResponse } from '../common';
3
- import { Schedule, ScheduleSlice } from './entities';
4
-
5
- const ScheduleListResponse = CursorResponse.extend({
6
- schedules: z.array(Schedule)
7
- });
8
- const ScheduleDetailResponse = CursorResponse.extend({
9
- schedule: Schedule,
10
- slices: z.array(ScheduleSlice)
11
- });
12
- const CreateScheduleResponse = z.object({
13
- schedule: Schedule
14
- });
15
- const CancelScheduleResponse = z.object({
16
- id: z.uuid()
17
- });
18
- const CancelAllSchedulesResponse = z.object({
19
- ids: z.array(z.uuid())
20
- });
21
-
22
- export { CancelAllSchedulesResponse, CancelScheduleResponse, CreateScheduleResponse, ScheduleDetailResponse, ScheduleListResponse };
@@ -1,29 +0,0 @@
1
- import { z } from 'zod';
2
- import { RefineLegIdMatchesSymbol, RefineMinimumOneSymbol, RefineUniqueSymbols, RefineWeightingSum } from '../common/refinement';
3
- import { UnsignedDecimalString, AssetWeight, Side } from '../common/schema';
4
- import { InstrumentId } from '../instrument';
5
-
6
- const MAX_TWAP_DURATION_SEC = 60 * 60 * 24 * 31;
7
- const MIN_TWAP_SLICE_INTERVAL_SEC = 15;
8
- const FINAL_TWAP_SLICE_START_HEADROOM_SEC = 15;
9
- const TWAPSliceIntervalSec = z.int().min(MIN_TWAP_SLICE_INTERVAL_SEC).max(MAX_TWAP_DURATION_SEC);
10
- const TWAPTargetNotional = UnsignedDecimalString.refine((value) => /[1-9]/.test(value), {
11
- message: "Target notional must be greater than zero"
12
- });
13
- const TWAPOpenLeg = z.object({
14
- /** SYMBOL-MIGRATION switch-to-id: mirrors `symbol` today; becomes required once requests always carry `id`. */
15
- id: InstrumentId.optional(),
16
- /** Instrument ID. */
17
- symbol: InstrumentId,
18
- /** Direction to take. */
19
- side: Side,
20
- /** Share of the parent target notional allocated to this leg. */
21
- weight: AssetWeight
22
- }).superRefine(RefineLegIdMatchesSymbol);
23
- const TWAPOpenLegs = z.array(TWAPOpenLeg).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
24
- const TriggerTWAPOpenLeg = TWAPOpenLeg.strict();
25
- const TriggerTWAPOpenLegs = z.tuple([
26
- TriggerTWAPOpenLeg
27
- ]).rest(TriggerTWAPOpenLeg).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
28
-
29
- export { FINAL_TWAP_SLICE_START_HEADROOM_SEC, MAX_TWAP_DURATION_SEC, MIN_TWAP_SLICE_INTERVAL_SEC, TWAPOpenLeg, TWAPOpenLegs, TWAPSliceIntervalSec, TWAPTargetNotional, TriggerTWAPOpenLegs };