@pear-protocol/types 2.21.0 → 2.22.1

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 (169) 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/users/entities.d.ts +4 -0
  9. package/dist/users/response.d.ts +2 -0
  10. package/package.json +3 -2
  11. package/dist/auth/api-keys.js +0 -44
  12. package/dist/auth/entities.js +0 -25
  13. package/dist/auth/index.js +0 -4
  14. package/dist/auth/payloads.js +0 -84
  15. package/dist/auth/response.js +0 -82
  16. package/dist/baskets/recommended/entities.js +0 -22
  17. package/dist/baskets/recommended/index.js +0 -2
  18. package/dist/baskets/recommended/responses.js +0 -8
  19. package/dist/baskets/saved/entities.js +0 -23
  20. package/dist/baskets/saved/payloads.js +0 -18
  21. package/dist/baskets/saved/responses.js +0 -14
  22. package/dist/bundle.js +0 -36
  23. package/dist/common/address.js +0 -5
  24. package/dist/common/array.js +0 -17
  25. package/dist/common/client-id.js +0 -5
  26. package/dist/common/hex-string.js +0 -5
  27. package/dist/common/index.js +0 -4
  28. package/dist/common/refinement.js +0 -64
  29. package/dist/common/request.js +0 -24
  30. package/dist/common/response.js +0 -28
  31. package/dist/common/schema.js +0 -18
  32. package/dist/common/trade-legs.js +0 -50
  33. package/dist/connector/index.js +0 -12
  34. package/dist/copy/entities.js +0 -151
  35. package/dist/copy/index.js +0 -5
  36. package/dist/copy/payloads.js +0 -8
  37. package/dist/copy/performance.js +0 -63
  38. package/dist/copy/queries.js +0 -20
  39. package/dist/copy/responses.js +0 -89
  40. package/dist/execution/entities.js +0 -196
  41. package/dist/execution/index.js +0 -3
  42. package/dist/execution/queries.js +0 -18
  43. package/dist/execution/responses.js +0 -12
  44. package/dist/fee/entities.js +0 -34
  45. package/dist/fee/index.js +0 -3
  46. package/dist/fee/queries.js +0 -12
  47. package/dist/fee/responses.js +0 -29
  48. package/dist/fill/entities.js +0 -82
  49. package/dist/fill/index.js +0 -3
  50. package/dist/fill/queries.js +0 -14
  51. package/dist/fill/responses.js +0 -23
  52. package/dist/funding/entities.js +0 -16
  53. package/dist/funding/index.js +0 -3
  54. package/dist/funding/queries.js +0 -8
  55. package/dist/funding/responses.js +0 -11
  56. package/dist/instrument/entities.js +0 -102
  57. package/dist/instrument/index.js +0 -3
  58. package/dist/instrument/queries.js +0 -15
  59. package/dist/instrument/responses.js +0 -20
  60. package/dist/instrument-precision/index.js +0 -56
  61. package/dist/ladder/entities.js +0 -24
  62. package/dist/ladder/index.js +0 -4
  63. package/dist/ladder/payloads.js +0 -96
  64. package/dist/ladder/queries.js +0 -12
  65. package/dist/ladder/responses.js +0 -18
  66. package/dist/leverage/index.js +0 -2
  67. package/dist/leverage/payloads.js +0 -14
  68. package/dist/leverage/response.js +0 -5
  69. package/dist/margin/index.js +0 -2
  70. package/dist/margin/payloads.js +0 -20
  71. package/dist/margin/response.js +0 -11
  72. package/dist/market/entities.js +0 -52
  73. package/dist/market/index.js +0 -4
  74. package/dist/market/payloads.js +0 -11
  75. package/dist/market/queries.js +0 -19
  76. package/dist/market/responses.js +0 -18
  77. package/dist/misc/index.js +0 -2
  78. package/dist/misc/payloads.js +0 -99
  79. package/dist/misc/responses.js +0 -85
  80. package/dist/notification/entities.js +0 -274
  81. package/dist/notification/index.js +0 -4
  82. package/dist/notification/payloads.js +0 -15
  83. package/dist/notification/queries.js +0 -29
  84. package/dist/notification/responses.js +0 -20
  85. package/dist/order/entities.js +0 -81
  86. package/dist/order/index.js +0 -1
  87. package/dist/portfolio/entities.js +0 -77
  88. package/dist/portfolio/index.js +0 -3
  89. package/dist/portfolio/queries.js +0 -34
  90. package/dist/portfolio/responses.js +0 -33
  91. package/dist/position/entities.js +0 -433
  92. package/dist/position/index.js +0 -3
  93. package/dist/position/queries.js +0 -109
  94. package/dist/position/responses.js +0 -41
  95. package/dist/price/entities.js +0 -10
  96. package/dist/price/index.js +0 -3
  97. package/dist/price/queries.js +0 -8
  98. package/dist/price/responses.js +0 -15
  99. package/dist/realtime/channels.js +0 -16
  100. package/dist/realtime/frames.js +0 -140
  101. package/dist/realtime/index.js +0 -6
  102. package/dist/realtime/messages.js +0 -118
  103. package/dist/realtime/public-events.js +0 -92
  104. package/dist/realtime/user-events.js +0 -32
  105. package/dist/realtime/vault-events.js +0 -42
  106. package/dist/rebalance/entities.js +0 -86
  107. package/dist/rebalance/index.js +0 -4
  108. package/dist/rebalance/payloads.js +0 -56
  109. package/dist/rebalance/queries.js +0 -14
  110. package/dist/rebalance/responses.js +0 -41
  111. package/dist/schedule/entities.js +0 -239
  112. package/dist/schedule/index.js +0 -5
  113. package/dist/schedule/payloads.js +0 -85
  114. package/dist/schedule/queries.js +0 -30
  115. package/dist/schedule/randomization.js +0 -15
  116. package/dist/schedule/responses.js +0 -22
  117. package/dist/schedule/twap-config.js +0 -29
  118. package/dist/statistics/entities.js +0 -105
  119. package/dist/statistics/index.js +0 -3
  120. package/dist/statistics/queries.js +0 -111
  121. package/dist/statistics/responses.js +0 -67
  122. package/dist/sync/index.js +0 -2
  123. package/dist/sync/payloads.js +0 -136
  124. package/dist/sync/responses.js +0 -28
  125. package/dist/tca/entities.js +0 -9
  126. package/dist/tca/index.js +0 -3
  127. package/dist/tca/queries.js +0 -14
  128. package/dist/tca/responses.js +0 -126
  129. package/dist/trade/entities.js +0 -101
  130. package/dist/trade/index.js +0 -4
  131. package/dist/trade/payloads.js +0 -84
  132. package/dist/trade/queries.js +0 -9
  133. package/dist/trade/responses.js +0 -25
  134. package/dist/trade-accounts/entities.js +0 -61
  135. package/dist/trade-accounts/index.js +0 -4
  136. package/dist/trade-accounts/payloads.js +0 -132
  137. package/dist/trade-accounts/queries.js +0 -7
  138. package/dist/trade-accounts/response.js +0 -79
  139. package/dist/traders/index.js +0 -2
  140. package/dist/traders/performance.js +0 -21
  141. package/dist/traders/public.js +0 -192
  142. package/dist/trigger/common/index.js +0 -39
  143. package/dist/trigger/entities/conditions.js +0 -174
  144. package/dist/trigger/entities/index.js +0 -257
  145. package/dist/trigger/index.js +0 -9
  146. package/dist/trigger/oracle.js +0 -22
  147. package/dist/trigger/payloads/conditions.js +0 -213
  148. package/dist/trigger/payloads/config.js +0 -3
  149. package/dist/trigger/payloads/index.js +0 -173
  150. package/dist/trigger/queries.js +0 -16
  151. package/dist/trigger/refinement/index.js +0 -2
  152. package/dist/trigger/refinement/static.refinement.js +0 -50
  153. package/dist/trigger/refinement/trailing.refinement.js +0 -83
  154. package/dist/trigger/responses.js +0 -18
  155. package/dist/triggers/entities.js +0 -27
  156. package/dist/triggers/index.js +0 -3
  157. package/dist/triggers/queries.js +0 -10
  158. package/dist/triggers/responses.js +0 -9
  159. package/dist/users/entities.js +0 -45
  160. package/dist/users/index.js +0 -4
  161. package/dist/users/payloads.js +0 -33
  162. package/dist/users/queries.js +0 -8
  163. package/dist/users/response.js +0 -28
  164. package/dist/vaults/entities.js +0 -96
  165. package/dist/vaults/index.js +0 -4
  166. package/dist/vaults/payloads.js +0 -65
  167. package/dist/vaults/queries.js +0 -66
  168. package/dist/vaults/responses.js +0 -368
  169. /package/dist/{baskets/saved/index.js → rewards/index.d.ts} +0 -0
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
- import { normalizeArray, CursorFindParams } from '../common';
3
- import { Connector } from '../connector';
4
-
5
- const StatusEnum = z.enum([
6
- "ACTIVE",
7
- "COMPLETED",
8
- "CANCELLED"
9
- ]);
10
- const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(StatusEnum));
11
- const ExecutionListParams = CursorFindParams.extend({
12
- connector: Connector.optional(),
13
- status: StatusArray.optional(),
14
- includeSchedule: z.coerce.boolean().optional().default(false),
15
- includeTriggers: z.coerce.boolean().optional().default(false)
16
- });
17
-
18
- export { ExecutionListParams };
@@ -1,12 +0,0 @@
1
- import { z } from 'zod';
2
- import { CursorResponse } from '../common';
3
- import { Execution } from './entities';
4
-
5
- const ExecutionListResponse = CursorResponse.extend({
6
- executions: z.array(Execution)
7
- });
8
- const GetExecutionResponse = z.object({
9
- execution: Execution
10
- });
11
-
12
- export { ExecutionListResponse, GetExecutionResponse };
@@ -1,34 +0,0 @@
1
- import { z } from 'zod';
2
- import { Connector } from '../connector';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- const MAX_FEE_BPS = 10;
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
- ]);
17
- const FeeConnector = z.enum(Connector.options);
18
- const FeeRole = z.enum([
19
- "basic",
20
- "pro",
21
- "vault"
22
- ]);
23
- 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}`);
24
- 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');
25
- const ORDERED_VALIDITY_WINDOW_MESSAGE = "endsAt must be later than startsAt";
26
- function hasOrderedValidityWindow(window) {
27
- if (!window.startsAt || !window.endsAt) {
28
- return true;
29
- }
30
- return new Date(window.startsAt).getTime() < new Date(window.endsAt).getTime();
31
- }
32
- __name(hasOrderedValidityWindow, "hasOrderedValidityWindow");
33
-
34
- export { DiscountRate, FeeBps, FeeConnector, FeeDiscountScope, FeeOverrideScope, FeeRole, MAX_FEE_BPS, ORDERED_VALIDITY_WINDOW_MESSAGE, hasOrderedValidityWindow };
package/dist/fee/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from './entities';
2
- export * from './queries';
3
- export * from './responses';
@@ -1,12 +0,0 @@
1
- import { z } from 'zod';
2
- import { ClientIdCode } from '../common/client-id';
3
- import { FeeConnector } from './entities';
4
-
5
- const QuoteFeeParams = z.object({
6
- clientId: ClientIdCode
7
- });
8
- const GetFeeRecipientParams = z.object({
9
- connector: FeeConnector
10
- });
11
-
12
- export { GetFeeRecipientParams, QuoteFeeParams };
@@ -1,29 +0,0 @@
1
- import { z } from 'zod';
2
- import { DiscountRate, FeeDiscountScope, FeeBps, FeeOverrideScope } from './entities';
3
-
4
- const AppliedFeeDiscount = z.object({
5
- scope: FeeDiscountScope,
6
- rate: DiscountRate
7
- }).describe("A discount applied to the quoted fee");
8
- const FeeResponse = z.object({
9
- // Connector-native fee recipient; absent means the order names none, so it carries no fee
10
- feeRecipient: z.string().optional(),
11
- // The (role, connector) rate the quote started from
12
- baseBps: FeeBps,
13
- // The rate that replaced the base; absent when no override matched
14
- overrideBps: FeeBps.optional(),
15
- // Which scope that override came from
16
- overrideScope: FeeOverrideScope.optional(),
17
- // Every discount taken off the amount. Rates add up rather than compound, and the total is
18
- // capped at 100%, so a deep stack floors the fee at zero.
19
- discounts: z.array(AppliedFeeDiscount),
20
- // What the trade actually pays. Always a multiple of 0.1 bps: resolution rounds up to that step
21
- // so a discounted fee cannot shrink to nothing.
22
- finalBps: FeeBps
23
- }).describe("Resolved trading fee and connector fee recipient for the caller's trade account");
24
- const FeeRecipientResponse = z.object({
25
- // Connector-native recipient identifier (Hyperliquid builder address, Lighter integrator account index)
26
- recipient: z.string().optional()
27
- }).describe("Connector-native fee recipient to approve for the caller's role");
28
-
29
- export { AppliedFeeDiscount, FeeRecipientResponse, FeeResponse };
@@ -1,82 +0,0 @@
1
- import { z } from 'zod';
2
- import { Side } from '../common/schema';
3
- import { Connector } from '../connector';
4
- import { InstrumentId } from '../instrument';
5
-
6
- const FillStatus = z.enum([
7
- "PROVISIONAL",
8
- "CONFIRMED",
9
- "RECONCILED"
10
- ]);
11
- const Fill = z.object({
12
- /**
13
- * Fill UUID
14
- */
15
- id: z.uuid(),
16
- /** Client order ID (abbreviated as cloid) */
17
- cloid: z.string().optional(),
18
- /** Exchange-native fill ID (tradeId / tid / etc) */
19
- exchangeFillId: z.string().optional(),
20
- /**
21
- * Fill lifecycle status
22
- */
23
- status: FillStatus,
24
- /**
25
- * Trade account UUID
26
- */
27
- tradeAccountId: z.uuid(),
28
- /**
29
- * Instrument ID
30
- */
31
- symbol: InstrumentId,
32
- /**
33
- * Position UUID
34
- */
35
- positionId: z.uuid(),
36
- /**
37
- * Connector
38
- */
39
- connector: Connector,
40
- /**
41
- * Side
42
- */
43
- side: Side,
44
- /**
45
- * Reduce only flag
46
- */
47
- reduceOnly: z.boolean(),
48
- /** True when the fill was created from external sync. */
49
- isExternal: z.boolean(),
50
- /**
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
- */
54
- synthetic: z.boolean(),
55
- quantity: z.string(),
56
- /** Filled price — "0" on an unpriceable gone-close synthetic (no price guessing). */
57
- price: z.string(),
58
- /** USD value — "0" on an unpriceable gone-close synthetic (cannot compute without price). */
59
- usd: z.string(),
60
- /**
61
- * Trade fee paid
62
- */
63
- tradeFee: z.string().optional(),
64
- /**
65
- * Pear fee paid
66
- */
67
- pearFee: z.string().optional(),
68
- /**
69
- * Timestamp
70
- */
71
- timestamp: z.string(),
72
- /**
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
- */
76
- original: z.object({
77
- exchangeFillId: z.string(),
78
- quantity: z.string()
79
- }).optional()
80
- });
81
-
82
- export { Fill, FillStatus };
@@ -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
- import { CursorFindParams } from '../common';
3
- import { Connector } from '../connector';
4
-
5
- const FillOrderBy = z.union([
6
- z.literal("timestamp"),
7
- z.literal("-timestamp")
8
- ]);
9
- const FillListParams = CursorFindParams.extend({
10
- connector: Connector.optional(),
11
- orderBy: FillOrderBy.default("-timestamp")
12
- });
13
-
14
- export { FillListParams, FillOrderBy };
@@ -1,23 +0,0 @@
1
- import { z } from 'zod';
2
- import { CursorResponse } from '../common';
3
- import { InstrumentId } from '../instrument';
4
- import { Fill } from './entities';
5
-
6
- const FillListResponse = CursorResponse.extend({
7
- fills: z.array(Fill)
8
- });
9
- const PositionFillListResponse = z.object({
10
- fills: z.array(Fill)
11
- });
12
- const ProvisionalFill = z.object({
13
- id: z.uuid(),
14
- positionId: z.uuid(),
15
- symbol: InstrumentId,
16
- cloid: z.string().optional(),
17
- status: z.literal("PROVISIONAL")
18
- });
19
- const ProvisionalFillListResponse = z.object({
20
- fills: z.array(ProvisionalFill)
21
- });
22
-
23
- export { FillListResponse, PositionFillListResponse, ProvisionalFill, ProvisionalFillListResponse };
@@ -1,16 +0,0 @@
1
- import { z } from 'zod';
2
- import { InstrumentId } from '../instrument';
3
-
4
- const FundingInfo = z.object({
5
- /**
6
- * Funding rate
7
- */
8
- r: z.string(),
9
- /**
10
- * Next funding time in milliseconds
11
- */
12
- nft: z.number()
13
- });
14
- const InstrumentFundingMap = z.record(InstrumentId, FundingInfo);
15
-
16
- export { FundingInfo, InstrumentFundingMap };
@@ -1,3 +0,0 @@
1
- export * from './entities';
2
- export * from './queries';
3
- export * from './responses';
@@ -1,8 +0,0 @@
1
- import { z } from 'zod';
2
- import { Connector } from '../connector';
3
-
4
- const FundingQueryParams = z.object({
5
- connector: Connector
6
- });
7
-
8
- export { FundingQueryParams };
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
- import { InstrumentFundingMap } from './entities';
3
-
4
- const FundingResponse = z.object({
5
- /**
6
- * Funding rates and next funding times for instruments
7
- */
8
- funding: InstrumentFundingMap
9
- });
10
-
11
- export { FundingResponse };
@@ -1,102 +0,0 @@
1
- import { z } from 'zod';
2
- import { Connector } from '../connector';
3
- import { InstrumentPrecision } from '../instrument-precision';
4
-
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([
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
- ]);
21
- const InstrumentTradeabilityReason = z.string().nullable();
22
- const InstrumentTradeability = z.object({
23
- status: InstrumentTradeabilityStatus,
24
- reason: InstrumentTradeabilityReason
25
- });
26
- const Instrument = z.object({
27
- /**
28
- * Exchange specific instrument identifier
29
- * @example (dexIndex + assetIndex) on Hyperliquid
30
- * @example "BTCUSDT" on Binance
31
- */
32
- id: InstrumentId,
33
- /**
34
- * The base asset of the instrument.
35
- * @example "BTC"
36
- */
37
- base: z.string(),
38
- /**
39
- * The quote asset of the instrument.
40
- * @example "USDT"
41
- */
42
- quote: z.string(),
43
- /**
44
- * The connector of the instrument.
45
- * @example "hyperliquid"
46
- * @example "binance"
47
- */
48
- connector: Connector,
49
- /**
50
- * The type of the instrument.
51
- * @example "spot"
52
- * @example "perp"
53
- * @example "hip3"
54
- */
55
- type: InstrumentType,
56
- /**
57
- * The maximum leverage of the instrument.
58
- * @example 1
59
- */
60
- leverage: z.int().min(1),
61
- /**
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
- */
65
- marginMode: InstrumentMarginMode,
66
- /**
67
- * The precision of the instrument.
68
- */
69
- precision: InstrumentPrecision,
70
- /**
71
- * Whether this instrument can be traded normally.
72
- */
73
- tradeability: InstrumentTradeability
74
- });
75
- const InstrumentLite = z.object({
76
- /**
77
- * Exchange specific instrument identifier
78
- * @example (dexIndex + assetIndex) on Hyperliquid
79
- * @example "BTCUSDT" on Binance
80
- */
81
- id: InstrumentId,
82
- /**
83
- * The base asset of the instrument.
84
- * @example "BTC"
85
- */
86
- base: z.string(),
87
- /**
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
- */
91
- marginMode: InstrumentMarginMode,
92
- /**
93
- * Minimal precision — only the contract size the syncer needs for BASE-unit normalization.
94
- */
95
- precision: z.object({
96
- quantity: z.object({
97
- contractSize: z.number()
98
- })
99
- })
100
- });
101
-
102
- export { Instrument, InstrumentId, InstrumentLite, InstrumentMarginMode, InstrumentTradeability, InstrumentTradeabilityReason, InstrumentTradeabilityStatus, InstrumentType };
@@ -1,3 +0,0 @@
1
- export * from './entities';
2
- export * from './queries';
3
- export * from './responses';
@@ -1,15 +0,0 @@
1
- import { z } from 'zod';
2
- import { Connector } from '../connector';
3
-
4
- const InstrumentScope = z.enum([
5
- "tradable",
6
- "reduce_only",
7
- "not_tradable",
8
- "all"
9
- ]);
10
- const InstrumentListParams = z.object({
11
- connector: Connector,
12
- scope: InstrumentScope.default("all")
13
- });
14
-
15
- export { InstrumentListParams, InstrumentScope };
@@ -1,20 +0,0 @@
1
- import { z } from 'zod';
2
- import { Instrument, InstrumentId, InstrumentLite } from './entities';
3
-
4
- const InstrumentListResponse = z.object({
5
- /**
6
- * The list of instruments.
7
- */
8
- instruments: z.array(Instrument)
9
- });
10
- const InstrumentSymbolToIdMapResponse = z.object({
11
- data: z.record(z.string(), InstrumentId)
12
- });
13
- const InstrumentListLiteResponse = z.object({
14
- /**
15
- * The list of instruments, trimmed to the lightweight consumer fields.
16
- */
17
- instruments: z.array(InstrumentLite)
18
- });
19
-
20
- export { InstrumentListLiteResponse, InstrumentListResponse, InstrumentSymbolToIdMapResponse };
@@ -1,56 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const InstrumentPrecision = z.object({
4
- quantity: z.object({
5
- /**
6
- * The maximum number of decimals accepted.
7
- * @example 4 for a 0.0001 step size.
8
- */
9
- decimals: z.int(),
10
- /**
11
- * The smallest step size.
12
- * @example 0.01 for a 2 decimal precision.
13
- */
14
- step: z.number(),
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
- */
20
- contractSize: z.number(),
21
- /**
22
- * The venue's minimum order quantity for market (IOC) orders, in contracts, when it has one.
23
- * @example 10 on Binance ALLUSDT, where one step is 1.
24
- */
25
- min: z.number().transform((val) => val === null ? void 0 : val).optional().nullable()
26
- }),
27
- price: z.object({
28
- /**
29
- * The maximum number of decimals.
30
- * @example 4 for a 0.0001 tick size.
31
- */
32
- decimals: z.int(),
33
- /**
34
- * The smallest increment.
35
- * @example 0.01 for a 2 decimal precision.
36
- */
37
- tick: z.number().transform((val) => val === null ? void 0 : val).optional().nullable(),
38
- /**
39
- * The number of significant figures.
40
- * @example 5 on Hyperliquid V2.
41
- */
42
- sigFigs: z.int().transform((val) => val === null ? void 0 : val).optional().nullable()
43
- }),
44
- notional: z.object({
45
- /**
46
- * The minimum notional amount in USD.
47
- */
48
- min: z.number().transform((val) => val === null ? void 0 : val).optional().nullable(),
49
- /**
50
- * The maximum notional amount in USD.
51
- */
52
- max: z.number().transform((val) => val === null ? void 0 : val).optional().nullable()
53
- }).optional()
54
- });
55
-
56
- export { InstrumentPrecision };
@@ -1,24 +0,0 @@
1
- import { z } from 'zod';
2
- import { Connector } from '../connector';
3
- import { Trigger } from '../trigger';
4
- import { AttachTriggerMarketCloseList } from '../trigger/payloads';
5
- import { LadderConfig } from './payloads';
6
-
7
- const LadderStatus = z.enum([
8
- "ACTIVE",
9
- "COMPLETED",
10
- "CANCELLED"
11
- ]);
12
- const Ladder = z.object({
13
- id: z.uuid(),
14
- connector: Connector,
15
- positionKey: z.string(),
16
- config: LadderConfig,
17
- status: LadderStatus,
18
- attachTriggers: AttachTriggerMarketCloseList.optional(),
19
- triggers: z.array(Trigger),
20
- createdAt: z.string(),
21
- updatedAt: z.string()
22
- });
23
-
24
- export { Ladder, LadderStatus };
@@ -1,4 +0,0 @@
1
- export * from './entities';
2
- export * from './payloads';
3
- export * from './queries';
4
- export * from './responses';
@@ -1,96 +0,0 @@
1
- import { z } from 'zod';
2
- import { ClientIdCode } from '../common/client-id';
3
- import { RefineMinimumTwoSymbols, RefineUniqueSymbols, RefineWeightingSum, RefineTwoUniqueSymbols, RefineMinimumOneSymbol } from '../common/refinement';
4
- import { AssetWeight, Side } from '../common/schema';
5
- import { TradeLegPostOnly } from '../common/trade-legs';
6
- import { InstrumentId } from '../instrument';
7
- import { MetricTrack } from '../trigger/common';
8
- import { AttachTriggerMarketCloseList } from '../trigger/payloads';
9
-
10
- const LadderThreshold = z.number().positive({
11
- message: "Threshold must be greater than 0"
12
- });
13
- const LadderConfig = z.object({
14
- thresholdStart: LadderThreshold,
15
- thresholdEnd: LadderThreshold,
16
- levels: z.int().min(2).max(50),
17
- weighting: z.literal("EQUAL").default("EQUAL")
18
- }).refine((config) => config.thresholdStart !== config.thresholdEnd, {
19
- message: "thresholds must differ"
20
- });
21
- const PriceSource = z.enum([
22
- "mid",
23
- "mark"
24
- ], {
25
- message: "Price source must be mid or mark"
26
- });
27
- const WeightedRatioBasketItem = z.object({
28
- symbol: InstrumentId,
29
- side: Side,
30
- weight: AssetWeight
31
- });
32
- const WeightedRatioBasket = z.array(WeightedRatioBasketItem).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum);
33
- const LadderRatioOpen = z.object({
34
- type: z.literal("ratio"),
35
- data: z.object({
36
- priceSource: PriceSource,
37
- symbol_a: InstrumentId,
38
- symbol_b: InstrumentId,
39
- track: MetricTrack
40
- }).superRefine(RefineTwoUniqueSymbols)
41
- });
42
- const LadderPriceOpen = z.object({
43
- type: z.literal("price"),
44
- data: z.object({
45
- priceSource: PriceSource,
46
- symbol: InstrumentId,
47
- track: MetricTrack
48
- })
49
- });
50
- const LadderWeightedRatioOpen = z.object({
51
- type: z.literal("weighted_ratio"),
52
- data: z.object({
53
- priceSource: PriceSource,
54
- basket: WeightedRatioBasket,
55
- track: MetricTrack
56
- })
57
- });
58
- const LadderConditionOpen = z.discriminatedUnion("type", [
59
- LadderRatioOpen,
60
- LadderPriceOpen,
61
- LadderWeightedRatioOpen
62
- ]);
63
- const LadderAttachTriggers = AttachTriggerMarketCloseList.superRefine((attachTriggers, ctx) => {
64
- attachTriggers.forEach((attachTrigger, index) => {
65
- if (attachTrigger.condition.type === "notional" || attachTrigger.condition.type === "notional_trailing") {
66
- ctx.addIssue({
67
- code: "custom",
68
- path: [
69
- index,
70
- "condition",
71
- "type"
72
- ],
73
- message: "Ladder brackets cannot use notional conditions; use upnl or upnl_bps."
74
- });
75
- }
76
- });
77
- });
78
- const CreateLadderMarketOpen = z.object({
79
- type: z.literal("MARKET"),
80
- intent: z.literal("OPEN"),
81
- clientId: ClientIdCode,
82
- condition: LadderConditionOpen,
83
- config: LadderConfig,
84
- attachTriggers: LadderAttachTriggers.optional(),
85
- payload: z.object({
86
- type: z.literal("MARKET"),
87
- legs: z.tuple([
88
- TradeLegPostOnly
89
- ]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols)
90
- })
91
- }).strict();
92
- const CreateLadder = z.discriminatedUnion("type", [
93
- CreateLadderMarketOpen
94
- ]);
95
-
96
- export { CreateLadder, CreateLadderMarketOpen, LadderConditionOpen, LadderConfig };
@@ -1,12 +0,0 @@
1
- import { z } from 'zod';
2
- import { normalizeArray, CursorFindParams } from '../common';
3
- import { Connector } from '../connector';
4
- import { LadderStatus } from './entities';
5
-
6
- const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(LadderStatus));
7
- const LadderListParams = CursorFindParams.extend({
8
- connector: Connector.optional(),
9
- status: StatusArray.optional()
10
- });
11
-
12
- export { LadderListParams };
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
- import { CursorResponse } from '../common';
3
- import { Ladder } from './entities';
4
-
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
- });
17
-
18
- export { CancelLadderResponse, CreateLadderResponse, LadderListResponse, LadderResponse };
@@ -1,2 +0,0 @@
1
- export * from './payloads';
2
- export * from './response';
@@ -1,14 +0,0 @@
1
- import { z } from 'zod';
2
- import { InstrumentId } from '../instrument/entities';
3
-
4
- const MarginMode = z.enum([
5
- "cross",
6
- "isolated"
7
- ]);
8
- const SetLeverage = z.object({
9
- symbol: InstrumentId,
10
- leverage: z.int().positive(),
11
- marginMode: MarginMode.optional()
12
- });
13
-
14
- export { MarginMode, SetLeverage };
@@ -1,5 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const SetLeverageResponse = z.object({});
4
-
5
- export { SetLeverageResponse };