@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,16 @@
1
1
  import { z } from 'zod';
2
2
 
3
- const ApiKeyScope = z.enum(["read", "read_write"]).describe("API key access scope");
3
+ const ApiKeyScope = z.enum([
4
+ "read",
5
+ "read_write"
6
+ ]).describe("API key access scope");
4
7
  const CreateApiKeyInput = z.object({
5
8
  label: z.string().trim().min(1, "Label is required").max(100).describe("Human label for the key"),
6
9
  scope: ApiKeyScope.default("read"),
7
10
  /** ISO-8601 datetime; omit for a key that never expires. */
8
- expiresAt: z.iso.datetime({ offset: true }).optional().describe("Optional expiry (ISO-8601)")
11
+ expiresAt: z.iso.datetime({
12
+ offset: true
13
+ }).optional().describe("Optional expiry (ISO-8601)")
9
14
  }).describe("Create a new API key");
10
15
  const CreateApiKeyOutput = z.object({
11
16
  id: z.uuid(),
@@ -27,7 +32,10 @@ const ApiKeySummary = z.object({
27
32
  const ListApiKeysOutput = z.array(ApiKeySummary).describe("All API keys for the user");
28
33
  const ApiKeyMeResponse = z.object({
29
34
  id: z.uuid().describe("User UUID that owns the API key"),
30
- role: z.enum(["basic", "pro"]).describe("User role"),
35
+ role: z.enum([
36
+ "basic",
37
+ "pro"
38
+ ]).describe("User role"),
31
39
  scope: ApiKeyScope,
32
40
  authMethod: z.literal("api_key")
33
41
  }).describe("Identity of the caller authenticated via an API key");
@@ -1,9 +1,17 @@
1
1
  import { z } from 'zod';
2
2
 
3
- const LoginMethod = z.enum(["email", "evm_wallet", "oauth", "x"]).describe("Authentication provider used for the current session");
3
+ const LoginMethod = z.enum([
4
+ "email",
5
+ "evm_wallet",
6
+ "oauth",
7
+ "x"
8
+ ]).describe("Authentication provider used for the current session");
4
9
  const AuthenticatedUser = z.object({
5
10
  id: z.uuid().describe("User UUID"),
6
- role: z.enum(["basic", "pro"]).describe("User role"),
11
+ role: z.enum([
12
+ "basic",
13
+ "pro"
14
+ ]).describe("User role"),
7
15
  providerId: z.string().nullable().describe("Provider identifier (wallet address or email)"),
8
16
  loginMethod: LoginMethod.describe("Authentication provider used for the current session")
9
17
  }).describe("Current authenticated user info");
@@ -20,6 +20,12 @@ export declare const StartXLinkRequest: z.ZodObject<{
20
20
  }, z.core.$strip>;
21
21
  export declare const StartXLoginRequest: z.ZodObject<{
22
22
  returnTo: z.ZodOptional<z.ZodString>;
23
+ handoffId: z.ZodString;
24
+ handoffChallenge: z.ZodString;
25
+ }, z.core.$strip>;
26
+ export declare const ExchangeXLoginRequest: z.ZodObject<{
27
+ ticket: z.ZodString;
28
+ handoffVerifier: z.ZodString;
23
29
  }, z.core.$strip>;
24
30
  export declare const WalletLoginRequest: z.ZodObject<{
25
31
  method: z.ZodLiteral<"wallet">;
@@ -78,6 +84,7 @@ export type LinkEmailRequest = z.infer<typeof LinkEmailRequest>;
78
84
  export type LinkWalletRequest = z.infer<typeof LinkWalletRequest>;
79
85
  export type StartXLinkRequest = z.infer<typeof StartXLinkRequest>;
80
86
  export type StartXLoginRequest = z.infer<typeof StartXLoginRequest>;
87
+ export type ExchangeXLoginRequest = z.infer<typeof ExchangeXLoginRequest>;
81
88
  export type EmailLoginRequest = z.infer<typeof EmailLoginRequest>;
82
89
  export type LoginRequest = z.infer<typeof LoginRequest>;
83
90
  export type RefreshTokenRequest = z.infer<typeof RefreshTokenRequest>;
@@ -22,15 +22,18 @@ const LinkWalletRequest = z.object({
22
22
  nonce: SignedNonce
23
23
  }).describe("Link wallet credentials to the authenticated account");
24
24
  const StartXLinkRequest = z.object({
25
- returnTo: z.string().optional().describe(
26
- "Page to send the browser back to once the link finishes, normally the page the user is on. Must be on the calling origin; defaults to that origin."
27
- )
25
+ returnTo: z.string().optional().describe("Page to send the browser back to once the link finishes, normally the page the user is on. Must be on the calling origin; defaults to that origin.")
28
26
  }).describe("Start of the X account link flow");
27
+ const PkceValue = z.string().regex(/^[A-Za-z0-9_-]{43}$/, "Must be 43 base64url characters");
29
28
  const StartXLoginRequest = z.object({
30
- returnTo: z.string().optional().describe(
31
- "Page to send the browser back to once the sign-in finishes, normally the page the user is on. Must be on the calling origin; defaults to that origin."
32
- )
29
+ returnTo: z.string().optional().describe("Page to send the browser back to once the sign-in finishes, normally the page the user is on. Must be on the calling origin; defaults to that origin. Any fragment is dropped - the flow returns its ticket there."),
30
+ handoffId: z.string().regex(/^[A-Za-z0-9_-]{1,64}$/, "Must be 1-64 URL-safe characters").describe("Names this sign-in attempt. Echoed back on the return URL so a browser that started more than one knows which secret this outcome belongs to."),
31
+ handoffChallenge: PkceValue.describe("Base64url SHA-256 of a random verifier this browser keeps. The finished sign-in is redeemed by presenting that verifier, so only the browser that started the flow can collect it.")
33
32
  }).describe("Start of the X sign-in flow");
33
+ const ExchangeXLoginRequest = z.object({
34
+ ticket: z.string().min(1, "Ticket is required").describe("Single-use ticket from the return URL fragment"),
35
+ handoffVerifier: PkceValue.describe("The verifier whose challenge started this sign-in")
36
+ }).describe("Redemption of a finished X sign-in for a session");
34
37
  const WalletLoginRequest = z.object({
35
38
  method: z.literal("wallet").describe('Must be "wallet" for wallet authentication'),
36
39
  address: EthereumAddress,
@@ -58,7 +61,10 @@ const ResetPasswordRequest = z.object({
58
61
  token: z.string().min(1, "Token is required").describe("Password reset token"),
59
62
  password: Password.describe("New password to set")
60
63
  }).describe("Reset password using a password reset token");
61
- const LoginRequest = z.discriminatedUnion("method", [WalletLoginRequest, EmailLoginRequest]);
64
+ const LoginRequest = z.discriminatedUnion("method", [
65
+ WalletLoginRequest,
66
+ EmailLoginRequest
67
+ ]);
62
68
  const RefreshTokenRequest = z.object({
63
69
  refreshToken: z.string().min(1, "Refresh token is required").describe("Refresh token")
64
70
  }).describe("Refresh token request");
@@ -69,9 +75,7 @@ const LogoutRequest = z.object({
69
75
  refreshToken: z.string().min(1, "Refresh token is required").describe("Refresh token to revoke")
70
76
  }).describe("Logout and revoke refresh token");
71
77
  const OauthInteractionConfirmRequest = z.object({
72
- scopes: z.array(z.string()).default([]).describe(
73
- "The scope set the user granted at consent (opaque to the AS; empty resolves to the read-only fail-safe)"
74
- )
78
+ scopes: z.array(z.string()).default([]).describe("The scope set the user granted at consent (opaque to the AS; empty resolves to the read-only fail-safe)")
75
79
  }).describe("Consent confirmation body \u2014 the granted scope set");
76
80
 
77
- export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, OauthInteractionConfirmRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, StartXLinkRequest, StartXLoginRequest, VerifyEmailRequest, WalletLoginRequest };
81
+ export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ExchangeXLoginRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, OauthInteractionConfirmRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, StartXLinkRequest, StartXLoginRequest, VerifyEmailRequest, WalletLoginRequest };
@@ -26,7 +26,10 @@ const ResetPasswordResponse = z.void().describe("Successful password reset respo
26
26
  const VerifyEmailResponse = z.object({
27
27
  verified: z.literal(true).describe("Always true; the claim behind the token is now verified"),
28
28
  email: z.string().describe("Email address the verified claim belongs to"),
29
- flow: z.enum(["register", "link"]).describe("Claim flow the token was issued for"),
29
+ flow: z.enum([
30
+ "register",
31
+ "link"
32
+ ]).describe("Claim flow the token was issued for"),
30
33
  verifiedAt: z.string().describe("ISO-8601 timestamp of when the claim was verified")
31
34
  }).describe("Successful email verification response");
32
35
  const LinkEmailResponse = z.void().describe("Successful email verification response");
@@ -1,10 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
1
3
  function normalizeArray(val) {
2
4
  if (!val) return void 0;
3
5
  if (Array.isArray(val)) return val;
4
6
  if (typeof val === "string") {
5
- return val.includes(",") ? val.split(",").map((s) => s.trim()) : [val];
7
+ return val.includes(",") ? val.split(",").map((s) => s.trim()) : [
8
+ val
9
+ ];
6
10
  }
7
- return [String(val)];
11
+ return [
12
+ String(val)
13
+ ];
8
14
  }
15
+ __name(normalizeArray, "normalizeArray");
9
16
 
10
17
  export { normalizeArray };
@@ -1,52 +1,58 @@
1
- import 'zod';
2
-
3
- const RefineMinimumOneSymbol = (basket, ctx) => {
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ const RefineMinimumOneSymbol = /* @__PURE__ */ __name((basket, ctx) => {
4
4
  if (basket.length < 1) {
5
5
  ctx.addIssue({
6
6
  code: "custom",
7
7
  message: "At least one symbol is required."
8
8
  });
9
9
  }
10
- };
11
- const RefineMinimumTwoSymbols = (basket, ctx) => {
10
+ }, "RefineMinimumOneSymbol");
11
+ const RefineMinimumTwoSymbols = /* @__PURE__ */ __name((basket, ctx) => {
12
12
  if (basket.length < 2) {
13
13
  ctx.addIssue({
14
14
  code: "custom",
15
15
  message: "At least two symbols are required."
16
16
  });
17
17
  }
18
- };
19
- const RefineTwoUniqueSymbols = (pair, ctx) => {
18
+ }, "RefineMinimumTwoSymbols");
19
+ const RefineTwoUniqueSymbols = /* @__PURE__ */ __name((pair, ctx) => {
20
20
  if (pair.symbol_a === pair.symbol_b) {
21
21
  ctx.addIssue({
22
22
  code: "custom",
23
23
  message: "Symbols cannot be the same."
24
24
  });
25
25
  }
26
- };
27
- const RefineUniqueSymbols = (basket, ctx) => {
26
+ }, "RefineTwoUniqueSymbols");
27
+ const RefineUniqueSymbols = /* @__PURE__ */ __name((basket, ctx) => {
28
28
  const symbols = basket.map((item) => item.symbol);
29
29
  const uniqueSymbols = new Set(symbols);
30
30
  if (symbols.length !== uniqueSymbols.size) {
31
31
  const duplicates = symbols.filter((symbol, index) => symbols.indexOf(symbol) !== index);
32
32
  ctx.addIssue({
33
33
  code: "custom",
34
- message: `Duplicate symbols found: ${[...new Set(duplicates)].join(", ")}`,
35
- path: ["basket"]
34
+ message: `Duplicate symbols found: ${[
35
+ ...new Set(duplicates)
36
+ ].join(", ")}`,
37
+ path: [
38
+ "basket"
39
+ ]
36
40
  });
37
41
  }
38
- };
39
- const RefineWeightingSum = (basket, ctx) => {
42
+ }, "RefineUniqueSymbols");
43
+ const RefineWeightingSum = /* @__PURE__ */ __name((basket, ctx) => {
40
44
  const totalWeight = basket.reduce((acc, curr) => acc + curr.weight, 0);
41
45
  if (Math.abs(totalWeight - 1) > 1e-9) {
42
46
  ctx.addIssue({
43
47
  code: "custom",
44
48
  message: `The sum of weights must be exactly 1, but got ${totalWeight}`,
45
- path: ["basket"]
49
+ path: [
50
+ "basket"
51
+ ]
46
52
  });
47
53
  }
48
- };
49
- const RefineMinimumOneBuyOneSell = (basket, ctx) => {
54
+ }, "RefineWeightingSum");
55
+ const RefineMinimumOneBuyOneSell = /* @__PURE__ */ __name((basket, ctx) => {
50
56
  const buyCount = basket.filter((item) => item.side === "BUY").length;
51
57
  const sellCount = basket.filter((item) => item.side === "SELL").length;
52
58
  if (buyCount < 1 || sellCount < 1) {
@@ -55,14 +61,14 @@ const RefineMinimumOneBuyOneSell = (basket, ctx) => {
55
61
  message: "At least one BUY and one SELL are required."
56
62
  });
57
63
  }
58
- };
59
- const RefineMinimumOneKeyValuePair = (data, ctx) => {
64
+ }, "RefineMinimumOneBuyOneSell");
65
+ const RefineMinimumOneKeyValuePair = /* @__PURE__ */ __name((data, ctx) => {
60
66
  if (Object.keys(data).length < 1) {
61
67
  ctx.addIssue({
62
68
  code: "custom",
63
69
  message: "Empty object is not allowed."
64
70
  });
65
71
  }
66
- };
72
+ }, "RefineMinimumOneKeyValuePair");
67
73
 
68
74
  export { RefineMinimumOneBuyOneSell, RefineMinimumOneKeyValuePair, RefineMinimumOneSymbol, RefineMinimumTwoSymbols, RefineTwoUniqueSymbols, RefineUniqueSymbols, RefineWeightingSum };
@@ -2,22 +2,22 @@ import { z } from 'zod';
2
2
 
3
3
  const CursorFindParams = z.object({
4
4
  /**
5
- * The maximum number of items to retrieve.
6
- */
5
+ * The maximum number of items to retrieve.
6
+ */
7
7
  limit: z.coerce.number().int().positive().max(2e3).optional().default(20),
8
8
  /**
9
- * Opaque pagination cursor returned by the API.
10
- */
9
+ * Opaque pagination cursor returned by the API.
10
+ */
11
11
  cursor: z.string().optional()
12
12
  });
13
13
  const PaginationFindParams = z.object({
14
14
  /**
15
- * The maximum number of items to retrieve.
16
- */
15
+ * The maximum number of items to retrieve.
16
+ */
17
17
  limit: z.coerce.number().int().positive().max(100).optional().default(20),
18
18
  /**
19
- * The number of items to skip before retrieving the returned items.
20
- */
19
+ * The number of items to skip before retrieving the returned items.
20
+ */
21
21
  offset: z.coerce.number().int().min(0).optional().default(0)
22
22
  });
23
23
 
@@ -2,26 +2,26 @@ import { z } from 'zod';
2
2
 
3
3
  const PaginatedResponse = z.object({
4
4
  /**
5
- * The maximum number of items retrieved.
6
- */
5
+ * The maximum number of items retrieved.
6
+ */
7
7
  limit: z.number(),
8
8
  /**
9
- * The number of items to skip before retrieving the returned items.
10
- */
9
+ * The number of items to skip before retrieving the returned items.
10
+ */
11
11
  offset: z.number(),
12
12
  /**
13
- * The total number of items.
14
- */
13
+ * The total number of items.
14
+ */
15
15
  count: z.number()
16
16
  });
17
17
  const CursorResponse = z.object({
18
18
  /**
19
- * The maximum number of items retrieved.
20
- */
19
+ * The maximum number of items retrieved.
20
+ */
21
21
  limit: z.number(),
22
22
  /**
23
- * The cursor to use for pagination.
24
- */
23
+ * The cursor to use for pagination.
24
+ */
25
25
  nextCursor: z.string().optional()
26
26
  });
27
27
 
@@ -2,9 +2,16 @@ import z from 'zod';
2
2
 
3
3
  const UnsignedDecimalString = z.string().regex(/^\d+(\.\d+)?$/, "Must be a valid decimal string");
4
4
  const SignedDecimalString = z.string().regex(/^[+-]\d+(\.\d+)?$/, "Must be a valid signed decimal string").transform((val) => val);
5
- const Side = z.enum(["BUY", "SELL"], {
5
+ const Side = z.enum([
6
+ "BUY",
7
+ "SELL"
8
+ ], {
6
9
  message: "Side must be either BUY or SELL"
7
10
  });
8
- const AssetWeight = z.number().positive({ message: "Weight must be greater than 0" }).max(1, { message: "Weight must be less than 1" });
11
+ const AssetWeight = z.number().positive({
12
+ message: "Weight must be greater than 0"
13
+ }).max(1, {
14
+ message: "Weight must be less than 1"
15
+ });
9
16
 
10
17
  export { AssetWeight, Side, SignedDecimalString, UnsignedDecimalString };
@@ -2,29 +2,34 @@ import { z } from 'zod';
2
2
  import { InstrumentId } from '../instrument';
3
3
  import { UnsignedDecimalString, Side } from './schema';
4
4
 
5
- const TradeLegMode = z.enum(["QUANTITY", "USD"]);
5
+ const TradeLegMode = z.enum([
6
+ "QUANTITY",
7
+ "USD"
8
+ ]);
6
9
  const TradeLeg = z.object({
7
10
  /**
8
- * Instrument ID
9
- */
11
+ * Instrument ID
12
+ */
10
13
  symbol: InstrumentId,
11
14
  /**
12
- * Side
13
- */
15
+ * Side
16
+ */
14
17
  side: Side,
15
18
  /**
16
- * Mode to interpret the amount
17
- */
19
+ * Mode to interpret the amount
20
+ */
18
21
  mode: TradeLegMode,
19
22
  /**
20
- * Quantity or USD amount
21
- */
23
+ * Quantity or USD amount
24
+ */
22
25
  amount: UnsignedDecimalString,
23
26
  /**
24
- * Reduce only flag
25
- */
27
+ * Reduce only flag
28
+ */
26
29
  reduceOnly: z.boolean()
27
30
  });
28
- const TradeLegPostOnly = TradeLeg.omit({ reduceOnly: true });
31
+ const TradeLegPostOnly = TradeLeg.omit({
32
+ reduceOnly: true
33
+ });
29
34
 
30
35
  export { TradeLeg, TradeLegPostOnly };
@@ -1,5 +1,11 @@
1
1
  import { z } from 'zod';
2
2
 
3
- const Connector = z.enum(["hyperliquid", "binance", "bybit", "okx", "lighter"]);
3
+ const Connector = z.enum([
4
+ "hyperliquid",
5
+ "binance",
6
+ "bybit",
7
+ "okx",
8
+ "lighter"
9
+ ]);
4
10
 
5
11
  export { Connector };
@@ -5,129 +5,158 @@ import { InstrumentId } from '../instrument';
5
5
  import { Order } from '../order';
6
6
  import { Position } from '../position';
7
7
 
8
- const ExecutionIntent = z.enum(["OPEN", "CLOSE", "ADJUST", "REVERSE"]);
9
- const ExecutionOrderType = z.enum(["MARKET"]);
10
- const ExecutionStatus = z.enum(["IDLE", "ACTIVE", "COMPLETED", "FAILED", "CANCELLED"]);
11
- const ExecutionLegMode = z.enum(["QUANTITY", "USD"]);
8
+ const ExecutionIntent = z.enum([
9
+ "OPEN",
10
+ "CLOSE",
11
+ "ADJUST",
12
+ "REVERSE"
13
+ ]);
14
+ const ExecutionOrderType = z.enum([
15
+ "MARKET"
16
+ ]);
17
+ const ExecutionStatus = z.enum([
18
+ "IDLE",
19
+ "ACTIVE",
20
+ "COMPLETED",
21
+ "FAILED",
22
+ "CANCELLED"
23
+ ]);
24
+ const ExecutionLegMode = z.enum([
25
+ "QUANTITY",
26
+ "USD"
27
+ ]);
12
28
  const ExecutionLeg = z.object({
13
29
  /**
14
- * Instrument ID
15
- */
30
+ * Instrument ID
31
+ */
16
32
  symbol: InstrumentId,
17
33
  /**
18
- * Side
19
- */
34
+ * Side
35
+ */
20
36
  side: Side,
21
37
  /**
22
- * Mode to interpret the amount
23
- */
38
+ * Mode to interpret the amount
39
+ */
24
40
  mode: ExecutionLegMode,
25
41
  /**
26
- * Quantity or USD amount
27
- */
42
+ * Quantity or USD amount
43
+ */
28
44
  amount: UnsignedDecimalString,
29
45
  /**
30
- * Reduce only flag
31
- */
46
+ * Reduce only flag
47
+ */
32
48
  reduceOnly: z.boolean()
33
49
  });
34
50
  const BaseExecution = z.object({
35
51
  /**
36
- * Execution UUID
37
- */
52
+ * Execution UUID
53
+ */
38
54
  id: z.uuid(),
39
55
  /**
40
- * Connector
41
- */
56
+ * Connector
57
+ */
42
58
  connector: Connector,
43
59
  /**
44
- * Intent
45
- */
60
+ * Intent
61
+ */
46
62
  intent: ExecutionIntent,
47
63
  /**
48
- * Order type
49
- */
64
+ * Order type
65
+ */
50
66
  orderType: ExecutionOrderType,
51
67
  /**
52
- * Status
53
- */
68
+ * Status
69
+ */
54
70
  status: ExecutionStatus,
55
71
  /**
56
- * Error message
57
- */
72
+ * Error message
73
+ */
58
74
  error: z.string().optional(),
59
75
  /**
60
- * Created at timestamp
61
- */
76
+ * Created at timestamp
77
+ */
62
78
  createdAt: z.string(),
63
79
  /**
64
- * Updated at timestamp
65
- */
80
+ * Updated at timestamp
81
+ */
66
82
  updatedAt: z.string(),
67
83
  /**
68
- * Orders
69
- */
84
+ * Orders
85
+ */
70
86
  orders: z.array(Order).optional()
71
87
  });
72
88
  const MarketOpenExecution = BaseExecution.extend({
73
89
  /**
74
- * Intent
75
- */
90
+ * Intent
91
+ */
76
92
  intent: z.literal("OPEN"),
77
93
  /**
78
- * Order type
79
- */
94
+ * Order type
95
+ */
80
96
  orderType: z.literal("MARKET"),
81
97
  /**
82
- * Requested legs
83
- */
84
- legs: z.tuple([ExecutionLeg]).rest(ExecutionLeg)
98
+ * Requested legs
99
+ */
100
+ legs: z.tuple([
101
+ ExecutionLeg
102
+ ]).rest(ExecutionLeg)
85
103
  });
86
104
  const MarketAdjustExecution = BaseExecution.extend({
87
105
  /**
88
- * Intent
89
- */
106
+ * Intent
107
+ */
90
108
  intent: z.literal("ADJUST"),
91
109
  /**
92
- * Order type
93
- */
110
+ * Order type
111
+ */
94
112
  orderType: z.literal("MARKET"),
95
113
  /**
96
- * Position
97
- */
98
- position: Position.pick({ id: true, exposure: true }),
99
- /**
100
- * Requested legs
101
- */
102
- legs: z.tuple([ExecutionLeg]).rest(ExecutionLeg)
114
+ * Position
115
+ */
116
+ position: Position.pick({
117
+ id: true,
118
+ exposure: true
119
+ }),
120
+ /**
121
+ * Requested legs
122
+ */
123
+ legs: z.tuple([
124
+ ExecutionLeg
125
+ ]).rest(ExecutionLeg)
103
126
  });
104
127
  const MarketCloseExecution = BaseExecution.extend({
105
128
  /**
106
- * Intent
107
- */
129
+ * Intent
130
+ */
108
131
  intent: z.literal("CLOSE"),
109
132
  /**
110
- * Order type
111
- */
133
+ * Order type
134
+ */
112
135
  orderType: z.literal("MARKET"),
113
136
  /**
114
- * Position
115
- */
116
- position: Position.pick({ id: true, exposure: true })
137
+ * Position
138
+ */
139
+ position: Position.pick({
140
+ id: true,
141
+ exposure: true
142
+ })
117
143
  });
118
144
  const MarketReverseExecution = BaseExecution.extend({
119
145
  /**
120
- * Intent
121
- */
146
+ * Intent
147
+ */
122
148
  intent: z.literal("REVERSE"),
123
149
  /**
124
- * Order type
125
- */
150
+ * Order type
151
+ */
126
152
  orderType: z.literal("MARKET"),
127
153
  /**
128
- * Position
129
- */
130
- position: Position.pick({ id: true, exposure: true })
154
+ * Position
155
+ */
156
+ position: Position.pick({
157
+ id: true,
158
+ exposure: true
159
+ })
131
160
  });
132
161
  const MarketExecution = z.discriminatedUnion("intent", [
133
162
  MarketOpenExecution,
@@ -135,6 +164,8 @@ const MarketExecution = z.discriminatedUnion("intent", [
135
164
  MarketCloseExecution,
136
165
  MarketReverseExecution
137
166
  ]);
138
- const Execution = z.discriminatedUnion("orderType", [MarketExecution]);
167
+ const Execution = z.discriminatedUnion("orderType", [
168
+ MarketExecution
169
+ ]);
139
170
 
140
171
  export { BaseExecution, Execution, ExecutionIntent, ExecutionLegMode, ExecutionOrderType, ExecutionStatus, MarketAdjustExecution, MarketCloseExecution, MarketExecution, MarketOpenExecution, MarketReverseExecution };
@@ -2,7 +2,11 @@ import { z } from 'zod';
2
2
  import { normalizeArray, CursorFindParams } from '../common';
3
3
  import { Connector } from '../connector';
4
4
 
5
- const StatusEnum = z.enum(["ACTIVE", "COMPLETED", "CANCELLED"]);
5
+ const StatusEnum = z.enum([
6
+ "ACTIVE",
7
+ "COMPLETED",
8
+ "CANCELLED"
9
+ ]);
6
10
  const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(StatusEnum));
7
11
  const ExecutionListParams = CursorFindParams.extend({
8
12
  connector: Connector.optional(),
@@ -5,6 +5,8 @@ import { Execution } from './entities';
5
5
  const ExecutionListResponse = CursorResponse.extend({
6
6
  executions: z.array(Execution)
7
7
  });
8
- const GetExecutionResponse = z.object({ execution: Execution });
8
+ const GetExecutionResponse = z.object({
9
+ execution: Execution
10
+ });
9
11
 
10
12
  export { ExecutionListResponse, GetExecutionResponse };