@pear-protocol/types 1.23.0 → 1.24.1

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 (71) hide show
  1. package/dist/auth/api-keys.js +11 -3
  2. package/dist/auth/entities.js +10 -2
  3. package/dist/auth/payloads.d.ts +15 -0
  4. package/dist/auth/payloads.js +19 -5
  5. package/dist/auth/response.js +4 -1
  6. package/dist/common/array.js +9 -2
  7. package/dist/common/refinement.js +25 -19
  8. package/dist/common/request.js +8 -8
  9. package/dist/common/response.js +10 -10
  10. package/dist/common/schema.js +9 -2
  11. package/dist/common/trade-legs.js +17 -12
  12. package/dist/connector/index.js +7 -1
  13. package/dist/execution/entities.js +96 -65
  14. package/dist/execution/queries.js +5 -1
  15. package/dist/execution/responses.js +3 -1
  16. package/dist/fee/entities.js +17 -3
  17. package/dist/fill/entities.js +33 -29
  18. package/dist/fill/queries.js +4 -1
  19. package/dist/funding/entities.js +4 -4
  20. package/dist/funding/responses.js +2 -2
  21. package/dist/instrument/entities.js +56 -44
  22. package/dist/instrument/queries.js +6 -1
  23. package/dist/instrument/responses.js +4 -4
  24. package/dist/instrument-precision/index.js +23 -23
  25. package/dist/ladder/entities.js +5 -1
  26. package/dist/ladder/payloads.js +15 -4
  27. package/dist/ladder/queries.js +0 -1
  28. package/dist/ladder/responses.js +12 -4
  29. package/dist/leverage/payloads.js +4 -1
  30. package/dist/notification/entities.js +37 -28
  31. package/dist/notification/payloads.js +9 -3
  32. package/dist/notification/queries.js +5 -1
  33. package/dist/notification/responses.js +4 -4
  34. package/dist/order/entities.js +38 -30
  35. package/dist/portfolio/queries.js +18 -3
  36. package/dist/position/entities.js +95 -72
  37. package/dist/position/queries.js +29 -23
  38. package/dist/price/entities.js +4 -1
  39. package/dist/price/responses.js +4 -4
  40. package/dist/rebalance/entities.js +23 -6
  41. package/dist/rebalance/payloads.js +23 -11
  42. package/dist/rebalance/queries.js +2 -8
  43. package/dist/rebalance/responses.js +12 -4
  44. package/dist/saved-baskets/entities.js +3 -1
  45. package/dist/saved-baskets/payloads.js +3 -1
  46. package/dist/schedule/entities.js +87 -71
  47. package/dist/schedule/payloads.js +36 -33
  48. package/dist/schedule/queries.js +5 -1
  49. package/dist/schedule/responses.js +12 -4
  50. package/dist/statistics/queries.js +15 -3
  51. package/dist/sync/payloads.js +13 -17
  52. package/dist/tca/entities.js +4 -1
  53. package/dist/tca/responses.js +4 -1
  54. package/dist/trade/payloads.js +37 -23
  55. package/dist/trade/responses.js +15 -5
  56. package/dist/trade-accounts/entities.js +4 -1
  57. package/dist/trade-accounts/response.js +6 -2
  58. package/dist/trigger/common/index.js +27 -6
  59. package/dist/trigger/entities/conditions.js +14 -15
  60. package/dist/trigger/entities/index.js +89 -80
  61. package/dist/trigger/oracle.js +10 -3
  62. package/dist/trigger/payloads/conditions.js +8 -2
  63. package/dist/trigger/payloads/index.js +18 -4
  64. package/dist/trigger/queries.js +5 -1
  65. package/dist/trigger/refinement/static.refinement.js +5 -2
  66. package/dist/trigger/refinement/trailing.refinement.js +8 -6
  67. package/dist/trigger/responses.js +12 -4
  68. package/dist/triggers/entities.js +8 -2
  69. package/dist/users/entities.js +4 -1
  70. package/dist/users/payloads.js +17 -18
  71. package/package.json +1 -1
@@ -9,23 +9,31 @@ const RebalanceManualResponse = z.object({
9
9
  }),
10
10
  z.object({
11
11
  outcome: z.literal("partial_rebalance"),
12
- messages: z.tuple([z.string()]).rest(z.string())
12
+ messages: z.tuple([
13
+ z.string()
14
+ ]).rest(z.string())
13
15
  }),
14
16
  z.object({
15
17
  outcome: z.literal("no_rebalance"),
16
- messages: z.tuple([z.string()]).rest(z.string())
18
+ messages: z.tuple([
19
+ z.string()
20
+ ]).rest(z.string())
17
21
  }),
18
22
  // `failed` only occurs on background runs (dispatch/cron); MANUAL execution errors throw and surface as HTTP errors instead.
19
23
  z.object({
20
24
  outcome: z.literal("failed"),
21
- messages: z.tuple([z.string()]).rest(z.string())
25
+ messages: z.tuple([
26
+ z.string()
27
+ ]).rest(z.string())
22
28
  })
23
29
  ])
24
30
  });
25
31
  const AutoRebalanceListResponse = CursorResponse.extend({
26
32
  items: z.array(AutoRebalanceConfig)
27
33
  });
28
- const CreateAutoRebalanceResponse = z.object({ config: AutoRebalanceConfig });
34
+ const CreateAutoRebalanceResponse = z.object({
35
+ config: AutoRebalanceConfig
36
+ });
29
37
  const RebalanceEventListResponse = CursorResponse.extend({
30
38
  items: z.array(RebalanceEvent)
31
39
  });
@@ -10,7 +10,9 @@ const SavedBasketLeg = z.object({
10
10
  const SavedBasket = z.object({
11
11
  id: z.uuid(),
12
12
  name: z.string(),
13
- legs: z.tuple([SavedBasketLeg]).rest(SavedBasketLeg),
13
+ legs: z.tuple([
14
+ SavedBasketLeg
15
+ ]).rest(SavedBasketLeg),
14
16
  createdAt: z.string(),
15
17
  updatedAt: z.string()
16
18
  });
@@ -3,7 +3,9 @@ import { RefineUniqueSymbols, RefineWeightingSum } from '../common/refinement';
3
3
  import { SavedBasketLeg } from './entities';
4
4
 
5
5
  const SavedBasketName = z.string().trim().min(1, "Name is required").max(48).describe("Display name, unique per trade account (case-insensitive)");
6
- const SavedBasketLegs = z.tuple([SavedBasketLeg]).rest(SavedBasketLeg).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum).refine((value) => value.length <= 20, "Basket must have at most 20 legs").describe("At least one leg, up to 20");
6
+ const SavedBasketLegs = z.tuple([
7
+ SavedBasketLeg
8
+ ]).rest(SavedBasketLeg).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum).refine((value) => value.length <= 20, "Basket must have at most 20 legs").describe("At least one leg, up to 20");
7
9
  const CreateSavedBasketPayload = z.object({
8
10
  name: SavedBasketName,
9
11
  legs: SavedBasketLegs
@@ -5,10 +5,23 @@ import { Fill } from '../fill/entities';
5
5
  import { InstrumentId } from '../instrument';
6
6
  import { TWAPRandomization } from './randomization';
7
7
 
8
- const ScheduleStrategy = z.enum(["TWAP", "VWAP"]);
9
- const ScheduleStatus = z.enum(["ACTIVE", "COMPLETED", "FAILED", "CANCELLED"]);
10
- const ScheduleIntent = z.enum(["OPEN", "CLOSE"]);
11
- const ScheduleExecutionType = z.enum(["MARKET"]);
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
+ ]);
12
25
  const ScheduleCancelledReason = z.enum([
13
26
  "POSITION_CLOSED",
14
27
  "USER",
@@ -18,144 +31,147 @@ const ScheduleCancelledReason = z.enum([
18
31
  ]);
19
32
  const TWAPOpenLeg = z.object({
20
33
  /**
21
- * Instrument ID
22
- */
34
+ * Instrument ID
35
+ */
23
36
  symbol: InstrumentId,
24
37
  /**
25
- * Side
26
- */
38
+ * Side
39
+ */
27
40
  side: Side,
28
41
  /**
29
- * Share of the parent target notional allocated to this leg
30
- */
42
+ * Share of the parent target notional allocated to this leg
43
+ */
31
44
  weight: AssetWeight
32
45
  });
33
46
  const BaseSchedule = z.object({
34
47
  /**
35
- * Schedule UUID
36
- */
48
+ * Schedule UUID
49
+ */
37
50
  id: z.uuid(),
38
51
  /**
39
- * Connector
40
- */
52
+ * Connector
53
+ */
41
54
  connector: Connector,
42
55
  /**
43
- * Schedule strategy
44
- */
56
+ * Schedule strategy
57
+ */
45
58
  strategy: ScheduleStrategy,
46
59
  /**
47
- * Schedule status
48
- */
60
+ * Schedule status
61
+ */
49
62
  status: ScheduleStatus,
50
63
  /**
51
- * Intent
52
- */
64
+ * Intent
65
+ */
53
66
  intent: ScheduleIntent,
54
67
  /**
55
- * Position key
56
- */
68
+ * Position key
69
+ */
57
70
  positionKey: z.string(),
58
71
  /**
59
- * Execution type
60
- */
72
+ * Execution type
73
+ */
61
74
  executionType: ScheduleExecutionType,
62
75
  /**
63
- * Last slice at timestamp
64
- */
76
+ * Last slice at timestamp
77
+ */
65
78
  lastSliceAt: z.string().optional(),
66
79
  /**
67
- * Start at timestamp
68
- */
80
+ * Start at timestamp
81
+ */
69
82
  startAt: z.string(),
70
83
  /**
71
- * End at timestamp
72
- */
84
+ * End at timestamp
85
+ */
73
86
  endAt: z.string(),
74
87
  /**
75
- * When the schedule was cancelled
76
- */
88
+ * When the schedule was cancelled
89
+ */
77
90
  cancelledAt: z.string().optional(),
78
91
  /**
79
- * Reason for the schedule being cancelled
80
- */
92
+ * Reason for the schedule being cancelled
93
+ */
81
94
  cancelledReason: ScheduleCancelledReason.optional(),
82
95
  /**
83
- * Created at timestamp
84
- */
96
+ * Created at timestamp
97
+ */
85
98
  createdAt: z.string(),
86
99
  /**
87
- * Updated at timestamp
88
- */
100
+ * Updated at timestamp
101
+ */
89
102
  updatedAt: z.string(),
90
103
  /**
91
- * Fills
92
- */
104
+ * Fills
105
+ */
93
106
  fills: z.array(Fill).optional()
94
107
  });
95
108
  const TWAPOpen = BaseSchedule.extend({
96
109
  /**
97
- * Strategy
98
- */
110
+ * Strategy
111
+ */
99
112
  strategy: z.literal("TWAP"),
100
113
  /**
101
- * Intent
102
- */
114
+ * Intent
115
+ */
103
116
  intent: z.literal("OPEN"),
104
117
  /**
105
- * Slice interval in seconds
106
- */
118
+ * Slice interval in seconds
119
+ */
107
120
  sliceIntervalSec: z.number(),
108
121
  /**
109
- * Number of slices planned inside the execution window
110
- */
122
+ * Number of slices planned inside the execution window
123
+ */
111
124
  sliceCount: z.number().int().positive(),
112
125
  /**
113
- * Bounded timing and basket-size randomization
114
- */
126
+ * Bounded timing and basket-size randomization
127
+ */
115
128
  randomization: TWAPRandomization,
116
129
  /**
117
- * Parent-order leg allocation
118
- */
130
+ * Parent-order leg allocation
131
+ */
119
132
  legs: z.array(TWAPOpenLeg),
120
133
  /**
121
- * Target notional
122
- */
134
+ * Target notional
135
+ */
123
136
  targetNotional: UnsignedDecimalString,
124
137
  /**
125
- * Remaining notional
126
- */
138
+ * Remaining notional
139
+ */
127
140
  remainingNotional: UnsignedDecimalString
128
141
  });
129
142
  const TWAPClose = BaseSchedule.extend({
130
143
  /**
131
- * Strategy
132
- */
144
+ * Strategy
145
+ */
133
146
  strategy: z.literal("TWAP"),
134
147
  /**
135
- * Intent
136
- */
148
+ * Intent
149
+ */
137
150
  intent: z.literal("CLOSE"),
138
151
  /**
139
- * Slice interval in seconds
140
- */
152
+ * Slice interval in seconds
153
+ */
141
154
  sliceIntervalSec: z.number(),
142
155
  /**
143
- * Number of slices planned inside the execution window
144
- */
156
+ * Number of slices planned inside the execution window
157
+ */
145
158
  sliceCount: z.number().int().positive(),
146
159
  /**
147
- * Bounded timing and basket-size randomization
148
- */
160
+ * Bounded timing and basket-size randomization
161
+ */
149
162
  randomization: TWAPRandomization,
150
163
  /**
151
- * Position UUID
152
- */
164
+ * Position UUID
165
+ */
153
166
  positionId: z.uuid(),
154
167
  /**
155
- * Initial exposure
156
- */
168
+ * Initial exposure
169
+ */
157
170
  initialExposure: z.record(InstrumentId, SignedDecimalString)
158
171
  });
159
- const Schedule = z.discriminatedUnion("intent", [TWAPOpen, TWAPClose]);
172
+ const Schedule = z.discriminatedUnion("intent", [
173
+ TWAPOpen,
174
+ TWAPClose
175
+ ]);
160
176
 
161
177
  export { Schedule, ScheduleCancelledReason, ScheduleExecutionType, ScheduleIntent, ScheduleStatus, ScheduleStrategy, TWAPClose, TWAPOpen };
@@ -13,16 +13,16 @@ const TargetNotional = UnsignedDecimalString.refine((value) => /[1-9]/.test(valu
13
13
  });
14
14
  const TWAPOpenLeg = z.object({
15
15
  /**
16
- * Instrument ID
17
- */
16
+ * Instrument ID
17
+ */
18
18
  symbol: InstrumentId,
19
19
  /**
20
- * Direction to take
21
- */
20
+ * Direction to take
21
+ */
22
22
  side: Side,
23
23
  /**
24
- * Share of the parent target notional allocated to this leg
25
- */
24
+ * Share of the parent target notional allocated to this leg
25
+ */
26
26
  weight: AssetWeight
27
27
  });
28
28
  const TWAPOpenLegs = z.array(TWAPOpenLeg).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
@@ -46,60 +46,63 @@ const BaseSchedule = z.object({
46
46
  });
47
47
  const CreateTWAPOpen = BaseSchedule.safeExtend({
48
48
  /**
49
- * Strategy
50
- */
49
+ * Strategy
50
+ */
51
51
  strategy: z.literal("TWAP"),
52
52
  /**
53
- * Intent
54
- */
53
+ * Intent
54
+ */
55
55
  intent: z.literal("OPEN"),
56
56
  /**
57
- * Execution type
58
- */
57
+ * Execution type
58
+ */
59
59
  executionType: z.literal("MARKET"),
60
60
  /**
61
- * Parent-order allocation for each leg
62
- */
61
+ * Parent-order allocation for each leg
62
+ */
63
63
  legs: TWAPOpenLegs,
64
64
  /**
65
- * Target notional
66
- */
65
+ * Target notional
66
+ */
67
67
  targetNotional: TargetNotional,
68
68
  /**
69
- * Slice interval in seconds
70
- */
69
+ * Slice interval in seconds
70
+ */
71
71
  sliceIntervalSec: SliceIntervalSec,
72
72
  /**
73
- * Attribution route code (client_ids.code)
74
- */
73
+ * Attribution route code (client_ids.code)
74
+ */
75
75
  clientId: ClientIdCode
76
76
  });
77
77
  const CreateTWAPClose = BaseSchedule.safeExtend({
78
78
  /**
79
- * Strategy
80
- */
79
+ * Strategy
80
+ */
81
81
  strategy: z.literal("TWAP"),
82
82
  /**
83
- * Intent
84
- */
83
+ * Intent
84
+ */
85
85
  intent: z.literal("CLOSE"),
86
86
  /**
87
- * Execution type
88
- */
87
+ * Execution type
88
+ */
89
89
  executionType: z.literal("MARKET"),
90
90
  /**
91
- * Position UUID
92
- */
91
+ * Position UUID
92
+ */
93
93
  positionId: z.uuid(),
94
94
  /**
95
- * Slice interval in seconds
96
- */
95
+ * Slice interval in seconds
96
+ */
97
97
  sliceIntervalSec: SliceIntervalSec,
98
98
  /**
99
- * Attribution route code (client_ids.code)
100
- */
99
+ * Attribution route code (client_ids.code)
100
+ */
101
101
  clientId: ClientIdCode
102
102
  });
103
- const CreateSchedule = z.discriminatedUnion("intent", [CreateTWAPOpen, CreateTWAPClose]);
103
+ const CreateSchedule = z.discriminatedUnion("intent", [
104
+ CreateTWAPOpen,
105
+ CreateTWAPClose
106
+ ]);
104
107
 
105
108
  export { CreateSchedule, CreateTWAPClose, CreateTWAPOpen };
@@ -2,7 +2,11 @@ import { z } from 'zod';
2
2
  import { normalizeArray, CursorFindParams } from '../common';
3
3
  import { Connector } from '../connector';
4
4
 
5
- const StatusEnum = z.enum(["ACTIVE", "COMPLETED", "CANCELLED"]);
5
+ const StatusEnum = z.enum([
6
+ "ACTIVE",
7
+ "COMPLETED",
8
+ "CANCELLED"
9
+ ]);
6
10
  const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(StatusEnum));
7
11
  const ScheduleListParams = CursorFindParams.extend({
8
12
  connector: Connector.optional(),
@@ -2,9 +2,17 @@ import { z } from 'zod';
2
2
  import { CursorResponse } from '../common';
3
3
  import { Schedule } from './entities';
4
4
 
5
- const ScheduleListResponse = CursorResponse.extend({ schedules: z.array(Schedule) });
6
- const CreateScheduleResponse = z.object({ schedule: Schedule });
7
- const CancelScheduleResponse = z.object({ id: z.uuid() });
8
- const CancelAllSchedulesResponse = z.object({ ids: z.array(z.uuid()) });
5
+ const ScheduleListResponse = CursorResponse.extend({
6
+ schedules: z.array(Schedule)
7
+ });
8
+ const CreateScheduleResponse = z.object({
9
+ schedule: Schedule
10
+ });
11
+ const CancelScheduleResponse = z.object({
12
+ id: z.uuid()
13
+ });
14
+ const CancelAllSchedulesResponse = z.object({
15
+ ids: z.array(z.uuid())
16
+ });
9
17
 
10
18
  export { CancelAllSchedulesResponse, CancelScheduleResponse, CreateScheduleResponse, ScheduleListResponse };
@@ -4,7 +4,11 @@ import { Connector } from '../connector';
4
4
 
5
5
  const VolumeStatisticsQueryParams = z.object({
6
6
  connector: Connector,
7
- resolution: z.enum(["1h", "4h", "24h"]),
7
+ resolution: z.enum([
8
+ "1h",
9
+ "4h",
10
+ "24h"
11
+ ]),
8
12
  startDate: z.coerce.date().optional(),
9
13
  endDate: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
10
14
  // Per-client scope; absent serves the global series. The literal 'other'
@@ -15,7 +19,11 @@ const VolumeStatisticsQueryParams = z.object({
15
19
  });
16
20
  const OiStatisticsQueryParams = z.object({
17
21
  connector: Connector,
18
- resolution: z.enum(["1h", "4h", "24h"]),
22
+ resolution: z.enum([
23
+ "1h",
24
+ "4h",
25
+ "24h"
26
+ ]),
19
27
  startDate: z.coerce.date().optional(),
20
28
  endDate: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
21
29
  // Per-client scope; absent serves the global series. The literal 'other'
@@ -30,7 +38,11 @@ const StatisticsTotalsQueryParams = z.object({
30
38
  // selects the unattributed (NULL) bucket; an unknown code returns zero totals.
31
39
  clientId: z.string().trim().min(1).optional()
32
40
  });
33
- const LeaderboardSortBy = z.enum(["trades", "totalNetPnl", "volume"]);
41
+ const LeaderboardSortBy = z.enum([
42
+ "trades",
43
+ "totalNetPnl",
44
+ "volume"
45
+ ]);
34
46
  const LEADERBOARD_MAX_LIMIT = 200;
35
47
  const UnixSeconds = z.coerce.number().int().min(0).transform((seconds) => new Date(seconds * 1e3));
36
48
  const ConnectorArray = z.preprocess((arg) => normalizeArray(arg), z.array(Connector));
@@ -7,7 +7,9 @@ import { PositionClosedReason, PositionStatus, PositionOrigin } from '../positio
7
7
 
8
8
  const ExchangeFillId = z.string().trim().min(1, "Exchange fill ID must be non-empty");
9
9
  const MsTimestamp = z.number().int().positive().describe("Unix timestamp in milliseconds");
10
- const LiquidationMark = z.object({ mark: UnsignedDecimalString }).nullable();
10
+ const LiquidationMark = z.object({
11
+ mark: UnsignedDecimalString
12
+ }).nullable();
11
13
  const OriginalFillRef = z.object({
12
14
  exchangeFillId: ExchangeFillId,
13
15
  quantity: UnsignedDecimalString
@@ -52,11 +54,13 @@ const ReconcileReplacementExternalFill = z.object({
52
54
  builderFee: UnsignedDecimalString,
53
55
  liquidation: LiquidationMark
54
56
  });
55
- const ConfirmFillsRequest = z.record(z.uuid().describe("Position ID"), z.tuple([ConfirmableExternalFill]).rest(ConfirmableExternalFill)).superRefine(RefineMinimumOneKeyValuePair);
56
- const ReconcileFillsRequest = z.record(
57
- z.string().trim().min(1, "CLOID must be non-empty"),
58
- z.tuple([ReconcileReplacementExternalFill, ReconcileReplacementExternalFill]).rest(ReconcileReplacementExternalFill)
59
- ).superRefine(RefineMinimumOneKeyValuePair);
57
+ const ConfirmFillsRequest = z.record(z.uuid().describe("Position ID"), z.tuple([
58
+ ConfirmableExternalFill
59
+ ]).rest(ConfirmableExternalFill)).superRefine(RefineMinimumOneKeyValuePair);
60
+ const ReconcileFillsRequest = z.record(z.string().trim().min(1, "CLOID must be non-empty"), z.tuple([
61
+ ReconcileReplacementExternalFill,
62
+ ReconcileReplacementExternalFill
63
+ ]).rest(ReconcileReplacementExternalFill)).superRefine(RefineMinimumOneKeyValuePair);
60
64
  const SyncFillsSinceRequest = z.object({
61
65
  overlapMs: z.number().int().positive()
62
66
  });
@@ -105,17 +109,11 @@ const ApplicablePosition = z.object({
105
109
  });
106
110
  const WATERMARK_FUTURE_SKEW_MS = 3e5;
107
111
  const SyncMeta = z.object({
108
- externalMaxTs: z.number().int().nonnegative().refine(
109
- (timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS,
110
- "externalMaxTs must not be ahead of server time"
111
- ).nullable().describe("watermark advance source")
112
+ externalMaxTs: z.number().int().nonnegative().refine((timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS, "externalMaxTs must not be ahead of server time").nullable().describe("watermark advance source")
112
113
  });
113
114
  const CreateApplicablesMeta = SyncMeta.extend({
114
115
  firstSyncStartedAt: z.number().int().nonnegative().optional().describe("backend-issued timestamp returned before the first fill-history fetch"),
115
- newestFillTs: z.number().int().nonnegative().refine(
116
- (timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS,
117
- "newestFillTs must not be ahead of server time"
118
- ).optional().describe("raw newest fetched fill \u2014 settle-gate source, never trim-advanced")
116
+ newestFillTs: z.number().int().nonnegative().refine((timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS, "newestFillTs must not be ahead of server time").optional().describe("raw newest fetched fill \u2014 settle-gate source, never trim-advanced")
119
117
  });
120
118
  const CreateApplicablesRequest = z.object({
121
119
  applicables: z.array(ApplicablePosition),
@@ -128,9 +126,7 @@ const FundingPaymentEntry = z.object({
128
126
  instrumentId: InstrumentId,
129
127
  fundingRate: OptionallySignedDecimalString.describe("applied funding rate, optionally signed"),
130
128
  notional: OptionallySignedDecimalString.describe("funding amount in USD notional, optionally signed"),
131
- fundingPerUnit: OptionallySignedDecimalString.describe(
132
- "signed funding per 1 unit of size (notional / szi); attribution coefficient"
133
- ),
129
+ fundingPerUnit: OptionallySignedDecimalString.describe("signed funding per 1 unit of size (notional / szi); attribution coefficient"),
134
130
  timestamp: MsTimestamp
135
131
  });
136
132
  const CreateFundingPaymentsRequest = z.object({
@@ -1,6 +1,9 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  const TcaMetricStatus = z.literal("FINAL");
4
- const TcaTimingGranularity = z.enum(["BATCH", "LEG"]);
4
+ const TcaTimingGranularity = z.enum([
5
+ "BATCH",
6
+ "LEG"
7
+ ]);
5
8
 
6
9
  export { TcaMetricStatus, TcaTimingGranularity };
@@ -14,7 +14,10 @@ const TcaBenchmarkResponse = z.object({
14
14
  legIndex: z.number(),
15
15
  connector: Connector,
16
16
  symbol: z.string(),
17
- side: z.enum(["BUY", "SELL"]),
17
+ side: z.enum([
18
+ "BUY",
19
+ "SELL"
20
+ ]),
18
21
  decisionPrice: optionalNumeric,
19
22
  arrivalMid: optionalNumeric,
20
23
  arrivalBid: optionalNumeric,
@@ -7,54 +7,68 @@ import { AttachTriggerMarketClose } from '../trigger';
7
7
  const CreateMarketOpen = z.object({
8
8
  type: z.literal("MARKET"),
9
9
  /**
10
- * Requested legs
11
- */
12
- legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure"),
10
+ * Requested legs
11
+ */
12
+ legs: z.tuple([
13
+ TradeLegPostOnly
14
+ ]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure"),
13
15
  /**
14
- * Close trigger to attach to the execution
15
- */
16
+ * Close trigger to attach to the execution
17
+ */
16
18
  trigger: AttachTriggerMarketClose.optional(),
17
19
  /**
18
- * Attribution route code (client_ids.code)
19
- */
20
+ * Attribution route code (client_ids.code)
21
+ */
20
22
  clientId: ClientIdCode
21
23
  });
22
24
  const CreateMarketAdjust = z.object({
23
25
  type: z.literal("MARKET"),
24
26
  /**
25
- * Requested legs
26
- */
27
- legs: z.tuple([TradeLeg]).rest(TradeLeg).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to modify the position"),
27
+ * Requested legs
28
+ */
29
+ legs: z.tuple([
30
+ TradeLeg
31
+ ]).rest(TradeLeg).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to modify the position"),
28
32
  /**
29
- * Attribution route code (client_ids.code)
30
- */
33
+ * Attribution route code (client_ids.code)
34
+ */
31
35
  clientId: ClientIdCode
32
36
  });
33
37
  const CreateMarketClose = z.object({
34
38
  type: z.literal("MARKET"),
35
39
  /**
36
- * Attribution route code (client_ids.code)
37
- */
40
+ * Attribution route code (client_ids.code)
41
+ */
38
42
  clientId: ClientIdCode
39
43
  });
40
44
  const CreateMarketReverse = z.object({
41
45
  type: z.literal("MARKET"),
42
46
  /**
43
- * Attribution route code (client_ids.code)
44
- */
47
+ * Attribution route code (client_ids.code)
48
+ */
45
49
  clientId: ClientIdCode
46
50
  });
47
51
  const CreateMarketCloseAll = z.object({
48
52
  type: z.literal("MARKET"),
49
53
  /**
50
- * Attribution route code (client_ids.code)
51
- */
54
+ * Attribution route code (client_ids.code)
55
+ */
52
56
  clientId: ClientIdCode
53
57
  });
54
- const CreateTradeOpen = z.discriminatedUnion("type", [CreateMarketOpen]);
55
- const CreateTradeAdjust = z.discriminatedUnion("type", [CreateMarketAdjust]);
56
- const CreateTradeClose = z.discriminatedUnion("type", [CreateMarketClose]);
57
- const CreateTradeReverse = z.discriminatedUnion("type", [CreateMarketReverse]);
58
- const CreateTradeCloseAll = z.discriminatedUnion("type", [CreateMarketCloseAll]);
58
+ const CreateTradeOpen = z.discriminatedUnion("type", [
59
+ CreateMarketOpen
60
+ ]);
61
+ const CreateTradeAdjust = z.discriminatedUnion("type", [
62
+ CreateMarketAdjust
63
+ ]);
64
+ const CreateTradeClose = z.discriminatedUnion("type", [
65
+ CreateMarketClose
66
+ ]);
67
+ const CreateTradeReverse = z.discriminatedUnion("type", [
68
+ CreateMarketReverse
69
+ ]);
70
+ const CreateTradeCloseAll = z.discriminatedUnion("type", [
71
+ CreateMarketCloseAll
72
+ ]);
59
73
 
60
74
  export { CreateMarketAdjust, CreateMarketClose, CreateMarketCloseAll, CreateMarketOpen, CreateMarketReverse, CreateTradeAdjust, CreateTradeClose, CreateTradeCloseAll, CreateTradeOpen, CreateTradeReverse };