@pear-protocol/types 1.15.0 → 1.16.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/rebalance/entities.d.ts +2 -0
- package/dist/rebalance/entities.js +6 -1
- package/dist/rebalance/responses.d.ts +2 -0
- package/dist/sync/payloads.d.ts +20 -1
- package/dist/sync/payloads.js +10 -3
- package/dist/sync/responses.d.ts +1 -0
- package/dist/sync/responses.js +3 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export declare const AutoRebalancePausedReason: z.ZodEnum<{
|
|
|
8
8
|
USER: "USER";
|
|
9
9
|
POSITION_CHANGED: "POSITION_CHANGED";
|
|
10
10
|
REPEATED_FAILURES: "REPEATED_FAILURES";
|
|
11
|
+
INVALID_LIVE_BETA_EXPOSURE: "INVALID_LIVE_BETA_EXPOSURE";
|
|
11
12
|
}>;
|
|
12
13
|
export type AutoRebalancePausedReason = z.infer<typeof AutoRebalancePausedReason>;
|
|
13
14
|
export declare const AutoRebalanceWeightSource: z.ZodEnum<{
|
|
@@ -39,6 +40,7 @@ export declare const AutoRebalanceConfig: z.ZodObject<{
|
|
|
39
40
|
USER: "USER";
|
|
40
41
|
POSITION_CHANGED: "POSITION_CHANGED";
|
|
41
42
|
REPEATED_FAILURES: "REPEATED_FAILURES";
|
|
43
|
+
INVALID_LIVE_BETA_EXPOSURE: "INVALID_LIVE_BETA_EXPOSURE";
|
|
42
44
|
}>>;
|
|
43
45
|
weightSource: z.ZodEnum<{
|
|
44
46
|
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
@@ -3,7 +3,12 @@ import { UnsignedDecimalString } from '../common/schema';
|
|
|
3
3
|
import { InstrumentId } from '../instrument';
|
|
4
4
|
|
|
5
5
|
const AutoRebalanceStatus = z.enum(["ACTIVE", "PAUSED"]);
|
|
6
|
-
const AutoRebalancePausedReason = z.enum([
|
|
6
|
+
const AutoRebalancePausedReason = z.enum([
|
|
7
|
+
"USER",
|
|
8
|
+
"POSITION_CHANGED",
|
|
9
|
+
"REPEATED_FAILURES",
|
|
10
|
+
"INVALID_LIVE_BETA_EXPOSURE"
|
|
11
|
+
]);
|
|
7
12
|
const AutoRebalanceWeightSource = z.enum(["INITIAL_WEIGHT", "LIVE_BETA"]);
|
|
8
13
|
const AutoRebalanceTimeframe = z.enum(["1h", "4h", "1d"]);
|
|
9
14
|
const RebalanceEventStatus = z.enum(["SUCCESS", "FAILED"]);
|
|
@@ -28,6 +28,7 @@ export declare const AutoRebalanceListResponse: z.ZodObject<{
|
|
|
28
28
|
USER: "USER";
|
|
29
29
|
POSITION_CHANGED: "POSITION_CHANGED";
|
|
30
30
|
REPEATED_FAILURES: "REPEATED_FAILURES";
|
|
31
|
+
INVALID_LIVE_BETA_EXPOSURE: "INVALID_LIVE_BETA_EXPOSURE";
|
|
31
32
|
}>>;
|
|
32
33
|
weightSource: z.ZodEnum<{
|
|
33
34
|
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
@@ -56,6 +57,7 @@ export declare const CreateAutoRebalanceResponse: z.ZodObject<{
|
|
|
56
57
|
USER: "USER";
|
|
57
58
|
POSITION_CHANGED: "POSITION_CHANGED";
|
|
58
59
|
REPEATED_FAILURES: "REPEATED_FAILURES";
|
|
60
|
+
INVALID_LIVE_BETA_EXPOSURE: "INVALID_LIVE_BETA_EXPOSURE";
|
|
59
61
|
}>>;
|
|
60
62
|
weightSource: z.ZodEnum<{
|
|
61
63
|
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
package/dist/sync/payloads.d.ts
CHANGED
|
@@ -325,6 +325,14 @@ export declare const ApplicablePosition: z.ZodObject<{
|
|
|
325
325
|
}, z.core.$strip>;
|
|
326
326
|
}, z.core.$strip>;
|
|
327
327
|
export type ApplicablePosition = z.output<typeof ApplicablePosition>;
|
|
328
|
+
/**
|
|
329
|
+
* Headroom above server time still accepted for the sync watermark: absorbs
|
|
330
|
+
* NTP drift between exchange and server clocks plus the deliberate first-sync
|
|
331
|
+
* trim advance (the exchanges-sdk syncer sends externalMaxTs + OVERLAP_MS + 1,
|
|
332
|
+
* ~60s past the newest fill), while a unit mistake (seconds↔ms conversion)
|
|
333
|
+
* overshoots it by orders of magnitude.
|
|
334
|
+
*/
|
|
335
|
+
export declare const WATERMARK_FUTURE_SKEW_MS = 300000;
|
|
328
336
|
/**
|
|
329
337
|
* Cycle-level metadata for the unified sync request.
|
|
330
338
|
*/
|
|
@@ -332,11 +340,21 @@ export declare const SyncMeta: z.ZodObject<{
|
|
|
332
340
|
externalMaxTs: z.ZodNullable<z.ZodNumber>;
|
|
333
341
|
}, z.core.$strip>;
|
|
334
342
|
export type SyncMeta = z.output<typeof SyncMeta>;
|
|
343
|
+
/**
|
|
344
|
+
* Cycle-level metadata for the fills-create request specifically — extends the
|
|
345
|
+
* shared SyncMeta with a first-sync boundary meaningful only to the fills-create
|
|
346
|
+
* checkpoint, so it does not leak into the unrelated funding-payments contract.
|
|
347
|
+
*/
|
|
348
|
+
export declare const CreateApplicablesMeta: z.ZodObject<{
|
|
349
|
+
externalMaxTs: z.ZodNullable<z.ZodNumber>;
|
|
350
|
+
firstSyncStartedAt: z.ZodOptional<z.ZodNumber>;
|
|
351
|
+
}, z.core.$strip>;
|
|
352
|
+
export type CreateApplicablesMeta = z.output<typeof CreateApplicablesMeta>;
|
|
335
353
|
/**
|
|
336
354
|
* POST /sync/create request — the discover+apply phase of the cycle.
|
|
337
355
|
* - applicables: baskets keyed by positionKey, find-or-created during apply.
|
|
338
356
|
* - exchangePositions: the exchange snapshot, enforced source of truth at verify.
|
|
339
|
-
* - meta: cycle metadata (watermark).
|
|
357
|
+
* - meta: cycle metadata (watermark, first-sync pre-fetch boundary).
|
|
340
358
|
*
|
|
341
359
|
*/
|
|
342
360
|
export declare const CreateApplicablesRequest: z.ZodObject<{
|
|
@@ -410,6 +428,7 @@ export declare const CreateApplicablesRequest: z.ZodObject<{
|
|
|
410
428
|
}, z.core.$strip>>;
|
|
411
429
|
meta: z.ZodObject<{
|
|
412
430
|
externalMaxTs: z.ZodNullable<z.ZodNumber>;
|
|
431
|
+
firstSyncStartedAt: z.ZodOptional<z.ZodNumber>;
|
|
413
432
|
}, z.core.$strip>;
|
|
414
433
|
}, z.core.$strip>;
|
|
415
434
|
export type CreateApplicablesRequest = z.output<typeof CreateApplicablesRequest>;
|
package/dist/sync/payloads.js
CHANGED
|
@@ -103,13 +103,20 @@ const ApplicablePosition = z.object({
|
|
|
103
103
|
fills: z.array(ApplicableFill).min(1, "Applicable must carry at least one fill"),
|
|
104
104
|
metadata: ApplicableMetadata
|
|
105
105
|
});
|
|
106
|
+
const WATERMARK_FUTURE_SKEW_MS = 3e5;
|
|
106
107
|
const SyncMeta = z.object({
|
|
107
|
-
externalMaxTs: z.number().int().nonnegative().
|
|
108
|
+
externalMaxTs: z.number().int().nonnegative().refine(
|
|
109
|
+
(timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS,
|
|
110
|
+
"externalMaxTs must not be ahead of server time"
|
|
111
|
+
).nullable().describe("watermark advance source")
|
|
112
|
+
});
|
|
113
|
+
const CreateApplicablesMeta = SyncMeta.extend({
|
|
114
|
+
firstSyncStartedAt: z.number().int().nonnegative().optional().describe("backend-issued timestamp returned before the first fill-history fetch")
|
|
108
115
|
});
|
|
109
116
|
const CreateApplicablesRequest = z.object({
|
|
110
117
|
applicables: z.array(ApplicablePosition),
|
|
111
118
|
exchangePositions: z.array(ExternalPosition),
|
|
112
|
-
meta:
|
|
119
|
+
meta: CreateApplicablesMeta
|
|
113
120
|
});
|
|
114
121
|
const OptionallySignedDecimalString = z.string().regex(/^[+-]?\d+(\.\d+)?$/, "Must be a valid signed decimal string");
|
|
115
122
|
const FundingPaymentEntry = z.object({
|
|
@@ -127,4 +134,4 @@ const CreateFundingPaymentsRequest = z.object({
|
|
|
127
134
|
meta: SyncMeta
|
|
128
135
|
});
|
|
129
136
|
|
|
130
|
-
export { ApplicableFill, ApplicableMetadata, ApplicablePosition, ConfirmFillsRequest, ConfirmableExternalFill, CreateApplicablesRequest, CreateFundingPaymentsRequest, ExternalPosition, FundingPaymentEntry, ReconcileFillsRequest, ReconcileReplacementExternalFill, SyncFillsSinceRequest, SyncFundingSinceRequest, SyncMeta, UnknownExternalFill };
|
|
137
|
+
export { ApplicableFill, ApplicableMetadata, ApplicablePosition, ConfirmFillsRequest, ConfirmableExternalFill, CreateApplicablesMeta, CreateApplicablesRequest, CreateFundingPaymentsRequest, ExternalPosition, FundingPaymentEntry, ReconcileFillsRequest, ReconcileReplacementExternalFill, SyncFillsSinceRequest, SyncFundingSinceRequest, SyncMeta, UnknownExternalFill, WATERMARK_FUTURE_SKEW_MS };
|
package/dist/sync/responses.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const SyncFillsResponse: z.ZodObject<{}, z.core.$strip>;
|
|
|
3
3
|
export declare const SyncFillsSinceResponse: z.ZodObject<{
|
|
4
4
|
sinceMs: z.ZodNumber;
|
|
5
5
|
neverSynced: z.ZodBoolean;
|
|
6
|
+
firstSyncStartedAt: z.ZodOptional<z.ZodNumber>;
|
|
6
7
|
confirmedExchangeFillIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
8
|
}, z.core.$strip>;
|
|
8
9
|
export declare const SyncFundingSinceResponse: z.ZodObject<{
|
package/dist/sync/responses.js
CHANGED
|
@@ -7,6 +7,9 @@ const SyncFillsSinceResponse = z.object({
|
|
|
7
7
|
// genesis. Clients use this to detect an account that has never imported its trade history —
|
|
8
8
|
// `sinceMs === 0` alone is ambiguous (a clamped watermark also yields 0).
|
|
9
9
|
neverSynced: z.boolean(),
|
|
10
|
+
// Backend-clock boundary returned only for a never-synced account. The syncer carries this
|
|
11
|
+
// through when an empty exchange fetch provides no fill-derived checkpoint.
|
|
12
|
+
firstSyncStartedAt: z.number().int().nonnegative().optional(),
|
|
10
13
|
confirmedExchangeFillIds: z.array(z.string()).optional()
|
|
11
14
|
});
|
|
12
15
|
const SyncFundingSinceResponse = z.object({
|