@pear-protocol/types 0.0.17 → 0.0.19
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/fill/responses.d.ts +2 -0
- package/dist/fill/responses.js +2 -0
- package/dist/trade/payloads.d.ts +88 -48
- package/dist/trigger/common/index.d.ts +40 -0
- package/dist/trigger/common/index.js +11 -0
- package/dist/trigger/entities/conditions.d.ts +215 -155
- package/dist/trigger/entities/conditions.js +81 -185
- package/dist/trigger/entities/index.d.ts +401 -352
- package/dist/trigger/entities/index.js +22 -8
- package/dist/trigger/index.d.ts +2 -0
- package/dist/trigger/index.js +2 -0
- package/dist/trigger/payloads/conditions.d.ts +117 -176
- package/dist/trigger/payloads/conditions.js +110 -57
- package/dist/trigger/payloads/index.d.ts +440 -164
- package/dist/trigger/payloads/index.js +32 -51
- package/dist/trigger/refinement/index.d.ts +2 -0
- package/dist/trigger/refinement/index.js +2 -0
- package/dist/trigger/refinement/static.refinement.d.ts +18 -0
- package/dist/trigger/refinement/static.refinement.js +40 -0
- package/dist/trigger/refinement/trailing.refinement.d.ts +27 -0
- package/dist/trigger/refinement/trailing.refinement.js +81 -0
- package/dist/trigger/responses.d.ts +262 -218
- package/package.json +4 -2
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { RefineMinimumTwoSymbols, RefineUniqueSymbols, RefineWeightingSum, RefineMinimumOneBuyOneSell, RefineTwoUniqueSymbols } from '../../common/refinement';
|
|
3
3
|
import { Side } from '../../common/schema';
|
|
4
4
|
import { InstrumentId } from '../../instrument';
|
|
5
|
+
import { MetricTrack } from '../common';
|
|
5
6
|
|
|
6
|
-
const TriggerDirectionEnum = z.enum(["ABOVE", "BELOW"], {
|
|
7
|
-
message: "Trigger direction must be ABOVE or BELOW"
|
|
8
|
-
});
|
|
9
7
|
const TriggerThreshold = z.number().positive({
|
|
10
8
|
message: "Threshold must be greater than 0"
|
|
11
9
|
});
|
|
@@ -13,97 +11,152 @@ const PriceSource = z.enum(["mid", "mark"], {
|
|
|
13
11
|
message: "Price source must be mid or mark"
|
|
14
12
|
});
|
|
15
13
|
const AssetWeight = z.number().positive({ message: "Weight must be greater than 0" }).max(1, { message: "Weight must be less than 1" });
|
|
16
|
-
const
|
|
17
|
-
|
|
14
|
+
const WeightedRatioBasketItem = z.object({
|
|
15
|
+
symbol: InstrumentId,
|
|
16
|
+
side: Side,
|
|
17
|
+
weight: AssetWeight
|
|
18
|
+
});
|
|
19
|
+
const WeightedRatioBasket = z.array(WeightedRatioBasketItem).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum).superRefine(RefineMinimumOneBuyOneSell);
|
|
20
|
+
const RatioOpen = z.object({
|
|
21
|
+
type: z.literal("ratio"),
|
|
18
22
|
data: z.object({
|
|
19
23
|
priceSource: PriceSource,
|
|
20
24
|
symbol_a: InstrumentId,
|
|
21
25
|
symbol_b: InstrumentId,
|
|
22
|
-
|
|
26
|
+
track: MetricTrack,
|
|
23
27
|
threshold: TriggerThreshold
|
|
24
28
|
}).superRefine(RefineTwoUniqueSymbols)
|
|
25
29
|
});
|
|
26
|
-
const
|
|
27
|
-
type: z.literal("
|
|
30
|
+
const PriceOpen = z.object({
|
|
31
|
+
type: z.literal("price"),
|
|
28
32
|
data: z.object({
|
|
29
33
|
priceSource: PriceSource,
|
|
30
34
|
symbol: InstrumentId,
|
|
31
|
-
|
|
35
|
+
track: MetricTrack,
|
|
32
36
|
threshold: TriggerThreshold
|
|
33
37
|
})
|
|
34
38
|
});
|
|
35
|
-
const
|
|
36
|
-
type: z.literal("
|
|
39
|
+
const WeightedRatioOpen = z.object({
|
|
40
|
+
type: z.literal("weighted_ratio"),
|
|
37
41
|
data: z.object({
|
|
38
42
|
priceSource: PriceSource,
|
|
39
|
-
basket:
|
|
40
|
-
|
|
41
|
-
symbol: InstrumentId,
|
|
42
|
-
weight: AssetWeight
|
|
43
|
-
})
|
|
44
|
-
).superRefine(RefineMinimumTwoSymbols).superRefine(RefineWeightingSum).superRefine(RefineUniqueSymbols),
|
|
45
|
-
direction: TriggerDirectionEnum,
|
|
43
|
+
basket: WeightedRatioBasket,
|
|
44
|
+
track: MetricTrack,
|
|
46
45
|
threshold: TriggerThreshold
|
|
47
46
|
})
|
|
48
47
|
});
|
|
49
|
-
const
|
|
50
|
-
type: z.literal("
|
|
48
|
+
const RatioCloseStatic = z.object({
|
|
49
|
+
type: z.literal("ratio"),
|
|
50
|
+
data: z.object({
|
|
51
|
+
priceSource: PriceSource,
|
|
52
|
+
symbol_a: InstrumentId,
|
|
53
|
+
symbol_b: InstrumentId,
|
|
54
|
+
threshold: TriggerThreshold
|
|
55
|
+
}).superRefine(RefineTwoUniqueSymbols)
|
|
56
|
+
});
|
|
57
|
+
const PriceCloseStatic = z.object({
|
|
58
|
+
type: z.literal("price"),
|
|
51
59
|
data: z.object({
|
|
52
60
|
priceSource: PriceSource,
|
|
53
|
-
|
|
54
|
-
z.object({
|
|
55
|
-
symbol: InstrumentId,
|
|
56
|
-
side: Side,
|
|
57
|
-
weight: AssetWeight
|
|
58
|
-
})
|
|
59
|
-
).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum).superRefine(RefineMinimumOneBuyOneSell),
|
|
60
|
-
direction: TriggerDirectionEnum,
|
|
61
|
+
symbol: InstrumentId,
|
|
61
62
|
threshold: TriggerThreshold
|
|
62
63
|
})
|
|
63
64
|
});
|
|
64
|
-
const
|
|
65
|
-
type: z.literal("
|
|
65
|
+
const WeightedRatioCloseStatic = z.object({
|
|
66
|
+
type: z.literal("weighted_ratio"),
|
|
66
67
|
data: z.object({
|
|
67
68
|
priceSource: PriceSource,
|
|
68
|
-
|
|
69
|
+
basket: WeightedRatioBasket,
|
|
69
70
|
threshold: TriggerThreshold
|
|
70
71
|
})
|
|
71
72
|
});
|
|
72
|
-
const
|
|
73
|
-
type: z.literal("
|
|
73
|
+
const NotionalCloseStatic = z.object({
|
|
74
|
+
type: z.literal("notional"),
|
|
74
75
|
data: z.object({
|
|
75
76
|
priceSource: PriceSource,
|
|
76
|
-
direction: TriggerDirectionEnum,
|
|
77
77
|
threshold: TriggerThreshold
|
|
78
78
|
})
|
|
79
79
|
});
|
|
80
|
-
const
|
|
81
|
-
type: z.literal("
|
|
80
|
+
const UpnlCloseStatic = z.object({
|
|
81
|
+
type: z.literal("upnl"),
|
|
82
82
|
data: z.object({
|
|
83
83
|
priceSource: PriceSource,
|
|
84
|
-
|
|
85
|
-
threshold_bps: TriggerThreshold
|
|
84
|
+
threshold: z.number()
|
|
86
85
|
})
|
|
87
86
|
});
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
const UpnlBpsCloseStatic = z.object({
|
|
88
|
+
type: z.literal("upnl_bps"),
|
|
89
|
+
data: z.object({
|
|
90
|
+
priceSource: PriceSource,
|
|
91
|
+
threshold: z.number()
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
const RatioCloseTrailing = z.object({
|
|
95
|
+
type: z.literal("ratio_trailing"),
|
|
96
|
+
data: z.object({
|
|
97
|
+
priceSource: PriceSource,
|
|
98
|
+
symbol_a: InstrumentId,
|
|
99
|
+
symbol_b: InstrumentId
|
|
100
|
+
}).superRefine(RefineTwoUniqueSymbols)
|
|
101
|
+
});
|
|
102
|
+
const PriceCloseTrailing = z.object({
|
|
103
|
+
type: z.literal("price_trailing"),
|
|
104
|
+
data: z.object({
|
|
105
|
+
priceSource: PriceSource,
|
|
106
|
+
symbol: InstrumentId
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
const WeightedRatioCloseTrailing = z.object({
|
|
110
|
+
type: z.literal("weighted_ratio_trailing"),
|
|
111
|
+
data: z.object({
|
|
112
|
+
priceSource: PriceSource,
|
|
113
|
+
basket: WeightedRatioBasket
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
const NotionalCloseTrailing = z.object({
|
|
117
|
+
type: z.literal("notional_trailing"),
|
|
118
|
+
data: z.object({
|
|
119
|
+
priceSource: PriceSource
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
const UpnlCloseTrailing = z.object({
|
|
123
|
+
type: z.literal("upnl_trailing"),
|
|
124
|
+
data: z.object({
|
|
125
|
+
priceSource: PriceSource
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
const UpnlBpsCloseTrailing = z.object({
|
|
129
|
+
type: z.literal("upnl_bps_trailing"),
|
|
130
|
+
data: z.object({
|
|
131
|
+
priceSource: PriceSource
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
const CreateTriggerConditionOpen = z.discriminatedUnion("type", [RatioOpen, PriceOpen, WeightedRatioOpen]);
|
|
135
|
+
const CreateTriggerConditionCloseStatic = z.discriminatedUnion("type", [
|
|
136
|
+
RatioCloseStatic,
|
|
137
|
+
PriceCloseStatic,
|
|
138
|
+
WeightedRatioCloseStatic,
|
|
139
|
+
NotionalCloseStatic,
|
|
140
|
+
UpnlCloseStatic,
|
|
141
|
+
UpnlBpsCloseStatic
|
|
142
|
+
]);
|
|
143
|
+
const CreateTriggerConditionCloseTrailing = z.discriminatedUnion("type", [
|
|
144
|
+
RatioCloseTrailing,
|
|
145
|
+
PriceCloseTrailing,
|
|
146
|
+
WeightedRatioCloseTrailing,
|
|
147
|
+
NotionalCloseTrailing,
|
|
148
|
+
UpnlCloseTrailing,
|
|
149
|
+
UpnlBpsCloseTrailing
|
|
93
150
|
]);
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
CreateTriggerConditionWeightedRatioV1,
|
|
99
|
-
CreateTriggerConditionPositionValueV1,
|
|
100
|
-
CreateTriggerConditionPositionUPnLValueV1,
|
|
101
|
-
CreateTriggerConditionPositionUPnLPercentageV1
|
|
151
|
+
const CreateTriggerConditionAttachStatic = z.discriminatedUnion("type", [
|
|
152
|
+
NotionalCloseStatic,
|
|
153
|
+
UpnlCloseStatic,
|
|
154
|
+
UpnlBpsCloseStatic
|
|
102
155
|
]);
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
156
|
+
const CreateTriggerConditionAttachTrailing = z.discriminatedUnion("type", [
|
|
157
|
+
NotionalCloseTrailing,
|
|
158
|
+
UpnlCloseTrailing,
|
|
159
|
+
UpnlBpsCloseTrailing
|
|
107
160
|
]);
|
|
108
161
|
|
|
109
|
-
export {
|
|
162
|
+
export { CreateTriggerConditionAttachStatic, CreateTriggerConditionAttachTrailing, CreateTriggerConditionCloseStatic, CreateTriggerConditionCloseTrailing, CreateTriggerConditionOpen };
|