@pear-protocol/types 2.21.0 → 2.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +1 -0
- package/dist/fee/entities.d.ts +1 -0
- package/dist/fee/responses.d.ts +26 -0
- package/dist/index.js +7355 -3
- package/dist/rewards/entities.d.ts +28 -0
- package/dist/rewards/payloads.d.ts +7 -0
- package/dist/rewards/responses.d.ts +73 -0
- package/dist/users/entities.d.ts +4 -0
- package/dist/users/response.d.ts +2 -0
- package/package.json +3 -2
- package/dist/auth/api-keys.js +0 -44
- package/dist/auth/entities.js +0 -25
- package/dist/auth/index.js +0 -4
- package/dist/auth/payloads.js +0 -84
- package/dist/auth/response.js +0 -82
- package/dist/baskets/recommended/entities.js +0 -22
- package/dist/baskets/recommended/index.js +0 -2
- package/dist/baskets/recommended/responses.js +0 -8
- package/dist/baskets/saved/entities.js +0 -23
- package/dist/baskets/saved/payloads.js +0 -18
- package/dist/baskets/saved/responses.js +0 -14
- package/dist/bundle.js +0 -36
- package/dist/common/address.js +0 -5
- package/dist/common/array.js +0 -17
- package/dist/common/client-id.js +0 -5
- package/dist/common/hex-string.js +0 -5
- package/dist/common/index.js +0 -4
- package/dist/common/refinement.js +0 -64
- package/dist/common/request.js +0 -24
- package/dist/common/response.js +0 -28
- package/dist/common/schema.js +0 -18
- package/dist/common/trade-legs.js +0 -50
- package/dist/connector/index.js +0 -12
- package/dist/copy/entities.js +0 -151
- package/dist/copy/index.js +0 -5
- package/dist/copy/payloads.js +0 -8
- package/dist/copy/performance.js +0 -63
- package/dist/copy/queries.js +0 -20
- package/dist/copy/responses.js +0 -89
- package/dist/execution/entities.js +0 -196
- package/dist/execution/index.js +0 -3
- package/dist/execution/queries.js +0 -18
- package/dist/execution/responses.js +0 -12
- package/dist/fee/entities.js +0 -34
- package/dist/fee/index.js +0 -3
- package/dist/fee/queries.js +0 -12
- package/dist/fee/responses.js +0 -29
- package/dist/fill/entities.js +0 -82
- package/dist/fill/index.js +0 -3
- package/dist/fill/queries.js +0 -14
- package/dist/fill/responses.js +0 -23
- package/dist/funding/entities.js +0 -16
- package/dist/funding/index.js +0 -3
- package/dist/funding/queries.js +0 -8
- package/dist/funding/responses.js +0 -11
- package/dist/instrument/entities.js +0 -102
- package/dist/instrument/index.js +0 -3
- package/dist/instrument/queries.js +0 -15
- package/dist/instrument/responses.js +0 -20
- package/dist/instrument-precision/index.js +0 -56
- package/dist/ladder/entities.js +0 -24
- package/dist/ladder/index.js +0 -4
- package/dist/ladder/payloads.js +0 -96
- package/dist/ladder/queries.js +0 -12
- package/dist/ladder/responses.js +0 -18
- package/dist/leverage/index.js +0 -2
- package/dist/leverage/payloads.js +0 -14
- package/dist/leverage/response.js +0 -5
- package/dist/margin/index.js +0 -2
- package/dist/margin/payloads.js +0 -20
- package/dist/margin/response.js +0 -11
- package/dist/market/entities.js +0 -52
- package/dist/market/index.js +0 -4
- package/dist/market/payloads.js +0 -11
- package/dist/market/queries.js +0 -19
- package/dist/market/responses.js +0 -18
- package/dist/misc/index.js +0 -2
- package/dist/misc/payloads.js +0 -99
- package/dist/misc/responses.js +0 -85
- package/dist/notification/entities.js +0 -274
- package/dist/notification/index.js +0 -4
- package/dist/notification/payloads.js +0 -15
- package/dist/notification/queries.js +0 -29
- package/dist/notification/responses.js +0 -20
- package/dist/order/entities.js +0 -81
- package/dist/order/index.js +0 -1
- package/dist/portfolio/entities.js +0 -77
- package/dist/portfolio/index.js +0 -3
- package/dist/portfolio/queries.js +0 -34
- package/dist/portfolio/responses.js +0 -33
- package/dist/position/entities.js +0 -433
- package/dist/position/index.js +0 -3
- package/dist/position/queries.js +0 -109
- package/dist/position/responses.js +0 -41
- package/dist/price/entities.js +0 -10
- package/dist/price/index.js +0 -3
- package/dist/price/queries.js +0 -8
- package/dist/price/responses.js +0 -15
- package/dist/realtime/channels.js +0 -16
- package/dist/realtime/frames.js +0 -140
- package/dist/realtime/index.js +0 -6
- package/dist/realtime/messages.js +0 -118
- package/dist/realtime/public-events.js +0 -92
- package/dist/realtime/user-events.js +0 -32
- package/dist/realtime/vault-events.js +0 -42
- package/dist/rebalance/entities.js +0 -86
- package/dist/rebalance/index.js +0 -4
- package/dist/rebalance/payloads.js +0 -56
- package/dist/rebalance/queries.js +0 -14
- package/dist/rebalance/responses.js +0 -41
- package/dist/schedule/entities.js +0 -239
- package/dist/schedule/index.js +0 -5
- package/dist/schedule/payloads.js +0 -85
- package/dist/schedule/queries.js +0 -30
- package/dist/schedule/randomization.js +0 -15
- package/dist/schedule/responses.js +0 -22
- package/dist/schedule/twap-config.js +0 -29
- package/dist/statistics/entities.js +0 -105
- package/dist/statistics/index.js +0 -3
- package/dist/statistics/queries.js +0 -111
- package/dist/statistics/responses.js +0 -67
- package/dist/sync/index.js +0 -2
- package/dist/sync/payloads.js +0 -136
- package/dist/sync/responses.js +0 -28
- package/dist/tca/entities.js +0 -9
- package/dist/tca/index.js +0 -3
- package/dist/tca/queries.js +0 -14
- package/dist/tca/responses.js +0 -126
- package/dist/trade/entities.js +0 -101
- package/dist/trade/index.js +0 -4
- package/dist/trade/payloads.js +0 -84
- package/dist/trade/queries.js +0 -9
- package/dist/trade/responses.js +0 -25
- package/dist/trade-accounts/entities.js +0 -61
- package/dist/trade-accounts/index.js +0 -4
- package/dist/trade-accounts/payloads.js +0 -132
- package/dist/trade-accounts/queries.js +0 -7
- package/dist/trade-accounts/response.js +0 -79
- package/dist/traders/index.js +0 -2
- package/dist/traders/performance.js +0 -21
- package/dist/traders/public.js +0 -192
- package/dist/trigger/common/index.js +0 -39
- package/dist/trigger/entities/conditions.js +0 -174
- package/dist/trigger/entities/index.js +0 -257
- package/dist/trigger/index.js +0 -9
- package/dist/trigger/oracle.js +0 -22
- package/dist/trigger/payloads/conditions.js +0 -213
- package/dist/trigger/payloads/config.js +0 -3
- package/dist/trigger/payloads/index.js +0 -173
- package/dist/trigger/queries.js +0 -16
- package/dist/trigger/refinement/index.js +0 -2
- package/dist/trigger/refinement/static.refinement.js +0 -50
- package/dist/trigger/refinement/trailing.refinement.js +0 -83
- package/dist/trigger/responses.js +0 -18
- package/dist/triggers/entities.js +0 -27
- package/dist/triggers/index.js +0 -3
- package/dist/triggers/queries.js +0 -10
- package/dist/triggers/responses.js +0 -9
- package/dist/users/entities.js +0 -45
- package/dist/users/index.js +0 -4
- package/dist/users/payloads.js +0 -33
- package/dist/users/queries.js +0 -8
- package/dist/users/response.js +0 -28
- package/dist/vaults/entities.js +0 -96
- package/dist/vaults/index.js +0 -4
- package/dist/vaults/payloads.js +0 -65
- package/dist/vaults/queries.js +0 -66
- package/dist/vaults/responses.js +0 -368
- /package/dist/{baskets/saved/index.js → rewards/index.d.ts} +0 -0
package/dist/traders/public.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { CursorResponse } from '../common';
|
|
3
|
-
import { Connector } from '../connector';
|
|
4
|
-
import { CopyFollower } from '../copy/entities';
|
|
5
|
-
import { Ladder } from '../ladder/entities';
|
|
6
|
-
import { OpenPosition, OpenPositionLeg, ClosedPosition, ClosedPositionLeg } from '../position/entities';
|
|
7
|
-
import { ClosedPositionListParams } from '../position/queries';
|
|
8
|
-
import { TWAPOpen, TWAPClose } from '../schedule/entities';
|
|
9
|
-
import { TriggerMarketOpen, TriggerMarketAdjust, TriggerMarketClose, TriggerTWAPAdjust, TriggerTWAPClose } from '../trigger/entities';
|
|
10
|
-
|
|
11
|
-
const PublicTraderParams = z.object({
|
|
12
|
-
tradeAccountId: z.uuid()
|
|
13
|
-
});
|
|
14
|
-
const PublicTraderQuery = z.object({
|
|
15
|
-
/** Accept exact HTTP boolean strings without treating the string "false" as true. */
|
|
16
|
-
includeCopyState: z.union([
|
|
17
|
-
z.boolean(),
|
|
18
|
-
z.stringbool({
|
|
19
|
-
truthy: [
|
|
20
|
-
"true"
|
|
21
|
-
],
|
|
22
|
-
falsy: [
|
|
23
|
-
"false"
|
|
24
|
-
],
|
|
25
|
-
case: "sensitive"
|
|
26
|
-
})
|
|
27
|
-
]).optional().default(false)
|
|
28
|
-
});
|
|
29
|
-
const PublicTraderClosedPositionsParams = z.object({
|
|
30
|
-
limit: ClosedPositionListParams.shape.limit,
|
|
31
|
-
cursor: ClosedPositionListParams.shape.cursor,
|
|
32
|
-
startDate: ClosedPositionListParams.shape.startDate,
|
|
33
|
-
endDate: ClosedPositionListParams.shape.endDate,
|
|
34
|
-
positionId: ClosedPositionListParams.shape.positionId
|
|
35
|
-
}).strict();
|
|
36
|
-
const ViewerCopyStatus = z.enum([
|
|
37
|
-
"COPIED",
|
|
38
|
-
"PARTIAL",
|
|
39
|
-
"NOT_COPIED",
|
|
40
|
-
"PENDING",
|
|
41
|
-
"UNKNOWN"
|
|
42
|
-
]);
|
|
43
|
-
const PublicOpenPosition = OpenPosition.pick({
|
|
44
|
-
positionId: true,
|
|
45
|
-
status: true,
|
|
46
|
-
connector: true,
|
|
47
|
-
openedAt: true,
|
|
48
|
-
updatedAt: true,
|
|
49
|
-
copySubscriptionId: true,
|
|
50
|
-
realizedGrossPnl: true,
|
|
51
|
-
netCashflow: true
|
|
52
|
-
}).extend({
|
|
53
|
-
/** The selected follower's result for this leader position; absent without viewer context. */
|
|
54
|
-
copyStatus: ViewerCopyStatus.optional(),
|
|
55
|
-
/** The recorded attempt, exclusion, or lifecycle reason for this follower's result. */
|
|
56
|
-
copyReason: z.string().optional(),
|
|
57
|
-
legs: z.array(OpenPositionLeg.pick({
|
|
58
|
-
asset: true,
|
|
59
|
-
side: true,
|
|
60
|
-
realized: true,
|
|
61
|
-
remaining: true
|
|
62
|
-
}))
|
|
63
|
-
});
|
|
64
|
-
const PublicClosedPosition = ClosedPosition.pick({
|
|
65
|
-
positionId: true,
|
|
66
|
-
status: true,
|
|
67
|
-
connector: true,
|
|
68
|
-
openedAt: true,
|
|
69
|
-
closedAt: true,
|
|
70
|
-
closedReason: true,
|
|
71
|
-
grossPnl: true,
|
|
72
|
-
netPnl: true,
|
|
73
|
-
hasProvisionalFills: true
|
|
74
|
-
}).extend({
|
|
75
|
-
legs: z.array(ClosedPositionLeg.pick({
|
|
76
|
-
asset: true,
|
|
77
|
-
side: true,
|
|
78
|
-
entryVwap: true,
|
|
79
|
-
exitVwap: true,
|
|
80
|
-
entryNotional: true,
|
|
81
|
-
grossPnl: true,
|
|
82
|
-
netPnl: true
|
|
83
|
-
}))
|
|
84
|
-
});
|
|
85
|
-
const PublicTraderClosedPositionsResponse = CursorResponse.extend({
|
|
86
|
-
positions: z.array(PublicClosedPosition)
|
|
87
|
-
});
|
|
88
|
-
const triggerFields = {
|
|
89
|
-
id: true,
|
|
90
|
-
connector: true,
|
|
91
|
-
status: true,
|
|
92
|
-
intent: true,
|
|
93
|
-
type: true,
|
|
94
|
-
bracketType: true,
|
|
95
|
-
semanticBracketType: true,
|
|
96
|
-
condition: true,
|
|
97
|
-
context: true,
|
|
98
|
-
ladderId: true,
|
|
99
|
-
ladderIndex: true,
|
|
100
|
-
parentTriggerId: true,
|
|
101
|
-
triggeredAt: true,
|
|
102
|
-
cancelledAt: true,
|
|
103
|
-
cancelledReason: true,
|
|
104
|
-
createdAt: true,
|
|
105
|
-
updatedAt: true
|
|
106
|
-
};
|
|
107
|
-
const PublicTrigger = z.discriminatedUnion("type", [
|
|
108
|
-
z.discriminatedUnion("intent", [
|
|
109
|
-
TriggerMarketOpen.pick(triggerFields),
|
|
110
|
-
TriggerMarketAdjust.pick({
|
|
111
|
-
...triggerFields,
|
|
112
|
-
trailing: true
|
|
113
|
-
}),
|
|
114
|
-
TriggerMarketClose.pick({
|
|
115
|
-
...triggerFields,
|
|
116
|
-
trailing: true
|
|
117
|
-
})
|
|
118
|
-
]),
|
|
119
|
-
z.discriminatedUnion("intent", [
|
|
120
|
-
TriggerTWAPAdjust.pick({
|
|
121
|
-
...triggerFields,
|
|
122
|
-
trailing: true,
|
|
123
|
-
scheduleId: true
|
|
124
|
-
}),
|
|
125
|
-
TriggerTWAPClose.pick({
|
|
126
|
-
...triggerFields,
|
|
127
|
-
trailing: true,
|
|
128
|
-
scheduleId: true
|
|
129
|
-
})
|
|
130
|
-
])
|
|
131
|
-
]);
|
|
132
|
-
const scheduleFields = {
|
|
133
|
-
id: true,
|
|
134
|
-
connector: true,
|
|
135
|
-
status: true,
|
|
136
|
-
strategy: true,
|
|
137
|
-
intent: true,
|
|
138
|
-
executionType: true,
|
|
139
|
-
positionKey: true,
|
|
140
|
-
startAt: true,
|
|
141
|
-
endAt: true,
|
|
142
|
-
lastSliceAt: true,
|
|
143
|
-
sliceIntervalSec: true,
|
|
144
|
-
sliceCount: true,
|
|
145
|
-
randomization: true,
|
|
146
|
-
cancelledAt: true,
|
|
147
|
-
cancelledReason: true,
|
|
148
|
-
createdAt: true,
|
|
149
|
-
updatedAt: true
|
|
150
|
-
};
|
|
151
|
-
const PublicSchedule = z.discriminatedUnion("intent", [
|
|
152
|
-
TWAPOpen.pick({
|
|
153
|
-
...scheduleFields,
|
|
154
|
-
legs: true,
|
|
155
|
-
targetNotional: true,
|
|
156
|
-
remainingNotional: true
|
|
157
|
-
}),
|
|
158
|
-
TWAPClose.pick({
|
|
159
|
-
...scheduleFields,
|
|
160
|
-
positionId: true,
|
|
161
|
-
initialExposure: true
|
|
162
|
-
})
|
|
163
|
-
]);
|
|
164
|
-
const PublicLadder = Ladder.pick({
|
|
165
|
-
id: true,
|
|
166
|
-
connector: true,
|
|
167
|
-
status: true,
|
|
168
|
-
positionKey: true,
|
|
169
|
-
config: true,
|
|
170
|
-
attachTriggers: true,
|
|
171
|
-
createdAt: true,
|
|
172
|
-
updatedAt: true
|
|
173
|
-
}).extend({
|
|
174
|
-
triggers: z.array(PublicTrigger)
|
|
175
|
-
});
|
|
176
|
-
const PublicTraderResponse = z.object({
|
|
177
|
-
connector: Connector.describe("Exchange connector type"),
|
|
178
|
-
// Omit X identity when the owner hides it or has not linked an account.
|
|
179
|
-
xHandle: z.string().optional().describe("Public X handle at the last authorization; absent when hidden or unlinked"),
|
|
180
|
-
xName: z.string().optional().describe("Public X display name; absent when hidden or unlinked"),
|
|
181
|
-
xAvatarUrl: z.string().optional().describe("Public X avatar URL; absent when hidden or unlinked"),
|
|
182
|
-
xUserId: z.string().optional().describe("Immutable X numeric user ID; absent when hidden or unlinked"),
|
|
183
|
-
// Followers are complete; the latest-20 limit applies only to trading records.
|
|
184
|
-
followers: z.array(CopyFollower),
|
|
185
|
-
followerCount: z.number().int().nonnegative(),
|
|
186
|
-
positions: z.array(PublicOpenPosition),
|
|
187
|
-
triggers: z.array(PublicTrigger),
|
|
188
|
-
schedules: z.array(PublicSchedule),
|
|
189
|
-
ladders: z.array(PublicLadder)
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
export { PublicClosedPosition, PublicLadder, PublicOpenPosition, PublicSchedule, PublicTraderClosedPositionsParams, PublicTraderClosedPositionsResponse, PublicTraderParams, PublicTraderQuery, PublicTraderResponse, PublicTrigger, ViewerCopyStatus };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
const TriggerIntent = z.enum([
|
|
4
|
-
"OPEN",
|
|
5
|
-
"ADJUST",
|
|
6
|
-
"CLOSE"
|
|
7
|
-
]);
|
|
8
|
-
const TriggerStatus = z.enum([
|
|
9
|
-
"ACTIVE",
|
|
10
|
-
"TRIGGERED",
|
|
11
|
-
"CANCELLED"
|
|
12
|
-
]);
|
|
13
|
-
const TriggerCancelledReason = z.enum([
|
|
14
|
-
"POSITION_CLOSED",
|
|
15
|
-
"USER",
|
|
16
|
-
"SYSTEM",
|
|
17
|
-
"POSITION_NETTED",
|
|
18
|
-
"POSITION_LIQUIDATED",
|
|
19
|
-
"POSITION_REVERSED"
|
|
20
|
-
]);
|
|
21
|
-
const BracketType = z.enum([
|
|
22
|
-
"STOP_LOSS",
|
|
23
|
-
"TAKE_PROFIT",
|
|
24
|
-
"NONE"
|
|
25
|
-
]);
|
|
26
|
-
const MetricTrack = z.enum([
|
|
27
|
-
"PEAK",
|
|
28
|
-
"TROUGH"
|
|
29
|
-
]);
|
|
30
|
-
const TpSlBracketType = z.enum([
|
|
31
|
-
"TAKE_PROFIT",
|
|
32
|
-
"STOP_LOSS"
|
|
33
|
-
]);
|
|
34
|
-
const TrailingMode = z.enum([
|
|
35
|
-
"RELATIVE_BPS",
|
|
36
|
-
"ABSOLUTE_POINTS"
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
export { BracketType, MetricTrack, TpSlBracketType, TrailingMode, TriggerCancelledReason, TriggerIntent, TriggerStatus };
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Side } from '../../common/schema';
|
|
3
|
-
import { Connector } from '../../connector';
|
|
4
|
-
import { InstrumentId } from '../../instrument';
|
|
5
|
-
import { PriceSource } from '../../price';
|
|
6
|
-
import { MetricTrack } from '../common';
|
|
7
|
-
|
|
8
|
-
const Ratio = z.object({
|
|
9
|
-
type: z.literal("ratio"),
|
|
10
|
-
data: z.object({
|
|
11
|
-
priceSource: PriceSource,
|
|
12
|
-
symbol_a: InstrumentId,
|
|
13
|
-
symbol_b: InstrumentId,
|
|
14
|
-
track: MetricTrack,
|
|
15
|
-
threshold: z.number()
|
|
16
|
-
})
|
|
17
|
-
});
|
|
18
|
-
const Price = z.object({
|
|
19
|
-
type: z.literal("price"),
|
|
20
|
-
data: z.object({
|
|
21
|
-
priceSource: PriceSource,
|
|
22
|
-
symbol: InstrumentId,
|
|
23
|
-
track: MetricTrack,
|
|
24
|
-
threshold: z.number()
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
const WeightedRatio = z.object({
|
|
28
|
-
type: z.literal("weighted_ratio"),
|
|
29
|
-
data: z.object({
|
|
30
|
-
priceSource: PriceSource,
|
|
31
|
-
basket: z.array(z.object({
|
|
32
|
-
symbol: InstrumentId,
|
|
33
|
-
side: Side,
|
|
34
|
-
weight: z.number()
|
|
35
|
-
})),
|
|
36
|
-
track: MetricTrack,
|
|
37
|
-
threshold: z.number()
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
const Notional = z.object({
|
|
41
|
-
type: z.literal("notional"),
|
|
42
|
-
data: z.object({
|
|
43
|
-
priceSource: PriceSource,
|
|
44
|
-
track: MetricTrack,
|
|
45
|
-
threshold: z.number()
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
const Upnl = z.object({
|
|
49
|
-
type: z.literal("upnl"),
|
|
50
|
-
data: z.object({
|
|
51
|
-
priceSource: PriceSource,
|
|
52
|
-
track: MetricTrack,
|
|
53
|
-
threshold: z.number()
|
|
54
|
-
})
|
|
55
|
-
});
|
|
56
|
-
const UpnlBps = z.object({
|
|
57
|
-
type: z.literal("upnl_bps"),
|
|
58
|
-
data: z.object({
|
|
59
|
-
priceSource: PriceSource,
|
|
60
|
-
track: MetricTrack,
|
|
61
|
-
threshold: z.number()
|
|
62
|
-
})
|
|
63
|
-
});
|
|
64
|
-
const FundingRate = z.object({
|
|
65
|
-
type: z.literal("funding_rate"),
|
|
66
|
-
data: z.object({
|
|
67
|
-
connector: Connector,
|
|
68
|
-
symbol: InstrumentId,
|
|
69
|
-
track: MetricTrack,
|
|
70
|
-
threshold: z.number()
|
|
71
|
-
})
|
|
72
|
-
});
|
|
73
|
-
const PredictionMarket = z.object({
|
|
74
|
-
type: z.literal("prediction_market"),
|
|
75
|
-
data: z.object({
|
|
76
|
-
source: z.enum([
|
|
77
|
-
"kalshi",
|
|
78
|
-
"polymarket"
|
|
79
|
-
]),
|
|
80
|
-
marketKey: z.string().min(1),
|
|
81
|
-
track: MetricTrack,
|
|
82
|
-
threshold: z.number()
|
|
83
|
-
})
|
|
84
|
-
});
|
|
85
|
-
const BtcDominance = z.object({
|
|
86
|
-
type: z.literal("btc_dominance"),
|
|
87
|
-
data: z.object({
|
|
88
|
-
source: z.literal("coingecko"),
|
|
89
|
-
track: MetricTrack,
|
|
90
|
-
threshold: z.number()
|
|
91
|
-
})
|
|
92
|
-
});
|
|
93
|
-
const RatioTrailing = z.object({
|
|
94
|
-
type: z.literal("ratio_trailing"),
|
|
95
|
-
data: z.object({
|
|
96
|
-
priceSource: PriceSource,
|
|
97
|
-
symbol_a: InstrumentId,
|
|
98
|
-
symbol_b: InstrumentId
|
|
99
|
-
})
|
|
100
|
-
});
|
|
101
|
-
const PriceTrailing = z.object({
|
|
102
|
-
type: z.literal("price_trailing"),
|
|
103
|
-
data: z.object({
|
|
104
|
-
priceSource: PriceSource,
|
|
105
|
-
symbol: InstrumentId
|
|
106
|
-
})
|
|
107
|
-
});
|
|
108
|
-
const WeightedRatioTrailing = z.object({
|
|
109
|
-
type: z.literal("weighted_ratio_trailing"),
|
|
110
|
-
data: z.object({
|
|
111
|
-
priceSource: PriceSource,
|
|
112
|
-
basket: z.array(z.object({
|
|
113
|
-
symbol: InstrumentId,
|
|
114
|
-
side: Side,
|
|
115
|
-
weight: z.number()
|
|
116
|
-
}))
|
|
117
|
-
})
|
|
118
|
-
});
|
|
119
|
-
const NotionalTrailing = z.object({
|
|
120
|
-
type: z.literal("notional_trailing"),
|
|
121
|
-
data: z.object({
|
|
122
|
-
priceSource: PriceSource
|
|
123
|
-
})
|
|
124
|
-
});
|
|
125
|
-
const UpnlTrailing = z.object({
|
|
126
|
-
type: z.literal("upnl_trailing"),
|
|
127
|
-
data: z.object({
|
|
128
|
-
priceSource: PriceSource
|
|
129
|
-
})
|
|
130
|
-
});
|
|
131
|
-
const UpnlBpsTrailing = z.object({
|
|
132
|
-
type: z.literal("upnl_bps_trailing"),
|
|
133
|
-
data: z.object({
|
|
134
|
-
priceSource: PriceSource
|
|
135
|
-
})
|
|
136
|
-
});
|
|
137
|
-
const TriggerConditionOpen = z.discriminatedUnion("type", [
|
|
138
|
-
Ratio,
|
|
139
|
-
Price,
|
|
140
|
-
WeightedRatio,
|
|
141
|
-
FundingRate,
|
|
142
|
-
PredictionMarket,
|
|
143
|
-
BtcDominance
|
|
144
|
-
]);
|
|
145
|
-
const TriggerConditionAdjust = z.discriminatedUnion("type", [
|
|
146
|
-
Ratio,
|
|
147
|
-
Price,
|
|
148
|
-
WeightedRatio,
|
|
149
|
-
Notional,
|
|
150
|
-
Upnl,
|
|
151
|
-
UpnlBps,
|
|
152
|
-
FundingRate,
|
|
153
|
-
PredictionMarket,
|
|
154
|
-
BtcDominance
|
|
155
|
-
]);
|
|
156
|
-
const TriggerConditionClose = z.discriminatedUnion("type", [
|
|
157
|
-
Ratio,
|
|
158
|
-
Price,
|
|
159
|
-
WeightedRatio,
|
|
160
|
-
Notional,
|
|
161
|
-
Upnl,
|
|
162
|
-
UpnlBps,
|
|
163
|
-
RatioTrailing,
|
|
164
|
-
PriceTrailing,
|
|
165
|
-
WeightedRatioTrailing,
|
|
166
|
-
NotionalTrailing,
|
|
167
|
-
UpnlTrailing,
|
|
168
|
-
UpnlBpsTrailing,
|
|
169
|
-
FundingRate,
|
|
170
|
-
PredictionMarket,
|
|
171
|
-
BtcDominance
|
|
172
|
-
]);
|
|
173
|
-
|
|
174
|
-
export { TriggerConditionAdjust, TriggerConditionClose, TriggerConditionOpen };
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { SignedDecimalString } from '../../common/schema';
|
|
3
|
-
import { TradeLegPostOnly, TradeLeg } from '../../common/trade-legs';
|
|
4
|
-
import { Connector } from '../../connector';
|
|
5
|
-
import { Fill } from '../../fill';
|
|
6
|
-
import { InstrumentId } from '../../instrument';
|
|
7
|
-
import { TWAPRandomization } from '../../schedule/randomization';
|
|
8
|
-
import { TWAPSliceIntervalSec, MIN_TWAP_SLICE_INTERVAL_SEC, FINAL_TWAP_SLICE_START_HEADROOM_SEC, MAX_TWAP_DURATION_SEC, TWAPTargetNotional, TriggerTWAPOpenLegs } from '../../schedule/twap-config';
|
|
9
|
-
import { TrailingMode, BracketType, TriggerStatus, TriggerCancelledReason, TpSlBracketType } from '../common';
|
|
10
|
-
import { TriggerConditionOpen, TriggerConditionAdjust, TriggerConditionClose } from './conditions';
|
|
11
|
-
|
|
12
|
-
const Trailing = z.object({
|
|
13
|
-
/**
|
|
14
|
-
* Trailing mode to track the metric.
|
|
15
|
-
*/
|
|
16
|
-
mode: TrailingMode,
|
|
17
|
-
/**
|
|
18
|
-
* Delta value to track the metric in the given mode.
|
|
19
|
-
*/
|
|
20
|
-
deltaValue: z.number(),
|
|
21
|
-
/**
|
|
22
|
-
* Activation value to start tracking the metric.
|
|
23
|
-
* When omitted, trailing starts immediately from the current metric.
|
|
24
|
-
*/
|
|
25
|
-
activationValue: z.number().optional(),
|
|
26
|
-
/**
|
|
27
|
-
* Best metric seen
|
|
28
|
-
*/
|
|
29
|
-
bestMetricSeen: z.number().optional(),
|
|
30
|
-
/**
|
|
31
|
-
* Current stop value
|
|
32
|
-
*/
|
|
33
|
-
currentStopValue: z.number().optional(),
|
|
34
|
-
/**
|
|
35
|
-
* Timestamp (ms) when a stop/activation breach was detected.
|
|
36
|
-
*/
|
|
37
|
-
stopBreachedAt: z.number().optional()
|
|
38
|
-
});
|
|
39
|
-
const BaseTrigger = z.object({
|
|
40
|
-
/**
|
|
41
|
-
* Trigger UUID
|
|
42
|
-
*/
|
|
43
|
-
id: z.uuid(),
|
|
44
|
-
/**
|
|
45
|
-
* Trade account UUID
|
|
46
|
-
*/
|
|
47
|
-
tradeAccountId: z.uuid(),
|
|
48
|
-
/**
|
|
49
|
-
* Connector
|
|
50
|
-
*/
|
|
51
|
-
connector: Connector,
|
|
52
|
-
/**
|
|
53
|
-
* Status of the trigger
|
|
54
|
-
*/
|
|
55
|
-
status: TriggerStatus,
|
|
56
|
-
/**
|
|
57
|
-
* Parent ladder ID when this trigger is a ladder rung
|
|
58
|
-
*/
|
|
59
|
-
ladderId: z.uuid().optional(),
|
|
60
|
-
/**
|
|
61
|
-
* Zero-based rung index within the parent ladder
|
|
62
|
-
*/
|
|
63
|
-
ladderIndex: z.number().int().optional(),
|
|
64
|
-
/**
|
|
65
|
-
* Source open trigger that spawned this attached close trigger, when it originated from a conditional open
|
|
66
|
-
*/
|
|
67
|
-
parentTriggerId: z.uuid().optional(),
|
|
68
|
-
/**
|
|
69
|
-
* When the trigger was triggered
|
|
70
|
-
*/
|
|
71
|
-
triggeredAt: z.string().optional(),
|
|
72
|
-
/**
|
|
73
|
-
* When the trigger was cancelled
|
|
74
|
-
*/
|
|
75
|
-
cancelledAt: z.string().optional(),
|
|
76
|
-
/**
|
|
77
|
-
* Reason for the trigger being cancelled
|
|
78
|
-
*/
|
|
79
|
-
cancelledReason: TriggerCancelledReason.optional(),
|
|
80
|
-
/**
|
|
81
|
-
* Fills for the trigger
|
|
82
|
-
*/
|
|
83
|
-
fills: z.array(Fill).optional(),
|
|
84
|
-
/**
|
|
85
|
-
* Bracket type for trigger behavior
|
|
86
|
-
*/
|
|
87
|
-
bracketType: BracketType,
|
|
88
|
-
/**
|
|
89
|
-
* User-facing bracket semantics. `bracketType` is the crossing encoding the gateway
|
|
90
|
-
* fires on (wire-flipped for a price bracket on a short watched leg); this field is
|
|
91
|
-
* what the user asked for, so present this one as intent. Always stated: where a
|
|
92
|
-
* legacy client's encoding was unknowable, it carries `bracketType` as a best guess.
|
|
93
|
-
*/
|
|
94
|
-
semanticBracketType: BracketType,
|
|
95
|
-
/**
|
|
96
|
-
* Created at timestamp
|
|
97
|
-
*/
|
|
98
|
-
createdAt: z.string(),
|
|
99
|
-
/**
|
|
100
|
-
* Updated at timestamp
|
|
101
|
-
*/
|
|
102
|
-
updatedAt: z.string()
|
|
103
|
-
});
|
|
104
|
-
const TriggerMarketOpenAttachedTrigger = z.object({
|
|
105
|
-
kind: z.enum([
|
|
106
|
-
"STATIC",
|
|
107
|
-
"TRAILING"
|
|
108
|
-
]),
|
|
109
|
-
bracketType: TpSlBracketType
|
|
110
|
-
});
|
|
111
|
-
const TriggerMarketOpen = BaseTrigger.extend({
|
|
112
|
-
/**
|
|
113
|
-
* Intent
|
|
114
|
-
*/
|
|
115
|
-
intent: z.literal("OPEN"),
|
|
116
|
-
/**
|
|
117
|
-
* Order type
|
|
118
|
-
*/
|
|
119
|
-
type: z.literal("MARKET"),
|
|
120
|
-
/**
|
|
121
|
-
* Condition (only open conditions allowed)
|
|
122
|
-
*/
|
|
123
|
-
condition: TriggerConditionOpen,
|
|
124
|
-
/**
|
|
125
|
-
* Context
|
|
126
|
-
*/
|
|
127
|
-
context: z.object({
|
|
128
|
-
type: z.literal("MARKET"),
|
|
129
|
-
legs: z.tuple([
|
|
130
|
-
TradeLegPostOnly
|
|
131
|
-
]).rest(TradeLegPostOnly),
|
|
132
|
-
/**
|
|
133
|
-
* Close triggers configured to attach after this open trigger fires.
|
|
134
|
-
*/
|
|
135
|
-
attachedTriggers: z.array(TriggerMarketOpenAttachedTrigger)
|
|
136
|
-
})
|
|
137
|
-
});
|
|
138
|
-
const TriggerMarketAdjust = BaseTrigger.extend({
|
|
139
|
-
/**
|
|
140
|
-
* Intent
|
|
141
|
-
*/
|
|
142
|
-
intent: z.literal("ADJUST"),
|
|
143
|
-
/**
|
|
144
|
-
* Order type
|
|
145
|
-
*/
|
|
146
|
-
type: z.literal("MARKET"),
|
|
147
|
-
/**
|
|
148
|
-
* Condition (only adjust conditions allowed)
|
|
149
|
-
*/
|
|
150
|
-
condition: TriggerConditionAdjust,
|
|
151
|
-
/**
|
|
152
|
-
* Context
|
|
153
|
-
*/
|
|
154
|
-
context: z.object({
|
|
155
|
-
type: z.literal("MARKET"),
|
|
156
|
-
position: z.object({
|
|
157
|
-
id: z.uuid(),
|
|
158
|
-
initialExposure: z.record(InstrumentId, SignedDecimalString)
|
|
159
|
-
}),
|
|
160
|
-
legs: z.tuple([
|
|
161
|
-
TradeLeg
|
|
162
|
-
]).rest(TradeLeg)
|
|
163
|
-
}),
|
|
164
|
-
/**
|
|
165
|
-
* Optional: trailing configuration
|
|
166
|
-
*/
|
|
167
|
-
trailing: Trailing.optional()
|
|
168
|
-
});
|
|
169
|
-
const TriggerMarketClose = BaseTrigger.extend({
|
|
170
|
-
/**
|
|
171
|
-
* Intent
|
|
172
|
-
*/
|
|
173
|
-
intent: z.literal("CLOSE"),
|
|
174
|
-
/**
|
|
175
|
-
* Order type
|
|
176
|
-
*/
|
|
177
|
-
type: z.literal("MARKET"),
|
|
178
|
-
/**
|
|
179
|
-
* Condition (only close conditions allowed)
|
|
180
|
-
*/
|
|
181
|
-
condition: TriggerConditionClose,
|
|
182
|
-
/**
|
|
183
|
-
* Context
|
|
184
|
-
*/
|
|
185
|
-
context: z.object({
|
|
186
|
-
type: z.literal("MARKET"),
|
|
187
|
-
position: z.object({
|
|
188
|
-
id: z.uuid(),
|
|
189
|
-
initialExposure: z.record(InstrumentId, SignedDecimalString)
|
|
190
|
-
})
|
|
191
|
-
}),
|
|
192
|
-
/**
|
|
193
|
-
* Optional: trailing configuration
|
|
194
|
-
*/
|
|
195
|
-
trailing: Trailing.optional()
|
|
196
|
-
});
|
|
197
|
-
const TriggerMarket = z.discriminatedUnion("intent", [
|
|
198
|
-
TriggerMarketOpen,
|
|
199
|
-
TriggerMarketAdjust,
|
|
200
|
-
TriggerMarketClose
|
|
201
|
-
]);
|
|
202
|
-
const TriggerTWAPContext = z.object({
|
|
203
|
-
type: z.literal("TWAP"),
|
|
204
|
-
durationSec: z.int().min(MIN_TWAP_SLICE_INTERVAL_SEC + FINAL_TWAP_SLICE_START_HEADROOM_SEC).max(MAX_TWAP_DURATION_SEC),
|
|
205
|
-
sliceIntervalSec: TWAPSliceIntervalSec,
|
|
206
|
-
randomization: TWAPRandomization,
|
|
207
|
-
position: z.object({
|
|
208
|
-
id: z.uuid(),
|
|
209
|
-
initialExposure: z.record(InstrumentId, SignedDecimalString)
|
|
210
|
-
})
|
|
211
|
-
}).refine((context) => context.durationSec >= context.sliceIntervalSec + FINAL_TWAP_SLICE_START_HEADROOM_SEC, {
|
|
212
|
-
message: `TWAP duration must leave ${FINAL_TWAP_SLICE_START_HEADROOM_SEC} seconds after the first slice`,
|
|
213
|
-
path: [
|
|
214
|
-
"durationSec"
|
|
215
|
-
]
|
|
216
|
-
});
|
|
217
|
-
const TriggerTWAPAdjust = BaseTrigger.extend({
|
|
218
|
-
/** Intent. */
|
|
219
|
-
intent: z.literal("ADJUST"),
|
|
220
|
-
/** Order type. */
|
|
221
|
-
type: z.literal("TWAP"),
|
|
222
|
-
/** Schedule created when the trigger fired, absent before firing or after a skipped fire. */
|
|
223
|
-
scheduleId: z.uuid().optional(),
|
|
224
|
-
/** Condition. */
|
|
225
|
-
condition: TriggerConditionAdjust,
|
|
226
|
-
/** Persisted TWAP execution context. */
|
|
227
|
-
context: TriggerTWAPContext.safeExtend({
|
|
228
|
-
legs: TriggerTWAPOpenLegs,
|
|
229
|
-
targetNotional: TWAPTargetNotional
|
|
230
|
-
}),
|
|
231
|
-
/** Optional trailing configuration. */
|
|
232
|
-
trailing: Trailing.optional()
|
|
233
|
-
});
|
|
234
|
-
const TriggerTWAPClose = BaseTrigger.extend({
|
|
235
|
-
/** Intent. */
|
|
236
|
-
intent: z.literal("CLOSE"),
|
|
237
|
-
/** Order type. */
|
|
238
|
-
type: z.literal("TWAP"),
|
|
239
|
-
/** Schedule created when the trigger fired, absent before firing or after a skipped fire. */
|
|
240
|
-
scheduleId: z.uuid().optional(),
|
|
241
|
-
/** Condition. */
|
|
242
|
-
condition: TriggerConditionClose,
|
|
243
|
-
/** Persisted TWAP execution context. */
|
|
244
|
-
context: TriggerTWAPContext,
|
|
245
|
-
/** Optional trailing configuration. */
|
|
246
|
-
trailing: Trailing.optional()
|
|
247
|
-
});
|
|
248
|
-
const TriggerTWAP = z.discriminatedUnion("intent", [
|
|
249
|
-
TriggerTWAPAdjust,
|
|
250
|
-
TriggerTWAPClose
|
|
251
|
-
]);
|
|
252
|
-
const Trigger = z.discriminatedUnion("type", [
|
|
253
|
-
TriggerMarket,
|
|
254
|
-
TriggerTWAP
|
|
255
|
-
]);
|
|
256
|
-
|
|
257
|
-
export { Trailing, Trigger, TriggerMarket, TriggerMarketAdjust, TriggerMarketClose, TriggerMarketOpen, TriggerMarketOpenAttachedTrigger, TriggerTWAP, TriggerTWAPAdjust, TriggerTWAPClose };
|
package/dist/trigger/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './common';
|
|
2
|
-
export * from './entities';
|
|
3
|
-
export * from './entities/conditions';
|
|
4
|
-
export * from './oracle';
|
|
5
|
-
export * from './payloads';
|
|
6
|
-
export * from './payloads/conditions';
|
|
7
|
-
export * from './queries';
|
|
8
|
-
export * from './refinement';
|
|
9
|
-
export * from './responses';
|
package/dist/trigger/oracle.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
const OracleUnit = z.enum([
|
|
4
|
-
"cent",
|
|
5
|
-
"percent"
|
|
6
|
-
]);
|
|
7
|
-
const OracleValue = z.object({
|
|
8
|
-
value: z.number(),
|
|
9
|
-
unit: OracleUnit
|
|
10
|
-
});
|
|
11
|
-
const OracleTrigger = z.object({
|
|
12
|
-
id: z.string(),
|
|
13
|
-
category: z.enum([
|
|
14
|
-
"btcdom"
|
|
15
|
-
]),
|
|
16
|
-
source: z.enum([
|
|
17
|
-
"coingecko"
|
|
18
|
-
]),
|
|
19
|
-
oracle: OracleValue.nullable()
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export { OracleTrigger, OracleUnit, OracleValue };
|