@pear-protocol/types 1.24.0 → 1.25.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 (75) hide show
  1. package/dist/auth/api-keys.js +11 -3
  2. package/dist/auth/entities.js +10 -2
  3. package/dist/auth/payloads.d.ts +7 -0
  4. package/dist/auth/payloads.js +15 -11
  5. package/dist/auth/response.js +4 -1
  6. package/dist/common/array.js +9 -2
  7. package/dist/common/refinement.js +25 -19
  8. package/dist/common/request.js +8 -8
  9. package/dist/common/response.js +10 -10
  10. package/dist/common/schema.js +9 -2
  11. package/dist/common/trade-legs.js +17 -12
  12. package/dist/connector/index.js +7 -1
  13. package/dist/execution/entities.js +96 -65
  14. package/dist/execution/queries.js +5 -1
  15. package/dist/execution/responses.js +3 -1
  16. package/dist/fee/entities.js +17 -3
  17. package/dist/fill/entities.js +33 -29
  18. package/dist/fill/queries.js +4 -1
  19. package/dist/funding/entities.js +4 -4
  20. package/dist/funding/responses.js +2 -2
  21. package/dist/instrument/entities.js +56 -44
  22. package/dist/instrument/queries.js +6 -1
  23. package/dist/instrument/responses.js +4 -4
  24. package/dist/instrument-precision/index.js +23 -23
  25. package/dist/ladder/entities.js +5 -1
  26. package/dist/ladder/payloads.js +15 -4
  27. package/dist/ladder/queries.js +0 -1
  28. package/dist/ladder/responses.js +12 -4
  29. package/dist/leverage/payloads.js +4 -1
  30. package/dist/notification/entities.js +37 -28
  31. package/dist/notification/payloads.js +9 -3
  32. package/dist/notification/queries.js +5 -1
  33. package/dist/notification/responses.js +4 -4
  34. package/dist/order/entities.js +38 -30
  35. package/dist/portfolio/queries.js +18 -3
  36. package/dist/position/entities.js +95 -72
  37. package/dist/position/queries.js +29 -23
  38. package/dist/price/entities.js +4 -1
  39. package/dist/price/responses.js +4 -4
  40. package/dist/rebalance/entities.js +23 -6
  41. package/dist/rebalance/payloads.js +23 -11
  42. package/dist/rebalance/queries.js +2 -8
  43. package/dist/rebalance/responses.js +12 -4
  44. package/dist/saved-baskets/entities.js +3 -1
  45. package/dist/saved-baskets/payloads.js +3 -1
  46. package/dist/schedule/entities.js +87 -71
  47. package/dist/schedule/payloads.js +36 -33
  48. package/dist/schedule/queries.js +5 -1
  49. package/dist/schedule/responses.js +12 -4
  50. package/dist/statistics/entities.d.ts +1 -0
  51. package/dist/statistics/entities.js +12 -0
  52. package/dist/statistics/queries.d.ts +2 -0
  53. package/dist/statistics/queries.js +16 -3
  54. package/dist/statistics/responses.d.ts +1 -0
  55. package/dist/sync/payloads.js +13 -17
  56. package/dist/tca/entities.js +4 -1
  57. package/dist/tca/responses.js +4 -1
  58. package/dist/trade/payloads.js +37 -23
  59. package/dist/trade/responses.js +15 -5
  60. package/dist/trade-accounts/entities.js +4 -1
  61. package/dist/trade-accounts/response.js +6 -2
  62. package/dist/trigger/common/index.js +27 -6
  63. package/dist/trigger/entities/conditions.js +14 -15
  64. package/dist/trigger/entities/index.js +89 -80
  65. package/dist/trigger/oracle.js +10 -3
  66. package/dist/trigger/payloads/conditions.js +8 -2
  67. package/dist/trigger/payloads/index.js +18 -4
  68. package/dist/trigger/queries.js +5 -1
  69. package/dist/trigger/refinement/static.refinement.js +5 -2
  70. package/dist/trigger/refinement/trailing.refinement.js +8 -6
  71. package/dist/trigger/responses.js +12 -4
  72. package/dist/triggers/entities.js +8 -2
  73. package/dist/users/entities.js +4 -1
  74. package/dist/users/payloads.js +17 -18
  75. package/package.json +1 -1
@@ -1,11 +1,24 @@
1
1
  import { z } from 'zod';
2
2
  import { Connector } from '../connector';
3
3
 
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
6
  const MAX_FEE_BPS = 10;
5
- const FeeOverrideScope = z.enum(["user", "client_id"]);
6
- const FeeDiscountScope = z.enum(["user", "client_id", "connector", "all"]);
7
+ const FeeOverrideScope = z.enum([
8
+ "user",
9
+ "client_id"
10
+ ]);
11
+ const FeeDiscountScope = z.enum([
12
+ "user",
13
+ "client_id",
14
+ "connector",
15
+ "all"
16
+ ]);
7
17
  const FeeConnector = z.enum(Connector.options);
8
- const FeeRole = z.enum(["basic", "pro"]);
18
+ const FeeRole = z.enum([
19
+ "basic",
20
+ "pro"
21
+ ]);
9
22
  const FeeBps = z.string().regex(/^\d{1,2}(\.\d)?$/, "Fee bps must be a decimal with at most one decimal place").refine((value) => Number(value) <= MAX_FEE_BPS, `Fee bps must not exceed ${MAX_FEE_BPS}`);
10
23
  const DiscountRate = z.string().regex(/^(0(\.\d{1,4})?|1(\.0{1,4})?)$/, 'Discount rate must be a fraction from 0 to 1, e.g. "0.2" for 20% off');
11
24
  const ORDERED_VALIDITY_WINDOW_MESSAGE = "endsAt must be later than startsAt";
@@ -15,5 +28,6 @@ function hasOrderedValidityWindow(window) {
15
28
  }
16
29
  return new Date(window.startsAt).getTime() < new Date(window.endsAt).getTime();
17
30
  }
31
+ __name(hasOrderedValidityWindow, "hasOrderedValidityWindow");
18
32
 
19
33
  export { DiscountRate, FeeBps, FeeConnector, FeeDiscountScope, FeeOverrideScope, FeeRole, MAX_FEE_BPS, ORDERED_VALIDITY_WINDOW_MESSAGE, hasOrderedValidityWindow };
@@ -3,50 +3,54 @@ import { Side } from '../common/schema';
3
3
  import { Connector } from '../connector';
4
4
  import { InstrumentId } from '../instrument';
5
5
 
6
- const FillStatus = z.enum(["PROVISIONAL", "CONFIRMED", "RECONCILED"]);
6
+ const FillStatus = z.enum([
7
+ "PROVISIONAL",
8
+ "CONFIRMED",
9
+ "RECONCILED"
10
+ ]);
7
11
  const Fill = z.object({
8
12
  /**
9
- * Fill UUID
10
- */
13
+ * Fill UUID
14
+ */
11
15
  id: z.uuid(),
12
16
  /** Client order ID (abbreviated as cloid) */
13
17
  cloid: z.string().optional(),
14
18
  /** Exchange-native fill ID (tradeId / tid / etc) */
15
19
  exchangeFillId: z.string().optional(),
16
20
  /**
17
- * Fill lifecycle status
18
- */
21
+ * Fill lifecycle status
22
+ */
19
23
  status: FillStatus,
20
24
  /**
21
- * Trade account UUID
22
- */
25
+ * Trade account UUID
26
+ */
23
27
  tradeAccountId: z.uuid(),
24
28
  /**
25
- * Instrument ID
26
- */
29
+ * Instrument ID
30
+ */
27
31
  symbol: InstrumentId,
28
32
  /**
29
- * Position UUID
30
- */
33
+ * Position UUID
34
+ */
31
35
  positionId: z.uuid(),
32
36
  /**
33
- * Connector
34
- */
37
+ * Connector
38
+ */
35
39
  connector: Connector,
36
40
  /**
37
- * Side
38
- */
41
+ * Side
42
+ */
39
43
  side: Side,
40
44
  /**
41
- * Reduce only flag
42
- */
45
+ * Reduce only flag
46
+ */
43
47
  reduceOnly: z.boolean(),
44
48
  /** True when the fill was created from external sync. */
45
49
  isExternal: z.boolean(),
46
50
  /**
47
- * True when the fill is a synthetic bridge fill (gap/gone reconstruction).
48
- * Unpriceable gone-close synthetics carry "0" price/usd and should be displayed distinctly.
49
- */
51
+ * True when the fill is a synthetic bridge fill (gap/gone reconstruction).
52
+ * Unpriceable gone-close synthetics carry "0" price/usd and should be displayed distinctly.
53
+ */
50
54
  synthetic: z.boolean(),
51
55
  quantity: z.string(),
52
56
  /** Filled price — "0" on an unpriceable gone-close synthetic (no price guessing). */
@@ -54,21 +58,21 @@ const Fill = z.object({
54
58
  /** USD value — "0" on an unpriceable gone-close synthetic (cannot compute without price). */
55
59
  usd: z.string(),
56
60
  /**
57
- * Trade fee paid
58
- */
61
+ * Trade fee paid
62
+ */
59
63
  tradeFee: z.string().optional(),
60
64
  /**
61
- * Pear fee paid
62
- */
65
+ * Pear fee paid
66
+ */
63
67
  pearFee: z.string().optional(),
64
68
  /**
65
- * Timestamp
66
- */
69
+ * Timestamp
70
+ */
67
71
  timestamp: z.string(),
68
72
  /**
69
- * A fill spanning multiple positions gets a synthetic exchange fill id.
70
- * This `original` field contains the root exchange fill id and quantity.
71
- */
73
+ * A fill spanning multiple positions gets a synthetic exchange fill id.
74
+ * This `original` field contains the root exchange fill id and quantity.
75
+ */
72
76
  original: z.object({
73
77
  exchangeFillId: z.string(),
74
78
  quantity: z.string()
@@ -2,7 +2,10 @@ import { z } from 'zod';
2
2
  import { CursorFindParams } from '../common';
3
3
  import { Connector } from '../connector';
4
4
 
5
- const FillOrderBy = z.union([z.literal("timestamp"), z.literal("-timestamp")]);
5
+ const FillOrderBy = z.union([
6
+ z.literal("timestamp"),
7
+ z.literal("-timestamp")
8
+ ]);
6
9
  const FillListParams = CursorFindParams.extend({
7
10
  connector: Connector.optional(),
8
11
  orderBy: FillOrderBy.default("-timestamp")
@@ -3,12 +3,12 @@ import { InstrumentId } from '../instrument';
3
3
 
4
4
  const FundingInfo = z.object({
5
5
  /**
6
- * Funding rate
7
- */
6
+ * Funding rate
7
+ */
8
8
  r: z.string(),
9
9
  /**
10
- * Next funding time in milliseconds
11
- */
10
+ * Next funding time in milliseconds
11
+ */
12
12
  nft: z.number()
13
13
  });
14
14
  const InstrumentFundingMap = z.record(InstrumentId, FundingInfo);
@@ -3,8 +3,8 @@ import { InstrumentFundingMap } from './entities';
3
3
 
4
4
  const FundingResponse = z.object({
5
5
  /**
6
- * Funding rates and next funding times for instruments
7
- */
6
+ * Funding rates and next funding times for instruments
7
+ */
8
8
  funding: InstrumentFundingMap
9
9
  });
10
10
 
@@ -3,9 +3,21 @@ import { Connector } from '../connector';
3
3
  import { InstrumentPrecision } from '../instrument-precision';
4
4
 
5
5
  const InstrumentId = z.string().trim().min(1, "Instrument ID is required").max(64, "Instrument ID must be at most 64 characters").regex(/^[^\s][^\s]*$/, "Instrument ID contains invalid characters");
6
- const InstrumentType = z.enum(["spot", "perp", "hip3"]);
7
- const InstrumentMarginMode = z.enum(["isolated", "cross", "any"]);
8
- const InstrumentTradeabilityStatus = z.enum(["tradable", "reduce_only", "not_tradable"]);
6
+ const InstrumentType = z.enum([
7
+ "spot",
8
+ "perp",
9
+ "hip3"
10
+ ]);
11
+ const InstrumentMarginMode = z.enum([
12
+ "isolated",
13
+ "cross",
14
+ "any"
15
+ ]);
16
+ const InstrumentTradeabilityStatus = z.enum([
17
+ "tradable",
18
+ "reduce_only",
19
+ "not_tradable"
20
+ ]);
9
21
  const InstrumentTradeabilityReason = z.string().nullable();
10
22
  const InstrumentTradeability = z.object({
11
23
  status: InstrumentTradeabilityStatus,
@@ -13,73 +25,73 @@ const InstrumentTradeability = z.object({
13
25
  });
14
26
  const Instrument = z.object({
15
27
  /**
16
- * Exchange specific instrument identifier
17
- * @example (dexIndex + assetIndex) on Hyperliquid
18
- * @example "BTCUSDT" on Binance
19
- */
28
+ * Exchange specific instrument identifier
29
+ * @example (dexIndex + assetIndex) on Hyperliquid
30
+ * @example "BTCUSDT" on Binance
31
+ */
20
32
  id: InstrumentId,
21
33
  /**
22
- * The base asset of the instrument.
23
- * @example "BTC"
24
- */
34
+ * The base asset of the instrument.
35
+ * @example "BTC"
36
+ */
25
37
  base: z.string(),
26
38
  /**
27
- * The quote asset of the instrument.
28
- * @example "USDT"
29
- */
39
+ * The quote asset of the instrument.
40
+ * @example "USDT"
41
+ */
30
42
  quote: z.string(),
31
43
  /**
32
- * The connector of the instrument.
33
- * @example "hyperliquid"
34
- * @example "binance"
35
- */
44
+ * The connector of the instrument.
45
+ * @example "hyperliquid"
46
+ * @example "binance"
47
+ */
36
48
  connector: Connector,
37
49
  /**
38
- * The type of the instrument.
39
- * @example "spot"
40
- * @example "perp"
41
- * @example "hip3"
42
- */
50
+ * The type of the instrument.
51
+ * @example "spot"
52
+ * @example "perp"
53
+ * @example "hip3"
54
+ */
43
55
  type: InstrumentType,
44
56
  /**
45
- * The maximum leverage of the instrument.
46
- * @example 1
47
- */
57
+ * The maximum leverage of the instrument.
58
+ * @example 1
59
+ */
48
60
  leverage: z.int().min(1),
49
61
  /**
50
- * The margin modes this market offers, not the mode selected for an account.
51
- * `isolated` and `cross` mean the venue permits only that mode; `any` means the user chooses.
52
- */
62
+ * The margin modes this market offers, not the mode selected for an account.
63
+ * `isolated` and `cross` mean the venue permits only that mode; `any` means the user chooses.
64
+ */
53
65
  marginMode: InstrumentMarginMode,
54
66
  /**
55
- * The precision of the instrument.
56
- */
67
+ * The precision of the instrument.
68
+ */
57
69
  precision: InstrumentPrecision,
58
70
  /**
59
- * Whether this instrument can be traded normally.
60
- */
71
+ * Whether this instrument can be traded normally.
72
+ */
61
73
  tradeability: InstrumentTradeability
62
74
  });
63
75
  const InstrumentLite = z.object({
64
76
  /**
65
- * Exchange specific instrument identifier
66
- * @example (dexIndex + assetIndex) on Hyperliquid
67
- * @example "BTCUSDT" on Binance
68
- */
77
+ * Exchange specific instrument identifier
78
+ * @example (dexIndex + assetIndex) on Hyperliquid
79
+ * @example "BTCUSDT" on Binance
80
+ */
69
81
  id: InstrumentId,
70
82
  /**
71
- * The base asset of the instrument.
72
- * @example "BTC"
73
- */
83
+ * The base asset of the instrument.
84
+ * @example "BTC"
85
+ */
74
86
  base: z.string(),
75
87
  /**
76
- * The margin modes this market offers, not the mode selected for an account.
77
- * `isolated` and `cross` mean the venue permits only that mode; `any` means the user chooses.
78
- */
88
+ * The margin modes this market offers, not the mode selected for an account.
89
+ * `isolated` and `cross` mean the venue permits only that mode; `any` means the user chooses.
90
+ */
79
91
  marginMode: InstrumentMarginMode,
80
92
  /**
81
- * Minimal precision — only the contract size the syncer needs for BASE-unit normalization.
82
- */
93
+ * Minimal precision — only the contract size the syncer needs for BASE-unit normalization.
94
+ */
83
95
  precision: z.object({
84
96
  quantity: z.object({
85
97
  contractSize: z.number()
@@ -1,7 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { Connector } from '../connector';
3
3
 
4
- const InstrumentScope = z.enum(["tradable", "reduce_only", "not_tradable", "all"]);
4
+ const InstrumentScope = z.enum([
5
+ "tradable",
6
+ "reduce_only",
7
+ "not_tradable",
8
+ "all"
9
+ ]);
5
10
  const InstrumentListParams = z.object({
6
11
  connector: Connector,
7
12
  scope: InstrumentScope.default("all")
@@ -3,8 +3,8 @@ import { Instrument, InstrumentId, InstrumentLite } from './entities';
3
3
 
4
4
  const InstrumentListResponse = z.object({
5
5
  /**
6
- * The list of instruments.
7
- */
6
+ * The list of instruments.
7
+ */
8
8
  instruments: z.array(Instrument)
9
9
  });
10
10
  const InstrumentSymbolToIdMapResponse = z.object({
@@ -12,8 +12,8 @@ const InstrumentSymbolToIdMapResponse = z.object({
12
12
  });
13
13
  const InstrumentListLiteResponse = z.object({
14
14
  /**
15
- * The list of instruments, trimmed to the lightweight consumer fields.
16
- */
15
+ * The list of instruments, trimmed to the lightweight consumer fields.
16
+ */
17
17
  instruments: z.array(InstrumentLite)
18
18
  });
19
19
 
@@ -3,47 +3,47 @@ import { z } from 'zod';
3
3
  const InstrumentPrecision = z.object({
4
4
  quantity: z.object({
5
5
  /**
6
- * The maximum number of decimals accepted.
7
- * @example 4 for a 0.0001 step size.
8
- */
6
+ * The maximum number of decimals accepted.
7
+ * @example 4 for a 0.0001 step size.
8
+ */
9
9
  decimals: z.int(),
10
10
  /**
11
- * The smallest step size.
12
- * @example 0.01 for a 2 decimal precision.
13
- */
11
+ * The smallest step size.
12
+ * @example 0.01 for a 2 decimal precision.
13
+ */
14
14
  step: z.number(),
15
15
  /**
16
- * Size of one contract in base asset units.
17
- * For exchanges where 1 contract != 1 base unit (e.g., OKX: 1 contract = 0.01 BTC).
18
- * 1 means 1:1 mapping (most exchanges).
19
- */
16
+ * Size of one contract in base asset units.
17
+ * For exchanges where 1 contract != 1 base unit (e.g., OKX: 1 contract = 0.01 BTC).
18
+ * 1 means 1:1 mapping (most exchanges).
19
+ */
20
20
  contractSize: z.number()
21
21
  }),
22
22
  price: z.object({
23
23
  /**
24
- * The maximum number of decimals.
25
- * @example 4 for a 0.0001 tick size.
26
- */
24
+ * The maximum number of decimals.
25
+ * @example 4 for a 0.0001 tick size.
26
+ */
27
27
  decimals: z.int(),
28
28
  /**
29
- * The smallest increment.
30
- * @example 0.01 for a 2 decimal precision.
31
- */
29
+ * The smallest increment.
30
+ * @example 0.01 for a 2 decimal precision.
31
+ */
32
32
  tick: z.number().transform((val) => val === null ? void 0 : val).optional().nullable(),
33
33
  /**
34
- * The number of significant figures.
35
- * @example 5 on Hyperliquid V2.
36
- */
34
+ * The number of significant figures.
35
+ * @example 5 on Hyperliquid V2.
36
+ */
37
37
  sigFigs: z.int().transform((val) => val === null ? void 0 : val).optional().nullable()
38
38
  }),
39
39
  notional: z.object({
40
40
  /**
41
- * The minimum notional amount in USD.
42
- */
41
+ * The minimum notional amount in USD.
42
+ */
43
43
  min: z.number().transform((val) => val === null ? void 0 : val).optional().nullable(),
44
44
  /**
45
- * The maximum notional amount in USD.
46
- */
45
+ * The maximum notional amount in USD.
46
+ */
47
47
  max: z.number().transform((val) => val === null ? void 0 : val).optional().nullable()
48
48
  }).optional()
49
49
  });
@@ -4,7 +4,11 @@ import { Trigger } from '../trigger';
4
4
  import { AttachTriggerMarketCloseList } from '../trigger/payloads';
5
5
  import { LadderConfig } from './payloads';
6
6
 
7
- const LadderStatus = z.enum(["ACTIVE", "COMPLETED", "CANCELLED"]);
7
+ const LadderStatus = z.enum([
8
+ "ACTIVE",
9
+ "COMPLETED",
10
+ "CANCELLED"
11
+ ]);
8
12
  const Ladder = z.object({
9
13
  id: z.uuid(),
10
14
  connector: Connector,
@@ -18,7 +18,10 @@ const LadderConfig = z.object({
18
18
  }).refine((config) => config.thresholdStart !== config.thresholdEnd, {
19
19
  message: "thresholds must differ"
20
20
  });
21
- const PriceSource = z.enum(["mid", "mark"], {
21
+ const PriceSource = z.enum([
22
+ "mid",
23
+ "mark"
24
+ ], {
22
25
  message: "Price source must be mid or mark"
23
26
  });
24
27
  const WeightedRatioBasketItem = z.object({
@@ -62,7 +65,11 @@ const LadderAttachTriggers = AttachTriggerMarketCloseList.superRefine((attachTri
62
65
  if (attachTrigger.condition.type === "notional" || attachTrigger.condition.type === "notional_trailing") {
63
66
  ctx.addIssue({
64
67
  code: "custom",
65
- path: [index, "condition", "type"],
68
+ path: [
69
+ index,
70
+ "condition",
71
+ "type"
72
+ ],
66
73
  message: "Ladder brackets cannot use notional conditions; use upnl or upnl_bps."
67
74
  });
68
75
  }
@@ -77,9 +84,13 @@ const CreateLadderMarketOpen = z.object({
77
84
  attachTriggers: LadderAttachTriggers.optional(),
78
85
  payload: z.object({
79
86
  type: z.literal("MARKET"),
80
- legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols)
87
+ legs: z.tuple([
88
+ TradeLegPostOnly
89
+ ]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols)
81
90
  })
82
91
  }).strict();
83
- const CreateLadder = z.discriminatedUnion("type", [CreateLadderMarketOpen]);
92
+ const CreateLadder = z.discriminatedUnion("type", [
93
+ CreateLadderMarketOpen
94
+ ]);
84
95
 
85
96
  export { CreateLadder, CreateLadderMarketOpen, LadderConditionOpen, LadderConfig };
@@ -1,4 +1,3 @@
1
- import 'zod';
2
1
  import { CursorFindParams } from '../common';
3
2
  import { Connector } from '../connector';
4
3
 
@@ -2,9 +2,17 @@ import { z } from 'zod';
2
2
  import { CursorResponse } from '../common';
3
3
  import { Ladder } from './entities';
4
4
 
5
- const CreateLadderResponse = z.object({ ladder: Ladder });
6
- const LadderResponse = z.object({ ladder: Ladder });
7
- const LadderListResponse = CursorResponse.extend({ ladders: z.array(Ladder) });
8
- const CancelLadderResponse = z.object({ id: z.uuid() });
5
+ const CreateLadderResponse = z.object({
6
+ ladder: Ladder
7
+ });
8
+ const LadderResponse = z.object({
9
+ ladder: Ladder
10
+ });
11
+ const LadderListResponse = CursorResponse.extend({
12
+ ladders: z.array(Ladder)
13
+ });
14
+ const CancelLadderResponse = z.object({
15
+ id: z.uuid()
16
+ });
9
17
 
10
18
  export { CancelLadderResponse, CreateLadderResponse, LadderListResponse, LadderResponse };
@@ -1,7 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import { InstrumentId } from '../instrument/entities';
3
3
 
4
- const MarginMode = z.enum(["cross", "isolated"]);
4
+ const MarginMode = z.enum([
5
+ "cross",
6
+ "isolated"
7
+ ]);
5
8
  const SetLeverage = z.object({
6
9
  symbol: InstrumentId,
7
10
  leverage: z.int().positive(),
@@ -82,14 +82,18 @@ const AttachedTriggerDiscardedNotificationParameters = PositionLegParameters.saf
82
82
  positionId: z.uuid(),
83
83
  positionKey: z.string().min(1),
84
84
  connector: Connector,
85
- discarded: z.array(
86
- z.object({
87
- bracketType: z.enum(["STOP_LOSS", "TAKE_PROFIT"]),
88
- metric: NotificationMetric,
89
- level: z.number().optional(),
90
- reason: z.enum(["TRIGGER_LIMIT", "TRAILING_ALREADY_EXISTS"])
91
- })
92
- ).min(1),
85
+ discarded: z.array(z.object({
86
+ bracketType: z.enum([
87
+ "STOP_LOSS",
88
+ "TAKE_PROFIT"
89
+ ]),
90
+ metric: NotificationMetric,
91
+ level: z.number().optional(),
92
+ reason: z.enum([
93
+ "TRIGGER_LIMIT",
94
+ "TRAILING_ALREADY_EXISTS"
95
+ ])
96
+ })).min(1),
93
97
  activeTriggerLimit: z.number().int().positive()
94
98
  });
95
99
  const AutoRebalanceLeg = z.object({
@@ -102,14 +106,15 @@ const AutoRebalanceAnchor = {
102
106
  positionId: z.uuid(),
103
107
  positionKey: z.string().min(1),
104
108
  connector: Connector,
105
- weightSource: z.enum(["INITIAL_WEIGHT", "LIVE_BETA"])
109
+ weightSource: z.enum([
110
+ "INITIAL_WEIGHT",
111
+ "LIVE_BETA"
112
+ ])
106
113
  };
107
- const AutoRebalanceRunLegs = z.array(
108
- AutoRebalanceLeg.safeExtend({
109
- currentWeight: z.number(),
110
- targetWeight: z.number()
111
- })
112
- );
114
+ const AutoRebalanceRunLegs = z.array(AutoRebalanceLeg.safeExtend({
115
+ currentWeight: z.number(),
116
+ targetWeight: z.number()
117
+ }));
113
118
  const AutoRebalanceExecutedNotificationParameters = z.object({
114
119
  type: z.literal("auto_rebalance_executed"),
115
120
  ...AutoRebalanceAnchor,
@@ -128,7 +133,11 @@ const AutoRebalancePausedNotificationParameters = z.object({
128
133
  type: z.literal("auto_rebalance_paused"),
129
134
  ...AutoRebalanceAnchor,
130
135
  legs: z.array(AutoRebalanceLeg),
131
- pausedReason: z.enum(["POSITION_CHANGED", "REPEATED_FAILURES", "INVALID_LIVE_BETA_EXPOSURE"])
136
+ pausedReason: z.enum([
137
+ "POSITION_CHANGED",
138
+ "REPEATED_FAILURES",
139
+ "INVALID_LIVE_BETA_EXPOSURE"
140
+ ])
132
141
  });
133
142
  const TriggerCancelledMisScaledNotificationParameters = z.object({
134
143
  type: z.literal("trigger_cancelled_mis_scaled"),
@@ -150,28 +159,28 @@ const NotificationParameters = z.discriminatedUnion("type", [
150
159
  ]);
151
160
  const Notification = z.object({
152
161
  /**
153
- * Notification UUID
154
- */
162
+ * Notification UUID
163
+ */
155
164
  id: z.uuid(),
156
165
  /**
157
- * What kind of notification this is
158
- */
166
+ * What kind of notification this is
167
+ */
159
168
  category: NotificationCategory,
160
169
  /**
161
- * Category-specific display payload
162
- */
170
+ * Category-specific display payload
171
+ */
163
172
  parameters: NotificationParameters,
164
173
  /**
165
- * Whether the user has read it
166
- */
174
+ * Whether the user has read it
175
+ */
167
176
  isRead: z.boolean(),
168
177
  /**
169
- * Created at timestamp
170
- */
178
+ * Created at timestamp
179
+ */
171
180
  createdAt: z.string(),
172
181
  /**
173
- * Updated at timestamp
174
- */
182
+ * Updated at timestamp
183
+ */
175
184
  updatedAt: z.string()
176
185
  });
177
186
 
@@ -1,9 +1,15 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  const MarkNotificationsReadPayload = z.union([
4
- z.strictObject({ id: z.uuid() }),
5
- z.strictObject({ timestamp: z.coerce.number().int().positive() })
4
+ z.strictObject({
5
+ id: z.uuid()
6
+ }),
7
+ z.strictObject({
8
+ timestamp: z.coerce.number().int().positive()
9
+ })
6
10
  ]);
7
- const MarkNotificationUnreadPayload = z.strictObject({ id: z.uuid() });
11
+ const MarkNotificationUnreadPayload = z.strictObject({
12
+ id: z.uuid()
13
+ });
8
14
 
9
15
  export { MarkNotificationUnreadPayload, MarkNotificationsReadPayload };
@@ -17,7 +17,11 @@ const NotificationListParams = z.object({
17
17
  /**
18
18
  * Filter by read state: `all` (default), only `read`, or only `unread`.
19
19
  */
20
- scope: z.enum(["all", "read", "unread"]).optional().default("all")
20
+ scope: z.enum([
21
+ "all",
22
+ "read",
23
+ "unread"
24
+ ]).optional().default("all")
21
25
  }).refine((data) => !data.startDate || !data.endDate || data.startDate < data.endDate, {
22
26
  message: "startDate must be before endDate"
23
27
  });