@pear-protocol/types 1.24.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/api-keys.js +11 -3
- package/dist/auth/entities.js +10 -2
- package/dist/auth/payloads.d.ts +7 -0
- package/dist/auth/payloads.js +15 -11
- package/dist/auth/response.js +4 -1
- package/dist/common/array.js +9 -2
- package/dist/common/refinement.js +25 -19
- package/dist/common/request.js +8 -8
- package/dist/common/response.js +10 -10
- package/dist/common/schema.js +9 -2
- package/dist/common/trade-legs.js +17 -12
- package/dist/connector/index.js +7 -1
- package/dist/execution/entities.js +96 -65
- package/dist/execution/queries.js +5 -1
- package/dist/execution/responses.js +3 -1
- package/dist/fee/entities.js +17 -3
- package/dist/fill/entities.js +33 -29
- package/dist/fill/queries.js +4 -1
- package/dist/funding/entities.js +4 -4
- package/dist/funding/responses.js +2 -2
- package/dist/instrument/entities.js +56 -44
- package/dist/instrument/queries.js +6 -1
- package/dist/instrument/responses.js +4 -4
- package/dist/instrument-precision/index.js +23 -23
- package/dist/ladder/entities.js +5 -1
- package/dist/ladder/payloads.js +15 -4
- package/dist/ladder/queries.js +0 -1
- package/dist/ladder/responses.js +12 -4
- package/dist/leverage/payloads.js +4 -1
- package/dist/notification/entities.js +37 -28
- package/dist/notification/payloads.js +9 -3
- package/dist/notification/queries.js +5 -1
- package/dist/notification/responses.js +4 -4
- package/dist/order/entities.js +38 -30
- package/dist/portfolio/queries.js +18 -3
- package/dist/position/entities.js +95 -72
- package/dist/position/queries.js +29 -23
- package/dist/price/entities.js +4 -1
- package/dist/price/responses.js +4 -4
- package/dist/rebalance/entities.js +23 -6
- package/dist/rebalance/payloads.js +23 -11
- package/dist/rebalance/queries.js +2 -8
- package/dist/rebalance/responses.js +12 -4
- package/dist/saved-baskets/entities.js +3 -1
- package/dist/saved-baskets/payloads.js +3 -1
- package/dist/schedule/entities.js +87 -71
- package/dist/schedule/payloads.js +36 -33
- package/dist/schedule/queries.js +5 -1
- package/dist/schedule/responses.js +12 -4
- package/dist/statistics/entities.d.ts +1 -0
- package/dist/statistics/entities.js +12 -0
- package/dist/statistics/queries.d.ts +2 -0
- package/dist/statistics/queries.js +16 -3
- package/dist/statistics/responses.d.ts +1 -0
- package/dist/sync/payloads.js +13 -17
- package/dist/tca/entities.js +4 -1
- package/dist/tca/responses.js +4 -1
- package/dist/trade/payloads.js +37 -23
- package/dist/trade/responses.js +15 -5
- package/dist/trade-accounts/entities.js +4 -1
- package/dist/trade-accounts/response.js +6 -2
- package/dist/trigger/common/index.js +27 -6
- package/dist/trigger/entities/conditions.js +14 -15
- package/dist/trigger/entities/index.js +89 -80
- package/dist/trigger/oracle.js +10 -3
- package/dist/trigger/payloads/conditions.js +8 -2
- package/dist/trigger/payloads/index.js +18 -4
- package/dist/trigger/queries.js +5 -1
- package/dist/trigger/refinement/static.refinement.js +5 -2
- package/dist/trigger/refinement/trailing.refinement.js +8 -6
- package/dist/trigger/responses.js +12 -4
- package/dist/triggers/entities.js +8 -2
- package/dist/users/entities.js +4 -1
- package/dist/users/payloads.js +17 -18
- package/package.json +1 -1
package/dist/fee/entities.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Connector } from '../connector';
|
|
3
3
|
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
6
|
const MAX_FEE_BPS = 10;
|
|
5
|
-
const FeeOverrideScope = z.enum([
|
|
6
|
-
|
|
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
|
+
]);
|
|
7
17
|
const FeeConnector = z.enum(Connector.options);
|
|
8
|
-
const FeeRole = z.enum([
|
|
18
|
+
const FeeRole = z.enum([
|
|
19
|
+
"basic",
|
|
20
|
+
"pro"
|
|
21
|
+
]);
|
|
9
22
|
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}`);
|
|
10
23
|
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');
|
|
11
24
|
const ORDERED_VALIDITY_WINDOW_MESSAGE = "endsAt must be later than startsAt";
|
|
@@ -15,5 +28,6 @@ function hasOrderedValidityWindow(window) {
|
|
|
15
28
|
}
|
|
16
29
|
return new Date(window.startsAt).getTime() < new Date(window.endsAt).getTime();
|
|
17
30
|
}
|
|
31
|
+
__name(hasOrderedValidityWindow, "hasOrderedValidityWindow");
|
|
18
32
|
|
|
19
33
|
export { DiscountRate, FeeBps, FeeConnector, FeeDiscountScope, FeeOverrideScope, FeeRole, MAX_FEE_BPS, ORDERED_VALIDITY_WINDOW_MESSAGE, hasOrderedValidityWindow };
|
package/dist/fill/entities.js
CHANGED
|
@@ -3,50 +3,54 @@ import { Side } from '../common/schema';
|
|
|
3
3
|
import { Connector } from '../connector';
|
|
4
4
|
import { InstrumentId } from '../instrument';
|
|
5
5
|
|
|
6
|
-
const FillStatus = z.enum([
|
|
6
|
+
const FillStatus = z.enum([
|
|
7
|
+
"PROVISIONAL",
|
|
8
|
+
"CONFIRMED",
|
|
9
|
+
"RECONCILED"
|
|
10
|
+
]);
|
|
7
11
|
const Fill = z.object({
|
|
8
12
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
* Fill UUID
|
|
14
|
+
*/
|
|
11
15
|
id: z.uuid(),
|
|
12
16
|
/** Client order ID (abbreviated as cloid) */
|
|
13
17
|
cloid: z.string().optional(),
|
|
14
18
|
/** Exchange-native fill ID (tradeId / tid / etc) */
|
|
15
19
|
exchangeFillId: z.string().optional(),
|
|
16
20
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
* Fill lifecycle status
|
|
22
|
+
*/
|
|
19
23
|
status: FillStatus,
|
|
20
24
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
* Trade account UUID
|
|
26
|
+
*/
|
|
23
27
|
tradeAccountId: z.uuid(),
|
|
24
28
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
* Instrument ID
|
|
30
|
+
*/
|
|
27
31
|
symbol: InstrumentId,
|
|
28
32
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
* Position UUID
|
|
34
|
+
*/
|
|
31
35
|
positionId: z.uuid(),
|
|
32
36
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
* Connector
|
|
38
|
+
*/
|
|
35
39
|
connector: Connector,
|
|
36
40
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
* Side
|
|
42
|
+
*/
|
|
39
43
|
side: Side,
|
|
40
44
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
* Reduce only flag
|
|
46
|
+
*/
|
|
43
47
|
reduceOnly: z.boolean(),
|
|
44
48
|
/** True when the fill was created from external sync. */
|
|
45
49
|
isExternal: z.boolean(),
|
|
46
50
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
*/
|
|
50
54
|
synthetic: z.boolean(),
|
|
51
55
|
quantity: z.string(),
|
|
52
56
|
/** Filled price — "0" on an unpriceable gone-close synthetic (no price guessing). */
|
|
@@ -54,21 +58,21 @@ const Fill = z.object({
|
|
|
54
58
|
/** USD value — "0" on an unpriceable gone-close synthetic (cannot compute without price). */
|
|
55
59
|
usd: z.string(),
|
|
56
60
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
* Trade fee paid
|
|
62
|
+
*/
|
|
59
63
|
tradeFee: z.string().optional(),
|
|
60
64
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
* Pear fee paid
|
|
66
|
+
*/
|
|
63
67
|
pearFee: z.string().optional(),
|
|
64
68
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
* Timestamp
|
|
70
|
+
*/
|
|
67
71
|
timestamp: z.string(),
|
|
68
72
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
+
*/
|
|
72
76
|
original: z.object({
|
|
73
77
|
exchangeFillId: z.string(),
|
|
74
78
|
quantity: z.string()
|
package/dist/fill/queries.js
CHANGED
|
@@ -2,7 +2,10 @@ import { z } from 'zod';
|
|
|
2
2
|
import { CursorFindParams } from '../common';
|
|
3
3
|
import { Connector } from '../connector';
|
|
4
4
|
|
|
5
|
-
const FillOrderBy = z.union([
|
|
5
|
+
const FillOrderBy = z.union([
|
|
6
|
+
z.literal("timestamp"),
|
|
7
|
+
z.literal("-timestamp")
|
|
8
|
+
]);
|
|
6
9
|
const FillListParams = CursorFindParams.extend({
|
|
7
10
|
connector: Connector.optional(),
|
|
8
11
|
orderBy: FillOrderBy.default("-timestamp")
|
package/dist/funding/entities.js
CHANGED
|
@@ -3,12 +3,12 @@ import { InstrumentId } from '../instrument';
|
|
|
3
3
|
|
|
4
4
|
const FundingInfo = z.object({
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* Funding rate
|
|
7
|
+
*/
|
|
8
8
|
r: z.string(),
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* Next funding time in milliseconds
|
|
11
|
+
*/
|
|
12
12
|
nft: z.number()
|
|
13
13
|
});
|
|
14
14
|
const InstrumentFundingMap = z.record(InstrumentId, FundingInfo);
|
|
@@ -3,9 +3,21 @@ import { Connector } from '../connector';
|
|
|
3
3
|
import { InstrumentPrecision } from '../instrument-precision';
|
|
4
4
|
|
|
5
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
|
-
|
|
8
|
-
|
|
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
|
+
]);
|
|
9
21
|
const InstrumentTradeabilityReason = z.string().nullable();
|
|
10
22
|
const InstrumentTradeability = z.object({
|
|
11
23
|
status: InstrumentTradeabilityStatus,
|
|
@@ -13,73 +25,73 @@ const InstrumentTradeability = z.object({
|
|
|
13
25
|
});
|
|
14
26
|
const Instrument = z.object({
|
|
15
27
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
* Exchange specific instrument identifier
|
|
29
|
+
* @example (dexIndex + assetIndex) on Hyperliquid
|
|
30
|
+
* @example "BTCUSDT" on Binance
|
|
31
|
+
*/
|
|
20
32
|
id: InstrumentId,
|
|
21
33
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
* The base asset of the instrument.
|
|
35
|
+
* @example "BTC"
|
|
36
|
+
*/
|
|
25
37
|
base: z.string(),
|
|
26
38
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
* The quote asset of the instrument.
|
|
40
|
+
* @example "USDT"
|
|
41
|
+
*/
|
|
30
42
|
quote: z.string(),
|
|
31
43
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
* The connector of the instrument.
|
|
45
|
+
* @example "hyperliquid"
|
|
46
|
+
* @example "binance"
|
|
47
|
+
*/
|
|
36
48
|
connector: Connector,
|
|
37
49
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
* The type of the instrument.
|
|
51
|
+
* @example "spot"
|
|
52
|
+
* @example "perp"
|
|
53
|
+
* @example "hip3"
|
|
54
|
+
*/
|
|
43
55
|
type: InstrumentType,
|
|
44
56
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
* The maximum leverage of the instrument.
|
|
58
|
+
* @example 1
|
|
59
|
+
*/
|
|
48
60
|
leverage: z.int().min(1),
|
|
49
61
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
*/
|
|
53
65
|
marginMode: InstrumentMarginMode,
|
|
54
66
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
* The precision of the instrument.
|
|
68
|
+
*/
|
|
57
69
|
precision: InstrumentPrecision,
|
|
58
70
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
* Whether this instrument can be traded normally.
|
|
72
|
+
*/
|
|
61
73
|
tradeability: InstrumentTradeability
|
|
62
74
|
});
|
|
63
75
|
const InstrumentLite = z.object({
|
|
64
76
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
* Exchange specific instrument identifier
|
|
78
|
+
* @example (dexIndex + assetIndex) on Hyperliquid
|
|
79
|
+
* @example "BTCUSDT" on Binance
|
|
80
|
+
*/
|
|
69
81
|
id: InstrumentId,
|
|
70
82
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
* The base asset of the instrument.
|
|
84
|
+
* @example "BTC"
|
|
85
|
+
*/
|
|
74
86
|
base: z.string(),
|
|
75
87
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
*/
|
|
79
91
|
marginMode: InstrumentMarginMode,
|
|
80
92
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
* Minimal precision — only the contract size the syncer needs for BASE-unit normalization.
|
|
94
|
+
*/
|
|
83
95
|
precision: z.object({
|
|
84
96
|
quantity: z.object({
|
|
85
97
|
contractSize: z.number()
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Connector } from '../connector';
|
|
3
3
|
|
|
4
|
-
const InstrumentScope = z.enum([
|
|
4
|
+
const InstrumentScope = z.enum([
|
|
5
|
+
"tradable",
|
|
6
|
+
"reduce_only",
|
|
7
|
+
"not_tradable",
|
|
8
|
+
"all"
|
|
9
|
+
]);
|
|
5
10
|
const InstrumentListParams = z.object({
|
|
6
11
|
connector: Connector,
|
|
7
12
|
scope: InstrumentScope.default("all")
|
|
@@ -3,8 +3,8 @@ import { Instrument, InstrumentId, InstrumentLite } from './entities';
|
|
|
3
3
|
|
|
4
4
|
const InstrumentListResponse = z.object({
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* The list of instruments.
|
|
7
|
+
*/
|
|
8
8
|
instruments: z.array(Instrument)
|
|
9
9
|
});
|
|
10
10
|
const InstrumentSymbolToIdMapResponse = z.object({
|
|
@@ -12,8 +12,8 @@ const InstrumentSymbolToIdMapResponse = z.object({
|
|
|
12
12
|
});
|
|
13
13
|
const InstrumentListLiteResponse = z.object({
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
* The list of instruments, trimmed to the lightweight consumer fields.
|
|
16
|
+
*/
|
|
17
17
|
instruments: z.array(InstrumentLite)
|
|
18
18
|
});
|
|
19
19
|
|
|
@@ -3,47 +3,47 @@ import { z } from 'zod';
|
|
|
3
3
|
const InstrumentPrecision = z.object({
|
|
4
4
|
quantity: z.object({
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
* The maximum number of decimals accepted.
|
|
7
|
+
* @example 4 for a 0.0001 step size.
|
|
8
|
+
*/
|
|
9
9
|
decimals: z.int(),
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
* The smallest step size.
|
|
12
|
+
* @example 0.01 for a 2 decimal precision.
|
|
13
|
+
*/
|
|
14
14
|
step: z.number(),
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
20
|
contractSize: z.number()
|
|
21
21
|
}),
|
|
22
22
|
price: z.object({
|
|
23
23
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
* The maximum number of decimals.
|
|
25
|
+
* @example 4 for a 0.0001 tick size.
|
|
26
|
+
*/
|
|
27
27
|
decimals: z.int(),
|
|
28
28
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
* The smallest increment.
|
|
30
|
+
* @example 0.01 for a 2 decimal precision.
|
|
31
|
+
*/
|
|
32
32
|
tick: z.number().transform((val) => val === null ? void 0 : val).optional().nullable(),
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
* The number of significant figures.
|
|
35
|
+
* @example 5 on Hyperliquid V2.
|
|
36
|
+
*/
|
|
37
37
|
sigFigs: z.int().transform((val) => val === null ? void 0 : val).optional().nullable()
|
|
38
38
|
}),
|
|
39
39
|
notional: z.object({
|
|
40
40
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
* The minimum notional amount in USD.
|
|
42
|
+
*/
|
|
43
43
|
min: z.number().transform((val) => val === null ? void 0 : val).optional().nullable(),
|
|
44
44
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
* The maximum notional amount in USD.
|
|
46
|
+
*/
|
|
47
47
|
max: z.number().transform((val) => val === null ? void 0 : val).optional().nullable()
|
|
48
48
|
}).optional()
|
|
49
49
|
});
|
package/dist/ladder/entities.js
CHANGED
|
@@ -4,7 +4,11 @@ import { Trigger } from '../trigger';
|
|
|
4
4
|
import { AttachTriggerMarketCloseList } from '../trigger/payloads';
|
|
5
5
|
import { LadderConfig } from './payloads';
|
|
6
6
|
|
|
7
|
-
const LadderStatus = z.enum([
|
|
7
|
+
const LadderStatus = z.enum([
|
|
8
|
+
"ACTIVE",
|
|
9
|
+
"COMPLETED",
|
|
10
|
+
"CANCELLED"
|
|
11
|
+
]);
|
|
8
12
|
const Ladder = z.object({
|
|
9
13
|
id: z.uuid(),
|
|
10
14
|
connector: Connector,
|
package/dist/ladder/payloads.js
CHANGED
|
@@ -18,7 +18,10 @@ const LadderConfig = z.object({
|
|
|
18
18
|
}).refine((config) => config.thresholdStart !== config.thresholdEnd, {
|
|
19
19
|
message: "thresholds must differ"
|
|
20
20
|
});
|
|
21
|
-
const PriceSource = z.enum([
|
|
21
|
+
const PriceSource = z.enum([
|
|
22
|
+
"mid",
|
|
23
|
+
"mark"
|
|
24
|
+
], {
|
|
22
25
|
message: "Price source must be mid or mark"
|
|
23
26
|
});
|
|
24
27
|
const WeightedRatioBasketItem = z.object({
|
|
@@ -62,7 +65,11 @@ const LadderAttachTriggers = AttachTriggerMarketCloseList.superRefine((attachTri
|
|
|
62
65
|
if (attachTrigger.condition.type === "notional" || attachTrigger.condition.type === "notional_trailing") {
|
|
63
66
|
ctx.addIssue({
|
|
64
67
|
code: "custom",
|
|
65
|
-
path: [
|
|
68
|
+
path: [
|
|
69
|
+
index,
|
|
70
|
+
"condition",
|
|
71
|
+
"type"
|
|
72
|
+
],
|
|
66
73
|
message: "Ladder brackets cannot use notional conditions; use upnl or upnl_bps."
|
|
67
74
|
});
|
|
68
75
|
}
|
|
@@ -77,9 +84,13 @@ const CreateLadderMarketOpen = z.object({
|
|
|
77
84
|
attachTriggers: LadderAttachTriggers.optional(),
|
|
78
85
|
payload: z.object({
|
|
79
86
|
type: z.literal("MARKET"),
|
|
80
|
-
legs: z.tuple([
|
|
87
|
+
legs: z.tuple([
|
|
88
|
+
TradeLegPostOnly
|
|
89
|
+
]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols)
|
|
81
90
|
})
|
|
82
91
|
}).strict();
|
|
83
|
-
const CreateLadder = z.discriminatedUnion("type", [
|
|
92
|
+
const CreateLadder = z.discriminatedUnion("type", [
|
|
93
|
+
CreateLadderMarketOpen
|
|
94
|
+
]);
|
|
84
95
|
|
|
85
96
|
export { CreateLadder, CreateLadderMarketOpen, LadderConditionOpen, LadderConfig };
|
package/dist/ladder/queries.js
CHANGED
package/dist/ladder/responses.js
CHANGED
|
@@ -2,9 +2,17 @@ import { z } from 'zod';
|
|
|
2
2
|
import { CursorResponse } from '../common';
|
|
3
3
|
import { Ladder } from './entities';
|
|
4
4
|
|
|
5
|
-
const CreateLadderResponse = z.object({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
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
|
+
});
|
|
9
17
|
|
|
10
18
|
export { CancelLadderResponse, CreateLadderResponse, LadderListResponse, LadderResponse };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { InstrumentId } from '../instrument/entities';
|
|
3
3
|
|
|
4
|
-
const MarginMode = z.enum([
|
|
4
|
+
const MarginMode = z.enum([
|
|
5
|
+
"cross",
|
|
6
|
+
"isolated"
|
|
7
|
+
]);
|
|
5
8
|
const SetLeverage = z.object({
|
|
6
9
|
symbol: InstrumentId,
|
|
7
10
|
leverage: z.int().positive(),
|
|
@@ -82,14 +82,18 @@ const AttachedTriggerDiscardedNotificationParameters = PositionLegParameters.saf
|
|
|
82
82
|
positionId: z.uuid(),
|
|
83
83
|
positionKey: z.string().min(1),
|
|
84
84
|
connector: Connector,
|
|
85
|
-
discarded: z.array(
|
|
86
|
-
z.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
discarded: z.array(z.object({
|
|
86
|
+
bracketType: z.enum([
|
|
87
|
+
"STOP_LOSS",
|
|
88
|
+
"TAKE_PROFIT"
|
|
89
|
+
]),
|
|
90
|
+
metric: NotificationMetric,
|
|
91
|
+
level: z.number().optional(),
|
|
92
|
+
reason: z.enum([
|
|
93
|
+
"TRIGGER_LIMIT",
|
|
94
|
+
"TRAILING_ALREADY_EXISTS"
|
|
95
|
+
])
|
|
96
|
+
})).min(1),
|
|
93
97
|
activeTriggerLimit: z.number().int().positive()
|
|
94
98
|
});
|
|
95
99
|
const AutoRebalanceLeg = z.object({
|
|
@@ -102,14 +106,15 @@ const AutoRebalanceAnchor = {
|
|
|
102
106
|
positionId: z.uuid(),
|
|
103
107
|
positionKey: z.string().min(1),
|
|
104
108
|
connector: Connector,
|
|
105
|
-
weightSource: z.enum([
|
|
109
|
+
weightSource: z.enum([
|
|
110
|
+
"INITIAL_WEIGHT",
|
|
111
|
+
"LIVE_BETA"
|
|
112
|
+
])
|
|
106
113
|
};
|
|
107
|
-
const AutoRebalanceRunLegs = z.array(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
);
|
|
114
|
+
const AutoRebalanceRunLegs = z.array(AutoRebalanceLeg.safeExtend({
|
|
115
|
+
currentWeight: z.number(),
|
|
116
|
+
targetWeight: z.number()
|
|
117
|
+
}));
|
|
113
118
|
const AutoRebalanceExecutedNotificationParameters = z.object({
|
|
114
119
|
type: z.literal("auto_rebalance_executed"),
|
|
115
120
|
...AutoRebalanceAnchor,
|
|
@@ -128,7 +133,11 @@ const AutoRebalancePausedNotificationParameters = z.object({
|
|
|
128
133
|
type: z.literal("auto_rebalance_paused"),
|
|
129
134
|
...AutoRebalanceAnchor,
|
|
130
135
|
legs: z.array(AutoRebalanceLeg),
|
|
131
|
-
pausedReason: z.enum([
|
|
136
|
+
pausedReason: z.enum([
|
|
137
|
+
"POSITION_CHANGED",
|
|
138
|
+
"REPEATED_FAILURES",
|
|
139
|
+
"INVALID_LIVE_BETA_EXPOSURE"
|
|
140
|
+
])
|
|
132
141
|
});
|
|
133
142
|
const TriggerCancelledMisScaledNotificationParameters = z.object({
|
|
134
143
|
type: z.literal("trigger_cancelled_mis_scaled"),
|
|
@@ -150,28 +159,28 @@ const NotificationParameters = z.discriminatedUnion("type", [
|
|
|
150
159
|
]);
|
|
151
160
|
const Notification = z.object({
|
|
152
161
|
/**
|
|
153
|
-
|
|
154
|
-
|
|
162
|
+
* Notification UUID
|
|
163
|
+
*/
|
|
155
164
|
id: z.uuid(),
|
|
156
165
|
/**
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
* What kind of notification this is
|
|
167
|
+
*/
|
|
159
168
|
category: NotificationCategory,
|
|
160
169
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
170
|
+
* Category-specific display payload
|
|
171
|
+
*/
|
|
163
172
|
parameters: NotificationParameters,
|
|
164
173
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
174
|
+
* Whether the user has read it
|
|
175
|
+
*/
|
|
167
176
|
isRead: z.boolean(),
|
|
168
177
|
/**
|
|
169
|
-
|
|
170
|
-
|
|
178
|
+
* Created at timestamp
|
|
179
|
+
*/
|
|
171
180
|
createdAt: z.string(),
|
|
172
181
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
182
|
+
* Updated at timestamp
|
|
183
|
+
*/
|
|
175
184
|
updatedAt: z.string()
|
|
176
185
|
});
|
|
177
186
|
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
const MarkNotificationsReadPayload = z.union([
|
|
4
|
-
z.strictObject({
|
|
5
|
-
|
|
4
|
+
z.strictObject({
|
|
5
|
+
id: z.uuid()
|
|
6
|
+
}),
|
|
7
|
+
z.strictObject({
|
|
8
|
+
timestamp: z.coerce.number().int().positive()
|
|
9
|
+
})
|
|
6
10
|
]);
|
|
7
|
-
const MarkNotificationUnreadPayload = z.strictObject({
|
|
11
|
+
const MarkNotificationUnreadPayload = z.strictObject({
|
|
12
|
+
id: z.uuid()
|
|
13
|
+
});
|
|
8
14
|
|
|
9
15
|
export { MarkNotificationUnreadPayload, MarkNotificationsReadPayload };
|
|
@@ -17,7 +17,11 @@ const NotificationListParams = z.object({
|
|
|
17
17
|
/**
|
|
18
18
|
* Filter by read state: `all` (default), only `read`, or only `unread`.
|
|
19
19
|
*/
|
|
20
|
-
scope: z.enum([
|
|
20
|
+
scope: z.enum([
|
|
21
|
+
"all",
|
|
22
|
+
"read",
|
|
23
|
+
"unread"
|
|
24
|
+
]).optional().default("all")
|
|
21
25
|
}).refine((data) => !data.startDate || !data.endDate || data.startDate < data.endDate, {
|
|
22
26
|
message: "startDate must be before endDate"
|
|
23
27
|
});
|