@pear-protocol/types 2.20.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/fee/entities.d.ts +1 -0
  3. package/dist/fee/responses.d.ts +26 -0
  4. package/dist/index.js +7355 -3
  5. package/dist/rewards/entities.d.ts +28 -0
  6. package/dist/rewards/payloads.d.ts +7 -0
  7. package/dist/rewards/responses.d.ts +73 -0
  8. package/dist/statistics/queries.d.ts +25 -0
  9. package/dist/statistics/responses.d.ts +120 -0
  10. package/dist/sync/responses.d.ts +1 -0
  11. package/dist/users/entities.d.ts +4 -0
  12. package/dist/users/response.d.ts +3 -0
  13. package/package.json +4 -3
  14. package/dist/auth/api-keys.js +0 -44
  15. package/dist/auth/entities.js +0 -25
  16. package/dist/auth/index.js +0 -4
  17. package/dist/auth/payloads.js +0 -84
  18. package/dist/auth/response.js +0 -82
  19. package/dist/baskets/recommended/entities.js +0 -22
  20. package/dist/baskets/recommended/index.js +0 -2
  21. package/dist/baskets/recommended/responses.js +0 -8
  22. package/dist/baskets/saved/entities.js +0 -23
  23. package/dist/baskets/saved/payloads.js +0 -18
  24. package/dist/baskets/saved/responses.js +0 -14
  25. package/dist/bundle.js +0 -36
  26. package/dist/common/address.js +0 -5
  27. package/dist/common/array.js +0 -17
  28. package/dist/common/client-id.js +0 -5
  29. package/dist/common/hex-string.js +0 -5
  30. package/dist/common/index.js +0 -4
  31. package/dist/common/refinement.js +0 -64
  32. package/dist/common/request.js +0 -24
  33. package/dist/common/response.js +0 -28
  34. package/dist/common/schema.js +0 -18
  35. package/dist/common/trade-legs.js +0 -50
  36. package/dist/connector/index.js +0 -12
  37. package/dist/copy/entities.js +0 -151
  38. package/dist/copy/index.js +0 -5
  39. package/dist/copy/payloads.js +0 -8
  40. package/dist/copy/performance.js +0 -63
  41. package/dist/copy/queries.js +0 -20
  42. package/dist/copy/responses.js +0 -89
  43. package/dist/execution/entities.js +0 -196
  44. package/dist/execution/index.js +0 -3
  45. package/dist/execution/queries.js +0 -18
  46. package/dist/execution/responses.js +0 -12
  47. package/dist/fee/entities.js +0 -34
  48. package/dist/fee/index.js +0 -3
  49. package/dist/fee/queries.js +0 -12
  50. package/dist/fee/responses.js +0 -29
  51. package/dist/fill/entities.js +0 -82
  52. package/dist/fill/index.js +0 -3
  53. package/dist/fill/queries.js +0 -14
  54. package/dist/fill/responses.js +0 -23
  55. package/dist/funding/entities.js +0 -16
  56. package/dist/funding/index.js +0 -3
  57. package/dist/funding/queries.js +0 -8
  58. package/dist/funding/responses.js +0 -11
  59. package/dist/instrument/entities.js +0 -102
  60. package/dist/instrument/index.js +0 -3
  61. package/dist/instrument/queries.js +0 -15
  62. package/dist/instrument/responses.js +0 -20
  63. package/dist/instrument-precision/index.js +0 -56
  64. package/dist/ladder/entities.js +0 -24
  65. package/dist/ladder/index.js +0 -4
  66. package/dist/ladder/payloads.js +0 -96
  67. package/dist/ladder/queries.js +0 -12
  68. package/dist/ladder/responses.js +0 -18
  69. package/dist/leverage/index.js +0 -2
  70. package/dist/leverage/payloads.js +0 -14
  71. package/dist/leverage/response.js +0 -5
  72. package/dist/margin/index.js +0 -2
  73. package/dist/margin/payloads.js +0 -20
  74. package/dist/margin/response.js +0 -11
  75. package/dist/market/entities.js +0 -52
  76. package/dist/market/index.js +0 -4
  77. package/dist/market/payloads.js +0 -11
  78. package/dist/market/queries.js +0 -19
  79. package/dist/market/responses.js +0 -18
  80. package/dist/misc/index.js +0 -2
  81. package/dist/misc/payloads.js +0 -99
  82. package/dist/misc/responses.js +0 -85
  83. package/dist/notification/entities.js +0 -274
  84. package/dist/notification/index.js +0 -4
  85. package/dist/notification/payloads.js +0 -15
  86. package/dist/notification/queries.js +0 -29
  87. package/dist/notification/responses.js +0 -20
  88. package/dist/order/entities.js +0 -81
  89. package/dist/order/index.js +0 -1
  90. package/dist/portfolio/entities.js +0 -77
  91. package/dist/portfolio/index.js +0 -3
  92. package/dist/portfolio/queries.js +0 -34
  93. package/dist/portfolio/responses.js +0 -33
  94. package/dist/position/entities.js +0 -433
  95. package/dist/position/index.js +0 -3
  96. package/dist/position/queries.js +0 -109
  97. package/dist/position/responses.js +0 -41
  98. package/dist/price/entities.js +0 -10
  99. package/dist/price/index.js +0 -3
  100. package/dist/price/queries.js +0 -8
  101. package/dist/price/responses.js +0 -15
  102. package/dist/realtime/channels.js +0 -16
  103. package/dist/realtime/frames.js +0 -140
  104. package/dist/realtime/index.js +0 -6
  105. package/dist/realtime/messages.js +0 -118
  106. package/dist/realtime/public-events.js +0 -92
  107. package/dist/realtime/user-events.js +0 -32
  108. package/dist/realtime/vault-events.js +0 -42
  109. package/dist/rebalance/entities.js +0 -86
  110. package/dist/rebalance/index.js +0 -4
  111. package/dist/rebalance/payloads.js +0 -56
  112. package/dist/rebalance/queries.js +0 -14
  113. package/dist/rebalance/responses.js +0 -41
  114. package/dist/schedule/entities.js +0 -239
  115. package/dist/schedule/index.js +0 -5
  116. package/dist/schedule/payloads.js +0 -85
  117. package/dist/schedule/queries.js +0 -30
  118. package/dist/schedule/randomization.js +0 -15
  119. package/dist/schedule/responses.js +0 -22
  120. package/dist/schedule/twap-config.js +0 -29
  121. package/dist/statistics/entities.js +0 -105
  122. package/dist/statistics/index.js +0 -3
  123. package/dist/statistics/queries.js +0 -93
  124. package/dist/statistics/responses.js +0 -17
  125. package/dist/sync/index.js +0 -2
  126. package/dist/sync/payloads.js +0 -136
  127. package/dist/sync/responses.js +0 -26
  128. package/dist/tca/entities.js +0 -9
  129. package/dist/tca/index.js +0 -3
  130. package/dist/tca/queries.js +0 -14
  131. package/dist/tca/responses.js +0 -126
  132. package/dist/trade/entities.js +0 -101
  133. package/dist/trade/index.js +0 -4
  134. package/dist/trade/payloads.js +0 -84
  135. package/dist/trade/queries.js +0 -9
  136. package/dist/trade/responses.js +0 -25
  137. package/dist/trade-accounts/entities.js +0 -61
  138. package/dist/trade-accounts/index.js +0 -4
  139. package/dist/trade-accounts/payloads.js +0 -132
  140. package/dist/trade-accounts/queries.js +0 -7
  141. package/dist/trade-accounts/response.js +0 -79
  142. package/dist/traders/index.js +0 -2
  143. package/dist/traders/performance.js +0 -21
  144. package/dist/traders/public.js +0 -192
  145. package/dist/trigger/common/index.js +0 -39
  146. package/dist/trigger/entities/conditions.js +0 -174
  147. package/dist/trigger/entities/index.js +0 -257
  148. package/dist/trigger/index.js +0 -9
  149. package/dist/trigger/oracle.js +0 -22
  150. package/dist/trigger/payloads/conditions.js +0 -213
  151. package/dist/trigger/payloads/config.js +0 -3
  152. package/dist/trigger/payloads/index.js +0 -173
  153. package/dist/trigger/queries.js +0 -16
  154. package/dist/trigger/refinement/index.js +0 -2
  155. package/dist/trigger/refinement/static.refinement.js +0 -50
  156. package/dist/trigger/refinement/trailing.refinement.js +0 -83
  157. package/dist/trigger/responses.js +0 -18
  158. package/dist/triggers/entities.js +0 -27
  159. package/dist/triggers/index.js +0 -3
  160. package/dist/triggers/queries.js +0 -10
  161. package/dist/triggers/responses.js +0 -9
  162. package/dist/users/entities.js +0 -45
  163. package/dist/users/index.js +0 -4
  164. package/dist/users/payloads.js +0 -33
  165. package/dist/users/queries.js +0 -8
  166. package/dist/users/response.js +0 -27
  167. package/dist/vaults/entities.js +0 -96
  168. package/dist/vaults/index.js +0 -4
  169. package/dist/vaults/payloads.js +0 -65
  170. package/dist/vaults/queries.js +0 -66
  171. package/dist/vaults/responses.js +0 -368
  172. /package/dist/{baskets/saved/index.js → rewards/index.d.ts} +0 -0
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
- import { RefineUniqueSymbols, RefineWeightingSum } from '../../common/refinement';
3
- import { SavedBasketLeg } from './entities';
4
-
5
- const SavedBasketName = z.string().trim().min(1, "Name is required").max(48).describe("Display name, unique per trade account (case-insensitive)");
6
- const SavedBasketLegs = z.tuple([
7
- SavedBasketLeg
8
- ]).rest(SavedBasketLeg).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum).refine((value) => value.length <= 20, "Basket must have at most 20 legs").describe("At least one leg, up to 20");
9
- const CreateSavedBasketPayload = z.object({
10
- name: SavedBasketName,
11
- legs: SavedBasketLegs
12
- }).describe("Save the current basket under a name");
13
- const UpdateSavedBasketPayload = z.object({
14
- name: SavedBasketName.optional(),
15
- legs: SavedBasketLegs.optional()
16
- }).refine((value) => value.name !== void 0 || value.legs !== void 0, "Provide a name or legs to update").describe("Rename a saved basket and/or replace its legs");
17
-
18
- export { CreateSavedBasketPayload, UpdateSavedBasketPayload };
@@ -1,14 +0,0 @@
1
- import { z } from 'zod';
2
- import { SavedBasket } from './entities';
3
-
4
- const SavedBasketListResponse = z.object({
5
- baskets: z.array(SavedBasket)
6
- });
7
- const CreateSavedBasketResponse = z.object({
8
- basket: SavedBasket
9
- });
10
- const UpdateSavedBasketResponse = z.object({
11
- basket: SavedBasket
12
- });
13
-
14
- export { CreateSavedBasketResponse, SavedBasketListResponse, UpdateSavedBasketResponse };
package/dist/bundle.js DELETED
@@ -1,36 +0,0 @@
1
- export * from './auth';
2
- export * from './baskets/recommended';
3
- export * from './baskets/saved';
4
- export * from './common/address';
5
- export * from './common/trade-legs';
6
- export * from './connector';
7
- export * from './copy';
8
- export * from './execution';
9
- export * from './fee';
10
- export * from './fill';
11
- export * from './funding';
12
- export * from './instrument';
13
- export * from './instrument-precision';
14
- export * from './ladder';
15
- export * from './leverage';
16
- export * from './margin';
17
- export * from './market';
18
- export * from './misc';
19
- export * from './notification';
20
- export * from './order';
21
- export * from './portfolio';
22
- export * from './position';
23
- export * from './price';
24
- export * from './realtime';
25
- export * from './rebalance';
26
- export * from './schedule';
27
- export * from './statistics';
28
- export * from './sync';
29
- export * from './tca';
30
- export * from './trade';
31
- export * from './trade-accounts';
32
- export * from './traders';
33
- export * from './trigger';
34
- export * from './triggers';
35
- export * from './users';
36
- export * from './vaults';
@@ -1,5 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const EthereumAddress = z.string().regex(/^0x[a-fA-F0-9]{40}$/).transform((val) => val.toLowerCase());
4
-
5
- export { EthereumAddress };
@@ -1,17 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- function normalizeArray(val) {
4
- if (!val) return void 0;
5
- if (Array.isArray(val)) return val;
6
- if (typeof val === "string") {
7
- return val.includes(",") ? val.split(",").map((s) => s.trim()) : [
8
- val
9
- ];
10
- }
11
- return [
12
- String(val)
13
- ];
14
- }
15
- __name(normalizeArray, "normalizeArray");
16
-
17
- export { normalizeArray };
@@ -1,5 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const ClientIdCode = z.string().min(1).max(64).optional().describe("Attribution route code (client_ids.code)");
4
-
5
- export { ClientIdCode };
@@ -1,5 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const HexString = z.string().min(2, "Must include at least two hex characters").regex(/^0x[a-fA-F0-9]+$/, "Must be a valid hex string").transform((val) => val);
4
-
5
- export { HexString };
@@ -1,4 +0,0 @@
1
- export * from './array';
2
- export * from './client-id';
3
- export * from './request';
4
- export * from './response';
@@ -1,64 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const RefineMinimumOneSymbol = /* @__PURE__ */ __name((basket, ctx) => {
4
- if (basket.length < 1) {
5
- ctx.addIssue({
6
- code: "custom",
7
- message: "At least one symbol is required."
8
- });
9
- }
10
- }, "RefineMinimumOneSymbol");
11
- const RefineMinimumTwoSymbols = /* @__PURE__ */ __name((basket, ctx) => {
12
- if (basket.length < 2) {
13
- ctx.addIssue({
14
- code: "custom",
15
- message: "At least two symbols are required."
16
- });
17
- }
18
- }, "RefineMinimumTwoSymbols");
19
- const RefineTwoUniqueSymbols = /* @__PURE__ */ __name((pair, ctx) => {
20
- if (pair.symbol_a === pair.symbol_b) {
21
- ctx.addIssue({
22
- code: "custom",
23
- message: "Symbols cannot be the same."
24
- });
25
- }
26
- }, "RefineTwoUniqueSymbols");
27
- const RefineUniqueSymbols = /* @__PURE__ */ __name((basket, ctx) => {
28
- const symbols = basket.map((item) => item.symbol);
29
- const uniqueSymbols = new Set(symbols);
30
- if (symbols.length !== uniqueSymbols.size) {
31
- const duplicates = symbols.filter((symbol, index) => symbols.indexOf(symbol) !== index);
32
- ctx.addIssue({
33
- code: "custom",
34
- message: `Duplicate symbols found: ${[
35
- ...new Set(duplicates)
36
- ].join(", ")}`,
37
- path: [
38
- "basket"
39
- ]
40
- });
41
- }
42
- }, "RefineUniqueSymbols");
43
- const RefineLegIdMatchesSymbol = /* @__PURE__ */ __name((leg, ctx) => {
44
- if (leg.id !== void 0 && leg.id !== leg.symbol) {
45
- ctx.addIssue({
46
- code: "custom",
47
- message: `Leg id and symbol must name the same instrument, got id "${leg.id}" and symbol "${leg.symbol}".`
48
- });
49
- }
50
- }, "RefineLegIdMatchesSymbol");
51
- const RefineWeightingSum = /* @__PURE__ */ __name((basket, ctx) => {
52
- const totalWeight = basket.reduce((acc, curr) => acc + curr.weight, 0);
53
- if (Math.abs(totalWeight - 1) > 1e-9) {
54
- ctx.addIssue({
55
- code: "custom",
56
- message: `The sum of weights must be exactly 1, but got ${totalWeight}`,
57
- path: [
58
- "basket"
59
- ]
60
- });
61
- }
62
- }, "RefineWeightingSum");
63
-
64
- export { RefineLegIdMatchesSymbol, RefineMinimumOneSymbol, RefineMinimumTwoSymbols, RefineTwoUniqueSymbols, RefineUniqueSymbols, RefineWeightingSum };
@@ -1,24 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const CursorFindParams = z.object({
4
- /**
5
- * The maximum number of items to retrieve.
6
- */
7
- limit: z.coerce.number().int().positive().max(2e3).optional().default(20),
8
- /**
9
- * Opaque pagination cursor returned by the API.
10
- */
11
- cursor: z.string().optional()
12
- });
13
- const PaginationFindParams = z.object({
14
- /**
15
- * The maximum number of items to retrieve.
16
- */
17
- limit: z.coerce.number().int().positive().max(100).optional().default(20),
18
- /**
19
- * The number of items to skip before retrieving the returned items.
20
- */
21
- offset: z.coerce.number().int().min(0).optional().default(0)
22
- });
23
-
24
- export { CursorFindParams, PaginationFindParams };
@@ -1,28 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const PaginatedResponse = z.object({
4
- /**
5
- * The maximum number of items retrieved.
6
- */
7
- limit: z.number(),
8
- /**
9
- * The number of items to skip before retrieving the returned items.
10
- */
11
- offset: z.number(),
12
- /**
13
- * The total number of items.
14
- */
15
- count: z.number()
16
- });
17
- const CursorResponse = z.object({
18
- /**
19
- * The maximum number of items retrieved.
20
- */
21
- limit: z.number(),
22
- /**
23
- * The cursor to use for pagination.
24
- */
25
- nextCursor: z.string().optional()
26
- });
27
-
28
- export { CursorResponse, PaginatedResponse };
@@ -1,18 +0,0 @@
1
- import z from 'zod';
2
-
3
- const UnsignedDecimalString = z.string().regex(/^\d+(\.\d+)?$/, "Must be a valid decimal string");
4
- const DecimalString = z.string().regex(/^[+-]?\d+(\.\d+)?$/, "Must be a valid decimal string");
5
- const SignedDecimalString = z.string().regex(/^[+-]\d+(\.\d+)?$/, "Must be a valid signed decimal string").transform((val) => val);
6
- const Side = z.enum([
7
- "BUY",
8
- "SELL"
9
- ], {
10
- message: "Side must be either BUY or SELL"
11
- });
12
- const AssetWeight = z.number().positive({
13
- message: "Weight must be greater than 0"
14
- }).max(1, {
15
- message: "Weight must be less than 1"
16
- });
17
-
18
- export { AssetWeight, DecimalString, Side, SignedDecimalString, UnsignedDecimalString };
@@ -1,50 +0,0 @@
1
- import { z } from 'zod';
2
- import { InstrumentId } from '../instrument';
3
- import { RefineLegIdMatchesSymbol } from './refinement';
4
- import { UnsignedDecimalString, Side } from './schema';
5
-
6
- const TradeLegMode = z.enum([
7
- "QUANTITY",
8
- "USD"
9
- ]);
10
- const TradeLegShape = z.object({
11
- /** SYMBOL-MIGRATION switch-to-id: mirrors `symbol` today; becomes required once requests always carry `id`. */
12
- id: InstrumentId.optional(),
13
- /**
14
- * Instrument ID
15
- */
16
- symbol: InstrumentId,
17
- /**
18
- * Side
19
- */
20
- side: Side,
21
- /**
22
- * Mode to interpret the amount
23
- */
24
- mode: TradeLegMode,
25
- /**
26
- * Quantity or USD amount
27
- */
28
- amount: UnsignedDecimalString,
29
- /**
30
- * Reduce only flag
31
- */
32
- reduceOnly: z.boolean()
33
- });
34
- const TradeLegMaxImpactPrice = {
35
- /** Reject the former wire field instead of silently stripping a caller's price constraint. */
36
- limitPrice: z.never({
37
- error: "limitPrice is no longer supported; use maxImpactPrice instead."
38
- }).optional(),
39
- maxImpactPrice: UnsignedDecimalString.refine((value) => Number(value) > 0, "Max impact price must be positive").optional()
40
- };
41
- const TradeLeg = TradeLegShape.superRefine(RefineLegIdMatchesSymbol);
42
- const TradeLegPostOnly = TradeLegShape.omit({
43
- reduceOnly: true
44
- }).superRefine(RefineLegIdMatchesSymbol);
45
- const TradeLegWithMaxImpactPrice = TradeLegShape.extend(TradeLegMaxImpactPrice).strict().superRefine(RefineLegIdMatchesSymbol);
46
- const TradeLegPostOnlyWithMaxImpactPrice = TradeLegShape.omit({
47
- reduceOnly: true
48
- }).extend(TradeLegMaxImpactPrice).strict().superRefine(RefineLegIdMatchesSymbol);
49
-
50
- export { TradeLeg, TradeLegPostOnly, TradeLegPostOnlyWithMaxImpactPrice, TradeLegWithMaxImpactPrice };
@@ -1,12 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const Connector = z.enum([
4
- "hyperliquid",
5
- "binance",
6
- "bybit",
7
- "okx",
8
- "lighter",
9
- "lighter_rhc"
10
- ]);
11
-
12
- export { Connector };
@@ -1,151 +0,0 @@
1
- import { z } from 'zod';
2
- import { SignedDecimalString, UnsignedDecimalString } from '../common/schema';
3
- import { Connector } from '../connector';
4
- import { InstrumentId } from '../instrument';
5
- import { CopyPerformance, CopyEndCaptureStatus, CopyStartSnapshot } from './performance';
6
-
7
- const CopySubscriptionStatus = z.enum([
8
- "ACTIVE",
9
- "ENDED"
10
- ]);
11
- const CopySizing = z.discriminatedUnion("mode", [
12
- z.object({
13
- /**
14
- * Entry is the leader's own notional-over-equity fraction applied to the follower's equity, taken
15
- * at the moment of entry. There is nothing for the follower to size.
16
- */
17
- mode: z.literal("LEADER_EQUITY_FRACTION")
18
- })
19
- ]);
20
- const CopySubscriptionMetrics = z.object({
21
- volume: UnsignedDecimalString.describe("Lifetime executed USD turnover across opens and closes; excludes fees and funding"),
22
- grossRealizedPnl: SignedDecimalString.describe("Gross realized USD PnL over attributed positions during the copy period, including partial reductions; excludes fees and funding"),
23
- grossUpnl: SignedDecimalString.describe("Gross unrealized USD PnL observed for the subscription; fixed at the actual asynchronous end capture for ended subscriptions; excludes fees and funding"),
24
- fundingPayment: SignedDecimalString.describe("Signed USD funding attributed to exposure during the copy period; positive values are received funding"),
25
- tradeFee: SignedDecimalString.describe("Signed USD trade fees on attributed position fills; negative values are rebates"),
26
- pearFee: SignedDecimalString.describe("Signed USD Pear fees on attributed position fills; negative values are rebates"),
27
- totalNetPnl: SignedDecimalString.describe("Gross realized plus gross unrealized plus fundingPayment minus tradeFee and pearFee in USD")
28
- });
29
- const CopySubscription = z.object({
30
- id: z.uuid(),
31
- leaderTradeAccountId: z.uuid().describe("The account being copied"),
32
- followerTradeAccountId: z.uuid().describe("The account copies land in"),
33
- connector: Connector,
34
- status: CopySubscriptionStatus,
35
- sizing: CopySizing,
36
- startSnapshot: CopyStartSnapshot.optional(),
37
- endCapture: CopyEndCaptureStatus.optional(),
38
- endReason: z.enum([
39
- "UNSUBSCRIBED",
40
- "MANUAL_TRADE",
41
- "EXTERNAL_POSITION_DETECTED",
42
- "LEADER_EXTERNAL_ACTIVITY",
43
- "FAILURE_THRESHOLD"
44
- ]).optional(),
45
- performance: CopyPerformance.optional(),
46
- ...CopySubscriptionMetrics.omit({
47
- volume: true
48
- }).partial().shape,
49
- roi: SignedDecimalString.optional().describe("Whole-subscription net PnL divided by positive starting account equity, times 100; included with complete period performance"),
50
- provisional: z.literal(true).optional(),
51
- latestFillAt: z.string().datetime().optional().describe("Latest confirmed fill included in period accounting"),
52
- createdAt: z.string().describe("ISO 8601"),
53
- endedAt: z.string().optional().describe("ISO 8601; set once the follower unsubscribed")
54
- });
55
- const CopySubscriptionWithMetrics = CopySubscription.extend({
56
- ...CopySubscriptionMetrics.shape,
57
- status: z.literal("ACTIVE")
58
- });
59
- const CopyEndedSubscriptionWithVolume = CopySubscription.extend({
60
- status: z.literal("ENDED"),
61
- volume: CopySubscriptionMetrics.shape.volume
62
- });
63
- const CopySubscriptionRead = z.discriminatedUnion("status", [
64
- CopySubscriptionWithMetrics,
65
- CopyEndedSubscriptionWithVolume
66
- ]);
67
- const CopyActivityOutcome = z.enum([
68
- "COPIED",
69
- "PARTIAL",
70
- "SKIPPED",
71
- "FAILED"
72
- ]);
73
- const CopyActivityState = z.enum([
74
- "RECORDED",
75
- "DISPATCHED",
76
- "SETTLED"
77
- ]);
78
- const CopyActivityLeg = z.object({
79
- symbol: InstrumentId,
80
- targetQuantity: SignedDecimalString,
81
- deltaQuantity: SignedDecimalString
82
- });
83
- const CopySkipReason = z.enum([
84
- "SUBSCRIPTION_NOT_ACTIVE",
85
- "POSITION_EXCLUDED",
86
- "INCLUDED_IN_JOIN",
87
- "VENUE_MISMATCH",
88
- "BELOW_VENUE_MINIMUM",
89
- "PAIR_ALREADY_ENTERED",
90
- "ENTRY_EXPIRED",
91
- "FOLLOWER_LEG_ABSENT",
92
- "LEADER_LEG_REOPENED",
93
- "NO_FOLLOWER_DELTA",
94
- "LEADER_EQUITY_UNREADABLE",
95
- "FOLLOWER_EQUITY_UNREADABLE",
96
- "PRICE_UNAVAILABLE",
97
- "LEVERAGE_NOT_APPLIED"
98
- ]);
99
- const CopyLeaderAction = z.enum([
100
- "OPEN",
101
- "ADJUST",
102
- "CLOSE",
103
- "REVERSE"
104
- ]);
105
- const CopyExecutionSource = z.discriminatedUnion("origin", [
106
- z.object({
107
- origin: z.literal("DIRECT")
108
- }),
109
- z.object({
110
- origin: z.literal("SCHEDULE"),
111
- scheduleId: z.string()
112
- }),
113
- z.object({
114
- origin: z.literal("TRIGGER"),
115
- triggerId: z.string(),
116
- triggerIntent: z.enum([
117
- "OPEN",
118
- "ADJUST",
119
- "CLOSE"
120
- ]),
121
- bracketType: z.string().optional(),
122
- ladderId: z.string().optional()
123
- }),
124
- z.object({
125
- origin: z.literal("AUTO_REBALANCE"),
126
- configId: z.string()
127
- })
128
- ]);
129
- const CopyActivity = z.object({
130
- id: z.uuid(),
131
- leaderAction: CopyLeaderAction.describe("What the leader did"),
132
- executionSource: CopyExecutionSource.optional().describe("Leader source; absent for admission position joins"),
133
- state: CopyActivityState,
134
- outcome: CopyActivityOutcome.optional().describe("Absent until dispatch work settles"),
135
- skipReason: CopySkipReason.optional().describe("Why nothing was placed; set when the outcome is SKIPPED"),
136
- failureReason: z.string().optional().describe("Why execution stopped; set when the outcome is FAILED or PARTIAL"),
137
- followerLegs: z.array(CopyActivityLeg).describe("Actual fills received by the follower"),
138
- leaderEquityFraction: z.string().optional().describe("The leader position notional over their equity at that moment; absent when unvaluable"),
139
- createdAt: z.string().describe("ISO 8601")
140
- });
141
- const CopyFollower = z.object({
142
- tradeAccountId: z.uuid(),
143
- status: z.literal("ACTIVE"),
144
- followedAt: z.string().describe("ISO 8601 subscription creation time"),
145
- xUserId: z.string().optional(),
146
- xHandle: z.string().optional(),
147
- xName: z.string().optional(),
148
- xAvatarUrl: z.string().optional()
149
- });
150
-
151
- export { CopyActivity, CopyActivityLeg, CopyActivityOutcome, CopyActivityState, CopyEndedSubscriptionWithVolume, CopyExecutionSource, CopyFollower, CopyLeaderAction, CopySizing, CopySkipReason, CopySubscription, CopySubscriptionMetrics, CopySubscriptionRead, CopySubscriptionStatus, CopySubscriptionWithMetrics };
@@ -1,5 +0,0 @@
1
- export * from './entities';
2
- export * from './payloads';
3
- export * from './performance';
4
- export * from './queries';
5
- export * from './responses';
@@ -1,8 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const CreateCopySubscription = z.object({
4
- leaderTradeAccountId: z.uuid().describe("The account to copy"),
5
- syncExistingPositions: z.boolean().default(true).describe("Copy existing leader positions when subscribing")
6
- });
7
-
8
- export { CreateCopySubscription };
@@ -1,63 +0,0 @@
1
- import { z } from 'zod';
2
- import { SignedDecimalString } from '../common/schema';
3
-
4
- const Decimal = z.string().regex(/^[+-]?\d+(?:\.\d+)?$/);
5
- const CopyPnlBreakdown = z.object({
6
- grossRealizedPnl: SignedDecimalString,
7
- unrealizedPnl: SignedDecimalString,
8
- funding: SignedDecimalString,
9
- tradingFees: SignedDecimalString,
10
- platformFees: SignedDecimalString,
11
- netPnl: SignedDecimalString
12
- });
13
- const CopyStartingAccount = z.object({
14
- tradeAccountId: z.string(),
15
- capturedAt: z.string().datetime(),
16
- initialEquityUsd: Decimal,
17
- pnl: CopyPnlBreakdown
18
- });
19
- const CopyStartSnapshot = z.object({
20
- leader: CopyStartingAccount,
21
- follower: CopyStartingAccount
22
- });
23
- const CopyAccountPerformance = z.object({
24
- tradeAccountId: z.string(),
25
- capturedAt: z.string().datetime(),
26
- provisional: z.literal(true),
27
- latestFillAt: z.string().datetime().optional(),
28
- pnl: CopyPnlBreakdown,
29
- returnOnStartingEquityPercent: SignedDecimalString.optional()
30
- });
31
- const CopyCaptureTiming = z.literal("DELAYED");
32
- const CopyPerformance = z.object({
33
- kind: z.literal("OBSERVED"),
34
- boundaryAt: z.string().datetime(),
35
- timing: z.union([
36
- z.literal("LIVE"),
37
- CopyCaptureTiming
38
- ]),
39
- accountTimings: z.object({
40
- leader: CopyCaptureTiming,
41
- follower: CopyCaptureTiming
42
- }).optional(),
43
- leader: CopyAccountPerformance,
44
- follower: CopyAccountPerformance
45
- });
46
- const CopyEndCapture = z.object({
47
- leader: CopyAccountPerformance,
48
- follower: CopyAccountPerformance
49
- });
50
- const CopyEndCaptureStatus = z.discriminatedUnion("status", [
51
- z.object({
52
- status: z.literal("PENDING")
53
- }),
54
- z.object({
55
- status: z.literal("FAILED")
56
- }),
57
- z.object({
58
- status: z.literal("COMPLETE"),
59
- snapshot: CopyEndCapture
60
- })
61
- ]);
62
-
63
- export { CopyAccountPerformance, CopyCaptureTiming, CopyEndCapture, CopyEndCaptureStatus, CopyPerformance, CopyPnlBreakdown, CopyStartSnapshot, CopyStartingAccount };
@@ -1,20 +0,0 @@
1
- import { z } from 'zod';
2
- import { CopySubscriptionStatus } from './entities';
3
-
4
- const CopySubscriptionListQuery = z.object({
5
- status: CopySubscriptionStatus.optional()
6
- });
7
- const CopyActivityListParams = z.object({
8
- limit: z.coerce.number().int().min(1).max(200).default(50)
9
- });
10
- const CopyStatsParams = z.object({
11
- startDate: z.coerce.date().optional(),
12
- endDate: z.coerce.date().optional()
13
- }).refine((params) => !params.startDate || !params.endDate || params.startDate < params.endDate, {
14
- message: "startDate must be before endDate",
15
- path: [
16
- "startDate"
17
- ]
18
- });
19
-
20
- export { CopyActivityListParams, CopyStatsParams, CopySubscriptionListQuery };
@@ -1,89 +0,0 @@
1
- import { z } from 'zod';
2
- import { UnsignedDecimalString } from '../common/schema';
3
- import { CopySubscriptionWithMetrics, CopyFollower, CopySubscription, CopySkipReason, CopySubscriptionRead, CopyActivity, CopySubscriptionStatus } from './entities';
4
-
5
- const CopyStateResponse = z.discriminatedUnion("state", [
6
- z.object({
7
- state: z.literal("NONE")
8
- }),
9
- z.object({
10
- state: z.literal("ACTIVE"),
11
- subscription: CopySubscriptionWithMetrics
12
- })
13
- ]);
14
- const CopyFollowersResponse = z.object({
15
- followers: z.array(CopyFollower),
16
- followerCount: z.number().int().nonnegative()
17
- });
18
- const CopySubscriptionResponse = z.object({
19
- subscription: CopySubscription
20
- });
21
- const EndCopySubscriptionResponse = CopySubscriptionResponse;
22
- const CopyJoinResult = z.discriminatedUnion("outcome", [
23
- z.object({
24
- leaderPositionId: z.uuid(),
25
- outcome: z.literal("COPIED"),
26
- positionId: z.uuid()
27
- }),
28
- z.object({
29
- leaderPositionId: z.uuid(),
30
- outcome: z.literal("PARTIAL"),
31
- positionId: z.uuid(),
32
- reason: z.string()
33
- }),
34
- z.object({
35
- leaderPositionId: z.uuid(),
36
- outcome: z.literal("SKIPPED"),
37
- reason: CopySkipReason
38
- }),
39
- z.object({
40
- leaderPositionId: z.uuid(),
41
- outcome: z.literal("FAILED"),
42
- reason: z.string()
43
- }),
44
- z.object({
45
- leaderPositionId: z.uuid(),
46
- outcome: z.literal("UNCONFIRMED")
47
- })
48
- ]);
49
- const CreateCopySubscriptionResponse = CopySubscriptionResponse.extend({
50
- joinResults: z.array(CopyJoinResult)
51
- });
52
- const CopySubscriptionListResponse = z.object({
53
- subscriptions: z.array(CopySubscriptionRead)
54
- });
55
- const CopyActivityListResponse = z.object({
56
- activities: z.array(CopyActivity)
57
- });
58
- const CopyHealthResponse = z.object({
59
- status: z.enum([
60
- "ok",
61
- "degraded"
62
- ]),
63
- consumerRunning: z.boolean(),
64
- acceptanceBlocked: z.boolean().optional(),
65
- outbox: z.object({
66
- pending: z.number().int().nonnegative(),
67
- failed: z.number().int().nonnegative()
68
- }).optional()
69
- });
70
- const CopyFollowerStats = CopyFollower.pick({
71
- tradeAccountId: true,
72
- xUserId: true,
73
- xHandle: true,
74
- xName: true,
75
- xAvatarUrl: true
76
- }).extend({
77
- status: CopySubscriptionStatus,
78
- copiedTrades: z.number().int().nonnegative(),
79
- copiedVolumeUsd: UnsignedDecimalString
80
- });
81
- const CopyStatsResponse = z.object({
82
- currentFollowerCount: z.number().int().nonnegative(),
83
- lifetimeFollowerCount: z.number().int().nonnegative(),
84
- copiedTrades: z.number().int().nonnegative(),
85
- copiedVolumeUsd: UnsignedDecimalString,
86
- followers: z.array(CopyFollowerStats)
87
- });
88
-
89
- export { CopyActivityListResponse, CopyFollowerStats, CopyFollowersResponse, CopyHealthResponse, CopyJoinResult, CopyStateResponse, CopyStatsResponse, CopySubscriptionListResponse, CopySubscriptionResponse, CreateCopySubscriptionResponse, EndCopySubscriptionResponse };