@pear-protocol/types 1.23.0 → 1.24.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.
- package/dist/auth/api-keys.js +11 -3
- package/dist/auth/entities.js +10 -2
- package/dist/auth/payloads.d.ts +15 -0
- package/dist/auth/payloads.js +19 -5
- 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/queries.js +15 -3
- 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/trade/responses.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Execution } from '../execution/entities';
|
|
3
3
|
|
|
4
|
-
const CreateTradeOpenResponse = z.object({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
4
|
+
const CreateTradeOpenResponse = z.object({
|
|
5
|
+
execution: Execution
|
|
6
|
+
});
|
|
7
|
+
const CreateTradeAdjustResponse = z.object({
|
|
8
|
+
execution: Execution
|
|
9
|
+
});
|
|
10
|
+
const CreateTradeCloseResponse = z.object({
|
|
11
|
+
execution: Execution
|
|
12
|
+
});
|
|
13
|
+
const CreateTradeReverseResponse = z.object({
|
|
14
|
+
execution: Execution
|
|
15
|
+
});
|
|
16
|
+
const CreateTradeCloseAllResponse = z.object({
|
|
17
|
+
executions: z.array(Execution)
|
|
18
|
+
});
|
|
9
19
|
|
|
10
20
|
export { CreateTradeAdjustResponse, CreateTradeCloseAllResponse, CreateTradeCloseResponse, CreateTradeOpenResponse, CreateTradeReverseResponse };
|
|
@@ -9,7 +9,10 @@ const HyperliquidMetadata = z.object({
|
|
|
9
9
|
const LighterMetadata = z.object({
|
|
10
10
|
l1_address: z.string()
|
|
11
11
|
});
|
|
12
|
-
const ConnectorMetadata = z.union([
|
|
12
|
+
const ConnectorMetadata = z.union([
|
|
13
|
+
HyperliquidMetadata,
|
|
14
|
+
LighterMetadata
|
|
15
|
+
]).optional();
|
|
13
16
|
const TradeAccount = z.object({
|
|
14
17
|
id: z.uuid().describe("Trade account UUID"),
|
|
15
18
|
alias: z.string().describe("User-defined trade account alias"),
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { TradeAccount } from './entities';
|
|
3
3
|
|
|
4
|
-
const TradeAccountResponse = z.object({
|
|
5
|
-
|
|
4
|
+
const TradeAccountResponse = z.object({
|
|
5
|
+
account: TradeAccount
|
|
6
|
+
});
|
|
7
|
+
const TradeAccountListResponse = z.object({
|
|
8
|
+
accounts: z.array(TradeAccount)
|
|
9
|
+
});
|
|
6
10
|
const HyperliquidCredentialsResponse = z.object({
|
|
7
11
|
connector: z.literal("hyperliquid"),
|
|
8
12
|
account: TradeAccount,
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
const TriggerIntent = z.enum([
|
|
4
|
-
|
|
3
|
+
const TriggerIntent = z.enum([
|
|
4
|
+
"OPEN",
|
|
5
|
+
"ADJUST",
|
|
6
|
+
"CLOSE"
|
|
7
|
+
]);
|
|
8
|
+
const TriggerStatus = z.enum([
|
|
9
|
+
"ACTIVE",
|
|
10
|
+
"TRIGGERED",
|
|
11
|
+
"CANCELLED"
|
|
12
|
+
]);
|
|
5
13
|
const TriggerCancelledReason = z.enum([
|
|
6
14
|
"POSITION_CLOSED",
|
|
7
15
|
"USER",
|
|
@@ -9,9 +17,22 @@ const TriggerCancelledReason = z.enum([
|
|
|
9
17
|
"POSITION_NETTED",
|
|
10
18
|
"POSITION_REVERSED"
|
|
11
19
|
]);
|
|
12
|
-
const BracketType = z.enum([
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
const BracketType = z.enum([
|
|
21
|
+
"STOP_LOSS",
|
|
22
|
+
"TAKE_PROFIT",
|
|
23
|
+
"NONE"
|
|
24
|
+
]);
|
|
25
|
+
const MetricTrack = z.enum([
|
|
26
|
+
"PEAK",
|
|
27
|
+
"TROUGH"
|
|
28
|
+
]);
|
|
29
|
+
const TpSlBracketType = z.enum([
|
|
30
|
+
"TAKE_PROFIT",
|
|
31
|
+
"STOP_LOSS"
|
|
32
|
+
]);
|
|
33
|
+
const TrailingMode = z.enum([
|
|
34
|
+
"RELATIVE_BPS",
|
|
35
|
+
"ABSOLUTE_POINTS"
|
|
36
|
+
]);
|
|
16
37
|
|
|
17
38
|
export { BracketType, MetricTrack, TpSlBracketType, TrailingMode, TriggerCancelledReason, TriggerIntent, TriggerStatus };
|
|
@@ -28,13 +28,11 @@ const WeightedRatio = z.object({
|
|
|
28
28
|
type: z.literal("weighted_ratio"),
|
|
29
29
|
data: z.object({
|
|
30
30
|
priceSource: PriceSource,
|
|
31
|
-
basket: z.array(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
),
|
|
31
|
+
basket: z.array(z.object({
|
|
32
|
+
symbol: InstrumentId,
|
|
33
|
+
side: Side,
|
|
34
|
+
weight: z.number()
|
|
35
|
+
})),
|
|
38
36
|
track: MetricTrack,
|
|
39
37
|
threshold: z.number()
|
|
40
38
|
})
|
|
@@ -75,7 +73,10 @@ const FundingRate = z.object({
|
|
|
75
73
|
const PredictionMarket = z.object({
|
|
76
74
|
type: z.literal("prediction_market"),
|
|
77
75
|
data: z.object({
|
|
78
|
-
source: z.enum([
|
|
76
|
+
source: z.enum([
|
|
77
|
+
"kalshi",
|
|
78
|
+
"polymarket"
|
|
79
|
+
]),
|
|
79
80
|
marketKey: z.string().min(1),
|
|
80
81
|
track: MetricTrack,
|
|
81
82
|
threshold: z.number()
|
|
@@ -108,13 +109,11 @@ const WeightedRatioTrailing = z.object({
|
|
|
108
109
|
type: z.literal("weighted_ratio_trailing"),
|
|
109
110
|
data: z.object({
|
|
110
111
|
priceSource: PriceSource,
|
|
111
|
-
basket: z.array(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
})
|
|
117
|
-
)
|
|
112
|
+
basket: z.array(z.object({
|
|
113
|
+
symbol: InstrumentId,
|
|
114
|
+
side: Side,
|
|
115
|
+
weight: z.number()
|
|
116
|
+
}))
|
|
118
117
|
})
|
|
119
118
|
});
|
|
120
119
|
const NotionalTrailing = z.object({
|
|
@@ -9,170 +9,177 @@ import { TriggerConditionOpen, TriggerConditionAdjust, TriggerConditionClose } f
|
|
|
9
9
|
|
|
10
10
|
const Trailing = z.object({
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
* Trailing mode to track the metric.
|
|
13
|
+
*/
|
|
14
14
|
mode: TrailingMode,
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
* Delta value to track the metric in the given mode.
|
|
17
|
+
*/
|
|
18
18
|
deltaValue: z.number(),
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
* Activation value to start tracking the metric.
|
|
21
|
+
* When omitted, trailing starts immediately from the current metric.
|
|
22
|
+
*/
|
|
23
23
|
activationValue: z.number().optional(),
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
* Best metric seen
|
|
26
|
+
*/
|
|
27
27
|
bestMetricSeen: z.number().optional(),
|
|
28
28
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
* Current stop value
|
|
30
|
+
*/
|
|
31
31
|
currentStopValue: z.number().optional(),
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
* Timestamp (ms) when a stop/activation breach was detected.
|
|
34
|
+
*/
|
|
35
35
|
stopBreachedAt: z.number().optional()
|
|
36
36
|
});
|
|
37
37
|
const BaseTrigger = z.object({
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
* Trigger UUID
|
|
40
|
+
*/
|
|
41
41
|
id: z.uuid(),
|
|
42
42
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
* Trade account UUID
|
|
44
|
+
*/
|
|
45
45
|
tradeAccountId: z.uuid(),
|
|
46
46
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
* Connector
|
|
48
|
+
*/
|
|
49
49
|
connector: Connector,
|
|
50
50
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
* Status of the trigger
|
|
52
|
+
*/
|
|
53
53
|
status: TriggerStatus,
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
* Parent ladder ID when this trigger is a ladder rung
|
|
56
|
+
*/
|
|
57
57
|
ladderId: z.uuid().optional(),
|
|
58
58
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
* Zero-based rung index within the parent ladder
|
|
60
|
+
*/
|
|
61
61
|
ladderIndex: z.number().int().optional(),
|
|
62
62
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
* Source open trigger that spawned this attached close trigger, when it originated from a conditional open
|
|
64
|
+
*/
|
|
65
65
|
parentTriggerId: z.uuid().optional(),
|
|
66
66
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
* When the trigger was triggered
|
|
68
|
+
*/
|
|
69
69
|
triggeredAt: z.string().optional(),
|
|
70
70
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
* When the trigger was cancelled
|
|
72
|
+
*/
|
|
73
73
|
cancelledAt: z.string().optional(),
|
|
74
74
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
* Reason for the trigger being cancelled
|
|
76
|
+
*/
|
|
77
77
|
cancelledReason: TriggerCancelledReason.optional(),
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
* Fills for the trigger
|
|
80
|
+
*/
|
|
81
81
|
fills: z.array(Fill).optional(),
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
* Bracket type for trigger behavior
|
|
84
|
+
*/
|
|
85
85
|
bracketType: BracketType,
|
|
86
86
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
* User-facing bracket semantics. `bracketType` is the crossing encoding the gateway
|
|
88
|
+
* fires on (wire-flipped for a price bracket on a short watched leg); this field is
|
|
89
|
+
* what the user asked for. Absent whenever a legacy client's encoding is
|
|
90
|
+
* unknowable; do not present `bracketType` as user intent in that case.
|
|
91
|
+
*/
|
|
92
92
|
semanticBracketType: BracketType.optional(),
|
|
93
93
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
* Created at timestamp
|
|
95
|
+
*/
|
|
96
96
|
createdAt: z.string(),
|
|
97
97
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
* Updated at timestamp
|
|
99
|
+
*/
|
|
100
100
|
updatedAt: z.string()
|
|
101
101
|
});
|
|
102
102
|
const TriggerMarketOpenAttachedTrigger = z.object({
|
|
103
|
-
kind: z.enum([
|
|
103
|
+
kind: z.enum([
|
|
104
|
+
"STATIC",
|
|
105
|
+
"TRAILING"
|
|
106
|
+
]),
|
|
104
107
|
bracketType: TpSlBracketType
|
|
105
108
|
});
|
|
106
109
|
const TriggerMarketOpen = BaseTrigger.extend({
|
|
107
110
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
* Intent
|
|
112
|
+
*/
|
|
110
113
|
intent: z.literal("OPEN"),
|
|
111
114
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
* Order type
|
|
116
|
+
*/
|
|
114
117
|
type: z.literal("MARKET"),
|
|
115
118
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
* Condition (only open conditions allowed)
|
|
120
|
+
*/
|
|
118
121
|
condition: TriggerConditionOpen,
|
|
119
122
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
* Context
|
|
124
|
+
*/
|
|
122
125
|
context: z.object({
|
|
123
126
|
type: z.literal("MARKET"),
|
|
124
|
-
legs: z.tuple([
|
|
127
|
+
legs: z.tuple([
|
|
128
|
+
TradeLegPostOnly
|
|
129
|
+
]).rest(TradeLegPostOnly),
|
|
125
130
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
* Close triggers configured to attach after this open trigger fires.
|
|
132
|
+
*/
|
|
128
133
|
attachedTriggers: z.array(TriggerMarketOpenAttachedTrigger)
|
|
129
134
|
})
|
|
130
135
|
});
|
|
131
136
|
const TriggerMarketAdjust = BaseTrigger.extend({
|
|
132
137
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
* Intent
|
|
139
|
+
*/
|
|
135
140
|
intent: z.literal("ADJUST"),
|
|
136
141
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
* Order type
|
|
143
|
+
*/
|
|
139
144
|
type: z.literal("MARKET"),
|
|
140
145
|
/**
|
|
141
|
-
|
|
142
|
-
|
|
146
|
+
* Condition (only adjust conditions allowed)
|
|
147
|
+
*/
|
|
143
148
|
condition: TriggerConditionAdjust,
|
|
144
149
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
* Context
|
|
151
|
+
*/
|
|
147
152
|
context: z.object({
|
|
148
153
|
type: z.literal("MARKET"),
|
|
149
154
|
position: z.object({
|
|
150
155
|
id: z.uuid(),
|
|
151
156
|
initialExposure: z.record(InstrumentId, SignedDecimalString)
|
|
152
157
|
}),
|
|
153
|
-
legs: z.tuple([
|
|
158
|
+
legs: z.tuple([
|
|
159
|
+
TradeLeg
|
|
160
|
+
]).rest(TradeLeg)
|
|
154
161
|
}),
|
|
155
162
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
163
|
+
* Optional: trailing configuration
|
|
164
|
+
*/
|
|
158
165
|
trailing: Trailing.optional()
|
|
159
166
|
});
|
|
160
167
|
const TriggerMarketClose = BaseTrigger.extend({
|
|
161
168
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
169
|
+
* Intent
|
|
170
|
+
*/
|
|
164
171
|
intent: z.literal("CLOSE"),
|
|
165
172
|
/**
|
|
166
|
-
|
|
167
|
-
|
|
173
|
+
* Order type
|
|
174
|
+
*/
|
|
168
175
|
type: z.literal("MARKET"),
|
|
169
176
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
177
|
+
* Condition (only close conditions allowed)
|
|
178
|
+
*/
|
|
172
179
|
condition: TriggerConditionClose,
|
|
173
180
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
181
|
+
* Context
|
|
182
|
+
*/
|
|
176
183
|
context: z.object({
|
|
177
184
|
type: z.literal("MARKET"),
|
|
178
185
|
position: z.object({
|
|
@@ -181,8 +188,8 @@ const TriggerMarketClose = BaseTrigger.extend({
|
|
|
181
188
|
})
|
|
182
189
|
}),
|
|
183
190
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
191
|
+
* Optional: trailing configuration
|
|
192
|
+
*/
|
|
186
193
|
trailing: Trailing.optional()
|
|
187
194
|
});
|
|
188
195
|
const TriggerMarket = z.discriminatedUnion("intent", [
|
|
@@ -190,6 +197,8 @@ const TriggerMarket = z.discriminatedUnion("intent", [
|
|
|
190
197
|
TriggerMarketAdjust,
|
|
191
198
|
TriggerMarketClose
|
|
192
199
|
]);
|
|
193
|
-
const Trigger = z.discriminatedUnion("type", [
|
|
200
|
+
const Trigger = z.discriminatedUnion("type", [
|
|
201
|
+
TriggerMarket
|
|
202
|
+
]);
|
|
194
203
|
|
|
195
204
|
export { Trailing, Trigger, TriggerMarket, TriggerMarketAdjust, TriggerMarketClose, TriggerMarketOpen, TriggerMarketOpenAttachedTrigger };
|
package/dist/trigger/oracle.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
const OracleUnit = z.enum([
|
|
3
|
+
const OracleUnit = z.enum([
|
|
4
|
+
"cent",
|
|
5
|
+
"percent"
|
|
6
|
+
]);
|
|
4
7
|
const OracleValue = z.object({
|
|
5
8
|
value: z.number(),
|
|
6
9
|
unit: OracleUnit
|
|
7
10
|
});
|
|
8
11
|
const OracleTrigger = z.object({
|
|
9
12
|
id: z.string(),
|
|
10
|
-
category: z.enum([
|
|
11
|
-
|
|
13
|
+
category: z.enum([
|
|
14
|
+
"btcdom"
|
|
15
|
+
]),
|
|
16
|
+
source: z.enum([
|
|
17
|
+
"coingecko"
|
|
18
|
+
]),
|
|
12
19
|
oracle: OracleValue.nullable()
|
|
13
20
|
});
|
|
14
21
|
|
|
@@ -8,7 +8,10 @@ import { MetricTrack } from '../common';
|
|
|
8
8
|
const TriggerThreshold = z.number().positive({
|
|
9
9
|
message: "Threshold must be greater than 0"
|
|
10
10
|
});
|
|
11
|
-
const PriceSource = z.enum([
|
|
11
|
+
const PriceSource = z.enum([
|
|
12
|
+
"mid",
|
|
13
|
+
"mark"
|
|
14
|
+
], {
|
|
12
15
|
message: "Price source must be mid or mark"
|
|
13
16
|
});
|
|
14
17
|
const WeightedRatioBasketItem = z.object({
|
|
@@ -48,7 +51,10 @@ const WeightedRatioOpen = z.object({
|
|
|
48
51
|
const PredictionMarketOpen = z.object({
|
|
49
52
|
type: z.literal("prediction_market"),
|
|
50
53
|
data: z.object({
|
|
51
|
-
source: z.enum([
|
|
54
|
+
source: z.enum([
|
|
55
|
+
"kalshi",
|
|
56
|
+
"polymarket"
|
|
57
|
+
]),
|
|
52
58
|
marketKey: z.string().min(1),
|
|
53
59
|
track: MetricTrack,
|
|
54
60
|
threshold: TriggerThreshold
|
|
@@ -8,9 +8,13 @@ import { RefineTrailingConfig, RefineTrailingLogicalRules } from '../refinement/
|
|
|
8
8
|
import { CreateTriggerConditionAttachStatic, CreateTriggerConditionAttachTrailing, CreateTriggerConditionOpen, CreateTriggerConditionCloseStatic, CreateTriggerConditionCloseTrailing } from './conditions';
|
|
9
9
|
import { MAX_ATTACH_TRIGGERS } from './config';
|
|
10
10
|
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
13
|
const CreateTriggerMarketPayload = z.object({
|
|
12
14
|
type: z.literal("MARKET"),
|
|
13
|
-
legs: z.tuple([
|
|
15
|
+
legs: z.tuple([
|
|
16
|
+
TradeLegPostOnly.strict()
|
|
17
|
+
]).rest(TradeLegPostOnly.strict()).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure")
|
|
14
18
|
}).strict();
|
|
15
19
|
const TrailingConfig = z.object({
|
|
16
20
|
mode: TrailingMode,
|
|
@@ -29,7 +33,10 @@ const AttachTriggerMarketCloseTrailing = z.object({
|
|
|
29
33
|
condition: CreateTriggerConditionAttachTrailing,
|
|
30
34
|
trailing: TrailingConfig
|
|
31
35
|
}).superRefine(RefineTrailingLogicalRules);
|
|
32
|
-
const AttachTriggerMarketClose = z.union([
|
|
36
|
+
const AttachTriggerMarketClose = z.union([
|
|
37
|
+
AttachTriggerMarketCloseStatic,
|
|
38
|
+
AttachTriggerMarketCloseTrailing
|
|
39
|
+
]);
|
|
33
40
|
const AttachTriggerMarketCloseList = z.array(AttachTriggerMarketClose).max(MAX_ATTACH_TRIGGERS, `At most ${MAX_ATTACH_TRIGGERS} close triggers can be attached.`).superRefine((attachTriggers, ctx) => {
|
|
34
41
|
const trailingCount = attachTriggers.filter(isAttachTriggerMarketCloseTrailing).length;
|
|
35
42
|
if (trailingCount > 1) {
|
|
@@ -86,11 +93,18 @@ const CreateTriggerMarketCloseTrailing = z.object({
|
|
|
86
93
|
*/
|
|
87
94
|
clientId: ClientIdCode
|
|
88
95
|
}).superRefine(RefineTrailingLogicalRules);
|
|
89
|
-
const CreateTriggerMarketClose = z.union([
|
|
90
|
-
|
|
96
|
+
const CreateTriggerMarketClose = z.union([
|
|
97
|
+
CreateTriggerMarketCloseStatic,
|
|
98
|
+
CreateTriggerMarketCloseTrailing
|
|
99
|
+
]);
|
|
100
|
+
const CreateTriggerOpen = z.discriminatedUnion("intent", [
|
|
101
|
+
CreateTriggerMarketOpen,
|
|
102
|
+
CreateTriggerMarketAdjust
|
|
103
|
+
]);
|
|
91
104
|
const CreateTriggerClose = CreateTriggerMarketClose;
|
|
92
105
|
function isAttachTriggerMarketCloseTrailing(attachedTrigger) {
|
|
93
106
|
return "trailing" in attachedTrigger && attachedTrigger.trailing !== void 0;
|
|
94
107
|
}
|
|
108
|
+
__name(isAttachTriggerMarketCloseTrailing, "isAttachTriggerMarketCloseTrailing");
|
|
95
109
|
|
|
96
110
|
export { AttachTriggerMarketClose, AttachTriggerMarketCloseList, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketAdjust, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig, isAttachTriggerMarketCloseTrailing };
|
package/dist/trigger/queries.js
CHANGED
|
@@ -2,7 +2,11 @@ import { z } from 'zod';
|
|
|
2
2
|
import { normalizeArray, CursorFindParams } from '../common';
|
|
3
3
|
import { Connector } from '../connector';
|
|
4
4
|
|
|
5
|
-
const StatusEnum = z.enum([
|
|
5
|
+
const StatusEnum = z.enum([
|
|
6
|
+
"ACTIVE",
|
|
7
|
+
"COMPLETED",
|
|
8
|
+
"CANCELLED"
|
|
9
|
+
]);
|
|
6
10
|
const StatusArray = z.preprocess((arg) => normalizeArray(arg), z.array(StatusEnum));
|
|
7
11
|
const TriggerListParams = CursorFindParams.extend({
|
|
8
12
|
connector: Connector.optional(),
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const RefineStaticLogicalRules = /* @__PURE__ */ __name((value, context) => {
|
|
2
4
|
for (const issue of getStaticLogicalIssues({
|
|
3
5
|
conditionType: value.condition.type,
|
|
4
6
|
threshold: value.condition.data.threshold
|
|
@@ -8,7 +10,7 @@ const RefineStaticLogicalRules = (value, context) => {
|
|
|
8
10
|
message: issue.message
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
|
-
};
|
|
13
|
+
}, "RefineStaticLogicalRules");
|
|
12
14
|
function getStaticLogicalIssues(input) {
|
|
13
15
|
const { conditionType, threshold } = input;
|
|
14
16
|
const issues = [];
|
|
@@ -43,5 +45,6 @@ function getStaticLogicalIssues(input) {
|
|
|
43
45
|
}
|
|
44
46
|
return issues;
|
|
45
47
|
}
|
|
48
|
+
__name(getStaticLogicalIssues, "getStaticLogicalIssues");
|
|
46
49
|
|
|
47
50
|
export { RefineStaticLogicalRules, getStaticLogicalIssues };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const RefineTrailingConfig = (value, ctx) => {
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const RefineTrailingConfig = /* @__PURE__ */ __name((value, ctx) => {
|
|
4
4
|
for (const issue of getTrailingDeltaIssues(value)) {
|
|
5
5
|
ctx.addIssue({
|
|
6
6
|
code: "custom",
|
|
7
7
|
message: issue.message
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
};
|
|
11
|
-
const RefineTrailingLogicalRules = (value, ctx) => {
|
|
10
|
+
}, "RefineTrailingConfig");
|
|
11
|
+
const RefineTrailingLogicalRules = /* @__PURE__ */ __name((value, ctx) => {
|
|
12
12
|
for (const issue of getTrailingLogicalIssues({
|
|
13
13
|
conditionType: value.condition.type,
|
|
14
14
|
trailing: value.trailing
|
|
@@ -18,7 +18,7 @@ const RefineTrailingLogicalRules = (value, ctx) => {
|
|
|
18
18
|
message: issue.message
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
};
|
|
21
|
+
}, "RefineTrailingLogicalRules");
|
|
22
22
|
function getTrailingLogicalIssues(input) {
|
|
23
23
|
const { trailing } = input;
|
|
24
24
|
const issues = [];
|
|
@@ -51,6 +51,7 @@ function getTrailingLogicalIssues(input) {
|
|
|
51
51
|
}
|
|
52
52
|
return issues;
|
|
53
53
|
}
|
|
54
|
+
__name(getTrailingLogicalIssues, "getTrailingLogicalIssues");
|
|
54
55
|
function getTrailingDeltaIssues(trailing) {
|
|
55
56
|
const issues = [];
|
|
56
57
|
if (trailing.deltaValue <= 0) {
|
|
@@ -77,5 +78,6 @@ function getTrailingDeltaIssues(trailing) {
|
|
|
77
78
|
}
|
|
78
79
|
return issues;
|
|
79
80
|
}
|
|
81
|
+
__name(getTrailingDeltaIssues, "getTrailingDeltaIssues");
|
|
80
82
|
|
|
81
83
|
export { RefineTrailingConfig, RefineTrailingLogicalRules, getTrailingDeltaIssues, getTrailingLogicalIssues };
|
|
@@ -2,9 +2,17 @@ import { z } from 'zod';
|
|
|
2
2
|
import { CursorResponse } from '../common';
|
|
3
3
|
import { Trigger } from './entities';
|
|
4
4
|
|
|
5
|
-
const TriggerListResponse = CursorResponse.extend({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
5
|
+
const TriggerListResponse = CursorResponse.extend({
|
|
6
|
+
triggers: z.array(Trigger)
|
|
7
|
+
});
|
|
8
|
+
const CreateTriggerResponse = z.object({
|
|
9
|
+
trigger: Trigger
|
|
10
|
+
});
|
|
11
|
+
const CancelTriggerResponse = z.object({
|
|
12
|
+
id: z.uuid()
|
|
13
|
+
});
|
|
14
|
+
const CancelAllTriggersResponse = z.object({
|
|
15
|
+
ids: z.array(z.uuid())
|
|
16
|
+
});
|
|
9
17
|
|
|
10
18
|
export { CancelAllTriggersResponse, CancelTriggerResponse, CreateTriggerResponse, TriggerListResponse };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
const ExternalTriggerSource = z.enum([
|
|
3
|
+
const ExternalTriggerSource = z.enum([
|
|
4
|
+
"kalshi",
|
|
5
|
+
"polymarket"
|
|
6
|
+
]);
|
|
4
7
|
const TriggerOutcome = z.object({
|
|
5
8
|
id: z.string(),
|
|
6
9
|
label: z.string(),
|
|
@@ -13,7 +16,10 @@ const ExternalTrigger = z.object({
|
|
|
13
16
|
selectable: z.boolean(),
|
|
14
17
|
oracle: z.number().nullable(),
|
|
15
18
|
options: z.array(TriggerOutcome),
|
|
16
|
-
type: z.enum([
|
|
19
|
+
type: z.enum([
|
|
20
|
+
"binary",
|
|
21
|
+
"multi"
|
|
22
|
+
]),
|
|
17
23
|
title: z.string(),
|
|
18
24
|
imageUrl: z.string().nullable()
|
|
19
25
|
});
|
package/dist/users/entities.js
CHANGED
|
@@ -7,7 +7,10 @@ const UserPreferences = z.object({
|
|
|
7
7
|
const UserProfile = z.object({
|
|
8
8
|
id: z.uuid().describe("User UUID"),
|
|
9
9
|
displayName: z.string().describe("Public display name"),
|
|
10
|
-
role: z.enum([
|
|
10
|
+
role: z.enum([
|
|
11
|
+
"basic",
|
|
12
|
+
"pro"
|
|
13
|
+
]).describe("User role"),
|
|
11
14
|
address: z.string().nullable().describe("Linked wallet address (for evm_wallet provider)"),
|
|
12
15
|
email: z.string().nullable().describe("Linked email address (for email provider)"),
|
|
13
16
|
emailVerified: z.boolean().describe("Whether the email is verified"),
|