@pear-protocol/types 1.19.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/payloads.d.ts +3 -0
- package/dist/auth/payloads.js +4 -1
- package/dist/ladder/entities.d.ts +87 -0
- package/dist/ladder/entities.js +2 -0
- package/dist/ladder/payloads.d.ts +146 -2
- package/dist/ladder/payloads.js +14 -1
- package/dist/ladder/responses.d.ts +261 -0
- package/dist/notification/entities.d.ts +33 -2
- package/dist/notification/entities.js +18 -4
- package/dist/notification/responses.d.ts +15 -0
- package/dist/sync/payloads.d.ts +2 -0
- package/dist/sync/payloads.js +5 -1
- package/dist/trade/responses.d.ts +1 -273
- package/dist/trade/responses.js +1 -1
- package/dist/trigger/entities/index.d.ts +50 -0
- package/dist/trigger/entities/index.js +7 -0
- package/dist/trigger/payloads/index.d.ts +85 -0
- package/dist/trigger/payloads/index.js +14 -10
- package/dist/trigger/refinement/static.refinement.d.ts +11 -3
- package/dist/trigger/refinement/static.refinement.js +9 -2
- package/dist/trigger/responses.d.ts +30 -0
- package/package.json +1 -1
|
@@ -1095,277 +1095,5 @@ export declare const CreateTradeReverseResponse: z.ZodObject<{
|
|
|
1095
1095
|
}, z.core.$strip>], "intent">], "orderType">;
|
|
1096
1096
|
}, z.core.$strip>;
|
|
1097
1097
|
export type CreateTradeReverseResponse = z.output<typeof CreateTradeReverseResponse>;
|
|
1098
|
-
export declare const CreateTradeCloseAllResponse: z.ZodObject<{
|
|
1099
|
-
executions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1100
|
-
id: z.ZodUUID;
|
|
1101
|
-
connector: z.ZodEnum<{
|
|
1102
|
-
hyperliquid: "hyperliquid";
|
|
1103
|
-
binance: "binance";
|
|
1104
|
-
bybit: "bybit";
|
|
1105
|
-
okx: "okx";
|
|
1106
|
-
lighter: "lighter";
|
|
1107
|
-
}>;
|
|
1108
|
-
status: z.ZodEnum<{
|
|
1109
|
-
CANCELLED: "CANCELLED";
|
|
1110
|
-
IDLE: "IDLE";
|
|
1111
|
-
ACTIVE: "ACTIVE";
|
|
1112
|
-
COMPLETED: "COMPLETED";
|
|
1113
|
-
FAILED: "FAILED";
|
|
1114
|
-
}>;
|
|
1115
|
-
error: z.ZodOptional<z.ZodString>;
|
|
1116
|
-
createdAt: z.ZodString;
|
|
1117
|
-
updatedAt: z.ZodString;
|
|
1118
|
-
orders: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1119
|
-
id: z.ZodUUID;
|
|
1120
|
-
connector: z.ZodEnum<{
|
|
1121
|
-
hyperliquid: "hyperliquid";
|
|
1122
|
-
binance: "binance";
|
|
1123
|
-
bybit: "bybit";
|
|
1124
|
-
okx: "okx";
|
|
1125
|
-
lighter: "lighter";
|
|
1126
|
-
}>;
|
|
1127
|
-
status: z.ZodEnum<{
|
|
1128
|
-
PENDING: "PENDING";
|
|
1129
|
-
PARTIAL: "PARTIAL";
|
|
1130
|
-
FILLED: "FILLED";
|
|
1131
|
-
CANCELLED: "CANCELLED";
|
|
1132
|
-
REJECTED: "REJECTED";
|
|
1133
|
-
}>;
|
|
1134
|
-
error: z.ZodOptional<z.ZodString>;
|
|
1135
|
-
createdAt: z.ZodString;
|
|
1136
|
-
updatedAt: z.ZodString;
|
|
1137
|
-
type: z.ZodLiteral<"MARKET">;
|
|
1138
|
-
symbol: z.ZodString;
|
|
1139
|
-
side: z.ZodEnum<{
|
|
1140
|
-
BUY: "BUY";
|
|
1141
|
-
SELL: "SELL";
|
|
1142
|
-
}>;
|
|
1143
|
-
reduceOnly: z.ZodBoolean;
|
|
1144
|
-
quantity: z.ZodString;
|
|
1145
|
-
price: z.ZodString;
|
|
1146
|
-
filledQuantity: z.ZodString;
|
|
1147
|
-
filledPrice: z.ZodOptional<z.ZodString>;
|
|
1148
|
-
}, z.core.$strip>], "type">>>;
|
|
1149
|
-
intent: z.ZodLiteral<"OPEN">;
|
|
1150
|
-
orderType: z.ZodLiteral<"MARKET">;
|
|
1151
|
-
legs: z.ZodTuple<[z.ZodObject<{
|
|
1152
|
-
symbol: z.ZodString;
|
|
1153
|
-
side: z.ZodEnum<{
|
|
1154
|
-
BUY: "BUY";
|
|
1155
|
-
SELL: "SELL";
|
|
1156
|
-
}>;
|
|
1157
|
-
mode: z.ZodEnum<{
|
|
1158
|
-
QUANTITY: "QUANTITY";
|
|
1159
|
-
USD: "USD";
|
|
1160
|
-
}>;
|
|
1161
|
-
amount: z.ZodString;
|
|
1162
|
-
reduceOnly: z.ZodBoolean;
|
|
1163
|
-
}, z.core.$strip>], z.ZodObject<{
|
|
1164
|
-
symbol: z.ZodString;
|
|
1165
|
-
side: z.ZodEnum<{
|
|
1166
|
-
BUY: "BUY";
|
|
1167
|
-
SELL: "SELL";
|
|
1168
|
-
}>;
|
|
1169
|
-
mode: z.ZodEnum<{
|
|
1170
|
-
QUANTITY: "QUANTITY";
|
|
1171
|
-
USD: "USD";
|
|
1172
|
-
}>;
|
|
1173
|
-
amount: z.ZodString;
|
|
1174
|
-
reduceOnly: z.ZodBoolean;
|
|
1175
|
-
}, z.core.$strip>>;
|
|
1176
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1177
|
-
id: z.ZodUUID;
|
|
1178
|
-
connector: z.ZodEnum<{
|
|
1179
|
-
hyperliquid: "hyperliquid";
|
|
1180
|
-
binance: "binance";
|
|
1181
|
-
bybit: "bybit";
|
|
1182
|
-
okx: "okx";
|
|
1183
|
-
lighter: "lighter";
|
|
1184
|
-
}>;
|
|
1185
|
-
status: z.ZodEnum<{
|
|
1186
|
-
CANCELLED: "CANCELLED";
|
|
1187
|
-
IDLE: "IDLE";
|
|
1188
|
-
ACTIVE: "ACTIVE";
|
|
1189
|
-
COMPLETED: "COMPLETED";
|
|
1190
|
-
FAILED: "FAILED";
|
|
1191
|
-
}>;
|
|
1192
|
-
error: z.ZodOptional<z.ZodString>;
|
|
1193
|
-
createdAt: z.ZodString;
|
|
1194
|
-
updatedAt: z.ZodString;
|
|
1195
|
-
orders: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1196
|
-
id: z.ZodUUID;
|
|
1197
|
-
connector: z.ZodEnum<{
|
|
1198
|
-
hyperliquid: "hyperliquid";
|
|
1199
|
-
binance: "binance";
|
|
1200
|
-
bybit: "bybit";
|
|
1201
|
-
okx: "okx";
|
|
1202
|
-
lighter: "lighter";
|
|
1203
|
-
}>;
|
|
1204
|
-
status: z.ZodEnum<{
|
|
1205
|
-
PENDING: "PENDING";
|
|
1206
|
-
PARTIAL: "PARTIAL";
|
|
1207
|
-
FILLED: "FILLED";
|
|
1208
|
-
CANCELLED: "CANCELLED";
|
|
1209
|
-
REJECTED: "REJECTED";
|
|
1210
|
-
}>;
|
|
1211
|
-
error: z.ZodOptional<z.ZodString>;
|
|
1212
|
-
createdAt: z.ZodString;
|
|
1213
|
-
updatedAt: z.ZodString;
|
|
1214
|
-
type: z.ZodLiteral<"MARKET">;
|
|
1215
|
-
symbol: z.ZodString;
|
|
1216
|
-
side: z.ZodEnum<{
|
|
1217
|
-
BUY: "BUY";
|
|
1218
|
-
SELL: "SELL";
|
|
1219
|
-
}>;
|
|
1220
|
-
reduceOnly: z.ZodBoolean;
|
|
1221
|
-
quantity: z.ZodString;
|
|
1222
|
-
price: z.ZodString;
|
|
1223
|
-
filledQuantity: z.ZodString;
|
|
1224
|
-
filledPrice: z.ZodOptional<z.ZodString>;
|
|
1225
|
-
}, z.core.$strip>], "type">>>;
|
|
1226
|
-
intent: z.ZodLiteral<"ADJUST">;
|
|
1227
|
-
orderType: z.ZodLiteral<"MARKET">;
|
|
1228
|
-
position: z.ZodObject<{
|
|
1229
|
-
id: z.ZodUUID;
|
|
1230
|
-
exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
1231
|
-
}, z.core.$strip>;
|
|
1232
|
-
legs: z.ZodTuple<[z.ZodObject<{
|
|
1233
|
-
symbol: z.ZodString;
|
|
1234
|
-
side: z.ZodEnum<{
|
|
1235
|
-
BUY: "BUY";
|
|
1236
|
-
SELL: "SELL";
|
|
1237
|
-
}>;
|
|
1238
|
-
mode: z.ZodEnum<{
|
|
1239
|
-
QUANTITY: "QUANTITY";
|
|
1240
|
-
USD: "USD";
|
|
1241
|
-
}>;
|
|
1242
|
-
amount: z.ZodString;
|
|
1243
|
-
reduceOnly: z.ZodBoolean;
|
|
1244
|
-
}, z.core.$strip>], z.ZodObject<{
|
|
1245
|
-
symbol: z.ZodString;
|
|
1246
|
-
side: z.ZodEnum<{
|
|
1247
|
-
BUY: "BUY";
|
|
1248
|
-
SELL: "SELL";
|
|
1249
|
-
}>;
|
|
1250
|
-
mode: z.ZodEnum<{
|
|
1251
|
-
QUANTITY: "QUANTITY";
|
|
1252
|
-
USD: "USD";
|
|
1253
|
-
}>;
|
|
1254
|
-
amount: z.ZodString;
|
|
1255
|
-
reduceOnly: z.ZodBoolean;
|
|
1256
|
-
}, z.core.$strip>>;
|
|
1257
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1258
|
-
id: z.ZodUUID;
|
|
1259
|
-
connector: z.ZodEnum<{
|
|
1260
|
-
hyperliquid: "hyperliquid";
|
|
1261
|
-
binance: "binance";
|
|
1262
|
-
bybit: "bybit";
|
|
1263
|
-
okx: "okx";
|
|
1264
|
-
lighter: "lighter";
|
|
1265
|
-
}>;
|
|
1266
|
-
status: z.ZodEnum<{
|
|
1267
|
-
CANCELLED: "CANCELLED";
|
|
1268
|
-
IDLE: "IDLE";
|
|
1269
|
-
ACTIVE: "ACTIVE";
|
|
1270
|
-
COMPLETED: "COMPLETED";
|
|
1271
|
-
FAILED: "FAILED";
|
|
1272
|
-
}>;
|
|
1273
|
-
error: z.ZodOptional<z.ZodString>;
|
|
1274
|
-
createdAt: z.ZodString;
|
|
1275
|
-
updatedAt: z.ZodString;
|
|
1276
|
-
orders: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1277
|
-
id: z.ZodUUID;
|
|
1278
|
-
connector: z.ZodEnum<{
|
|
1279
|
-
hyperliquid: "hyperliquid";
|
|
1280
|
-
binance: "binance";
|
|
1281
|
-
bybit: "bybit";
|
|
1282
|
-
okx: "okx";
|
|
1283
|
-
lighter: "lighter";
|
|
1284
|
-
}>;
|
|
1285
|
-
status: z.ZodEnum<{
|
|
1286
|
-
PENDING: "PENDING";
|
|
1287
|
-
PARTIAL: "PARTIAL";
|
|
1288
|
-
FILLED: "FILLED";
|
|
1289
|
-
CANCELLED: "CANCELLED";
|
|
1290
|
-
REJECTED: "REJECTED";
|
|
1291
|
-
}>;
|
|
1292
|
-
error: z.ZodOptional<z.ZodString>;
|
|
1293
|
-
createdAt: z.ZodString;
|
|
1294
|
-
updatedAt: z.ZodString;
|
|
1295
|
-
type: z.ZodLiteral<"MARKET">;
|
|
1296
|
-
symbol: z.ZodString;
|
|
1297
|
-
side: z.ZodEnum<{
|
|
1298
|
-
BUY: "BUY";
|
|
1299
|
-
SELL: "SELL";
|
|
1300
|
-
}>;
|
|
1301
|
-
reduceOnly: z.ZodBoolean;
|
|
1302
|
-
quantity: z.ZodString;
|
|
1303
|
-
price: z.ZodString;
|
|
1304
|
-
filledQuantity: z.ZodString;
|
|
1305
|
-
filledPrice: z.ZodOptional<z.ZodString>;
|
|
1306
|
-
}, z.core.$strip>], "type">>>;
|
|
1307
|
-
intent: z.ZodLiteral<"CLOSE">;
|
|
1308
|
-
orderType: z.ZodLiteral<"MARKET">;
|
|
1309
|
-
position: z.ZodObject<{
|
|
1310
|
-
id: z.ZodUUID;
|
|
1311
|
-
exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
1312
|
-
}, z.core.$strip>;
|
|
1313
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1314
|
-
id: z.ZodUUID;
|
|
1315
|
-
connector: z.ZodEnum<{
|
|
1316
|
-
hyperliquid: "hyperliquid";
|
|
1317
|
-
binance: "binance";
|
|
1318
|
-
bybit: "bybit";
|
|
1319
|
-
okx: "okx";
|
|
1320
|
-
lighter: "lighter";
|
|
1321
|
-
}>;
|
|
1322
|
-
status: z.ZodEnum<{
|
|
1323
|
-
CANCELLED: "CANCELLED";
|
|
1324
|
-
IDLE: "IDLE";
|
|
1325
|
-
ACTIVE: "ACTIVE";
|
|
1326
|
-
COMPLETED: "COMPLETED";
|
|
1327
|
-
FAILED: "FAILED";
|
|
1328
|
-
}>;
|
|
1329
|
-
error: z.ZodOptional<z.ZodString>;
|
|
1330
|
-
createdAt: z.ZodString;
|
|
1331
|
-
updatedAt: z.ZodString;
|
|
1332
|
-
orders: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1333
|
-
id: z.ZodUUID;
|
|
1334
|
-
connector: z.ZodEnum<{
|
|
1335
|
-
hyperliquid: "hyperliquid";
|
|
1336
|
-
binance: "binance";
|
|
1337
|
-
bybit: "bybit";
|
|
1338
|
-
okx: "okx";
|
|
1339
|
-
lighter: "lighter";
|
|
1340
|
-
}>;
|
|
1341
|
-
status: z.ZodEnum<{
|
|
1342
|
-
PENDING: "PENDING";
|
|
1343
|
-
PARTIAL: "PARTIAL";
|
|
1344
|
-
FILLED: "FILLED";
|
|
1345
|
-
CANCELLED: "CANCELLED";
|
|
1346
|
-
REJECTED: "REJECTED";
|
|
1347
|
-
}>;
|
|
1348
|
-
error: z.ZodOptional<z.ZodString>;
|
|
1349
|
-
createdAt: z.ZodString;
|
|
1350
|
-
updatedAt: z.ZodString;
|
|
1351
|
-
type: z.ZodLiteral<"MARKET">;
|
|
1352
|
-
symbol: z.ZodString;
|
|
1353
|
-
side: z.ZodEnum<{
|
|
1354
|
-
BUY: "BUY";
|
|
1355
|
-
SELL: "SELL";
|
|
1356
|
-
}>;
|
|
1357
|
-
reduceOnly: z.ZodBoolean;
|
|
1358
|
-
quantity: z.ZodString;
|
|
1359
|
-
price: z.ZodString;
|
|
1360
|
-
filledQuantity: z.ZodString;
|
|
1361
|
-
filledPrice: z.ZodOptional<z.ZodString>;
|
|
1362
|
-
}, z.core.$strip>], "type">>>;
|
|
1363
|
-
intent: z.ZodLiteral<"REVERSE">;
|
|
1364
|
-
orderType: z.ZodLiteral<"MARKET">;
|
|
1365
|
-
position: z.ZodObject<{
|
|
1366
|
-
id: z.ZodUUID;
|
|
1367
|
-
exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
1368
|
-
}, z.core.$strip>;
|
|
1369
|
-
}, z.core.$strip>], "intent">], "orderType">>;
|
|
1370
|
-
}, z.core.$strip>;
|
|
1098
|
+
export declare const CreateTradeCloseAllResponse: z.ZodObject<{}, z.core.$strip>;
|
|
1371
1099
|
export type CreateTradeCloseAllResponse = z.output<typeof CreateTradeCloseAllResponse>;
|
package/dist/trade/responses.js
CHANGED
|
@@ -5,6 +5,6 @@ const CreateTradeOpenResponse = z.object({ execution: Execution });
|
|
|
5
5
|
const CreateTradeAdjustResponse = z.object({ execution: Execution });
|
|
6
6
|
const CreateTradeCloseResponse = z.object({ execution: Execution });
|
|
7
7
|
const CreateTradeReverseResponse = z.object({ execution: Execution });
|
|
8
|
-
const CreateTradeCloseAllResponse = z.object({
|
|
8
|
+
const CreateTradeCloseAllResponse = z.object({});
|
|
9
9
|
|
|
10
10
|
export { CreateTradeAdjustResponse, CreateTradeCloseAllResponse, CreateTradeCloseResponse, CreateTradeOpenResponse, CreateTradeReverseResponse };
|
|
@@ -79,6 +79,11 @@ declare const BaseTrigger: z.ZodObject<{
|
|
|
79
79
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
80
80
|
NONE: "NONE";
|
|
81
81
|
}>;
|
|
82
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
83
|
+
STOP_LOSS: "STOP_LOSS";
|
|
84
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
85
|
+
NONE: "NONE";
|
|
86
|
+
}>>;
|
|
82
87
|
createdAt: z.ZodString;
|
|
83
88
|
updatedAt: z.ZodString;
|
|
84
89
|
}, z.core.$strip>;
|
|
@@ -161,6 +166,11 @@ export declare const TriggerMarketOpen: z.ZodObject<{
|
|
|
161
166
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
162
167
|
NONE: "NONE";
|
|
163
168
|
}>;
|
|
169
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
170
|
+
STOP_LOSS: "STOP_LOSS";
|
|
171
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
172
|
+
NONE: "NONE";
|
|
173
|
+
}>>;
|
|
164
174
|
createdAt: z.ZodString;
|
|
165
175
|
updatedAt: z.ZodString;
|
|
166
176
|
intent: z.ZodLiteral<"OPEN">;
|
|
@@ -363,6 +373,11 @@ export declare const TriggerMarketAdjust: z.ZodObject<{
|
|
|
363
373
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
364
374
|
NONE: "NONE";
|
|
365
375
|
}>;
|
|
376
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
377
|
+
STOP_LOSS: "STOP_LOSS";
|
|
378
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
379
|
+
NONE: "NONE";
|
|
380
|
+
}>>;
|
|
366
381
|
createdAt: z.ZodString;
|
|
367
382
|
updatedAt: z.ZodString;
|
|
368
383
|
intent: z.ZodLiteral<"ADJUST">;
|
|
@@ -611,6 +626,11 @@ export declare const TriggerMarketClose: z.ZodObject<{
|
|
|
611
626
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
612
627
|
NONE: "NONE";
|
|
613
628
|
}>;
|
|
629
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
630
|
+
STOP_LOSS: "STOP_LOSS";
|
|
631
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
632
|
+
NONE: "NONE";
|
|
633
|
+
}>>;
|
|
614
634
|
createdAt: z.ZodString;
|
|
615
635
|
updatedAt: z.ZodString;
|
|
616
636
|
intent: z.ZodLiteral<"CLOSE">;
|
|
@@ -893,6 +913,11 @@ export declare const TriggerMarket: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
893
913
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
894
914
|
NONE: "NONE";
|
|
895
915
|
}>;
|
|
916
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
917
|
+
STOP_LOSS: "STOP_LOSS";
|
|
918
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
919
|
+
NONE: "NONE";
|
|
920
|
+
}>>;
|
|
896
921
|
createdAt: z.ZodString;
|
|
897
922
|
updatedAt: z.ZodString;
|
|
898
923
|
intent: z.ZodLiteral<"OPEN">;
|
|
@@ -1094,6 +1119,11 @@ export declare const TriggerMarket: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1094
1119
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1095
1120
|
NONE: "NONE";
|
|
1096
1121
|
}>;
|
|
1122
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
1123
|
+
STOP_LOSS: "STOP_LOSS";
|
|
1124
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1125
|
+
NONE: "NONE";
|
|
1126
|
+
}>>;
|
|
1097
1127
|
createdAt: z.ZodString;
|
|
1098
1128
|
updatedAt: z.ZodString;
|
|
1099
1129
|
intent: z.ZodLiteral<"ADJUST">;
|
|
@@ -1341,6 +1371,11 @@ export declare const TriggerMarket: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1341
1371
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1342
1372
|
NONE: "NONE";
|
|
1343
1373
|
}>;
|
|
1374
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
1375
|
+
STOP_LOSS: "STOP_LOSS";
|
|
1376
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1377
|
+
NONE: "NONE";
|
|
1378
|
+
}>>;
|
|
1344
1379
|
createdAt: z.ZodString;
|
|
1345
1380
|
updatedAt: z.ZodString;
|
|
1346
1381
|
intent: z.ZodLiteral<"CLOSE">;
|
|
@@ -1623,6 +1658,11 @@ export declare const Trigger: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[
|
|
|
1623
1658
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1624
1659
|
NONE: "NONE";
|
|
1625
1660
|
}>;
|
|
1661
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
1662
|
+
STOP_LOSS: "STOP_LOSS";
|
|
1663
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1664
|
+
NONE: "NONE";
|
|
1665
|
+
}>>;
|
|
1626
1666
|
createdAt: z.ZodString;
|
|
1627
1667
|
updatedAt: z.ZodString;
|
|
1628
1668
|
intent: z.ZodLiteral<"OPEN">;
|
|
@@ -1824,6 +1864,11 @@ export declare const Trigger: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[
|
|
|
1824
1864
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1825
1865
|
NONE: "NONE";
|
|
1826
1866
|
}>;
|
|
1867
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
1868
|
+
STOP_LOSS: "STOP_LOSS";
|
|
1869
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1870
|
+
NONE: "NONE";
|
|
1871
|
+
}>>;
|
|
1827
1872
|
createdAt: z.ZodString;
|
|
1828
1873
|
updatedAt: z.ZodString;
|
|
1829
1874
|
intent: z.ZodLiteral<"ADJUST">;
|
|
@@ -2071,6 +2116,11 @@ export declare const Trigger: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[
|
|
|
2071
2116
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
2072
2117
|
NONE: "NONE";
|
|
2073
2118
|
}>;
|
|
2119
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
2120
|
+
STOP_LOSS: "STOP_LOSS";
|
|
2121
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
2122
|
+
NONE: "NONE";
|
|
2123
|
+
}>>;
|
|
2074
2124
|
createdAt: z.ZodString;
|
|
2075
2125
|
updatedAt: z.ZodString;
|
|
2076
2126
|
intent: z.ZodLiteral<"CLOSE">;
|
|
@@ -83,6 +83,13 @@ const BaseTrigger = z.object({
|
|
|
83
83
|
* Bracket type for trigger behavior
|
|
84
84
|
*/
|
|
85
85
|
bracketType: BracketType,
|
|
86
|
+
/**
|
|
87
|
+
* User-facing bracket semantics. `bracketType` is the crossing encoding the gateway
|
|
88
|
+
* fires on (wire-flipped for a price bracket on a short watched leg); this field is
|
|
89
|
+
* what the user asked for. Absent whenever a legacy client's encoding is
|
|
90
|
+
* unknowable; do not present `bracketType` as user intent in that case.
|
|
91
|
+
*/
|
|
92
|
+
semanticBracketType: BracketType.optional(),
|
|
86
93
|
/**
|
|
87
94
|
* Created at timestamp
|
|
88
95
|
*/
|
|
@@ -152,6 +152,78 @@ export declare const AttachTriggerMarketClose: z.ZodUnion<readonly [z.ZodObject<
|
|
|
152
152
|
activationValue: z.ZodOptional<z.ZodNumber>;
|
|
153
153
|
}, z.core.$strip>;
|
|
154
154
|
}, z.core.$strip>]>;
|
|
155
|
+
export declare const AttachTriggerMarketCloseList: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
156
|
+
intent: z.ZodLiteral<"CLOSE">;
|
|
157
|
+
type: z.ZodLiteral<"MARKET">;
|
|
158
|
+
bracketType: z.ZodEnum<{
|
|
159
|
+
STOP_LOSS: "STOP_LOSS";
|
|
160
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
161
|
+
}>;
|
|
162
|
+
condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
163
|
+
type: z.ZodLiteral<"notional">;
|
|
164
|
+
data: z.ZodObject<{
|
|
165
|
+
priceSource: z.ZodEnum<{
|
|
166
|
+
mid: "mid";
|
|
167
|
+
mark: "mark";
|
|
168
|
+
}>;
|
|
169
|
+
threshold: z.ZodNumber;
|
|
170
|
+
}, z.core.$strip>;
|
|
171
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
172
|
+
type: z.ZodLiteral<"upnl">;
|
|
173
|
+
data: z.ZodObject<{
|
|
174
|
+
priceSource: z.ZodEnum<{
|
|
175
|
+
mid: "mid";
|
|
176
|
+
mark: "mark";
|
|
177
|
+
}>;
|
|
178
|
+
threshold: z.ZodNumber;
|
|
179
|
+
}, z.core.$strip>;
|
|
180
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
181
|
+
type: z.ZodLiteral<"upnl_bps">;
|
|
182
|
+
data: z.ZodObject<{
|
|
183
|
+
priceSource: z.ZodEnum<{
|
|
184
|
+
mid: "mid";
|
|
185
|
+
mark: "mark";
|
|
186
|
+
}>;
|
|
187
|
+
threshold: z.ZodNumber;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
}, z.core.$strip>], "type">;
|
|
190
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
191
|
+
intent: z.ZodLiteral<"CLOSE">;
|
|
192
|
+
type: z.ZodLiteral<"MARKET">;
|
|
193
|
+
condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
194
|
+
type: z.ZodLiteral<"notional_trailing">;
|
|
195
|
+
data: z.ZodObject<{
|
|
196
|
+
priceSource: z.ZodEnum<{
|
|
197
|
+
mid: "mid";
|
|
198
|
+
mark: "mark";
|
|
199
|
+
}>;
|
|
200
|
+
}, z.core.$strip>;
|
|
201
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
202
|
+
type: z.ZodLiteral<"upnl_trailing">;
|
|
203
|
+
data: z.ZodObject<{
|
|
204
|
+
priceSource: z.ZodEnum<{
|
|
205
|
+
mid: "mid";
|
|
206
|
+
mark: "mark";
|
|
207
|
+
}>;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
210
|
+
type: z.ZodLiteral<"upnl_bps_trailing">;
|
|
211
|
+
data: z.ZodObject<{
|
|
212
|
+
priceSource: z.ZodEnum<{
|
|
213
|
+
mid: "mid";
|
|
214
|
+
mark: "mark";
|
|
215
|
+
}>;
|
|
216
|
+
}, z.core.$strip>;
|
|
217
|
+
}, z.core.$strip>], "type">;
|
|
218
|
+
trailing: z.ZodObject<{
|
|
219
|
+
mode: z.ZodEnum<{
|
|
220
|
+
RELATIVE_BPS: "RELATIVE_BPS";
|
|
221
|
+
ABSOLUTE_POINTS: "ABSOLUTE_POINTS";
|
|
222
|
+
}>;
|
|
223
|
+
deltaValue: z.ZodNumber;
|
|
224
|
+
activationValue: z.ZodOptional<z.ZodNumber>;
|
|
225
|
+
}, z.core.$strip>;
|
|
226
|
+
}, z.core.$strip>]>>;
|
|
155
227
|
export declare const CreateTriggerMarketOpen: z.ZodObject<{
|
|
156
228
|
intent: z.ZodLiteral<"OPEN">;
|
|
157
229
|
type: z.ZodLiteral<"MARKET">;
|
|
@@ -480,6 +552,10 @@ export declare const CreateTriggerMarketCloseStatic: z.ZodObject<{
|
|
|
480
552
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
481
553
|
NONE: "NONE";
|
|
482
554
|
}>;
|
|
555
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
556
|
+
STOP_LOSS: "STOP_LOSS";
|
|
557
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
558
|
+
}>>;
|
|
483
559
|
condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
484
560
|
type: z.ZodLiteral<"ratio">;
|
|
485
561
|
data: z.ZodObject<{
|
|
@@ -631,6 +707,10 @@ export declare const CreateTriggerMarketClose: z.ZodUnion<readonly [z.ZodObject<
|
|
|
631
707
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
632
708
|
NONE: "NONE";
|
|
633
709
|
}>;
|
|
710
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
711
|
+
STOP_LOSS: "STOP_LOSS";
|
|
712
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
713
|
+
}>>;
|
|
634
714
|
condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
635
715
|
type: z.ZodLiteral<"ratio">;
|
|
636
716
|
data: z.ZodObject<{
|
|
@@ -1099,6 +1179,10 @@ export declare const CreateTriggerClose: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1099
1179
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1100
1180
|
NONE: "NONE";
|
|
1101
1181
|
}>;
|
|
1182
|
+
semanticBracketType: z.ZodOptional<z.ZodEnum<{
|
|
1183
|
+
STOP_LOSS: "STOP_LOSS";
|
|
1184
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
1185
|
+
}>>;
|
|
1102
1186
|
condition: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1103
1187
|
type: z.ZodLiteral<"ratio">;
|
|
1104
1188
|
data: z.ZodObject<{
|
|
@@ -1248,6 +1332,7 @@ export type CreateTriggerMarketClose = z.output<typeof CreateTriggerMarketClose>
|
|
|
1248
1332
|
export type AttachTriggerMarketCloseStatic = z.output<typeof AttachTriggerMarketCloseStatic>;
|
|
1249
1333
|
export type AttachTriggerMarketCloseTrailing = z.output<typeof AttachTriggerMarketCloseTrailing>;
|
|
1250
1334
|
export type AttachTriggerMarketClose = z.output<typeof AttachTriggerMarketClose>;
|
|
1335
|
+
export type AttachTriggerMarketCloseList = z.output<typeof AttachTriggerMarketCloseList>;
|
|
1251
1336
|
export type CreateTriggerOpen = z.output<typeof CreateTriggerOpen>;
|
|
1252
1337
|
export type CreateTriggerClose = z.output<typeof CreateTriggerClose>;
|
|
1253
1338
|
export type TrailingConfig = z.output<typeof TrailingConfig>;
|
|
@@ -30,19 +30,20 @@ const AttachTriggerMarketCloseTrailing = z.object({
|
|
|
30
30
|
trailing: TrailingConfig
|
|
31
31
|
}).superRefine(RefineTrailingLogicalRules);
|
|
32
32
|
const AttachTriggerMarketClose = z.union([AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing]);
|
|
33
|
+
const AttachTriggerMarketCloseList = z.array(AttachTriggerMarketClose).max(MAX_ATTACH_TRIGGERS, `At most ${MAX_ATTACH_TRIGGERS} close triggers can be attached.`).superRefine((attachTriggers, ctx) => {
|
|
34
|
+
const trailingCount = attachTriggers.filter(isAttachTriggerMarketCloseTrailing).length;
|
|
35
|
+
if (trailingCount > 1) {
|
|
36
|
+
ctx.addIssue({
|
|
37
|
+
code: "custom",
|
|
38
|
+
message: "At most one trailing close trigger can be attached."
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
33
42
|
const CreateTriggerMarketOpen = z.object({
|
|
34
43
|
intent: z.literal("OPEN"),
|
|
35
44
|
type: z.literal("MARKET"),
|
|
36
45
|
condition: CreateTriggerConditionOpen,
|
|
37
|
-
attachTriggers:
|
|
38
|
-
const trailingCount = attachTriggers.filter(isAttachTriggerMarketCloseTrailing).length;
|
|
39
|
-
if (trailingCount > 1) {
|
|
40
|
-
ctx.addIssue({
|
|
41
|
-
code: "custom",
|
|
42
|
-
message: "A market-open trigger can attach at most one trailing close trigger."
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}).optional(),
|
|
46
|
+
attachTriggers: AttachTriggerMarketCloseList.optional(),
|
|
46
47
|
payload: CreateTriggerMarketPayload,
|
|
47
48
|
/**
|
|
48
49
|
* Attribution route code (client_ids.code)
|
|
@@ -65,6 +66,9 @@ const CreateTriggerMarketCloseStatic = z.object({
|
|
|
65
66
|
type: z.literal("MARKET"),
|
|
66
67
|
positionId: z.uuid(),
|
|
67
68
|
bracketType: BracketType,
|
|
69
|
+
// User intent when bracketType is a side-dependent price-crossing encoding.
|
|
70
|
+
// Optional so older clients remain wire-compatible during rollout.
|
|
71
|
+
semanticBracketType: TpSlBracketType.optional(),
|
|
68
72
|
condition: CreateTriggerConditionCloseStatic,
|
|
69
73
|
/**
|
|
70
74
|
* Attribution route code (client_ids.code)
|
|
@@ -89,4 +93,4 @@ function isAttachTriggerMarketCloseTrailing(attachedTrigger) {
|
|
|
89
93
|
return "trailing" in attachedTrigger && attachedTrigger.trailing !== void 0;
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
export { AttachTriggerMarketClose, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketAdjust, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig, isAttachTriggerMarketCloseTrailing };
|
|
96
|
+
export { AttachTriggerMarketClose, AttachTriggerMarketCloseList, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketAdjust, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig, isAttachTriggerMarketCloseTrailing };
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
-
import type { BracketType } from '../common';
|
|
3
2
|
import type { CreateTriggerConditionCloseStatic } from '../payloads/conditions';
|
|
4
3
|
type ValidationFieldIssue = {
|
|
5
4
|
field: 'threshold';
|
|
6
5
|
message: string;
|
|
7
6
|
};
|
|
8
7
|
type ConditionType = CreateTriggerConditionCloseStatic['type'];
|
|
8
|
+
/** Surface every logical threshold issue on a static close trigger as a zod issue. */
|
|
9
9
|
export declare const RefineStaticLogicalRules: (value: {
|
|
10
|
-
bracketType: BracketType;
|
|
11
10
|
condition: CreateTriggerConditionCloseStatic;
|
|
12
11
|
}, context: z.RefinementCtx) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Validate a static close trigger's threshold against the rules its condition type implies.
|
|
14
|
+
*
|
|
15
|
+
* Deliberately blind to `bracketType`: it selects only the comparison direction (TAKE_PROFIT ->
|
|
16
|
+
* PEAK, STOP_LOSS -> TROUGH, NONE -> PEAK), and every sign pairs coherently with either direction. A positive
|
|
17
|
+
* STOP_LOSS is a profit floor ("close if my gain falls back to +10%") and a negative TAKE_PROFIT
|
|
18
|
+
* is a recovery exit ("close when my -30% loss recovers to -24%"); both are supported orders. A
|
|
19
|
+
* threshold that is already satisfied fires on the next evaluation pass, but catching that needs
|
|
20
|
+
* the position's current uPnL, which no pure function can see — it belongs in the usecase.
|
|
21
|
+
*/
|
|
13
22
|
export declare function getStaticLogicalIssues(input: {
|
|
14
|
-
bracketType: BracketType;
|
|
15
23
|
conditionType: ConditionType;
|
|
16
24
|
threshold: number;
|
|
17
25
|
}): ValidationFieldIssue[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const RefineStaticLogicalRules = (value, context) => {
|
|
2
2
|
for (const issue of getStaticLogicalIssues({
|
|
3
|
-
bracketType: value.bracketType,
|
|
4
3
|
conditionType: value.condition.type,
|
|
5
4
|
threshold: value.condition.data.threshold
|
|
6
5
|
})) {
|
|
@@ -23,7 +22,15 @@ function getStaticLogicalIssues(input) {
|
|
|
23
22
|
}
|
|
24
23
|
break;
|
|
25
24
|
}
|
|
26
|
-
case "upnl":
|
|
25
|
+
case "upnl": {
|
|
26
|
+
if (threshold === 0) {
|
|
27
|
+
issues.push({
|
|
28
|
+
field: "threshold",
|
|
29
|
+
message: "threshold must not be 0 for uPnL static triggers"
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
27
34
|
case "upnl_bps": {
|
|
28
35
|
if (threshold === 0) {
|
|
29
36
|
issues.push({
|