@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,213 +0,0 @@
1
- import { z } from 'zod';
2
- import { RefineMinimumTwoSymbols, RefineUniqueSymbols, RefineWeightingSum, RefineTwoUniqueSymbols } from '../../common/refinement';
3
- import { AssetWeight, Side } from '../../common/schema';
4
- import { Connector } from '../../connector';
5
- import { InstrumentId } from '../../instrument';
6
- import { MetricTrack } from '../common';
7
-
8
- const TriggerThreshold = z.number().positive({
9
- message: "Threshold must be greater than 0"
10
- });
11
- const PriceSource = z.enum([
12
- "mid",
13
- "mark"
14
- ], {
15
- message: "Price source must be mid or mark"
16
- });
17
- const WeightedRatioBasketItem = z.object({
18
- symbol: InstrumentId,
19
- side: Side,
20
- weight: AssetWeight
21
- });
22
- const WeightedRatioBasket = z.array(WeightedRatioBasketItem).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
23
- const RatioOpen = z.object({
24
- type: z.literal("ratio"),
25
- data: z.object({
26
- priceSource: PriceSource,
27
- symbol_a: InstrumentId,
28
- symbol_b: InstrumentId,
29
- track: MetricTrack,
30
- threshold: TriggerThreshold
31
- }).superRefine(RefineTwoUniqueSymbols)
32
- });
33
- const PriceOpen = z.object({
34
- type: z.literal("price"),
35
- data: z.object({
36
- priceSource: PriceSource,
37
- symbol: InstrumentId,
38
- track: MetricTrack,
39
- threshold: TriggerThreshold
40
- })
41
- });
42
- const WeightedRatioOpen = z.object({
43
- type: z.literal("weighted_ratio"),
44
- data: z.object({
45
- priceSource: PriceSource,
46
- basket: WeightedRatioBasket,
47
- track: MetricTrack,
48
- threshold: TriggerThreshold
49
- })
50
- });
51
- const PredictionMarketOpen = z.object({
52
- type: z.literal("prediction_market"),
53
- data: z.object({
54
- source: z.enum([
55
- "kalshi",
56
- "polymarket"
57
- ]),
58
- marketKey: z.string().min(1),
59
- track: MetricTrack,
60
- threshold: TriggerThreshold
61
- })
62
- });
63
- const FundingRateOpen = z.object({
64
- type: z.literal("funding_rate"),
65
- data: z.object({
66
- connector: Connector,
67
- symbol: InstrumentId,
68
- track: MetricTrack,
69
- threshold: z.number()
70
- })
71
- });
72
- const BtcDominanceOpen = z.object({
73
- type: z.literal("btc_dominance"),
74
- data: z.object({
75
- source: z.literal("coingecko"),
76
- track: MetricTrack,
77
- threshold: TriggerThreshold
78
- })
79
- });
80
- const RatioCloseStatic = z.object({
81
- type: z.literal("ratio"),
82
- data: z.object({
83
- priceSource: PriceSource,
84
- symbol_a: InstrumentId,
85
- symbol_b: InstrumentId,
86
- threshold: TriggerThreshold
87
- }).superRefine(RefineTwoUniqueSymbols)
88
- });
89
- const PriceCloseStatic = z.object({
90
- type: z.literal("price"),
91
- data: z.object({
92
- priceSource: PriceSource,
93
- symbol: InstrumentId,
94
- threshold: TriggerThreshold
95
- })
96
- });
97
- const WeightedRatioCloseStatic = z.object({
98
- type: z.literal("weighted_ratio"),
99
- data: z.object({
100
- priceSource: PriceSource,
101
- basket: WeightedRatioBasket,
102
- threshold: TriggerThreshold
103
- })
104
- });
105
- const NotionalCloseStatic = z.object({
106
- type: z.literal("notional"),
107
- data: z.object({
108
- priceSource: PriceSource,
109
- threshold: TriggerThreshold
110
- })
111
- });
112
- const UpnlCloseStatic = z.object({
113
- type: z.literal("upnl"),
114
- data: z.object({
115
- priceSource: PriceSource,
116
- threshold: z.number()
117
- })
118
- });
119
- const UpnlBpsCloseStatic = z.object({
120
- type: z.literal("upnl_bps"),
121
- data: z.object({
122
- priceSource: PriceSource,
123
- threshold: z.number()
124
- })
125
- });
126
- const PredictionMarketCloseStatic = z.object({
127
- type: z.literal("prediction_market"),
128
- data: z.object({
129
- source: z.enum([
130
- "kalshi",
131
- "polymarket"
132
- ]),
133
- marketKey: z.string().min(1),
134
- threshold: TriggerThreshold
135
- })
136
- });
137
- const RatioCloseTrailing = z.object({
138
- type: z.literal("ratio_trailing"),
139
- data: z.object({
140
- priceSource: PriceSource,
141
- symbol_a: InstrumentId,
142
- symbol_b: InstrumentId
143
- }).superRefine(RefineTwoUniqueSymbols)
144
- });
145
- const PriceCloseTrailing = z.object({
146
- type: z.literal("price_trailing"),
147
- data: z.object({
148
- priceSource: PriceSource,
149
- symbol: InstrumentId
150
- })
151
- });
152
- const WeightedRatioCloseTrailing = z.object({
153
- type: z.literal("weighted_ratio_trailing"),
154
- data: z.object({
155
- priceSource: PriceSource,
156
- basket: WeightedRatioBasket
157
- })
158
- });
159
- const NotionalCloseTrailing = z.object({
160
- type: z.literal("notional_trailing"),
161
- data: z.object({
162
- priceSource: PriceSource
163
- })
164
- });
165
- const UpnlCloseTrailing = z.object({
166
- type: z.literal("upnl_trailing"),
167
- data: z.object({
168
- priceSource: PriceSource
169
- })
170
- });
171
- const UpnlBpsCloseTrailing = z.object({
172
- type: z.literal("upnl_bps_trailing"),
173
- data: z.object({
174
- priceSource: PriceSource
175
- })
176
- });
177
- const CreateTriggerConditionOpen = z.discriminatedUnion("type", [
178
- RatioOpen,
179
- PriceOpen,
180
- WeightedRatioOpen,
181
- FundingRateOpen,
182
- PredictionMarketOpen,
183
- BtcDominanceOpen
184
- ]);
185
- const CreateTriggerConditionCloseStatic = z.discriminatedUnion("type", [
186
- RatioCloseStatic,
187
- PriceCloseStatic,
188
- WeightedRatioCloseStatic,
189
- NotionalCloseStatic,
190
- UpnlCloseStatic,
191
- UpnlBpsCloseStatic,
192
- PredictionMarketCloseStatic
193
- ]);
194
- const CreateTriggerConditionCloseTrailing = z.discriminatedUnion("type", [
195
- RatioCloseTrailing,
196
- PriceCloseTrailing,
197
- WeightedRatioCloseTrailing,
198
- NotionalCloseTrailing,
199
- UpnlCloseTrailing,
200
- UpnlBpsCloseTrailing
201
- ]);
202
- const CreateTriggerConditionAttachStatic = z.discriminatedUnion("type", [
203
- NotionalCloseStatic,
204
- UpnlCloseStatic,
205
- UpnlBpsCloseStatic
206
- ]);
207
- const CreateTriggerConditionAttachTrailing = z.discriminatedUnion("type", [
208
- NotionalCloseTrailing,
209
- UpnlCloseTrailing,
210
- UpnlBpsCloseTrailing
211
- ]);
212
-
213
- export { CreateTriggerConditionAttachStatic, CreateTriggerConditionAttachTrailing, CreateTriggerConditionCloseStatic, CreateTriggerConditionCloseTrailing, CreateTriggerConditionOpen };
@@ -1,3 +0,0 @@
1
- const MAX_ATTACH_TRIGGERS = 5;
2
-
3
- export { MAX_ATTACH_TRIGGERS };
@@ -1,173 +0,0 @@
1
- import { z } from 'zod';
2
- import { ClientIdCode } from '../../common/client-id';
3
- import { RefineMinimumOneSymbol, RefineUniqueSymbols } from '../../common/refinement';
4
- import { TradeLegPostOnly } from '../../common/trade-legs';
5
- import { TWAPRandomization, DEFAULT_TWAP_RANDOMIZATION } from '../../schedule/randomization';
6
- import { TWAPSliceIntervalSec, MIN_TWAP_SLICE_INTERVAL_SEC, FINAL_TWAP_SLICE_START_HEADROOM_SEC, MAX_TWAP_DURATION_SEC, TWAPTargetNotional, TriggerTWAPOpenLegs } from '../../schedule/twap-config';
7
- import { TrailingMode, TpSlBracketType, BracketType } from '../common';
8
- import { RefineStaticLogicalRules } from '../refinement/static.refinement';
9
- import { RefineTrailingConfig, RefineTrailingLogicalRules } from '../refinement/trailing.refinement';
10
- import { CreateTriggerConditionAttachStatic, CreateTriggerConditionAttachTrailing, CreateTriggerConditionOpen, CreateTriggerConditionCloseStatic, CreateTriggerConditionCloseTrailing } from './conditions';
11
- import { MAX_ATTACH_TRIGGERS } from './config';
12
-
13
- var __defProp = Object.defineProperty;
14
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
- const CreateTriggerMarketPayload = z.object({
16
- type: z.literal("MARKET"),
17
- legs: z.tuple([
18
- TradeLegPostOnly.strict()
19
- ]).rest(TradeLegPostOnly.strict()).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure")
20
- }).strict();
21
- const CreateTriggerTWAPConfig = z.object({
22
- type: z.literal("TWAP"),
23
- durationSec: z.int().min(MIN_TWAP_SLICE_INTERVAL_SEC + FINAL_TWAP_SLICE_START_HEADROOM_SEC).max(MAX_TWAP_DURATION_SEC),
24
- sliceIntervalSec: TWAPSliceIntervalSec,
25
- randomization: TWAPRandomization.optional().default(DEFAULT_TWAP_RANDOMIZATION)
26
- }).strict().refine((payload) => payload.durationSec >= payload.sliceIntervalSec + FINAL_TWAP_SLICE_START_HEADROOM_SEC, {
27
- message: `TWAP duration must leave ${FINAL_TWAP_SLICE_START_HEADROOM_SEC} seconds after the first slice`,
28
- path: [
29
- "durationSec"
30
- ]
31
- });
32
- const CreateTriggerTWAPAdjustPayload = CreateTriggerTWAPConfig.safeExtend({
33
- legs: TriggerTWAPOpenLegs,
34
- targetNotional: TWAPTargetNotional
35
- });
36
- const TrailingConfig = z.object({
37
- mode: TrailingMode,
38
- deltaValue: z.number(),
39
- activationValue: z.number().optional()
40
- }).superRefine(RefineTrailingConfig);
41
- const AttachTriggerMarketCloseStatic = z.object({
42
- intent: z.literal("CLOSE"),
43
- type: z.literal("MARKET"),
44
- bracketType: TpSlBracketType,
45
- condition: CreateTriggerConditionAttachStatic
46
- }).superRefine(RefineStaticLogicalRules);
47
- const AttachTriggerMarketCloseTrailing = z.object({
48
- intent: z.literal("CLOSE"),
49
- type: z.literal("MARKET"),
50
- condition: CreateTriggerConditionAttachTrailing,
51
- trailing: TrailingConfig
52
- }).superRefine(RefineTrailingLogicalRules);
53
- const AttachTriggerMarketClose = z.union([
54
- AttachTriggerMarketCloseStatic,
55
- AttachTriggerMarketCloseTrailing
56
- ]);
57
- const AttachTriggerMarketCloseList = z.array(AttachTriggerMarketClose).max(MAX_ATTACH_TRIGGERS, `At most ${MAX_ATTACH_TRIGGERS} close triggers can be attached.`).superRefine((attachTriggers, ctx) => {
58
- const trailingCount = attachTriggers.filter(isAttachTriggerMarketCloseTrailing).length;
59
- if (trailingCount > 1) {
60
- ctx.addIssue({
61
- code: "custom",
62
- message: "At most one trailing close trigger can be attached."
63
- });
64
- }
65
- });
66
- const CreateTriggerMarketOpen = z.object({
67
- intent: z.literal("OPEN"),
68
- type: z.literal("MARKET"),
69
- condition: CreateTriggerConditionOpen,
70
- attachTriggers: AttachTriggerMarketCloseList.optional(),
71
- payload: CreateTriggerMarketPayload,
72
- /**
73
- * Attribution route code (client_ids.code)
74
- */
75
- clientId: ClientIdCode
76
- }).strict();
77
- const CreateTriggerMarketAdjust = z.object({
78
- intent: z.literal("ADJUST"),
79
- type: z.literal("MARKET"),
80
- positionId: z.uuid(),
81
- condition: CreateTriggerConditionOpen,
82
- payload: CreateTriggerMarketPayload,
83
- /**
84
- * Attribution route code (client_ids.code)
85
- */
86
- clientId: ClientIdCode
87
- }).strict();
88
- const CreateTriggerTWAPAdjust = z.object({
89
- intent: z.literal("ADJUST"),
90
- type: z.literal("TWAP"),
91
- positionId: z.uuid(),
92
- condition: CreateTriggerConditionOpen,
93
- payload: CreateTriggerTWAPAdjustPayload,
94
- /**
95
- * Attribution route code (client_ids.code)
96
- */
97
- clientId: ClientIdCode
98
- }).strict();
99
- const CreateTriggerMarketCloseStatic = z.object({
100
- intent: z.literal("CLOSE"),
101
- type: z.literal("MARKET"),
102
- positionId: z.uuid(),
103
- bracketType: BracketType,
104
- // User intent when bracketType is a side-dependent price-crossing encoding.
105
- // Optional so older clients remain wire-compatible during rollout.
106
- semanticBracketType: TpSlBracketType.optional(),
107
- condition: CreateTriggerConditionCloseStatic,
108
- /**
109
- * Attribution route code (client_ids.code)
110
- */
111
- clientId: ClientIdCode
112
- }).superRefine(RefineStaticLogicalRules);
113
- const CreateTriggerMarketCloseTrailing = z.object({
114
- intent: z.literal("CLOSE"),
115
- type: z.literal("MARKET"),
116
- positionId: z.uuid(),
117
- condition: CreateTriggerConditionCloseTrailing,
118
- trailing: TrailingConfig,
119
- /**
120
- * Attribution route code (client_ids.code)
121
- */
122
- clientId: ClientIdCode
123
- }).superRefine(RefineTrailingLogicalRules);
124
- const CreateTriggerMarketClose = z.union([
125
- CreateTriggerMarketCloseStatic,
126
- CreateTriggerMarketCloseTrailing
127
- ]);
128
- const CreateTriggerTWAPCloseStatic = z.object({
129
- intent: z.literal("CLOSE"),
130
- type: z.literal("TWAP"),
131
- positionId: z.uuid(),
132
- bracketType: BracketType,
133
- semanticBracketType: TpSlBracketType.optional(),
134
- condition: CreateTriggerConditionCloseStatic,
135
- payload: CreateTriggerTWAPConfig,
136
- /**
137
- * Attribution route code (client_ids.code)
138
- */
139
- clientId: ClientIdCode
140
- }).strict().superRefine(RefineStaticLogicalRules);
141
- const CreateTriggerTWAPCloseTrailing = z.object({
142
- intent: z.literal("CLOSE"),
143
- type: z.literal("TWAP"),
144
- positionId: z.uuid(),
145
- condition: CreateTriggerConditionCloseTrailing,
146
- trailing: TrailingConfig,
147
- payload: CreateTriggerTWAPConfig,
148
- /**
149
- * Attribution route code (client_ids.code)
150
- */
151
- clientId: ClientIdCode
152
- }).strict().superRefine(RefineTrailingLogicalRules);
153
- const CreateTriggerTWAPClose = z.union([
154
- CreateTriggerTWAPCloseStatic,
155
- CreateTriggerTWAPCloseTrailing
156
- ]);
157
- const CreateTriggerOpen = z.discriminatedUnion("type", [
158
- z.discriminatedUnion("intent", [
159
- CreateTriggerMarketOpen,
160
- CreateTriggerMarketAdjust
161
- ]),
162
- CreateTriggerTWAPAdjust
163
- ]);
164
- const CreateTriggerClose = z.union([
165
- CreateTriggerMarketClose,
166
- CreateTriggerTWAPClose
167
- ]);
168
- function isAttachTriggerMarketCloseTrailing(attachedTrigger) {
169
- return "trailing" in attachedTrigger && attachedTrigger.trailing !== void 0;
170
- }
171
- __name(isAttachTriggerMarketCloseTrailing, "isAttachTriggerMarketCloseTrailing");
172
-
173
- export { AttachTriggerMarketClose, AttachTriggerMarketCloseList, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketAdjust, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, CreateTriggerTWAPAdjust, CreateTriggerTWAPClose, CreateTriggerTWAPCloseStatic, CreateTriggerTWAPCloseTrailing, TrailingConfig, isAttachTriggerMarketCloseTrailing };
@@ -1,16 +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 TriggerListParams = CursorFindParams.extend({
12
- connector: Connector.optional(),
13
- status: StatusArray.optional()
14
- });
15
-
16
- export { TriggerListParams };
@@ -1,2 +0,0 @@
1
- export * from './static.refinement';
2
- export * from './trailing.refinement';
@@ -1,50 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const RefineStaticLogicalRules = /* @__PURE__ */ __name((value, context) => {
4
- for (const issue of getStaticLogicalIssues({
5
- conditionType: value.condition.type,
6
- threshold: value.condition.data.threshold
7
- })) {
8
- context.addIssue({
9
- code: "custom",
10
- message: issue.message
11
- });
12
- }
13
- }, "RefineStaticLogicalRules");
14
- function getStaticLogicalIssues(input) {
15
- const { conditionType, threshold } = input;
16
- const issues = [];
17
- switch (conditionType) {
18
- case "notional": {
19
- if (threshold <= 0) {
20
- issues.push({
21
- field: "threshold",
22
- message: "threshold must be greater than 0 for notional static triggers"
23
- });
24
- }
25
- break;
26
- }
27
- case "upnl": {
28
- if (threshold === 0) {
29
- issues.push({
30
- field: "threshold",
31
- message: "threshold must not be 0 for uPnL static triggers"
32
- });
33
- }
34
- break;
35
- }
36
- case "upnl_bps": {
37
- if (threshold === 0) {
38
- issues.push({
39
- field: "threshold",
40
- message: "threshold must not be 0 for uPnL BPS static triggers"
41
- });
42
- }
43
- break;
44
- }
45
- }
46
- return issues;
47
- }
48
- __name(getStaticLogicalIssues, "getStaticLogicalIssues");
49
-
50
- export { RefineStaticLogicalRules, getStaticLogicalIssues };
@@ -1,83 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const RefineTrailingConfig = /* @__PURE__ */ __name((value, ctx) => {
4
- for (const issue of getTrailingDeltaIssues(value)) {
5
- ctx.addIssue({
6
- code: "custom",
7
- message: issue.message
8
- });
9
- }
10
- }, "RefineTrailingConfig");
11
- const RefineTrailingLogicalRules = /* @__PURE__ */ __name((value, ctx) => {
12
- for (const issue of getTrailingLogicalIssues({
13
- conditionType: value.condition.type,
14
- trailing: value.trailing
15
- })) {
16
- ctx.addIssue({
17
- code: "custom",
18
- message: issue.message
19
- });
20
- }
21
- }, "RefineTrailingLogicalRules");
22
- function getTrailingLogicalIssues(input) {
23
- const { trailing } = input;
24
- const issues = [];
25
- switch (input.conditionType) {
26
- case "notional_trailing": {
27
- if (trailing.activationValue != null && trailing.activationValue <= 0) {
28
- issues.push({
29
- field: "activationValue",
30
- message: "activationValue must be greater than 0 for notional trailing"
31
- });
32
- }
33
- break;
34
- }
35
- case "upnl_trailing":
36
- case "upnl_bps_trailing": {
37
- if (trailing.activationValue === 0) {
38
- issues.push({
39
- field: "activationValue",
40
- message: "activationValue must not be 0 for uPnL trailing"
41
- });
42
- }
43
- break;
44
- }
45
- }
46
- if (input.conditionType === "notional_trailing" && trailing.activationValue != null && trailing.mode === "ABSOLUTE_POINTS" && trailing.deltaValue >= trailing.activationValue) {
47
- issues.push({
48
- field: "deltaValue",
49
- message: "deltaValue must be less than activationValue for notional trailing in ABSOLUTE_POINTS mode"
50
- });
51
- }
52
- return issues;
53
- }
54
- __name(getTrailingLogicalIssues, "getTrailingLogicalIssues");
55
- function getTrailingDeltaIssues(trailing) {
56
- const issues = [];
57
- if (trailing.deltaValue <= 0) {
58
- issues.push({
59
- field: "deltaValue",
60
- message: "deltaValue must be greater than 0"
61
- });
62
- return issues;
63
- }
64
- if (trailing.mode !== "RELATIVE_BPS") {
65
- return issues;
66
- }
67
- if (!Number.isInteger(trailing.deltaValue)) {
68
- issues.push({
69
- field: "deltaValue",
70
- message: "deltaValue must be an integer in RELATIVE_BPS mode"
71
- });
72
- }
73
- if (trailing.deltaValue < 1 || trailing.deltaValue > 5e3) {
74
- issues.push({
75
- field: "deltaValue",
76
- message: "deltaValue must be between 1 and 5000 in RELATIVE_BPS mode"
77
- });
78
- }
79
- return issues;
80
- }
81
- __name(getTrailingDeltaIssues, "getTrailingDeltaIssues");
82
-
83
- export { RefineTrailingConfig, RefineTrailingLogicalRules, getTrailingDeltaIssues, getTrailingLogicalIssues };
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
- import { CursorResponse } from '../common';
3
- import { Trigger } from './entities';
4
-
5
- const TriggerListResponse = CursorResponse.extend({
6
- triggers: z.array(Trigger)
7
- });
8
- const CreateTriggerResponse = z.object({
9
- trigger: Trigger
10
- });
11
- const CancelTriggerResponse = z.object({
12
- id: z.uuid()
13
- });
14
- const CancelAllTriggersResponse = z.object({
15
- ids: z.array(z.uuid())
16
- });
17
-
18
- export { CancelAllTriggersResponse, CancelTriggerResponse, CreateTriggerResponse, TriggerListResponse };
@@ -1,27 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const ExternalTriggerSource = z.enum([
4
- "kalshi",
5
- "polymarket"
6
- ]);
7
- const TriggerOutcome = z.object({
8
- id: z.string(),
9
- label: z.string(),
10
- oracle: z.number().nullable()
11
- });
12
- const ExternalTrigger = z.object({
13
- id: z.string(),
14
- category: z.literal("prediction_market"),
15
- source: ExternalTriggerSource,
16
- selectable: z.boolean(),
17
- oracle: z.number().nullable(),
18
- options: z.array(TriggerOutcome),
19
- type: z.enum([
20
- "binary",
21
- "multi"
22
- ]),
23
- title: z.string(),
24
- imageUrl: z.string().nullable()
25
- });
26
-
27
- export { ExternalTrigger, ExternalTriggerSource, TriggerOutcome };
@@ -1,3 +0,0 @@
1
- export * from './entities';
2
- export * from './queries';
3
- export * from './responses';
@@ -1,10 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const SearchTriggersParams = z.object({
4
- category: z.string().optional(),
5
- search: z.string().optional(),
6
- cursor: z.string().optional(),
7
- pageSize: z.number().optional()
8
- });
9
-
10
- export { SearchTriggersParams };
@@ -1,9 +0,0 @@
1
- import { z } from 'zod';
2
- import { ExternalTrigger } from './entities';
3
-
4
- const SearchTriggersResponse = z.object({
5
- triggers: z.array(ExternalTrigger),
6
- nextCursor: z.string().nullable()
7
- });
8
-
9
- export { SearchTriggersResponse };
@@ -1,45 +0,0 @@
1
- import { z } from 'zod';
2
- import { EthereumAddress } from '../common/address';
3
- import { UnsignedDecimalString } from '../common/schema';
4
-
5
- const UserPreferences = z.object({
6
- slippageToleranceBps: z.int().describe("User slippage preference in basis points")
7
- }).describe("User preferences");
8
- const UserProfile = z.object({
9
- id: z.uuid().describe("User UUID"),
10
- displayName: z.string().describe("Public display name"),
11
- role: z.enum([
12
- "basic",
13
- "pro",
14
- "vault"
15
- ]).describe("User role"),
16
- address: z.string().nullable().describe("Linked wallet address (for evm_wallet provider)"),
17
- email: z.string().nullable().describe("Linked email address (for email provider)"),
18
- emailVerified: z.boolean().describe("Whether the email is verified"),
19
- // Nullable rather than optional to match `address` and `email` above. Splitting
20
- // conventions inside one object costs more than following its neighbours.
21
- xHandle: z.string().nullable().describe('Linked X handle, without the leading "@" (for x provider)'),
22
- xName: z.string().nullable().describe("Linked X display name"),
23
- xAvatarUrl: z.string().nullable().describe("Linked X avatar URL"),
24
- // A plain boolean rather than nullable, matching `emailVerified` above: this is the
25
- // owner's own setting, which is known whether or not an X account is linked. With none
26
- // linked it describes what would happen once one is.
27
- xHidden: z.boolean().describe("Whether the leaderboard and public trader profiles withhold the linked X account")
28
- }).describe("User profile of the authenticated user");
29
- const BoundReferralReferee = z.object({
30
- status: z.literal("BOUND").describe("The referee resolves to a V3 user with a permanent binding"),
31
- address: EthereumAddress.optional().describe("Linked EVM wallet address when the referee has one"),
32
- referredAt: z.number().int().nonnegative().optional().describe("V3 attribution time in epoch milliseconds; not the original legacy on-chain referral time, and absent on a historical binding without a recoverable date"),
33
- tradeCount: z.number().int().nonnegative().describe("Distinct Pear executions with at least one real confirmed Hyperliquid or Lighter fill"),
34
- volumeUsd: UnsignedDecimalString.describe("Post-binding V3 volume from real confirmed Pear fills on Hyperliquid and Lighter, in USD")
35
- });
36
- const PendingReferralReferee = z.object({
37
- status: z.literal("PENDING").describe("A verified legacy referee that has no V3 identity yet"),
38
- address: EthereumAddress.describe("The verified legacy wallet, the only fact a pending referee carries")
39
- });
40
- const ReferralReferee = z.discriminatedUnion("status", [
41
- BoundReferralReferee,
42
- PendingReferralReferee
43
- ]).describe("One referral-history entry, shaped by whether the referee is bound to a V3 user yet");
44
-
45
- export { BoundReferralReferee, PendingReferralReferee, ReferralReferee, UserPreferences, UserProfile };
@@ -1,4 +0,0 @@
1
- export * from './entities';
2
- export * from './payloads';
3
- export * from './queries';
4
- export * from './response';