@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,136 +0,0 @@
1
- import { z } from 'zod';
2
- import { UnsignedDecimalString, DecimalString, Side, SignedDecimalString } from '../common/schema';
3
- import { Connector } from '../connector';
4
- import { InstrumentId } from '../instrument';
5
- import { PositionClosedReason, PositionStatus, PositionOrigin } from '../position/entities';
6
-
7
- var __defProp = Object.defineProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- const ExchangeFillId = z.string().trim().min(1, "Exchange fill ID must be non-empty");
10
- const MsTimestamp = z.number().int().positive().describe("Unix timestamp in milliseconds");
11
- const LiquidationMark = z.object({
12
- mark: UnsignedDecimalString
13
- }).nullable();
14
- const TradeFee = DecimalString;
15
- const OriginalFillRef = z.object({
16
- exchangeFillId: ExchangeFillId,
17
- quantity: UnsignedDecimalString
18
- });
19
- const UnknownExternalFill = z.object({
20
- exchangeFillId: ExchangeFillId,
21
- cloid: z.string().nullable(),
22
- connector: Connector,
23
- symbol: InstrumentId,
24
- price: UnsignedDecimalString,
25
- quantity: UnsignedDecimalString,
26
- side: Side,
27
- reduceOnly: z.boolean(),
28
- timestamp: MsTimestamp,
29
- tradeFee: TradeFee,
30
- builderFee: UnsignedDecimalString,
31
- liquidation: LiquidationMark
32
- });
33
- const SyncFillsSinceRequest = z.object({
34
- overlapMs: z.number().int().positive()
35
- });
36
- const SyncFundingSinceRequest = z.object({
37
- overlapMs: z.number().int().positive()
38
- });
39
- const ExternalPosition = z.object({
40
- symbol: InstrumentId,
41
- size: UnsignedDecimalString.describe("BASE units, contractSize applied; always >= 0"),
42
- side: Side.describe("sign of the net position"),
43
- entryPrice: UnsignedDecimalString.describe("exchange-reported average entry"),
44
- markPrice: UnsignedDecimalString
45
- });
46
- const ApplicableFill = z.object({
47
- // Deterministic synthetic id (`synthetic-{positionKey}-{symbol}-{side}`) for synthetic fills,
48
- // exchange-native id for real fills.
49
- exchangeFillId: ExchangeFillId,
50
- cloid: z.string().nullable(),
51
- connector: Connector,
52
- symbol: InstrumentId,
53
- side: Side,
54
- quantity: UnsignedDecimalString.describe("BASE units"),
55
- price: UnsignedDecimalString.describe('"0" only on an unpriceable gone-close synthetic'),
56
- usd: UnsignedDecimalString.describe('"0" only on an unpriceable gone-close synthetic'),
57
- timestamp: MsTimestamp.describe("ms \u2014 apply replays in this order"),
58
- reduceOnly: z.boolean(),
59
- synthetic: z.boolean(),
60
- isExternal: z.boolean(),
61
- tradeFee: TradeFee,
62
- builderFee: UnsignedDecimalString,
63
- closedReason: PositionClosedReason.optional().describe("e.g. NETTED for a synthetic close fill"),
64
- liquidation: LiquidationMark.unwrap().extend({
65
- outcome: z.enum([
66
- "CLOSED",
67
- "REDUCED"
68
- ]).optional().describe("Position outcome after this reducing slice")
69
- }).nullable().optional(),
70
- original: OriginalFillRef.optional()
71
- });
72
- const ApplicableMetadata = z.object({
73
- initialExposureUSD: z.record(InstrumentId, SignedDecimalString).describe("opening cost basis from this position\u2019s own real fills; partial map allowed")
74
- });
75
- const ApplicablePosition = z.object({
76
- positionKey: z.string().trim().min(1, "positionKey must be non-empty"),
77
- exposure: z.record(InstrumentId, SignedDecimalString).describe("final position exposure (signed, BASE units)"),
78
- origin: PositionOrigin,
79
- status: PositionStatus,
80
- closedReason: PositionClosedReason.optional().describe("set when status is CLOSED, e.g. NETTED"),
81
- fills: z.array(ApplicableFill).min(1, "Applicable must carry at least one fill"),
82
- metadata: ApplicableMetadata
83
- });
84
- const WATERMARK_FUTURE_SKEW_MS = 3e5;
85
- const SyncMeta = z.object({
86
- externalMaxTs: z.number().int().nonnegative().refine((timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS, "externalMaxTs must not be ahead of server time").nullable().describe("watermark advance source")
87
- });
88
- const CreateApplicablesMeta = SyncMeta.extend({
89
- firstSyncStartedAt: z.number().int().nonnegative().optional().describe("backend-issued timestamp returned before the first fill-history fetch"),
90
- newestFillTs: z.number().int().nonnegative().refine((timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS, "newestFillTs must not be ahead of server time").optional().describe("raw newest fetched fill \u2014 settle-gate source, never trim-advanced; present exactly when externalMaxTs is"),
91
- executionsUpdatedAtEpochMs: z.number().int().nonnegative().describe("verbatim echo of fills/since executionsUpdatedAtEpochMs \u2014 stale-read gate token, not a client clock")
92
- }).superRefine(refineNewestFillTsPairsWithWatermark);
93
- const CreateApplicablesBulkFields = z.object({
94
- executionsUpdatedAtEpochMs: z.string().regex(/^\d+$/, "Must be a non-negative integer millisecond value").transform(Number).describe("mirror of meta.executionsUpdatedAtEpochMs, readable without decompressing the payload")
95
- });
96
- const CreateApplicablesRequest = z.object({
97
- applicables: z.array(ApplicablePosition),
98
- exchangePositions: z.array(ExternalPosition),
99
- meta: CreateApplicablesMeta
100
- });
101
- const OptionallySignedDecimalString = z.string().regex(/^[+-]?\d+(\.\d+)?$/, "Must be a valid signed decimal string");
102
- const FundingPaymentEntry = z.object({
103
- connector: Connector,
104
- instrumentId: InstrumentId,
105
- fundingRate: OptionallySignedDecimalString.describe("applied funding rate, optionally signed"),
106
- notional: OptionallySignedDecimalString.describe("funding amount in USD notional, optionally signed"),
107
- fundingPerUnit: OptionallySignedDecimalString.describe("signed funding per 1 unit of size (notional / szi); attribution coefficient"),
108
- timestamp: MsTimestamp
109
- });
110
- const CreateFundingPaymentsRequest = z.object({
111
- payments: z.array(FundingPaymentEntry),
112
- meta: SyncMeta
113
- });
114
- function refineNewestFillTsPairsWithWatermark(meta, ctx) {
115
- if (meta.externalMaxTs !== null && meta.newestFillTs === void 0) {
116
- ctx.addIssue({
117
- code: "custom",
118
- message: "newestFillTs is required when externalMaxTs is set",
119
- path: [
120
- "newestFillTs"
121
- ]
122
- });
123
- }
124
- if (meta.externalMaxTs === null && meta.newestFillTs !== void 0) {
125
- ctx.addIssue({
126
- code: "custom",
127
- message: "newestFillTs must be absent when externalMaxTs is null",
128
- path: [
129
- "newestFillTs"
130
- ]
131
- });
132
- }
133
- }
134
- __name(refineNewestFillTsPairsWithWatermark, "refineNewestFillTsPairsWithWatermark");
135
-
136
- export { ApplicableFill, ApplicableMetadata, ApplicablePosition, CreateApplicablesBulkFields, CreateApplicablesMeta, CreateApplicablesRequest, CreateFundingPaymentsRequest, ExternalPosition, FundingPaymentEntry, SyncFillsSinceRequest, SyncFundingSinceRequest, SyncMeta, UnknownExternalFill, WATERMARK_FUTURE_SKEW_MS };
@@ -1,26 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const SyncFillsResponse = z.object({});
4
- const SyncFillsSinceResponse = z.object({
5
- sinceMs: z.number().int().nonnegative(),
6
- // True only when the account has no checkpoint and nothing to anchor on, so sync starts from
7
- // genesis. Clients use this to detect an account that has never imported its trade history —
8
- // `sinceMs === 0` alone is ambiguous (a clamped watermark also yields 0).
9
- neverSynced: z.boolean(),
10
- // Backend-clock boundary returned only for a never-synced account. The syncer carries this
11
- // through when an empty exchange fetch provides no fill-derived checkpoint.
12
- firstSyncStartedAt: z.number().int().nonnegative().optional(),
13
- confirmedExchangeFillIds: z.array(z.string()).optional(),
14
- // Newest executions.updatedAt this response can have observed, as epoch ms ceiled to the next
15
- // whole millisecond (the column keeps microseconds); 0 when the account has no executions. The
16
- // client echoes it verbatim in the create meta — core defers the create when any execution
17
- // write postdates it. No client clock on the wire: ordering is against our own persisted
18
- // updated_at values (Postgres now() on insert, the engine's clock on updates — the settle
19
- // gate covers skew between those writers).
20
- executionsUpdatedAtEpochMs: z.number().int().nonnegative()
21
- });
22
- const SyncFundingSinceResponse = z.object({
23
- sinceMs: z.number().int().nonnegative()
24
- });
25
-
26
- export { SyncFillsResponse, SyncFillsSinceResponse, SyncFundingSinceResponse };
@@ -1,9 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const TcaMetricStatus = z.literal("FINAL");
4
- const TcaTimingGranularity = z.enum([
5
- "BATCH",
6
- "LEG"
7
- ]);
8
-
9
- export { TcaMetricStatus, TcaTimingGranularity };
package/dist/tca/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from './entities';
2
- export * from './queries';
3
- export * from './responses';
@@ -1,14 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const TcaPositionQueryParams = z.object({
4
- limit: z.coerce.number().int().positive().max(2e3).optional().default(100),
5
- cursor: z.iso.datetime().optional()
6
- });
7
- const TcaSummaryQueryParams = z.object({
8
- limit: z.coerce.number().int().positive().max(2e3).optional().default(100),
9
- cursor: z.iso.datetime().optional(),
10
- from: z.iso.datetime().optional(),
11
- to: z.iso.datetime().optional()
12
- });
13
-
14
- export { TcaPositionQueryParams, TcaSummaryQueryParams };
@@ -1,126 +0,0 @@
1
- import { z } from 'zod';
2
- import { Side } from '../common/schema';
3
- import { Connector } from '../connector';
4
- import { ExecutionStatus, ExecutionOrderType, ExecutionIntent } from '../execution/entities';
5
- import { TcaMetricStatus, TcaTimingGranularity } from './entities';
6
-
7
- const optionalNumeric = z.string().optional();
8
- const optionalTimestamp = z.iso.datetime().optional();
9
- const TcaBenchmarkResponse = z.object({
10
- id: z.uuid(),
11
- executionId: z.uuid(),
12
- orderId: z.uuid().optional(),
13
- cloid: z.string().optional(),
14
- legIndex: z.number(),
15
- connector: Connector,
16
- symbol: z.string(),
17
- side: z.enum([
18
- "BUY",
19
- "SELL"
20
- ]),
21
- decisionPrice: optionalNumeric,
22
- arrivalMid: optionalNumeric,
23
- arrivalBid: optionalNumeric,
24
- arrivalAsk: optionalNumeric,
25
- markPrice: optionalNumeric,
26
- indexPrice: optionalNumeric,
27
- source: z.string(),
28
- timestamp: z.iso.datetime(),
29
- quoteAsset: z.string().optional(),
30
- usdConversionPrice: optionalNumeric,
31
- createdAt: z.iso.datetime()
32
- });
33
- const TcaFillMetricResponse = z.object({
34
- id: z.uuid(),
35
- fillId: z.uuid(),
36
- benchmarkId: z.uuid().optional(),
37
- executionId: z.uuid().optional(),
38
- positionId: z.uuid().optional(),
39
- tradeAccountId: z.uuid(),
40
- connector: Connector,
41
- symbol: z.string(),
42
- cloid: z.string().optional(),
43
- exchangeFillId: z.string().optional(),
44
- slippageBps: optionalNumeric,
45
- slippageQuote: optionalNumeric,
46
- slippageUsd: optionalNumeric,
47
- implementationShortfallBps: optionalNumeric,
48
- spreadCostQuote: optionalNumeric,
49
- spreadCostUsd: optionalNumeric,
50
- tradeFee: optionalNumeric,
51
- pearFee: optionalNumeric,
52
- totalCostUsd: optionalNumeric,
53
- gatewayLatencyMs: z.number().optional(),
54
- timeToFillMs: z.number().optional(),
55
- quoteAsset: z.string().optional(),
56
- notionalQuote: optionalNumeric,
57
- notionalUsd: optionalNumeric,
58
- submittedAt: optionalTimestamp,
59
- acknowledgedAt: optionalTimestamp,
60
- exchangeExecutedAt: optionalTimestamp,
61
- timingGranularity: TcaTimingGranularity.optional(),
62
- status: TcaMetricStatus,
63
- createdAt: z.iso.datetime(),
64
- updatedAt: z.iso.datetime(),
65
- benchmark: TcaBenchmarkResponse.optional()
66
- });
67
- const TcaExecutionSummaryLegResponse = z.object({
68
- symbol: z.string(),
69
- side: Side,
70
- reduceOnly: z.boolean()
71
- });
72
- const TcaExecutionSummaryContextResponse = z.object({
73
- intent: ExecutionIntent,
74
- orderType: ExecutionOrderType,
75
- executionStatus: ExecutionStatus,
76
- positionId: z.uuid().optional(),
77
- scheduleId: z.uuid().optional(),
78
- triggerId: z.uuid().optional(),
79
- legs: z.array(TcaExecutionSummaryLegResponse)
80
- });
81
- const TcaExecutionSummaryResponse = z.object({
82
- id: z.uuid(),
83
- executionId: z.uuid(),
84
- tradeAccountId: z.uuid(),
85
- connector: Connector,
86
- executionContext: TcaExecutionSummaryContextResponse.optional(),
87
- notionalQuote: optionalNumeric,
88
- notionalUsd: optionalNumeric,
89
- weightedSlippageBps: optionalNumeric,
90
- totalSlippageUsd: optionalNumeric,
91
- totalTradeFee: optionalNumeric,
92
- totalPearFee: optionalNumeric,
93
- totalCostUsd: optionalNumeric,
94
- fillCount: z.number(),
95
- status: TcaMetricStatus,
96
- createdAt: z.iso.datetime(),
97
- updatedAt: z.iso.datetime()
98
- });
99
- const TcaExecutionResponse = z.object({
100
- summary: TcaExecutionSummaryResponse.optional(),
101
- fillMetrics: z.array(TcaFillMetricResponse)
102
- });
103
- const TcaPositionResponse = z.object({
104
- limit: z.number(),
105
- nextCursor: z.iso.datetime().optional(),
106
- fillMetrics: z.array(TcaFillMetricResponse)
107
- });
108
- const TcaSummaryTotalsResponse = z.object({
109
- executionCount: z.number(),
110
- fillCount: z.number(),
111
- notionalQuote: optionalNumeric,
112
- notionalUsd: optionalNumeric,
113
- weightedSlippageBps: optionalNumeric,
114
- totalSlippageUsd: optionalNumeric,
115
- totalTradeFee: optionalNumeric,
116
- totalPearFee: optionalNumeric,
117
- totalCostUsd: optionalNumeric
118
- });
119
- const TcaSummaryResponse = z.object({
120
- limit: z.number(),
121
- nextCursor: z.iso.datetime().optional(),
122
- summaries: z.array(TcaExecutionSummaryResponse),
123
- totals: TcaSummaryTotalsResponse
124
- });
125
-
126
- export { TcaBenchmarkResponse, TcaExecutionResponse, TcaExecutionSummaryContextResponse, TcaExecutionSummaryLegResponse, TcaExecutionSummaryResponse, TcaFillMetricResponse, TcaPositionResponse, TcaSummaryResponse, TcaSummaryTotalsResponse };
@@ -1,101 +0,0 @@
1
- import { z } from 'zod';
2
- import { SignedDecimalString, UnsignedDecimalString } from '../common/schema';
3
- import { Connector } from '../connector';
4
- import { FillStatus } from '../fill';
5
- import { InstrumentId } from '../instrument';
6
-
7
- const TradePositionState = z.object({
8
- signedQuantity: SignedDecimalString,
9
- basis: z.discriminatedUnion("kind", [
10
- z.object({
11
- kind: z.literal("FLAT")
12
- }),
13
- z.object({
14
- kind: z.literal("PRICED"),
15
- entryPrice: UnsignedDecimalString
16
- }),
17
- z.object({
18
- kind: z.literal("UNPRICED")
19
- })
20
- ])
21
- });
22
- const TradeRealization = z.discriminatedUnion("kind", [
23
- z.object({
24
- kind: z.literal("PRICED"),
25
- quantity: UnsignedDecimalString,
26
- entryPrice: UnsignedDecimalString,
27
- exitPrice: UnsignedDecimalString,
28
- grossPnl: SignedDecimalString
29
- }),
30
- z.object({
31
- kind: z.literal("UNPRICED"),
32
- quantity: UnsignedDecimalString
33
- })
34
- ]);
35
- const TradePositionEffect = z.discriminatedUnion("kind", [
36
- z.object({
37
- kind: z.literal("OPEN"),
38
- openedQuantity: UnsignedDecimalString
39
- }),
40
- z.object({
41
- kind: z.literal("INCREASE"),
42
- increasedQuantity: UnsignedDecimalString
43
- }),
44
- z.object({
45
- kind: z.literal("REDUCE"),
46
- reducedQuantity: UnsignedDecimalString,
47
- realization: TradeRealization
48
- }),
49
- z.object({
50
- kind: z.literal("CLOSE"),
51
- reducedQuantity: UnsignedDecimalString,
52
- realization: TradeRealization
53
- }),
54
- z.object({
55
- kind: z.literal("FLIP"),
56
- reducedQuantity: UnsignedDecimalString,
57
- openedQuantity: UnsignedDecimalString,
58
- realization: TradeRealization
59
- })
60
- ]);
61
- const TradeFill = z.object({
62
- id: z.uuid(),
63
- positionId: z.uuid(),
64
- symbol: InstrumentId,
65
- connector: Connector,
66
- side: z.enum([
67
- "BUY",
68
- "SELL"
69
- ]),
70
- quantity: UnsignedDecimalString,
71
- price: UnsignedDecimalString,
72
- /** Fee polarity is a charge: `+` is paid, `-` is a rebate — the opposite of `grossPnl`/`netCashflow`, where `+` is a gain. */
73
- tradeFee: SignedDecimalString.optional(),
74
- /** Same polarity as `tradeFee`: `+` is a charge paid to Pear. */
75
- pearFee: SignedDecimalString.optional(),
76
- /** Microsecond-precision UTC instant, rendered exactly like the group's `at`. */
77
- timestamp: z.iso.datetime(),
78
- /** RECONCILED rows are superseded and never listed, so only these two states can appear. */
79
- settlement: FillStatus.extract([
80
- "PROVISIONAL",
81
- "CONFIRMED"
82
- ]),
83
- executionId: z.uuid().optional(),
84
- positionEffect: TradePositionEffect,
85
- basisBefore: TradePositionState,
86
- basisAfter: TradePositionState
87
- });
88
- const TradeGroup = z.object({
89
- id: z.string().regex(/^(execution|fill):[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/),
90
- executionId: z.uuid().optional(),
91
- scheduleId: z.uuid().optional(),
92
- triggerId: z.uuid().optional(),
93
- connector: Connector,
94
- /** Earliest fill instant in the group at microsecond precision; the cursor key. */
95
- at: z.iso.datetime(),
96
- /** Priced realized PnL minus every fee in the group; `+` is a gain. */
97
- netCashflow: SignedDecimalString,
98
- trades: z.array(TradeFill)
99
- });
100
-
101
- export { TradeFill, TradeGroup, TradePositionEffect, TradePositionState, TradeRealization };
@@ -1,4 +0,0 @@
1
- export * from './entities';
2
- export * from './payloads';
3
- export * from './queries';
4
- export * from './responses';
@@ -1,84 +0,0 @@
1
- import { z } from 'zod';
2
- import { ClientIdCode } from '../common/client-id';
3
- import { RefineMinimumOneSymbol, RefineUniqueSymbols } from '../common/refinement';
4
- import { TradeLegPostOnlyWithMaxImpactPrice, TradeLegWithMaxImpactPrice } from '../common/trade-legs';
5
- import { AttachTriggerMarketClose } from '../trigger';
6
-
7
- const CreateMarketOpen = z.object({
8
- type: z.literal("MARKET"),
9
- /**
10
- * Requested legs
11
- */
12
- legs: z.tuple([
13
- TradeLegPostOnlyWithMaxImpactPrice
14
- ]).rest(TradeLegPostOnlyWithMaxImpactPrice).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure"),
15
- /**
16
- * Optional absolute deadline (epoch ms); the engine refuses to plan the open after this time.
17
- * The floor rejects an epoch-seconds timestamp sent by mistake, which would always be expired.
18
- */
19
- expiresAt: z.number().int().min(1e12).optional(),
20
- /**
21
- * Close trigger to attach to the execution
22
- */
23
- trigger: AttachTriggerMarketClose.optional(),
24
- /**
25
- * Attribution route code (client_ids.code)
26
- */
27
- clientId: ClientIdCode
28
- });
29
- const CreateMarketAdjust = z.object({
30
- type: z.literal("MARKET"),
31
- /**
32
- * Requested legs
33
- */
34
- legs: z.tuple([
35
- TradeLegWithMaxImpactPrice
36
- ]).rest(TradeLegWithMaxImpactPrice).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to modify the position"),
37
- /**
38
- * Optional absolute deadline (epoch ms); the engine refuses to plan the adjust after this time.
39
- * The floor rejects an epoch-seconds timestamp sent by mistake, which would always be expired.
40
- */
41
- expiresAt: z.number().int().min(1e12).optional(),
42
- /**
43
- * Attribution route code (client_ids.code)
44
- */
45
- clientId: ClientIdCode
46
- });
47
- const CreateMarketClose = z.object({
48
- type: z.literal("MARKET"),
49
- /**
50
- * Attribution route code (client_ids.code)
51
- */
52
- clientId: ClientIdCode
53
- });
54
- const CreateMarketReverse = z.object({
55
- type: z.literal("MARKET"),
56
- /**
57
- * Attribution route code (client_ids.code)
58
- */
59
- clientId: ClientIdCode
60
- });
61
- const CreateMarketCloseAll = z.object({
62
- type: z.literal("MARKET"),
63
- /**
64
- * Attribution route code (client_ids.code)
65
- */
66
- clientId: ClientIdCode
67
- });
68
- const CreateTradeOpen = z.discriminatedUnion("type", [
69
- CreateMarketOpen
70
- ]);
71
- const CreateTradeAdjust = z.discriminatedUnion("type", [
72
- CreateMarketAdjust
73
- ]);
74
- const CreateTradeClose = z.discriminatedUnion("type", [
75
- CreateMarketClose
76
- ]);
77
- const CreateTradeReverse = z.discriminatedUnion("type", [
78
- CreateMarketReverse
79
- ]);
80
- const CreateTradeCloseAll = z.discriminatedUnion("type", [
81
- CreateMarketCloseAll
82
- ]);
83
-
84
- export { CreateMarketAdjust, CreateMarketClose, CreateMarketCloseAll, CreateMarketOpen, CreateMarketReverse, CreateTradeAdjust, CreateTradeClose, CreateTradeCloseAll, CreateTradeOpen, CreateTradeReverse };
@@ -1,9 +0,0 @@
1
- import { z } from 'zod';
2
- import { CursorFindParams } from '../common';
3
-
4
- const TradeListParams = CursorFindParams.extend({
5
- /** Groups contain every fill in an execution, so keep pages bounded. */
6
- limit: z.coerce.number().int().positive().max(100).optional().default(20)
7
- });
8
-
9
- export { TradeListParams };
@@ -1,25 +0,0 @@
1
- import { z } from 'zod';
2
- import { CursorResponse } from '../common';
3
- import { Execution } from '../execution/entities';
4
- import { TradeGroup } from './entities';
5
-
6
- const CreateTradeOpenResponse = z.object({
7
- execution: Execution
8
- });
9
- const CreateTradeAdjustResponse = z.object({
10
- execution: Execution
11
- });
12
- const CreateTradeCloseResponse = z.object({
13
- execution: Execution
14
- });
15
- const CreateTradeReverseResponse = z.object({
16
- execution: Execution
17
- });
18
- const CreateTradeCloseAllResponse = z.object({
19
- executions: z.array(Execution)
20
- });
21
- const TradeListResponse = CursorResponse.extend({
22
- groups: z.array(TradeGroup)
23
- });
24
-
25
- export { CreateTradeAdjustResponse, CreateTradeCloseAllResponse, CreateTradeCloseResponse, CreateTradeOpenResponse, CreateTradeReverseResponse, TradeListResponse };
@@ -1,61 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const HyperliquidMetadata = z.object({
4
- agentWalletAddress: z.string(),
5
- isSubaccount: z.boolean(),
6
- mainAccountAddress: z.string()
7
- });
8
- const LighterMetadata = z.object({
9
- l1_address: z.string(),
10
- isSubaccount: z.boolean()
11
- });
12
- const commonFields = {
13
- id: z.uuid().describe("Trade account UUID"),
14
- alias: z.string().describe("User-defined trade account alias"),
15
- kind: z.enum([
16
- "eoa",
17
- "vault"
18
- ]).describe("Whether the account trades an EOA or a Pear vault"),
19
- exchangeIdentifier: z.string().describe("User identifier on the exchange"),
20
- createdAt: z.string().describe("Creation timestamp (ISO 8601)"),
21
- updatedAt: z.string().describe("Last update timestamp (ISO 8601)"),
22
- deletedAt: z.string().describe("Deletion timestamp (ISO 8601)").optional()
23
- };
24
- const NoConnectorMetadata = z.never().optional();
25
- const HyperliquidTradeAccount = z.object({
26
- ...commonFields,
27
- connector: z.literal("hyperliquid").describe("Exchange connector type"),
28
- metadata: HyperliquidMetadata.optional().describe("Connector-specific metadata")
29
- });
30
- const LighterTradeAccount = z.object({
31
- ...commonFields,
32
- connector: z.literal("lighter").describe("Exchange connector type"),
33
- metadata: LighterMetadata.optional().describe("Connector-specific metadata")
34
- });
35
- const BinanceTradeAccount = z.object({
36
- ...commonFields,
37
- connector: z.literal("binance").describe("Exchange connector type"),
38
- metadata: NoConnectorMetadata.describe("Connector-specific metadata")
39
- });
40
- const BybitTradeAccount = z.object({
41
- ...commonFields,
42
- connector: z.literal("bybit").describe("Exchange connector type"),
43
- metadata: NoConnectorMetadata.describe("Connector-specific metadata")
44
- });
45
- const OkxTradeAccount = z.object({
46
- ...commonFields,
47
- connector: z.literal("okx").describe("Exchange connector type"),
48
- metadata: NoConnectorMetadata.describe("Connector-specific metadata")
49
- });
50
- const TradeAccount = z.discriminatedUnion("connector", [
51
- HyperliquidTradeAccount,
52
- LighterTradeAccount,
53
- LighterTradeAccount.extend({
54
- connector: z.literal("lighter_rhc")
55
- }),
56
- BinanceTradeAccount,
57
- BybitTradeAccount,
58
- OkxTradeAccount
59
- ]);
60
-
61
- export { TradeAccount };
@@ -1,4 +0,0 @@
1
- export * from './entities';
2
- export * from './payloads';
3
- export * from './queries';
4
- export * from './response';