@pear-protocol/types 2.20.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 (172) 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/statistics/queries.d.ts +25 -0
  9. package/dist/statistics/responses.d.ts +120 -0
  10. package/dist/sync/responses.d.ts +1 -0
  11. package/dist/users/entities.d.ts +4 -0
  12. package/dist/users/response.d.ts +3 -0
  13. package/package.json +4 -3
  14. package/dist/auth/api-keys.js +0 -44
  15. package/dist/auth/entities.js +0 -25
  16. package/dist/auth/index.js +0 -4
  17. package/dist/auth/payloads.js +0 -84
  18. package/dist/auth/response.js +0 -82
  19. package/dist/baskets/recommended/entities.js +0 -22
  20. package/dist/baskets/recommended/index.js +0 -2
  21. package/dist/baskets/recommended/responses.js +0 -8
  22. package/dist/baskets/saved/entities.js +0 -23
  23. package/dist/baskets/saved/payloads.js +0 -18
  24. package/dist/baskets/saved/responses.js +0 -14
  25. package/dist/bundle.js +0 -36
  26. package/dist/common/address.js +0 -5
  27. package/dist/common/array.js +0 -17
  28. package/dist/common/client-id.js +0 -5
  29. package/dist/common/hex-string.js +0 -5
  30. package/dist/common/index.js +0 -4
  31. package/dist/common/refinement.js +0 -64
  32. package/dist/common/request.js +0 -24
  33. package/dist/common/response.js +0 -28
  34. package/dist/common/schema.js +0 -18
  35. package/dist/common/trade-legs.js +0 -50
  36. package/dist/connector/index.js +0 -12
  37. package/dist/copy/entities.js +0 -151
  38. package/dist/copy/index.js +0 -5
  39. package/dist/copy/payloads.js +0 -8
  40. package/dist/copy/performance.js +0 -63
  41. package/dist/copy/queries.js +0 -20
  42. package/dist/copy/responses.js +0 -89
  43. package/dist/execution/entities.js +0 -196
  44. package/dist/execution/index.js +0 -3
  45. package/dist/execution/queries.js +0 -18
  46. package/dist/execution/responses.js +0 -12
  47. package/dist/fee/entities.js +0 -34
  48. package/dist/fee/index.js +0 -3
  49. package/dist/fee/queries.js +0 -12
  50. package/dist/fee/responses.js +0 -29
  51. package/dist/fill/entities.js +0 -82
  52. package/dist/fill/index.js +0 -3
  53. package/dist/fill/queries.js +0 -14
  54. package/dist/fill/responses.js +0 -23
  55. package/dist/funding/entities.js +0 -16
  56. package/dist/funding/index.js +0 -3
  57. package/dist/funding/queries.js +0 -8
  58. package/dist/funding/responses.js +0 -11
  59. package/dist/instrument/entities.js +0 -102
  60. package/dist/instrument/index.js +0 -3
  61. package/dist/instrument/queries.js +0 -15
  62. package/dist/instrument/responses.js +0 -20
  63. package/dist/instrument-precision/index.js +0 -56
  64. package/dist/ladder/entities.js +0 -24
  65. package/dist/ladder/index.js +0 -4
  66. package/dist/ladder/payloads.js +0 -96
  67. package/dist/ladder/queries.js +0 -12
  68. package/dist/ladder/responses.js +0 -18
  69. package/dist/leverage/index.js +0 -2
  70. package/dist/leverage/payloads.js +0 -14
  71. package/dist/leverage/response.js +0 -5
  72. package/dist/margin/index.js +0 -2
  73. package/dist/margin/payloads.js +0 -20
  74. package/dist/margin/response.js +0 -11
  75. package/dist/market/entities.js +0 -52
  76. package/dist/market/index.js +0 -4
  77. package/dist/market/payloads.js +0 -11
  78. package/dist/market/queries.js +0 -19
  79. package/dist/market/responses.js +0 -18
  80. package/dist/misc/index.js +0 -2
  81. package/dist/misc/payloads.js +0 -99
  82. package/dist/misc/responses.js +0 -85
  83. package/dist/notification/entities.js +0 -274
  84. package/dist/notification/index.js +0 -4
  85. package/dist/notification/payloads.js +0 -15
  86. package/dist/notification/queries.js +0 -29
  87. package/dist/notification/responses.js +0 -20
  88. package/dist/order/entities.js +0 -81
  89. package/dist/order/index.js +0 -1
  90. package/dist/portfolio/entities.js +0 -77
  91. package/dist/portfolio/index.js +0 -3
  92. package/dist/portfolio/queries.js +0 -34
  93. package/dist/portfolio/responses.js +0 -33
  94. package/dist/position/entities.js +0 -433
  95. package/dist/position/index.js +0 -3
  96. package/dist/position/queries.js +0 -109
  97. package/dist/position/responses.js +0 -41
  98. package/dist/price/entities.js +0 -10
  99. package/dist/price/index.js +0 -3
  100. package/dist/price/queries.js +0 -8
  101. package/dist/price/responses.js +0 -15
  102. package/dist/realtime/channels.js +0 -16
  103. package/dist/realtime/frames.js +0 -140
  104. package/dist/realtime/index.js +0 -6
  105. package/dist/realtime/messages.js +0 -118
  106. package/dist/realtime/public-events.js +0 -92
  107. package/dist/realtime/user-events.js +0 -32
  108. package/dist/realtime/vault-events.js +0 -42
  109. package/dist/rebalance/entities.js +0 -86
  110. package/dist/rebalance/index.js +0 -4
  111. package/dist/rebalance/payloads.js +0 -56
  112. package/dist/rebalance/queries.js +0 -14
  113. package/dist/rebalance/responses.js +0 -41
  114. package/dist/schedule/entities.js +0 -239
  115. package/dist/schedule/index.js +0 -5
  116. package/dist/schedule/payloads.js +0 -85
  117. package/dist/schedule/queries.js +0 -30
  118. package/dist/schedule/randomization.js +0 -15
  119. package/dist/schedule/responses.js +0 -22
  120. package/dist/schedule/twap-config.js +0 -29
  121. package/dist/statistics/entities.js +0 -105
  122. package/dist/statistics/index.js +0 -3
  123. package/dist/statistics/queries.js +0 -93
  124. package/dist/statistics/responses.js +0 -17
  125. package/dist/sync/index.js +0 -2
  126. package/dist/sync/payloads.js +0 -136
  127. package/dist/sync/responses.js +0 -26
  128. package/dist/tca/entities.js +0 -9
  129. package/dist/tca/index.js +0 -3
  130. package/dist/tca/queries.js +0 -14
  131. package/dist/tca/responses.js +0 -126
  132. package/dist/trade/entities.js +0 -101
  133. package/dist/trade/index.js +0 -4
  134. package/dist/trade/payloads.js +0 -84
  135. package/dist/trade/queries.js +0 -9
  136. package/dist/trade/responses.js +0 -25
  137. package/dist/trade-accounts/entities.js +0 -61
  138. package/dist/trade-accounts/index.js +0 -4
  139. package/dist/trade-accounts/payloads.js +0 -132
  140. package/dist/trade-accounts/queries.js +0 -7
  141. package/dist/trade-accounts/response.js +0 -79
  142. package/dist/traders/index.js +0 -2
  143. package/dist/traders/performance.js +0 -21
  144. package/dist/traders/public.js +0 -192
  145. package/dist/trigger/common/index.js +0 -39
  146. package/dist/trigger/entities/conditions.js +0 -174
  147. package/dist/trigger/entities/index.js +0 -257
  148. package/dist/trigger/index.js +0 -9
  149. package/dist/trigger/oracle.js +0 -22
  150. package/dist/trigger/payloads/conditions.js +0 -213
  151. package/dist/trigger/payloads/config.js +0 -3
  152. package/dist/trigger/payloads/index.js +0 -173
  153. package/dist/trigger/queries.js +0 -16
  154. package/dist/trigger/refinement/index.js +0 -2
  155. package/dist/trigger/refinement/static.refinement.js +0 -50
  156. package/dist/trigger/refinement/trailing.refinement.js +0 -83
  157. package/dist/trigger/responses.js +0 -18
  158. package/dist/triggers/entities.js +0 -27
  159. package/dist/triggers/index.js +0 -3
  160. package/dist/triggers/queries.js +0 -10
  161. package/dist/triggers/responses.js +0 -9
  162. package/dist/users/entities.js +0 -45
  163. package/dist/users/index.js +0 -4
  164. package/dist/users/payloads.js +0 -33
  165. package/dist/users/queries.js +0 -8
  166. package/dist/users/response.js +0 -27
  167. package/dist/vaults/entities.js +0 -96
  168. package/dist/vaults/index.js +0 -4
  169. package/dist/vaults/payloads.js +0 -65
  170. package/dist/vaults/queries.js +0 -66
  171. package/dist/vaults/responses.js +0 -368
  172. /package/dist/{baskets/saved/index.js → rewards/index.d.ts} +0 -0
@@ -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 };
@@ -1,105 +0,0 @@
1
- import { z } from 'zod';
2
- import { Connector } from '../connector';
3
- import { CopyFollower } from '../copy/entities';
4
-
5
- const LeaderboardRow = z.object({
6
- // The row's identity, and the only safe key to render or join by.
7
- tradeAccountId: z.string(),
8
- // The trader the account belongs to, so a consumer can group the several rows one person
9
- // earns across venues. The board deliberately publishes no exchange identifier: a wallet
10
- // address beside a real name and a PnL deanonymizes a trader for good, and an address is
11
- // not reversible once scraped. Neither id here is a credential — every route that takes
12
- // one checks ownership or role, never knowledge of the id.
13
- // This guarantee applies to private routes. Shared public profiles are addressable by
14
- // tradeAccountId and omit the exchange identifier, including when the owner shows X identity.
15
- userId: z.string(),
16
- connector: Connector,
17
- // Followers when this board was cached, independent of the performance date range.
18
- followers: z.array(CopyFollower),
19
- followerCount: z.number().int().nonnegative(),
20
- // Every fill inside the window, whatever period its position began in — so unlike the
21
- // money fields below, this can report trading whose fees and PnL belong to another window.
22
- volume: z.string(),
23
- // Positions the window watched open, as are the fees and the return beside them.
24
- grossRealizedPnl: z.string(),
25
- // Zero once the window has closed — unrealized PnL is a value as of now, so only a window
26
- // that still contains now can report it. A window ending in the future does.
27
- grossUpnl: z.string(),
28
- // Net funding carry over the range, signed: negative when the trader paid to hold.
29
- // Account-level, so a client-scoped board reports the account's whole carry —
30
- // funding_payments carries no position id to attribute it any finer.
31
- fundingPayment: z.string(),
32
- totalNetPnl: z.string(),
33
- // V2 calls this builderFee; V3 names it for the column it comes from.
34
- pearFee: z.string(),
35
- tradeFee: z.string(),
36
- totalTrades: z.number(),
37
- // This account's return over the window, as a ratio: "0.25" is +25%. The measured
38
- // positions' PnL divided by the capital that earned it, so each position weighs by the
39
- // money it put at risk — a measure of how the account's dollars did, not of how its
40
- // individual calls went.
41
- //
42
- // One formula on every position: (realized + unrealized - fees paid) over the most cash that
43
- // position had committed at one time. A closed position holds nothing, so its unrealized half
44
- // is zero and this reduces to what the trader kept; a partly reduced open position counts
45
- // both the profit it banked and the worth of what it still holds. Only fees of fills that
46
- // happened are charged, so a running position never pays for the exit it has not made.
47
- //
48
- // The denominator is cash committed, not market value: each opening fill adds what it paid,
49
- // each closing fill releases the share of that commitment the quantity it closed was holding,
50
- // and the peak of that running total is what the return is measured against. So it is not the
51
- // size the position opened at — a position scaled up afterwards is measured against what it
52
- // went on to risk — and not the sum of everything it ever opened either, since capital
53
- // reduced and recommitted counts once rather than twice.
54
- //
55
- // Measuring cash rather than market value is deliberate. A market-value denominator can fall
56
- // below the money actually put in when a position is averaged down, which inflates the
57
- // return; and no historical price series is kept, so market value could only ever be sampled
58
- // at the fills themselves.
59
- //
60
- // Measured only where the window holds both the position's open and the moment the
61
- // measurement is taken at: now for a running position, the closing fill for a finished
62
- // one. A position that closed after the window ended is therefore left out — the window
63
- // holds only part of what it realized, and part of a return is not a return.
64
- //
65
- // Absent when the board could measure none of the account's positions — never "0", which
66
- // would claim a break-even trader. An account reaches the board with nothing measurable
67
- // when its only trading in the window closed positions opened before it, when a closed
68
- // window left its open positions unpriced, or when every position it opened in the window
69
- // closed after it.
70
- roi: z.string().optional(),
71
- // The trader's linked X account, published to every caller — the board names its traders
72
- // on the open internet, signed in or not. Absent for an account whose owner has connected
73
- // no X account, and absent for one who hid the link from the board. Never null-with-a-key:
74
- // absence is the signal.
75
- //
76
- // Whatever X reported at the owner's last authorization. Nothing re-reads X in between,
77
- // so a trader who renamed and has not signed in since is named by their old handle.
78
- xHandle: z.string().optional(),
79
- xName: z.string().optional(),
80
- xAvatarUrl: z.string().optional(),
81
- // Immutable X numeric id. Link by this, never by the handle: X frees a renamed handle
82
- // for anyone to claim immediately, so a cached handle can point at a stranger.
83
- xUserId: z.string().optional()
84
- });
85
- const VolumeStatistics = z.object({
86
- timestamp: z.number(),
87
- volume: z.number(),
88
- fees: z.number(),
89
- trades: z.number(),
90
- users: z.number(),
91
- newUsers: z.number()
92
- });
93
- const OiStatistics = z.object({
94
- timestamp: z.number(),
95
- openInterest: z.number(),
96
- openPositions: z.number()
97
- });
98
- const StatisticsTotals = z.object({
99
- totalVolume: z.number(),
100
- totalFees: z.number(),
101
- totalTrades: z.number(),
102
- totalUsers: z.number()
103
- });
104
-
105
- export { LeaderboardRow, OiStatistics, StatisticsTotals, VolumeStatistics };
@@ -1,3 +0,0 @@
1
- export * from './entities';
2
- export * from './queries';
3
- export * from './responses';
@@ -1,93 +0,0 @@
1
- import { z } from 'zod';
2
- import { normalizeArray } from '../common/array';
3
- import { Connector } from '../connector';
4
-
5
- const VolumeStatisticsQueryParams = z.object({
6
- connector: Connector.optional(),
7
- resolution: z.enum([
8
- "1h",
9
- "4h",
10
- "24h"
11
- ]),
12
- startDate: z.coerce.date().optional(),
13
- endDate: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
14
- // Per-client scope; absent serves the global series. The literal 'other'
15
- // selects the unattributed (NULL) bucket; an unknown code returns an empty series.
16
- clientId: z.string().trim().min(1).optional()
17
- }).refine((data) => !data.startDate || data.startDate < data.endDate, {
18
- message: "startDate must be before endDate"
19
- });
20
- const OiStatisticsQueryParams = z.object({
21
- connector: Connector.optional(),
22
- resolution: z.enum([
23
- "1h",
24
- "4h",
25
- "24h"
26
- ]),
27
- startDate: z.coerce.date().optional(),
28
- endDate: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
29
- // Per-client scope; absent serves the global series. The literal 'other'
30
- // selects the unattributed (NULL) bucket; an unknown code returns an empty series.
31
- clientId: z.string().trim().min(1).optional()
32
- }).refine((data) => !data.startDate || data.startDate < data.endDate, {
33
- message: "startDate must be before endDate"
34
- });
35
- const StatisticsTotalsQueryParams = z.object({
36
- connector: Connector.optional(),
37
- // Per-client scope; absent serves the global totals. The literal 'other'
38
- // selects the unattributed (NULL) bucket; an unknown code returns zero totals.
39
- clientId: z.string().trim().min(1).optional()
40
- });
41
- const LeaderboardSortBy = z.enum([
42
- "trades",
43
- "totalNetPnl",
44
- "volume",
45
- "roi"
46
- ]);
47
- const LEADERBOARD_MAX_LIMIT = 200;
48
- const UnixSeconds = z.coerce.number().int().min(0).transform((seconds) => new Date(seconds * 1e3));
49
- const ConnectorArray = z.preprocess((arg) => normalizeArray(arg), z.array(Connector));
50
- const AssetArray = z.preprocess((arg) => normalizeArray(arg), z.array(z.string().trim().min(1)));
51
- const LeaderboardQueryParams = z.object({
52
- // Attribution filter, not a scope boundary — any caller may pass any client.
53
- clientId: z.string().optional(),
54
- // Absent means every connector. The filter applies before the top-N cut, so
55
- // two connectors return the top N across both combined, not N of each.
56
- connector: ConnectorArray.optional(),
57
- // Absent means every asset. Filtering is per-leg: a long-BTC / short-ETH basket
58
- // contributes only its BTC leg to an asset=BTC board. Each asset's realized-PnL
59
- // walk is independent, so selecting a subset leaves every remaining walk complete.
60
- asset: AssetArray.optional(),
61
- sortBy: LeaderboardSortBy.default("totalNetPnl"),
62
- // Inclusive, and it scopes the money without scoping the trading. Volume and totalTrades
63
- // count every fill inside the window, whatever period its position began in. Realized
64
- // PnL, unrealized PnL, the fees behind them and roi count only for a position whose
65
- // opening fill lands at or after this, so an exit is never booked — nor its fee charged —
66
- // against an entry the window never saw. Volume is therefore additive across two adjacent
67
- // windows and PnL is not, and a row can report volume beside no fees at all.
68
- startDate: UnixSeconds.optional(),
69
- // Exclusive. Unrealized PnL is included whenever the window still contains now — an
70
- // absent endDate, or one that has not yet arrived. Only a window that has already closed
71
- // is settled and reproducible, and only there is unrealized PnL omitted: it is a value as
72
- // of now, and now is outside such a window.
73
- endDate: UnixSeconds.optional(),
74
- // Whether an account whose owner linked no X account may hold a row. Off by default,
75
- // because a trader who has not linked X does not qualify for the campaign the board
76
- // feeds. Eligibility turns on linking, so admission does too: a trader who linked X
77
- // and then withheld the handle keeps their rank and loses only their name.
78
- // The gate is on the account, not on the viewer: it applies before the top-N cut, so
79
- // it selects who makes the board rather than thinning the rows that came back, and
80
- // every caller is served exactly the same board.
81
- //
82
- // Deliberately not `z.coerce.boolean()`, which reads the string "false" as true and
83
- // would leave the default impossible to restore explicitly from a URL.
84
- includeUnlinkedX: z.union([
85
- z.boolean(),
86
- z.stringbool()
87
- ]).optional().default(false),
88
- limit: z.coerce.number().int().positive().max(LEADERBOARD_MAX_LIMIT).default(LEADERBOARD_MAX_LIMIT)
89
- }).refine((data) => !data.startDate || !data.endDate || data.startDate < data.endDate, {
90
- message: "startDate must be before endDate"
91
- });
92
-
93
- export { LEADERBOARD_MAX_LIMIT, LeaderboardQueryParams, LeaderboardSortBy, OiStatisticsQueryParams, StatisticsTotalsQueryParams, VolumeStatisticsQueryParams };
@@ -1,17 +0,0 @@
1
- import { z } from 'zod';
2
- import { LeaderboardRow, VolumeStatistics, OiStatistics, StatisticsTotals } from './entities';
3
-
4
- const LeaderboardResponse = z.object({
5
- data: z.array(LeaderboardRow)
6
- });
7
- const VolumeStatisticsResponse = z.object({
8
- data: z.array(VolumeStatistics)
9
- });
10
- const OiStatisticsResponse = z.object({
11
- data: z.array(OiStatistics)
12
- });
13
- const StatisticsTotalsResponse = z.object({
14
- data: StatisticsTotals
15
- });
16
-
17
- export { LeaderboardResponse, OiStatisticsResponse, StatisticsTotalsResponse, VolumeStatisticsResponse };
@@ -1,2 +0,0 @@
1
- export * from './payloads';
2
- export * from './responses';