@0xmonaco/types 0.7.5 → 0.7.7
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.
- package/package.json +2 -2
- package/dist/api/index.d.ts +0 -18
- package/dist/api/index.js +0 -6
- package/dist/applications/index.d.ts +0 -23
- package/dist/applications/index.js +0 -5
- package/dist/applications/responses.d.ts +0 -22
- package/dist/applications/responses.js +0 -5
- package/dist/auth/index.d.ts +0 -81
- package/dist/auth/index.js +0 -6
- package/dist/auth/responses.d.ts +0 -67
- package/dist/auth/responses.js +0 -5
- package/dist/contracts/balances.d.ts +0 -43
- package/dist/contracts/balances.js +0 -5
- package/dist/contracts/index.d.ts +0 -27
- package/dist/contracts/index.js +0 -5
- package/dist/fees/index.d.ts +0 -39
- package/dist/fees/index.js +0 -6
- package/dist/fees/responses.d.ts +0 -54
- package/dist/fees/responses.js +0 -86
- package/dist/index.d.ts +0 -20
- package/dist/index.js +0 -21
- package/dist/margin-accounts/index.d.ts +0 -110
- package/dist/margin-accounts/index.js +0 -0
- package/dist/market/index.d.ts +0 -312
- package/dist/market/index.js +0 -5
- package/dist/positions/index.d.ts +0 -128
- package/dist/positions/index.js +0 -0
- package/dist/profile/index.d.ts +0 -405
- package/dist/profile/index.js +0 -5
- package/dist/sdk/index.d.ts +0 -131
- package/dist/sdk/index.js +0 -0
- package/dist/sdk/network.d.ts +0 -25
- package/dist/sdk/network.js +0 -5
- package/dist/trading/index.d.ts +0 -132
- package/dist/trading/index.js +0 -6
- package/dist/trading/orders.d.ts +0 -137
- package/dist/trading/orders.js +0 -9
- package/dist/trading/responses.d.ts +0 -347
- package/dist/trading/responses.js +0 -5
- package/dist/validation/common.d.ts +0 -179
- package/dist/validation/common.js +0 -199
- package/dist/validation/index.d.ts +0 -22
- package/dist/validation/index.js +0 -24
- package/dist/validation/margin-accounts.d.ts +0 -55
- package/dist/validation/margin-accounts.js +0 -59
- package/dist/validation/market.d.ts +0 -214
- package/dist/validation/market.js +0 -225
- package/dist/validation/positions.d.ts +0 -89
- package/dist/validation/positions.js +0 -93
- package/dist/validation/profile.d.ts +0 -69
- package/dist/validation/profile.js +0 -44
- package/dist/validation/trading.d.ts +0 -350
- package/dist/validation/trading.js +0 -313
- package/dist/validation/vault.d.ts +0 -66
- package/dist/validation/vault.js +0 -79
- package/dist/vault/index.d.ts +0 -84
- package/dist/vault/index.js +0 -5
- package/dist/vault/responses.d.ts +0 -51
- package/dist/vault/responses.js +0 -5
- package/dist/websocket/base.d.ts +0 -31
- package/dist/websocket/base.js +0 -5
- package/dist/websocket/clients/orderbook-client.d.ts +0 -14
- package/dist/websocket/clients/orderbook-client.js +0 -3
- package/dist/websocket/events/balance-events.d.ts +0 -48
- package/dist/websocket/events/balance-events.js +0 -6
- package/dist/websocket/events/conditional-order-events.d.ts +0 -33
- package/dist/websocket/events/conditional-order-events.js +0 -0
- package/dist/websocket/events/index.d.ts +0 -7
- package/dist/websocket/events/index.js +0 -7
- package/dist/websocket/events/movement-events.d.ts +0 -64
- package/dist/websocket/events/movement-events.js +0 -6
- package/dist/websocket/events/ohlcv-events.d.ts +0 -31
- package/dist/websocket/events/ohlcv-events.js +0 -5
- package/dist/websocket/events/orderbook-events.d.ts +0 -72
- package/dist/websocket/events/orderbook-events.js +0 -5
- package/dist/websocket/events/orders-events.d.ts +0 -284
- package/dist/websocket/events/orders-events.js +0 -0
- package/dist/websocket/events/trade-events.d.ts +0 -34
- package/dist/websocket/events/trade-events.js +0 -5
- package/dist/websocket/index.d.ts +0 -8
- package/dist/websocket/index.js +0 -8
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Market API Validation Schemas
|
|
3
|
-
*/
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
/**
|
|
6
|
-
* Candlestick interval validation
|
|
7
|
-
*/
|
|
8
|
-
export declare const IntervalSchema: z.ZodEnum<{
|
|
9
|
-
"1m": "1m";
|
|
10
|
-
"5m": "5m";
|
|
11
|
-
"15m": "15m";
|
|
12
|
-
"1h": "1h";
|
|
13
|
-
"4h": "4h";
|
|
14
|
-
"1d": "1d";
|
|
15
|
-
"30m": "30m";
|
|
16
|
-
"1w": "1w";
|
|
17
|
-
"1M": "1M";
|
|
18
|
-
}>;
|
|
19
|
-
/**
|
|
20
|
-
* Timestamp validation (milliseconds since epoch)
|
|
21
|
-
*
|
|
22
|
-
* Validates that the timestamp is:
|
|
23
|
-
* - A positive integer
|
|
24
|
-
* - At least Jan 1, 2000 (catches seconds vs milliseconds errors)
|
|
25
|
-
* - Within JavaScript's safe integer range
|
|
26
|
-
* - Not unreasonably far in the future (max 1 year ahead)
|
|
27
|
-
*
|
|
28
|
-
* **Why these bounds matter:**
|
|
29
|
-
* - Prevents typos (e.g., using seconds instead of milliseconds: 1609459200 vs 1609459200000)
|
|
30
|
-
* - Catches date calculation errors (e.g., Date.now() * 1000 instead of Date.now())
|
|
31
|
-
* - Ensures timestamps won't cause precision issues in JavaScript
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* // Valid timestamps (milliseconds)
|
|
36
|
-
* validate(TimestampSchema, 1609459200000); // Jan 1, 2021 ✅
|
|
37
|
-
* validate(TimestampSchema, Date.now()); // Current time ✅
|
|
38
|
-
* validate(TimestampSchema, Date.now() + 86400000); // Tomorrow ✅
|
|
39
|
-
*
|
|
40
|
-
* // Invalid timestamps
|
|
41
|
-
* validate(TimestampSchema, 1609459200); // Seconds instead of ms (Jan 19, 1970) ❌
|
|
42
|
-
* validate(TimestampSchema, Date.now() * 1000); // Way too large ❌
|
|
43
|
-
* validate(TimestampSchema, 9999999999999999); // Far future (year 2286) ❌
|
|
44
|
-
* validate(TimestampSchema, 100000); // Too old (Jan 1, 1970) ❌
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare const TimestampSchema: z.ZodNumber;
|
|
48
|
-
/**
|
|
49
|
-
* Get Candlesticks validation schema (by trading pair ID)
|
|
50
|
-
*
|
|
51
|
-
* Validates parameters for fetching candlestick (OHLCV) data using a trading pair UUID.
|
|
52
|
-
* Ensures that the time range is valid by checking that startTime < endTime.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* // Valid request
|
|
57
|
-
* validate(GetCandlesticksSchema, {
|
|
58
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
59
|
-
* interval: "1h",
|
|
60
|
-
* startTime: 1609459200000, // Jan 1, 2021
|
|
61
|
-
* endTime: 1640995200000 // Jan 1, 2022
|
|
62
|
-
* });
|
|
63
|
-
*
|
|
64
|
-
* // Invalid: backwards time range
|
|
65
|
-
* validate(GetCandlesticksSchema, {
|
|
66
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
67
|
-
* interval: "1h",
|
|
68
|
-
* startTime: 1640995200000, // Jan 1, 2022
|
|
69
|
-
* endTime: 1609459200000 // Jan 1, 2021
|
|
70
|
-
* });
|
|
71
|
-
* // ValidationError: startTime must be less than endTime
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export declare const GetCandlesticksSchema: z.ZodObject<{
|
|
75
|
-
tradingPairId: z.ZodUUID;
|
|
76
|
-
interval: z.ZodEnum<{
|
|
77
|
-
"1m": "1m";
|
|
78
|
-
"5m": "5m";
|
|
79
|
-
"15m": "15m";
|
|
80
|
-
"1h": "1h";
|
|
81
|
-
"4h": "4h";
|
|
82
|
-
"1d": "1d";
|
|
83
|
-
"30m": "30m";
|
|
84
|
-
"1w": "1w";
|
|
85
|
-
"1M": "1M";
|
|
86
|
-
}>;
|
|
87
|
-
startTime: z.ZodNumber;
|
|
88
|
-
endTime: z.ZodNumber;
|
|
89
|
-
}, z.core.$strip>;
|
|
90
|
-
/**
|
|
91
|
-
* Trading pair symbol validation
|
|
92
|
-
*
|
|
93
|
-
* Validates trading pair symbols like "BTC/USDT", "ETH/USD", etc.
|
|
94
|
-
* Symbol format: BASE/QUOTE where:
|
|
95
|
-
* - BASE and QUOTE are 1-10 alphanumeric characters
|
|
96
|
-
* - Separated by a forward slash
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* // Valid symbols
|
|
101
|
-
* validate(TradingPairSymbolSchema, "BTC/USDT"); ✅
|
|
102
|
-
* validate(TradingPairSymbolSchema, "ETH/USD"); ✅
|
|
103
|
-
* validate(TradingPairSymbolSchema, "MTK/USDCo"); ✅
|
|
104
|
-
*
|
|
105
|
-
* // Invalid symbols
|
|
106
|
-
* validate(TradingPairSymbolSchema, "BTC"); ❌ Missing quote token
|
|
107
|
-
* validate(TradingPairSymbolSchema, "BTC-USDT"); ❌ Wrong separator
|
|
108
|
-
* validate(TradingPairSymbolSchema, "/USDT"); ❌ Missing base token
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
export declare const TradingPairSymbolSchema: z.ZodString;
|
|
112
|
-
/**
|
|
113
|
-
* Candlestick limit validation
|
|
114
|
-
*
|
|
115
|
-
* Validates the limit parameter for candlestick queries:
|
|
116
|
-
* - Must be a positive integer
|
|
117
|
-
* - Maximum of 500 bars per request
|
|
118
|
-
* - Server defaults to 350 if not specified
|
|
119
|
-
*/
|
|
120
|
-
export declare const CandlestickLimitSchema: z.ZodOptional<z.ZodNumber>;
|
|
121
|
-
/**
|
|
122
|
-
* Get Candlesticks By Trading Pair ID validation schema
|
|
123
|
-
*
|
|
124
|
-
* Validates parameters for fetching candlestick (OHLCV) data using a trading pair UUID.
|
|
125
|
-
* All time parameters are optional and can be used independently:
|
|
126
|
-
* - Use `endTime` + `limit` for backward pagination (TradingView primary pattern)
|
|
127
|
-
* - Use `startTime` + `limit` for forward pagination
|
|
128
|
-
* - Use just `limit` for most recent bars
|
|
129
|
-
* - Use `startTime` + `endTime` + `limit` for a specific range (capped at limit)
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```typescript
|
|
133
|
-
* // Get 350 most recent bars
|
|
134
|
-
* validate(GetCandlesticksByPairIdSchema, {
|
|
135
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
136
|
-
* interval: "1h",
|
|
137
|
-
* limit: 350
|
|
138
|
-
* });
|
|
139
|
-
*
|
|
140
|
-
* // Backward pagination (TradingView pattern)
|
|
141
|
-
* validate(GetCandlesticksByPairIdSchema, {
|
|
142
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
143
|
-
* interval: "1h",
|
|
144
|
-
* endTime: 1640995200000,
|
|
145
|
-
* limit: 350
|
|
146
|
-
* });
|
|
147
|
-
*
|
|
148
|
-
* // Specific range
|
|
149
|
-
* validate(GetCandlesticksByPairIdSchema, {
|
|
150
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
151
|
-
* interval: "1h",
|
|
152
|
-
* startTime: 1609459200000,
|
|
153
|
-
* endTime: 1640995200000,
|
|
154
|
-
* limit: 350
|
|
155
|
-
* });
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
export declare const GetCandlesticksByPairIdSchema: z.ZodObject<{
|
|
159
|
-
tradingPairId: z.ZodUUID;
|
|
160
|
-
interval: z.ZodEnum<{
|
|
161
|
-
"1m": "1m";
|
|
162
|
-
"5m": "5m";
|
|
163
|
-
"15m": "15m";
|
|
164
|
-
"1h": "1h";
|
|
165
|
-
"4h": "4h";
|
|
166
|
-
"1d": "1d";
|
|
167
|
-
"30m": "30m";
|
|
168
|
-
"1w": "1w";
|
|
169
|
-
"1M": "1M";
|
|
170
|
-
}>;
|
|
171
|
-
startTime: z.ZodOptional<z.ZodNumber>;
|
|
172
|
-
endTime: z.ZodOptional<z.ZodNumber>;
|
|
173
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
174
|
-
}, z.core.$strip>;
|
|
175
|
-
/**
|
|
176
|
-
* @deprecated Use GetCandlesticksByPairIdSchema instead. Symbol-based lookups are no longer supported.
|
|
177
|
-
*/
|
|
178
|
-
export declare const GetCandlesticksBySymbolSchema: z.ZodObject<{
|
|
179
|
-
tradingPairId: z.ZodUUID;
|
|
180
|
-
interval: z.ZodEnum<{
|
|
181
|
-
"1m": "1m";
|
|
182
|
-
"5m": "5m";
|
|
183
|
-
"15m": "15m";
|
|
184
|
-
"1h": "1h";
|
|
185
|
-
"4h": "4h";
|
|
186
|
-
"1d": "1d";
|
|
187
|
-
"30m": "30m";
|
|
188
|
-
"1w": "1w";
|
|
189
|
-
"1M": "1M";
|
|
190
|
-
}>;
|
|
191
|
-
startTime: z.ZodOptional<z.ZodNumber>;
|
|
192
|
-
endTime: z.ZodOptional<z.ZodNumber>;
|
|
193
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
194
|
-
}, z.core.$strip>;
|
|
195
|
-
/**
|
|
196
|
-
* Get Trading Pair validation schema
|
|
197
|
-
*/
|
|
198
|
-
export declare const GetTradingPairSchema: z.ZodObject<{
|
|
199
|
-
tradingPairId: z.ZodUUID;
|
|
200
|
-
}, z.core.$strip>;
|
|
201
|
-
/**
|
|
202
|
-
* Search Trading Pairs validation schema
|
|
203
|
-
*/
|
|
204
|
-
export declare const SearchTradingPairsSchema: z.ZodObject<{
|
|
205
|
-
query: z.ZodOptional<z.ZodString>;
|
|
206
|
-
page_size: z.ZodOptional<z.ZodNumber>;
|
|
207
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
208
|
-
}, z.core.$strip>;
|
|
209
|
-
/**
|
|
210
|
-
* Get Market Metadata validation schema
|
|
211
|
-
*/
|
|
212
|
-
export declare const GetMarketMetadataSchema: z.ZodObject<{
|
|
213
|
-
tradingPairId: z.ZodUUID;
|
|
214
|
-
}, z.core.$strip>;
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Market API Validation Schemas
|
|
3
|
-
*/
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { UUIDSchema } from "./trading";
|
|
6
|
-
/**
|
|
7
|
-
* Candlestick interval validation
|
|
8
|
-
*/
|
|
9
|
-
export const IntervalSchema = z.enum(["1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w", "1M"], {
|
|
10
|
-
message: 'Interval must be one of: "1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w", "1M"',
|
|
11
|
-
});
|
|
12
|
-
/**
|
|
13
|
-
* Maximum allowed future offset for timestamps (1 year in milliseconds)
|
|
14
|
-
*
|
|
15
|
-
* Allows queries for future dates (e.g., for scheduling or filtering) but
|
|
16
|
-
* prevents unreasonably far future dates that are likely input errors.
|
|
17
|
-
*/
|
|
18
|
-
const MAX_TIMESTAMP_FUTURE_OFFSET_MS = 365 * 24 * 60 * 60 * 1000; // 1 year
|
|
19
|
-
/**
|
|
20
|
-
* Minimum allowed timestamp (Jan 1, 2000 in milliseconds)
|
|
21
|
-
*
|
|
22
|
-
* This catches the common error of passing timestamps in seconds instead of milliseconds.
|
|
23
|
-
* Any timestamp before year 2000 is likely an error (either seconds or invalid date).
|
|
24
|
-
*/
|
|
25
|
-
const MIN_TIMESTAMP_MS = 946684800000; // Jan 1, 2000 00:00:00 UTC
|
|
26
|
-
/**
|
|
27
|
-
* Timestamp validation (milliseconds since epoch)
|
|
28
|
-
*
|
|
29
|
-
* Validates that the timestamp is:
|
|
30
|
-
* - A positive integer
|
|
31
|
-
* - At least Jan 1, 2000 (catches seconds vs milliseconds errors)
|
|
32
|
-
* - Within JavaScript's safe integer range
|
|
33
|
-
* - Not unreasonably far in the future (max 1 year ahead)
|
|
34
|
-
*
|
|
35
|
-
* **Why these bounds matter:**
|
|
36
|
-
* - Prevents typos (e.g., using seconds instead of milliseconds: 1609459200 vs 1609459200000)
|
|
37
|
-
* - Catches date calculation errors (e.g., Date.now() * 1000 instead of Date.now())
|
|
38
|
-
* - Ensures timestamps won't cause precision issues in JavaScript
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* // Valid timestamps (milliseconds)
|
|
43
|
-
* validate(TimestampSchema, 1609459200000); // Jan 1, 2021 ✅
|
|
44
|
-
* validate(TimestampSchema, Date.now()); // Current time ✅
|
|
45
|
-
* validate(TimestampSchema, Date.now() + 86400000); // Tomorrow ✅
|
|
46
|
-
*
|
|
47
|
-
* // Invalid timestamps
|
|
48
|
-
* validate(TimestampSchema, 1609459200); // Seconds instead of ms (Jan 19, 1970) ❌
|
|
49
|
-
* validate(TimestampSchema, Date.now() * 1000); // Way too large ❌
|
|
50
|
-
* validate(TimestampSchema, 9999999999999999); // Far future (year 2286) ❌
|
|
51
|
-
* validate(TimestampSchema, 100000); // Too old (Jan 1, 1970) ❌
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export const TimestampSchema = z
|
|
55
|
-
.number()
|
|
56
|
-
.int()
|
|
57
|
-
.positive({
|
|
58
|
-
message: "Timestamp must be a positive integer (milliseconds since epoch)",
|
|
59
|
-
})
|
|
60
|
-
.min(MIN_TIMESTAMP_MS, {
|
|
61
|
-
message: "Timestamp must be at least Jan 1, 2000 (946684800000 ms). Did you pass seconds instead of milliseconds?",
|
|
62
|
-
})
|
|
63
|
-
.max(Number.MAX_SAFE_INTEGER, {
|
|
64
|
-
message: "Timestamp must not exceed JavaScript's maximum safe integer",
|
|
65
|
-
})
|
|
66
|
-
.refine((value) => value <= Date.now() + MAX_TIMESTAMP_FUTURE_OFFSET_MS, {
|
|
67
|
-
message: "Timestamp must not be unreasonably far in the future (max 1 year ahead)",
|
|
68
|
-
});
|
|
69
|
-
/**
|
|
70
|
-
* Get Candlesticks validation schema (by trading pair ID)
|
|
71
|
-
*
|
|
72
|
-
* Validates parameters for fetching candlestick (OHLCV) data using a trading pair UUID.
|
|
73
|
-
* Ensures that the time range is valid by checking that startTime < endTime.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* // Valid request
|
|
78
|
-
* validate(GetCandlesticksSchema, {
|
|
79
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
80
|
-
* interval: "1h",
|
|
81
|
-
* startTime: 1609459200000, // Jan 1, 2021
|
|
82
|
-
* endTime: 1640995200000 // Jan 1, 2022
|
|
83
|
-
* });
|
|
84
|
-
*
|
|
85
|
-
* // Invalid: backwards time range
|
|
86
|
-
* validate(GetCandlesticksSchema, {
|
|
87
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
88
|
-
* interval: "1h",
|
|
89
|
-
* startTime: 1640995200000, // Jan 1, 2022
|
|
90
|
-
* endTime: 1609459200000 // Jan 1, 2021
|
|
91
|
-
* });
|
|
92
|
-
* // ValidationError: startTime must be less than endTime
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
export const GetCandlesticksSchema = z
|
|
96
|
-
.object({
|
|
97
|
-
tradingPairId: UUIDSchema,
|
|
98
|
-
interval: IntervalSchema,
|
|
99
|
-
startTime: TimestampSchema,
|
|
100
|
-
endTime: TimestampSchema,
|
|
101
|
-
})
|
|
102
|
-
.refine((data) => data.startTime < data.endTime, {
|
|
103
|
-
message: "startTime must be less than endTime",
|
|
104
|
-
path: ["endTime"],
|
|
105
|
-
});
|
|
106
|
-
/**
|
|
107
|
-
* Trading pair symbol validation
|
|
108
|
-
*
|
|
109
|
-
* Validates trading pair symbols like "BTC/USDT", "ETH/USD", etc.
|
|
110
|
-
* Symbol format: BASE/QUOTE where:
|
|
111
|
-
* - BASE and QUOTE are 1-10 alphanumeric characters
|
|
112
|
-
* - Separated by a forward slash
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```typescript
|
|
116
|
-
* // Valid symbols
|
|
117
|
-
* validate(TradingPairSymbolSchema, "BTC/USDT"); ✅
|
|
118
|
-
* validate(TradingPairSymbolSchema, "ETH/USD"); ✅
|
|
119
|
-
* validate(TradingPairSymbolSchema, "MTK/USDCo"); ✅
|
|
120
|
-
*
|
|
121
|
-
* // Invalid symbols
|
|
122
|
-
* validate(TradingPairSymbolSchema, "BTC"); ❌ Missing quote token
|
|
123
|
-
* validate(TradingPairSymbolSchema, "BTC-USDT"); ❌ Wrong separator
|
|
124
|
-
* validate(TradingPairSymbolSchema, "/USDT"); ❌ Missing base token
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
export const TradingPairSymbolSchema = z
|
|
128
|
-
.string()
|
|
129
|
-
.min(1, "Trading pair symbol cannot be empty")
|
|
130
|
-
.regex(/^[A-Za-z0-9]{1,10}\/[A-Za-z0-9]{1,10}$/, {
|
|
131
|
-
message: 'Trading pair symbol must be in format "BASE/QUOTE" (e.g., "BTC/USDT", "ETH/USD")',
|
|
132
|
-
});
|
|
133
|
-
/**
|
|
134
|
-
* Candlestick limit validation
|
|
135
|
-
*
|
|
136
|
-
* Validates the limit parameter for candlestick queries:
|
|
137
|
-
* - Must be a positive integer
|
|
138
|
-
* - Maximum of 500 bars per request
|
|
139
|
-
* - Server defaults to 350 if not specified
|
|
140
|
-
*/
|
|
141
|
-
export const CandlestickLimitSchema = z
|
|
142
|
-
.number()
|
|
143
|
-
.int()
|
|
144
|
-
.positive({ message: "Limit must be a positive integer" })
|
|
145
|
-
.max(500, { message: "Limit cannot exceed 500 bars per request" })
|
|
146
|
-
.optional();
|
|
147
|
-
/**
|
|
148
|
-
* Get Candlesticks By Trading Pair ID validation schema
|
|
149
|
-
*
|
|
150
|
-
* Validates parameters for fetching candlestick (OHLCV) data using a trading pair UUID.
|
|
151
|
-
* All time parameters are optional and can be used independently:
|
|
152
|
-
* - Use `endTime` + `limit` for backward pagination (TradingView primary pattern)
|
|
153
|
-
* - Use `startTime` + `limit` for forward pagination
|
|
154
|
-
* - Use just `limit` for most recent bars
|
|
155
|
-
* - Use `startTime` + `endTime` + `limit` for a specific range (capped at limit)
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```typescript
|
|
159
|
-
* // Get 350 most recent bars
|
|
160
|
-
* validate(GetCandlesticksByPairIdSchema, {
|
|
161
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
162
|
-
* interval: "1h",
|
|
163
|
-
* limit: 350
|
|
164
|
-
* });
|
|
165
|
-
*
|
|
166
|
-
* // Backward pagination (TradingView pattern)
|
|
167
|
-
* validate(GetCandlesticksByPairIdSchema, {
|
|
168
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
169
|
-
* interval: "1h",
|
|
170
|
-
* endTime: 1640995200000,
|
|
171
|
-
* limit: 350
|
|
172
|
-
* });
|
|
173
|
-
*
|
|
174
|
-
* // Specific range
|
|
175
|
-
* validate(GetCandlesticksByPairIdSchema, {
|
|
176
|
-
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
177
|
-
* interval: "1h",
|
|
178
|
-
* startTime: 1609459200000,
|
|
179
|
-
* endTime: 1640995200000,
|
|
180
|
-
* limit: 350
|
|
181
|
-
* });
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
export const GetCandlesticksByPairIdSchema = z
|
|
185
|
-
.object({
|
|
186
|
-
tradingPairId: UUIDSchema,
|
|
187
|
-
interval: IntervalSchema,
|
|
188
|
-
startTime: TimestampSchema.optional(),
|
|
189
|
-
endTime: TimestampSchema.optional(),
|
|
190
|
-
limit: CandlestickLimitSchema,
|
|
191
|
-
})
|
|
192
|
-
.refine((data) => {
|
|
193
|
-
// Only validate startTime < endTime if both are provided
|
|
194
|
-
if (data.startTime !== undefined && data.endTime !== undefined) {
|
|
195
|
-
return data.startTime < data.endTime;
|
|
196
|
-
}
|
|
197
|
-
return true;
|
|
198
|
-
}, {
|
|
199
|
-
message: "startTime must be less than endTime",
|
|
200
|
-
path: ["endTime"],
|
|
201
|
-
});
|
|
202
|
-
/**
|
|
203
|
-
* @deprecated Use GetCandlesticksByPairIdSchema instead. Symbol-based lookups are no longer supported.
|
|
204
|
-
*/
|
|
205
|
-
export const GetCandlesticksBySymbolSchema = GetCandlesticksByPairIdSchema;
|
|
206
|
-
/**
|
|
207
|
-
* Get Trading Pair validation schema
|
|
208
|
-
*/
|
|
209
|
-
export const GetTradingPairSchema = z.object({
|
|
210
|
-
tradingPairId: UUIDSchema,
|
|
211
|
-
});
|
|
212
|
-
/**
|
|
213
|
-
* Search Trading Pairs validation schema
|
|
214
|
-
*/
|
|
215
|
-
export const SearchTradingPairsSchema = z.object({
|
|
216
|
-
query: z.string().min(1, "Search query cannot be empty").optional(),
|
|
217
|
-
page_size: z.number().int().min(1).max(100).optional(),
|
|
218
|
-
page: z.number().int().min(1).optional(),
|
|
219
|
-
});
|
|
220
|
-
/**
|
|
221
|
-
* Get Market Metadata validation schema
|
|
222
|
-
*/
|
|
223
|
-
export const GetMarketMetadataSchema = z.object({
|
|
224
|
-
tradingPairId: UUIDSchema,
|
|
225
|
-
});
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Positions API Validation Schemas
|
|
3
|
-
*/
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
export declare const ListPositionsSchema: z.ZodObject<{
|
|
6
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
7
|
-
page_size: z.ZodOptional<z.ZodNumber>;
|
|
8
|
-
margin_account_id: z.ZodOptional<z.ZodUUID>;
|
|
9
|
-
trading_pair_id: z.ZodOptional<z.ZodUUID>;
|
|
10
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
11
|
-
OPEN: "OPEN";
|
|
12
|
-
CLOSED: "CLOSED";
|
|
13
|
-
LIQUIDATING: "LIQUIDATING";
|
|
14
|
-
}>>;
|
|
15
|
-
}, z.core.$strip>;
|
|
16
|
-
export declare const GetPositionSchema: z.ZodObject<{
|
|
17
|
-
positionId: z.ZodUUID;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
export declare const ClosePositionSchema: z.ZodObject<{
|
|
20
|
-
positionId: z.ZodUUID;
|
|
21
|
-
request: z.ZodObject<{
|
|
22
|
-
closeType: z.ZodEnum<{
|
|
23
|
-
LIMIT: "LIMIT";
|
|
24
|
-
MARKET: "MARKET";
|
|
25
|
-
IOC: "IOC";
|
|
26
|
-
}>;
|
|
27
|
-
limitPrice: z.ZodOptional<z.ZodString>;
|
|
28
|
-
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
29
|
-
quantity: z.ZodOptional<z.ZodString>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
}, z.core.$strip>;
|
|
32
|
-
export declare const GetPositionRiskSchema: z.ZodObject<{
|
|
33
|
-
positionId: z.ZodUUID;
|
|
34
|
-
}, z.core.$strip>;
|
|
35
|
-
export declare const AddPositionMarginSchema: z.ZodObject<{
|
|
36
|
-
positionId: z.ZodUUID;
|
|
37
|
-
request: z.ZodObject<{
|
|
38
|
-
amount: z.ZodString;
|
|
39
|
-
asset: z.ZodString;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
|
-
}, z.core.$strip>;
|
|
42
|
-
export declare const ReducePositionMarginSchema: z.ZodObject<{
|
|
43
|
-
positionId: z.ZodUUID;
|
|
44
|
-
request: z.ZodObject<{
|
|
45
|
-
amount: z.ZodString;
|
|
46
|
-
}, z.core.$strip>;
|
|
47
|
-
}, z.core.$strip>;
|
|
48
|
-
export declare const AttachPositionTpSlSchema: z.ZodObject<{
|
|
49
|
-
positionId: z.ZodUUID;
|
|
50
|
-
request: z.ZodObject<{
|
|
51
|
-
takeProfit: z.ZodOptional<z.ZodObject<{
|
|
52
|
-
triggerPrice: z.ZodString;
|
|
53
|
-
orderType: z.ZodEnum<{
|
|
54
|
-
LIMIT: "LIMIT";
|
|
55
|
-
MARKET: "MARKET";
|
|
56
|
-
}>;
|
|
57
|
-
limitPrice: z.ZodOptional<z.ZodString>;
|
|
58
|
-
quantity: z.ZodOptional<z.ZodString>;
|
|
59
|
-
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
60
|
-
GTC: "GTC";
|
|
61
|
-
IOC: "IOC";
|
|
62
|
-
}>>;
|
|
63
|
-
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
64
|
-
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
65
|
-
}, z.core.$strip>>;
|
|
66
|
-
stopLoss: z.ZodOptional<z.ZodObject<{
|
|
67
|
-
triggerPrice: z.ZodString;
|
|
68
|
-
orderType: z.ZodEnum<{
|
|
69
|
-
LIMIT: "LIMIT";
|
|
70
|
-
MARKET: "MARKET";
|
|
71
|
-
}>;
|
|
72
|
-
limitPrice: z.ZodOptional<z.ZodString>;
|
|
73
|
-
quantity: z.ZodOptional<z.ZodString>;
|
|
74
|
-
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
75
|
-
GTC: "GTC";
|
|
76
|
-
IOC: "IOC";
|
|
77
|
-
}>>;
|
|
78
|
-
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
79
|
-
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
80
|
-
}, z.core.$strip>>;
|
|
81
|
-
}, z.core.$strip>;
|
|
82
|
-
}, z.core.$strip>;
|
|
83
|
-
export declare const ListPositionHistorySchema: z.ZodObject<{
|
|
84
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
85
|
-
page_size: z.ZodOptional<z.ZodNumber>;
|
|
86
|
-
position_id: z.ZodOptional<z.ZodUUID>;
|
|
87
|
-
margin_account_id: z.ZodOptional<z.ZodUUID>;
|
|
88
|
-
trading_pair_id: z.ZodOptional<z.ZodUUID>;
|
|
89
|
-
}, z.core.$strip>;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Positions API Validation Schemas
|
|
3
|
-
*/
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { ConditionalTimeInForceSchema, ISO8601DateSchema, OrderTypeSchema, PositiveDecimalStringSchema, SlippageToleranceBpsSchema, UUIDSchema, } from "./trading";
|
|
6
|
-
const PaginationSchema = z.object({
|
|
7
|
-
page: z.number().int().min(1, "Page must be at least 1").optional(),
|
|
8
|
-
page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
|
|
9
|
-
});
|
|
10
|
-
const PositionStatusSchema = z.enum(["OPEN", "CLOSED", "LIQUIDATING"], {
|
|
11
|
-
message: 'Position status must be "OPEN", "CLOSED", or "LIQUIDATING"',
|
|
12
|
-
});
|
|
13
|
-
const ClosePositionTypeSchema = z.enum(["MARKET", "LIMIT", "IOC"], {
|
|
14
|
-
message: 'Close type must be "MARKET", "LIMIT", or "IOC"',
|
|
15
|
-
});
|
|
16
|
-
const PositionIdSchema = z.object({
|
|
17
|
-
positionId: UUIDSchema,
|
|
18
|
-
});
|
|
19
|
-
export const ListPositionsSchema = PaginationSchema.extend({
|
|
20
|
-
margin_account_id: UUIDSchema.optional(),
|
|
21
|
-
trading_pair_id: UUIDSchema.optional(),
|
|
22
|
-
status: PositionStatusSchema.optional(),
|
|
23
|
-
});
|
|
24
|
-
export const GetPositionSchema = PositionIdSchema;
|
|
25
|
-
export const ClosePositionSchema = PositionIdSchema.extend({
|
|
26
|
-
request: z.object({
|
|
27
|
-
closeType: ClosePositionTypeSchema,
|
|
28
|
-
limitPrice: PositiveDecimalStringSchema.optional(),
|
|
29
|
-
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
30
|
-
quantity: PositiveDecimalStringSchema.optional(),
|
|
31
|
-
}),
|
|
32
|
-
})
|
|
33
|
-
.refine((data) => data.request.closeType !== "LIMIT" || data.request.limitPrice !== undefined, {
|
|
34
|
-
message: "limitPrice is required for LIMIT close requests",
|
|
35
|
-
path: ["request", "limitPrice"],
|
|
36
|
-
})
|
|
37
|
-
.refine((data) => data.request.closeType === "LIMIT" || data.request.limitPrice === undefined, {
|
|
38
|
-
message: "limitPrice is only allowed for LIMIT close requests",
|
|
39
|
-
path: ["request", "limitPrice"],
|
|
40
|
-
});
|
|
41
|
-
export const GetPositionRiskSchema = PositionIdSchema;
|
|
42
|
-
export const AddPositionMarginSchema = PositionIdSchema.extend({
|
|
43
|
-
request: z.object({
|
|
44
|
-
amount: PositiveDecimalStringSchema,
|
|
45
|
-
asset: z.string().trim().min(1, "Asset cannot be empty"),
|
|
46
|
-
}),
|
|
47
|
-
});
|
|
48
|
-
export const ReducePositionMarginSchema = PositionIdSchema.extend({
|
|
49
|
-
request: z.object({
|
|
50
|
-
amount: PositiveDecimalStringSchema,
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
const TpSlLegSchema = z
|
|
54
|
-
.object({
|
|
55
|
-
triggerPrice: PositiveDecimalStringSchema,
|
|
56
|
-
orderType: OrderTypeSchema,
|
|
57
|
-
limitPrice: PositiveDecimalStringSchema.optional(),
|
|
58
|
-
quantity: PositiveDecimalStringSchema.optional(),
|
|
59
|
-
timeInForce: ConditionalTimeInForceSchema.optional(),
|
|
60
|
-
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
61
|
-
expiresAt: ISO8601DateSchema.optional(),
|
|
62
|
-
})
|
|
63
|
-
.refine((data) => data.orderType !== "LIMIT" || data.limitPrice !== undefined, {
|
|
64
|
-
message: "limitPrice is required for LIMIT TP/SL legs",
|
|
65
|
-
path: ["limitPrice"],
|
|
66
|
-
})
|
|
67
|
-
.refine((data) => data.orderType !== "MARKET" || data.limitPrice === undefined, {
|
|
68
|
-
message: "limitPrice must not be provided for MARKET TP/SL legs",
|
|
69
|
-
path: ["limitPrice"],
|
|
70
|
-
})
|
|
71
|
-
.refine((data) => data.orderType !== "MARKET" || data.timeInForce === undefined, {
|
|
72
|
-
message: "timeInForce is only allowed for LIMIT TP/SL legs",
|
|
73
|
-
path: ["timeInForce"],
|
|
74
|
-
})
|
|
75
|
-
.refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
|
|
76
|
-
message: "slippageToleranceBps is only allowed for MARKET TP/SL legs",
|
|
77
|
-
path: ["slippageToleranceBps"],
|
|
78
|
-
});
|
|
79
|
-
export const AttachPositionTpSlSchema = PositionIdSchema.extend({
|
|
80
|
-
request: z
|
|
81
|
-
.object({
|
|
82
|
-
takeProfit: TpSlLegSchema.optional(),
|
|
83
|
-
stopLoss: TpSlLegSchema.optional(),
|
|
84
|
-
})
|
|
85
|
-
.refine((data) => data.takeProfit !== undefined || data.stopLoss !== undefined, {
|
|
86
|
-
message: "At least one of takeProfit or stopLoss is required",
|
|
87
|
-
}),
|
|
88
|
-
});
|
|
89
|
-
export const ListPositionHistorySchema = PaginationSchema.extend({
|
|
90
|
-
position_id: UUIDSchema.optional(),
|
|
91
|
-
margin_account_id: UUIDSchema.optional(),
|
|
92
|
-
trading_pair_id: UUIDSchema.optional(),
|
|
93
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Profile API Validation Schemas
|
|
3
|
-
*
|
|
4
|
-
* Zod schemas for validating profile API inputs before making requests.
|
|
5
|
-
* Provides clear, actionable error messages for invalid parameters.
|
|
6
|
-
*/
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
/**
|
|
9
|
-
* Ledger entry type validation
|
|
10
|
-
*/
|
|
11
|
-
export declare const LedgerEntryTypeSchema: z.ZodEnum<{
|
|
12
|
-
CREDIT: "CREDIT";
|
|
13
|
-
DEBIT: "DEBIT";
|
|
14
|
-
LOCK: "LOCK";
|
|
15
|
-
UNLOCK: "UNLOCK";
|
|
16
|
-
FEE: "FEE";
|
|
17
|
-
}>;
|
|
18
|
-
/**
|
|
19
|
-
* Transaction type validation
|
|
20
|
-
*/
|
|
21
|
-
export declare const TransactionTypeSchema: z.ZodEnum<{
|
|
22
|
-
FEE: "FEE";
|
|
23
|
-
DEPOSIT: "DEPOSIT";
|
|
24
|
-
WITHDRAWAL: "WITHDRAWAL";
|
|
25
|
-
TRADE: "TRADE";
|
|
26
|
-
FUNDING: "FUNDING";
|
|
27
|
-
LIQUIDATION: "LIQUIDATION";
|
|
28
|
-
INTEREST: "INTEREST";
|
|
29
|
-
REWARD: "REWARD";
|
|
30
|
-
}>;
|
|
31
|
-
/**
|
|
32
|
-
* Get User Movements validation schema
|
|
33
|
-
*
|
|
34
|
-
* Validates parameters for fetching paginated user movements.
|
|
35
|
-
* All fields are optional — an empty object or undefined is valid.
|
|
36
|
-
*/
|
|
37
|
-
export declare const GetUserMovementsSchema: z.ZodObject<{
|
|
38
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
39
|
-
page_size: z.ZodOptional<z.ZodNumber>;
|
|
40
|
-
entry_type: z.ZodOptional<z.ZodEnum<{
|
|
41
|
-
CREDIT: "CREDIT";
|
|
42
|
-
DEBIT: "DEBIT";
|
|
43
|
-
LOCK: "LOCK";
|
|
44
|
-
UNLOCK: "UNLOCK";
|
|
45
|
-
FEE: "FEE";
|
|
46
|
-
}>>;
|
|
47
|
-
transaction_type: z.ZodOptional<z.ZodEnum<{
|
|
48
|
-
FEE: "FEE";
|
|
49
|
-
DEPOSIT: "DEPOSIT";
|
|
50
|
-
WITHDRAWAL: "WITHDRAWAL";
|
|
51
|
-
TRADE: "TRADE";
|
|
52
|
-
FUNDING: "FUNDING";
|
|
53
|
-
LIQUIDATION: "LIQUIDATION";
|
|
54
|
-
INTEREST: "INTEREST";
|
|
55
|
-
REWARD: "REWARD";
|
|
56
|
-
}>>;
|
|
57
|
-
asset_id: z.ZodOptional<z.ZodUUID>;
|
|
58
|
-
}, z.core.$strip>;
|
|
59
|
-
/**
|
|
60
|
-
* Get User Trades validation schema
|
|
61
|
-
*
|
|
62
|
-
* Validates parameters for fetching paginated user trades.
|
|
63
|
-
* All fields are optional — an empty object or undefined is valid.
|
|
64
|
-
*/
|
|
65
|
-
export declare const GetUserTradesSchema: z.ZodObject<{
|
|
66
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
67
|
-
page_size: z.ZodOptional<z.ZodNumber>;
|
|
68
|
-
trading_pair_id: z.ZodOptional<z.ZodUUID>;
|
|
69
|
-
}, z.core.$strip>;
|