@pear-protocol/types
Advanced tools
| import { z } from 'zod'; | ||
| export declare const AutoRebalanceStatus: z.ZodEnum<{ | ||
| ACTIVE: "ACTIVE"; | ||
| PAUSED: "PAUSED"; | ||
| }>; | ||
| export type AutoRebalanceStatus = z.infer<typeof AutoRebalanceStatus>; | ||
| export declare const AutoRebalanceWeightSource: z.ZodEnum<{ | ||
| INITIAL_WEIGHT: "INITIAL_WEIGHT"; | ||
| LIVE_BETA: "LIVE_BETA"; | ||
| }>; | ||
| export type AutoRebalanceWeightSource = z.infer<typeof AutoRebalanceWeightSource>; | ||
| export declare const AutoRebalanceTimeframe: z.ZodEnum<{ | ||
| "1d": "1d"; | ||
| "1h": "1h"; | ||
| "4h": "4h"; | ||
| }>; | ||
| export type AutoRebalanceTimeframe = z.infer<typeof AutoRebalanceTimeframe>; | ||
| export declare const RebalanceEventStatus: z.ZodEnum<{ | ||
| FAILED: "FAILED"; | ||
| SUCCESS: "SUCCESS"; | ||
| }>; | ||
| export type RebalanceEventStatus = z.infer<typeof RebalanceEventStatus>; | ||
| export declare const WeightMap: z.ZodRecord<z.ZodString, z.ZodNumber>; | ||
| export type WeightMap = z.output<typeof WeightMap>; | ||
| export declare const AutoRebalanceConfig: z.ZodObject<{ | ||
| id: z.ZodUUID; | ||
| positionId: z.ZodUUID; | ||
| status: z.ZodEnum<{ | ||
| ACTIVE: "ACTIVE"; | ||
| PAUSED: "PAUSED"; | ||
| }>; | ||
| weightSource: z.ZodEnum<{ | ||
| INITIAL_WEIGHT: "INITIAL_WEIGHT"; | ||
| LIVE_BETA: "LIVE_BETA"; | ||
| }>; | ||
| minimumDriftPct: z.ZodString; | ||
| timeframe: z.ZodOptional<z.ZodEnum<{ | ||
| "1d": "1d"; | ||
| "1h": "1h"; | ||
| "4h": "4h"; | ||
| }>>; | ||
| createdAt: z.ZodISODateTime; | ||
| updatedAt: z.ZodISODateTime; | ||
| }, z.core.$strip>; | ||
| export type AutoRebalanceConfig = z.output<typeof AutoRebalanceConfig>; | ||
| export declare const RebalanceEvent: z.ZodObject<{ | ||
| id: z.ZodUUID; | ||
| autoRebalanceConfigId: z.ZodUUID; | ||
| positionId: z.ZodUUID; | ||
| weightSource: z.ZodEnum<{ | ||
| INITIAL_WEIGHT: "INITIAL_WEIGHT"; | ||
| LIVE_BETA: "LIVE_BETA"; | ||
| }>; | ||
| driftPct: z.ZodString; | ||
| currentWeights: z.ZodRecord<z.ZodString, z.ZodNumber>; | ||
| targetWeights: z.ZodRecord<z.ZodString, z.ZodNumber>; | ||
| status: z.ZodEnum<{ | ||
| FAILED: "FAILED"; | ||
| SUCCESS: "SUCCESS"; | ||
| }>; | ||
| error: z.ZodOptional<z.ZodString>; | ||
| createdAt: z.ZodISODateTime; | ||
| }, z.core.$strip>; | ||
| export type RebalanceEvent = z.output<typeof RebalanceEvent>; |
| import { z } from 'zod'; | ||
| import { UnsignedDecimalString } from '../common/schema'; | ||
| import { InstrumentId } from '../instrument'; | ||
| const AutoRebalanceStatus = z.enum(["ACTIVE", "PAUSED"]); | ||
| const AutoRebalanceWeightSource = z.enum(["INITIAL_WEIGHT", "LIVE_BETA"]); | ||
| const AutoRebalanceTimeframe = z.enum(["1h", "4h", "1d"]); | ||
| const RebalanceEventStatus = z.enum(["SUCCESS", "FAILED"]); | ||
| const WeightMap = z.record(InstrumentId, z.number()); | ||
| const AutoRebalanceConfig = z.object({ | ||
| id: z.uuid(), | ||
| positionId: z.uuid(), | ||
| status: AutoRebalanceStatus, | ||
| weightSource: AutoRebalanceWeightSource, | ||
| minimumDriftPct: UnsignedDecimalString, | ||
| timeframe: AutoRebalanceTimeframe.optional(), | ||
| createdAt: z.iso.datetime(), | ||
| updatedAt: z.iso.datetime() | ||
| }); | ||
| const RebalanceEvent = z.object({ | ||
| id: z.uuid(), | ||
| autoRebalanceConfigId: z.uuid(), | ||
| positionId: z.uuid(), | ||
| weightSource: AutoRebalanceWeightSource, | ||
| driftPct: UnsignedDecimalString, | ||
| currentWeights: WeightMap, | ||
| targetWeights: WeightMap, | ||
| status: RebalanceEventStatus, | ||
| error: z.string().optional(), | ||
| createdAt: z.iso.datetime() | ||
| }); | ||
| export { AutoRebalanceConfig, AutoRebalanceStatus, AutoRebalanceTimeframe, AutoRebalanceWeightSource, RebalanceEvent, RebalanceEventStatus, WeightMap }; |
| import { z } from 'zod'; | ||
| export declare const AutoRebalanceListParams: z.ZodObject<{ | ||
| limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>; | ||
| cursor: z.ZodOptional<z.ZodString>; | ||
| status: z.ZodOptional<z.ZodPipe<z.ZodTransform<string[] | (("ACTIVE" | "PAUSED")[] & any[]) | undefined, ("ACTIVE" | "PAUSED")[]>, z.ZodArray<z.ZodEnum<{ | ||
| ACTIVE: "ACTIVE"; | ||
| PAUSED: "PAUSED"; | ||
| }>>>>; | ||
| weightSource: z.ZodOptional<z.ZodPipe<z.ZodTransform<string[] | (("INITIAL_WEIGHT" | "LIVE_BETA")[] & any[]) | undefined, ("INITIAL_WEIGHT" | "LIVE_BETA")[]>, z.ZodArray<z.ZodEnum<{ | ||
| INITIAL_WEIGHT: "INITIAL_WEIGHT"; | ||
| LIVE_BETA: "LIVE_BETA"; | ||
| }>>>>; | ||
| positionId: z.ZodOptional<z.ZodUUID>; | ||
| }, z.core.$strip>; | ||
| export type AutoRebalanceListParamsInput = z.input<typeof AutoRebalanceListParams>; | ||
| export type AutoRebalanceListParams = z.output<typeof AutoRebalanceListParams>; | ||
| export declare const RebalanceEventListParams: z.ZodObject<{ | ||
| limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>; | ||
| cursor: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strip>; | ||
| export type RebalanceEventListParamsInput = z.input<typeof RebalanceEventListParams>; | ||
| export type RebalanceEventListParams = z.output<typeof RebalanceEventListParams>; |
| import { z } from 'zod'; | ||
| import { normalizeArray, CursorFindParams } from '../common'; | ||
| import { AutoRebalanceStatus, AutoRebalanceWeightSource } from './entities'; | ||
| const StatusArray = z.preprocess( | ||
| (arg) => normalizeArray(arg), | ||
| z.array(AutoRebalanceStatus) | ||
| ); | ||
| const WeightSourceArray = z.preprocess( | ||
| (arg) => normalizeArray(arg), | ||
| z.array(AutoRebalanceWeightSource) | ||
| ); | ||
| const AutoRebalanceListParams = CursorFindParams.extend({ | ||
| status: StatusArray.optional(), | ||
| weightSource: WeightSourceArray.optional(), | ||
| positionId: z.uuid().optional() | ||
| }); | ||
| const RebalanceEventListParams = CursorFindParams.extend({}); | ||
| export { AutoRebalanceListParams, RebalanceEventListParams }; |
@@ -33,2 +33,3 @@ import { z } from 'zod'; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -35,0 +36,0 @@ price: z.ZodString; |
@@ -12,9 +12,5 @@ import { z } from 'zod'; | ||
| id: z.uuid(), | ||
| /** | ||
| * Client order ID | ||
| */ | ||
| /** Client order ID (abbreviated as cloid) */ | ||
| cloid: z.string().optional(), | ||
| /** | ||
| * Exchange-native fill ID (tradeId / tid / etc) | ||
| */ | ||
| /** Exchange-native fill ID (tradeId / tid / etc) */ | ||
| exchangeFillId: z.string().optional(), | ||
@@ -49,17 +45,13 @@ /** | ||
| reduceOnly: z.boolean(), | ||
| /** | ||
| * True when the fill was created from external sync. | ||
| */ | ||
| /** True when the fill was created from external sync. */ | ||
| isExternal: z.boolean(), | ||
| /** | ||
| * Filled quantity | ||
| * True when the fill is a synthetic bridge fill (gap/gone reconstruction). | ||
| * Unpriceable gone-close synthetics carry "0" price/usd and should be displayed distinctly. | ||
| */ | ||
| synthetic: z.boolean(), | ||
| quantity: z.string(), | ||
| /** | ||
| * Filled price | ||
| */ | ||
| /** Filled price — "0" on an unpriceable gone-close synthetic (no price guessing). */ | ||
| price: z.string(), | ||
| /** | ||
| * USD value | ||
| */ | ||
| /** USD value — "0" on an unpriceable gone-close synthetic (cannot compute without price). */ | ||
| usd: z.string(), | ||
@@ -66,0 +58,0 @@ /** |
@@ -30,2 +30,3 @@ import { z } from 'zod'; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -70,2 +71,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -72,0 +74,0 @@ price: z.ZodString; |
@@ -80,2 +80,3 @@ import { z } from 'zod'; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -280,2 +281,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -526,2 +528,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -528,0 +531,0 @@ price: z.ZodString; |
@@ -14,2 +14,14 @@ import { z } from 'zod'; | ||
| /** | ||
| * Provenance of a position, derived from the SET of fill origins on it. | ||
| * - PEAR: opened via Pear, only Pear fills | ||
| * - EXTERNAL: opened directly on the exchange, only external fills | ||
| * - PARTIAL: a mix of Pear and external fills | ||
| */ | ||
| export declare const PositionOrigin: z.ZodEnum<{ | ||
| PARTIAL: "PARTIAL"; | ||
| PEAR: "PEAR"; | ||
| EXTERNAL: "EXTERNAL"; | ||
| }>; | ||
| export type PositionOrigin = z.infer<typeof PositionOrigin>; | ||
| /** | ||
| * The exposure of a position in directional units for each asset. | ||
@@ -30,2 +42,13 @@ * | ||
| export type PositionInitialExposureUSD = z.infer<typeof PositionInitialExposureUSD>; | ||
| /** | ||
| * Cumulative funding attributed to this position per asset, in USD (signed; | ||
| * negative = net paid). Derived by walking the position's exposure snapshots and | ||
| * summing each in-window funding event as `exposure × fundingPerUnit`. Across a | ||
| * fully-tracked account the per-position shares sum to the account funding (up to | ||
| * 20-dp rounding of the coefficient). | ||
| * | ||
| * @example { '0': '-1.25' } means 1.25 USD of BTC funding paid over the position's life | ||
| */ | ||
| export declare const PositionTotalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| export type PositionTotalFundingPayment = z.infer<typeof PositionTotalFundingPayment>; | ||
| export declare const Position: z.ZodObject<{ | ||
@@ -50,3 +73,9 @@ id: z.ZodUUID; | ||
| }>>>; | ||
| origin: z.ZodEnum<{ | ||
| PARTIAL: "PARTIAL"; | ||
| PEAR: "PEAR"; | ||
| EXTERNAL: "EXTERNAL"; | ||
| }>; | ||
| exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| totalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| closedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
@@ -53,0 +82,0 @@ initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; |
@@ -8,4 +8,6 @@ import { z } from 'zod'; | ||
| const PositionClosedReason = z.enum(["NETTED", "USER", "LIQUIDATED"]); | ||
| const PositionOrigin = z.enum(["PEAR", "EXTERNAL", "PARTIAL"]); | ||
| const PositionExposure = z.record(InstrumentId, SignedDecimalString); | ||
| const PositionInitialExposureUSD = z.record(InstrumentId, SignedDecimalString); | ||
| const PositionTotalFundingPayment = z.record(InstrumentId, SignedDecimalString); | ||
| const Position = z.object({ | ||
@@ -32,2 +34,3 @@ /** | ||
| closedReason: PositionClosedReason.nullable().optional(), | ||
| origin: PositionOrigin, | ||
| /** | ||
@@ -37,2 +40,3 @@ * Position exposure | ||
| exposure: PositionExposure, | ||
| totalFundingPayment: PositionTotalFundingPayment, | ||
| /** | ||
@@ -48,12 +52,6 @@ * Closed at timestamp | ||
| initialExposureUSD: PositionInitialExposureUSD, | ||
| /** | ||
| * Created at timestamp | ||
| */ | ||
| createdAt: z.string(), | ||
| /** | ||
| * Updated at timestamp | ||
| */ | ||
| updatedAt: z.string() | ||
| }); | ||
| export { Position, PositionClosedReason, PositionExposure, PositionInitialExposureUSD, PositionStatus }; | ||
| export { Position, PositionClosedReason, PositionExposure, PositionInitialExposureUSD, PositionOrigin, PositionStatus, PositionTotalFundingPayment }; |
@@ -22,3 +22,9 @@ import { z } from 'zod'; | ||
| }>>>; | ||
| origin: z.ZodEnum<{ | ||
| PARTIAL: "PARTIAL"; | ||
| PEAR: "PEAR"; | ||
| EXTERNAL: "EXTERNAL"; | ||
| }>; | ||
| exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| totalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| closedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
@@ -34,4 +40,9 @@ initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| createdAt: z.ZodISODateTime; | ||
| exposure: z.ZodRecord<z.ZodString, z.ZodString>; | ||
| exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| status: z.ZodLiteral<"OPEN">; | ||
| origin: z.ZodEnum<{ | ||
| PARTIAL: "PARTIAL"; | ||
| PEAR: "PEAR"; | ||
| EXTERNAL: "EXTERNAL"; | ||
| }>; | ||
| connector: z.ZodEnum<{ | ||
@@ -49,4 +60,9 @@ hyperliquid: "hyperliquid"; | ||
| createdAt: z.ZodISODateTime; | ||
| exposure: z.ZodRecord<z.ZodString, z.ZodString>; | ||
| exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| status: z.ZodLiteral<"OPEN">; | ||
| origin: z.ZodEnum<{ | ||
| PARTIAL: "PARTIAL"; | ||
| PEAR: "PEAR"; | ||
| EXTERNAL: "EXTERNAL"; | ||
| }>; | ||
| connector: z.ZodEnum<{ | ||
@@ -53,0 +69,0 @@ hyperliquid: "hyperliquid"; |
| import { z } from 'zod'; | ||
| import { SignedDecimalString } from '../common/schema'; | ||
| import { Connector } from '../connector'; | ||
| import { InstrumentId } from '../instrument'; | ||
| import { Position } from './entities'; | ||
| import { Position, PositionOrigin } from './entities'; | ||
@@ -12,4 +13,5 @@ const PositionListResponse = z.object({ | ||
| createdAt: z.iso.datetime(), | ||
| exposure: z.record(InstrumentId, z.string()), | ||
| exposure: z.record(InstrumentId, SignedDecimalString), | ||
| status: z.literal("OPEN"), | ||
| origin: PositionOrigin, | ||
| connector: Connector | ||
@@ -16,0 +18,0 @@ }); |
@@ -0,2 +1,4 @@ | ||
| export * from './entities'; | ||
| export * from './payloads'; | ||
| export * from './queries'; | ||
| export * from './responses'; |
@@ -0,2 +1,4 @@ | ||
| export * from './entities'; | ||
| export * from './payloads'; | ||
| export * from './queries'; | ||
| export * from './responses'; |
| import { z } from 'zod'; | ||
| export declare const RebalanceManually: z.ZodObject<{ | ||
| export declare const RebalanceManual: z.ZodObject<{ | ||
| orderType: z.ZodEnum<{ | ||
@@ -12,2 +12,48 @@ MARKET: "MARKET"; | ||
| }, z.core.$strip>; | ||
| export type RebalanceManually = z.output<typeof RebalanceManually>; | ||
| export type RebalanceManual = z.output<typeof RebalanceManual>; | ||
| declare const CreateInitialWeight: z.ZodObject<{ | ||
| weightSource: z.ZodLiteral<"INITIAL_WEIGHT">; | ||
| positionId: z.ZodUUID; | ||
| minimumDriftPct: z.ZodString; | ||
| }, z.core.$strip>; | ||
| declare const CreateLiveBeta: z.ZodObject<{ | ||
| weightSource: z.ZodLiteral<"LIVE_BETA">; | ||
| positionId: z.ZodUUID; | ||
| minimumDriftPct: z.ZodString; | ||
| timeframe: z.ZodEnum<{ | ||
| "1d": "1d"; | ||
| "1h": "1h"; | ||
| "4h": "4h"; | ||
| }>; | ||
| }, z.core.$strip>; | ||
| export declare const CreateAutoRebalanceConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{ | ||
| weightSource: z.ZodLiteral<"INITIAL_WEIGHT">; | ||
| positionId: z.ZodUUID; | ||
| minimumDriftPct: z.ZodString; | ||
| }, z.core.$strip>, z.ZodObject<{ | ||
| weightSource: z.ZodLiteral<"LIVE_BETA">; | ||
| positionId: z.ZodUUID; | ||
| minimumDriftPct: z.ZodString; | ||
| timeframe: z.ZodEnum<{ | ||
| "1d": "1d"; | ||
| "1h": "1h"; | ||
| "4h": "4h"; | ||
| }>; | ||
| }, z.core.$strip>], "weightSource">; | ||
| export declare const UpdateAutoRebalanceConfig: z.ZodObject<{ | ||
| minimumDriftPct: z.ZodOptional<z.ZodString>; | ||
| timeframe: z.ZodOptional<z.ZodEnum<{ | ||
| "1d": "1d"; | ||
| "1h": "1h"; | ||
| "4h": "4h"; | ||
| }>>; | ||
| status: z.ZodOptional<z.ZodEnum<{ | ||
| ACTIVE: "ACTIVE"; | ||
| PAUSED: "PAUSED"; | ||
| }>>; | ||
| }, z.core.$strip>; | ||
| export type CreateInitialWeight = z.output<typeof CreateInitialWeight>; | ||
| export type CreateLiveBeta = z.output<typeof CreateLiveBeta>; | ||
| export type CreateAutoRebalanceConfig = z.output<typeof CreateAutoRebalanceConfig>; | ||
| export type UpdateAutoRebalanceConfig = z.output<typeof UpdateAutoRebalanceConfig>; | ||
| export {}; |
| import { z } from 'zod'; | ||
| import { ClientIdCode } from '../common/client-id'; | ||
| import { RefineWeightingSum, RefineUniqueSymbols } from '../common/refinement'; | ||
| import { UnsignedDecimalString } from '../common/schema'; | ||
| import { ExecutionOrderType } from '../execution'; | ||
| import { InstrumentId } from '../instrument'; | ||
| import { AutoRebalanceTimeframe, AutoRebalanceStatus } from './entities'; | ||
| const RebalanceManually = z.object({ | ||
| const RebalanceManual = z.object({ | ||
| orderType: ExecutionOrderType, | ||
@@ -20,3 +22,23 @@ weightings: z.array( | ||
| }); | ||
| const MinimumDriftPct = UnsignedDecimalString.refine((value) => Number(value) > 0 && Number(value) <= 1, { | ||
| message: "minimumDriftPct must be greater than 0 and at most 1" | ||
| }); | ||
| const CreateInitialWeight = z.object({ | ||
| weightSource: z.literal("INITIAL_WEIGHT"), | ||
| positionId: z.uuid(), | ||
| minimumDriftPct: MinimumDriftPct | ||
| }); | ||
| const CreateLiveBeta = z.object({ | ||
| weightSource: z.literal("LIVE_BETA"), | ||
| positionId: z.uuid(), | ||
| minimumDriftPct: MinimumDriftPct, | ||
| timeframe: AutoRebalanceTimeframe | ||
| }); | ||
| const CreateAutoRebalanceConfig = z.discriminatedUnion("weightSource", [CreateInitialWeight, CreateLiveBeta]); | ||
| const UpdateAutoRebalanceConfig = z.object({ | ||
| minimumDriftPct: MinimumDriftPct.optional(), | ||
| timeframe: AutoRebalanceTimeframe.optional(), | ||
| status: AutoRebalanceStatus.optional() | ||
| }); | ||
| export { RebalanceManually }; | ||
| export { CreateAutoRebalanceConfig, RebalanceManual, UpdateAutoRebalanceConfig }; |
| import { z } from 'zod'; | ||
| export declare const RebalanceManuallyResponse: z.ZodObject<{ | ||
| plan: z.ZodUnion<readonly [z.ZodObject<{ | ||
| export declare const RebalanceManualResponse: z.ZodObject<{ | ||
| plan: z.ZodDiscriminatedUnion<[z.ZodObject<{ | ||
| outcome: z.ZodLiteral<"full_rebalance">; | ||
| }, z.core.$strip>, z.ZodObject<{ | ||
| outcome: z.ZodUnion<readonly [z.ZodLiteral<"partial_rebalance">, z.ZodLiteral<"no_rebalance">]>; | ||
| outcome: z.ZodLiteral<"partial_rebalance">; | ||
| messages: z.ZodTuple<[z.ZodString], z.ZodString>; | ||
| }, z.core.$strip>]>; | ||
| }, z.core.$strip>, z.ZodObject<{ | ||
| outcome: z.ZodLiteral<"no_rebalance">; | ||
| messages: z.ZodTuple<[z.ZodString], z.ZodString>; | ||
| }, z.core.$strip>, z.ZodObject<{ | ||
| outcome: z.ZodLiteral<"failed">; | ||
| messages: z.ZodTuple<[z.ZodString], z.ZodString>; | ||
| }, z.core.$strip>], "outcome">; | ||
| }, z.core.$strip>; | ||
| export type RebalanceManuallyResponse = z.output<typeof RebalanceManuallyResponse>; | ||
| export type RebalanceManualResponse = z.output<typeof RebalanceManualResponse>; | ||
| export declare const AutoRebalanceListResponse: z.ZodObject<{ | ||
| limit: z.ZodNumber; | ||
| nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>; | ||
| items: z.ZodArray<z.ZodObject<{ | ||
| id: z.ZodUUID; | ||
| positionId: z.ZodUUID; | ||
| status: z.ZodEnum<{ | ||
| ACTIVE: "ACTIVE"; | ||
| PAUSED: "PAUSED"; | ||
| }>; | ||
| weightSource: z.ZodEnum<{ | ||
| INITIAL_WEIGHT: "INITIAL_WEIGHT"; | ||
| LIVE_BETA: "LIVE_BETA"; | ||
| }>; | ||
| minimumDriftPct: z.ZodString; | ||
| timeframe: z.ZodOptional<z.ZodEnum<{ | ||
| "1d": "1d"; | ||
| "1h": "1h"; | ||
| "4h": "4h"; | ||
| }>>; | ||
| createdAt: z.ZodISODateTime; | ||
| updatedAt: z.ZodISODateTime; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>; | ||
| export type AutoRebalanceListResponse = z.output<typeof AutoRebalanceListResponse>; | ||
| export declare const CreateAutoRebalanceResponse: z.ZodObject<{ | ||
| config: z.ZodObject<{ | ||
| id: z.ZodUUID; | ||
| positionId: z.ZodUUID; | ||
| status: z.ZodEnum<{ | ||
| ACTIVE: "ACTIVE"; | ||
| PAUSED: "PAUSED"; | ||
| }>; | ||
| weightSource: z.ZodEnum<{ | ||
| INITIAL_WEIGHT: "INITIAL_WEIGHT"; | ||
| LIVE_BETA: "LIVE_BETA"; | ||
| }>; | ||
| minimumDriftPct: z.ZodString; | ||
| timeframe: z.ZodOptional<z.ZodEnum<{ | ||
| "1d": "1d"; | ||
| "1h": "1h"; | ||
| "4h": "4h"; | ||
| }>>; | ||
| createdAt: z.ZodISODateTime; | ||
| updatedAt: z.ZodISODateTime; | ||
| }, z.core.$strip>; | ||
| }, z.core.$strip>; | ||
| export type CreateAutoRebalanceResponse = z.output<typeof CreateAutoRebalanceResponse>; | ||
| export declare const RebalanceEventListResponse: z.ZodObject<{ | ||
| limit: z.ZodNumber; | ||
| nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>; | ||
| items: z.ZodArray<z.ZodObject<{ | ||
| id: z.ZodUUID; | ||
| autoRebalanceConfigId: z.ZodUUID; | ||
| positionId: z.ZodUUID; | ||
| weightSource: z.ZodEnum<{ | ||
| INITIAL_WEIGHT: "INITIAL_WEIGHT"; | ||
| LIVE_BETA: "LIVE_BETA"; | ||
| }>; | ||
| driftPct: z.ZodString; | ||
| currentWeights: z.ZodRecord<z.ZodString, z.ZodNumber>; | ||
| targetWeights: z.ZodRecord<z.ZodString, z.ZodNumber>; | ||
| status: z.ZodEnum<{ | ||
| FAILED: "FAILED"; | ||
| SUCCESS: "SUCCESS"; | ||
| }>; | ||
| error: z.ZodOptional<z.ZodString>; | ||
| createdAt: z.ZodISODateTime; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>; | ||
| export type RebalanceEventListResponse = z.output<typeof RebalanceEventListResponse>; |
| import { z } from 'zod'; | ||
| import { CursorResponse } from '../common'; | ||
| import { AutoRebalanceConfig, RebalanceEvent } from './entities'; | ||
| const RebalanceManuallyResponse = z.object({ | ||
| plan: z.union([ | ||
| const RebalanceManualResponse = z.object({ | ||
| plan: z.discriminatedUnion("outcome", [ | ||
| z.object({ | ||
@@ -9,8 +11,24 @@ outcome: z.literal("full_rebalance") | ||
| z.object({ | ||
| outcome: z.union([z.literal("partial_rebalance"), z.literal("no_rebalance")]), | ||
| outcome: z.literal("partial_rebalance"), | ||
| messages: z.tuple([z.string()]).rest(z.string()) | ||
| }), | ||
| z.object({ | ||
| outcome: z.literal("no_rebalance"), | ||
| messages: z.tuple([z.string()]).rest(z.string()) | ||
| }), | ||
| // `failed` only occurs on background runs (dispatch/cron); MANUAL execution errors throw and surface as HTTP errors instead. | ||
| z.object({ | ||
| outcome: z.literal("failed"), | ||
| messages: z.tuple([z.string()]).rest(z.string()) | ||
| }) | ||
| ]) | ||
| }); | ||
| const AutoRebalanceListResponse = CursorResponse.extend({ | ||
| items: z.array(AutoRebalanceConfig) | ||
| }); | ||
| const CreateAutoRebalanceResponse = z.object({ config: AutoRebalanceConfig }); | ||
| const RebalanceEventListResponse = CursorResponse.extend({ | ||
| items: z.array(RebalanceEvent) | ||
| }); | ||
| export { RebalanceManuallyResponse }; | ||
| export { AutoRebalanceListResponse, CreateAutoRebalanceResponse, RebalanceEventListResponse, RebalanceManualResponse }; |
@@ -117,2 +117,3 @@ import { z } from 'zod'; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -187,2 +188,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -274,2 +276,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -353,2 +356,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -439,2 +443,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -441,0 +446,0 @@ price: z.ZodString; |
@@ -62,2 +62,3 @@ import { z } from 'zod'; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -148,2 +149,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -230,2 +232,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -316,2 +319,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -318,0 +322,0 @@ price: z.ZodString; |
+251
-71
@@ -70,32 +70,2 @@ import { z } from 'zod'; | ||
| }, z.core.$strip>; | ||
| export declare const CreatableExternalFill: z.ZodObject<{ | ||
| type: z.ZodLiteral<"create">; | ||
| exchangeFillId: z.ZodString; | ||
| cloid: z.ZodNullable<z.ZodString>; | ||
| positionId: z.ZodUUID; | ||
| connector: z.ZodEnum<{ | ||
| hyperliquid: "hyperliquid"; | ||
| binance: "binance"; | ||
| bybit: "bybit"; | ||
| okx: "okx"; | ||
| lighter: "lighter"; | ||
| }>; | ||
| symbol: z.ZodString; | ||
| price: z.ZodString; | ||
| quantity: z.ZodString; | ||
| side: z.ZodEnum<{ | ||
| BUY: "BUY"; | ||
| SELL: "SELL"; | ||
| }>; | ||
| reduceOnly: z.ZodBoolean; | ||
| timestamp: z.ZodNumber; | ||
| tradeFee: z.ZodString; | ||
| liquidation: z.ZodNullable<z.ZodObject<{ | ||
| mark: z.ZodString; | ||
| }, z.core.$strip>>; | ||
| original: z.ZodOptional<z.ZodObject<{ | ||
| exchangeFillId: z.ZodString; | ||
| quantity: z.ZodString; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>; | ||
| export declare const ConfirmFillsRequest: z.ZodRecord<z.ZodUUID, z.ZodTuple<[z.ZodObject<{ | ||
@@ -209,7 +179,39 @@ type: z.ZodLiteral<"confirm">; | ||
| }, z.core.$strip>>>; | ||
| export declare const CreateFillsRequest: z.ZodRecord<z.ZodUUID, z.ZodTuple<[z.ZodObject<{ | ||
| type: z.ZodLiteral<"create">; | ||
| export declare const SyncFillsSinceRequest: z.ZodObject<{ | ||
| overlapMs: z.ZodNumber; | ||
| }, z.core.$strip>; | ||
| export declare const SyncFundingSinceRequest: z.ZodObject<{ | ||
| overlapMs: z.ZodNumber; | ||
| }, z.core.$strip>; | ||
| export type ConfirmFillsRequest = z.output<typeof ConfirmFillsRequest>; | ||
| export type ReconcileFillsRequest = z.output<typeof ReconcileFillsRequest>; | ||
| export type SyncFillsSinceRequest = z.output<typeof SyncFillsSinceRequest>; | ||
| export type SyncFundingSinceRequest = z.output<typeof SyncFundingSinceRequest>; | ||
| export type UnknownExternalFill = z.output<typeof UnknownExternalFill>; | ||
| export type ReconcileReplacementExternalFill = z.output<typeof ReconcileReplacementExternalFill>; | ||
| export type ConfirmableExternalFill = z.output<typeof ConfirmableExternalFill>; | ||
| /** | ||
| * An exchange-reported open position snapshot. The exchange position API is the | ||
| * source of truth for current exposure; sizes are normalized to BASE units | ||
| * (contractSize applied) so gap arithmetic against fills is unit-consistent. | ||
| */ | ||
| export declare const ExternalPosition: z.ZodObject<{ | ||
| symbol: z.ZodString; | ||
| size: z.ZodString; | ||
| side: z.ZodEnum<{ | ||
| BUY: "BUY"; | ||
| SELL: "SELL"; | ||
| }>; | ||
| entryPrice: z.ZodString; | ||
| markPrice: z.ZodString; | ||
| }, z.core.$strip>; | ||
| export type ExternalPosition = z.output<typeof ExternalPosition>; | ||
| /** | ||
| * A single fill bound to a positionKey basket. Every fill carries a price/usd: | ||
| * real and gap/opening synthetics a genuine value, unpriceable gone-close | ||
| * synthetics "0" (consumers treat 0-price as unpriceable). | ||
| */ | ||
| export declare const ApplicableFill: z.ZodObject<{ | ||
| exchangeFillId: z.ZodString; | ||
| cloid: z.ZodNullable<z.ZodString>; | ||
| positionId: z.ZodUUID; | ||
| connector: z.ZodEnum<{ | ||
@@ -223,4 +225,2 @@ hyperliquid: "hyperliquid"; | ||
| symbol: z.ZodString; | ||
| price: z.ZodString; | ||
| quantity: z.ZodString; | ||
| side: z.ZodEnum<{ | ||
@@ -230,8 +230,19 @@ BUY: "BUY"; | ||
| }>; | ||
| quantity: z.ZodString; | ||
| price: z.ZodString; | ||
| usd: z.ZodString; | ||
| timestamp: z.ZodNumber; | ||
| reduceOnly: z.ZodBoolean; | ||
| timestamp: z.ZodNumber; | ||
| synthetic: z.ZodBoolean; | ||
| isExternal: z.ZodBoolean; | ||
| tradeFee: z.ZodString; | ||
| liquidation: z.ZodNullable<z.ZodObject<{ | ||
| builderFee: z.ZodString; | ||
| closedReason: z.ZodOptional<z.ZodEnum<{ | ||
| NETTED: "NETTED"; | ||
| USER: "USER"; | ||
| LIQUIDATED: "LIQUIDATED"; | ||
| }>>; | ||
| liquidation: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
| mark: z.ZodString; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>>; | ||
| original: z.ZodOptional<z.ZodObject<{ | ||
@@ -241,7 +252,176 @@ exchangeFillId: z.ZodString; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>], z.ZodObject<{ | ||
| type: z.ZodLiteral<"create">; | ||
| exchangeFillId: z.ZodString; | ||
| cloid: z.ZodNullable<z.ZodString>; | ||
| positionId: z.ZodUUID; | ||
| }, z.core.$strip>; | ||
| export type ApplicableFill = z.output<typeof ApplicableFill>; | ||
| /** | ||
| * Position metadata for an applicable. Consumed ONLY when the apply step CREATES a | ||
| * new position for the positionKey. On merge into an existing position it is | ||
| * ignored. Origin/status/exposure are carried top-level on ApplicablePosition | ||
| * (client-authoritative lifecycle), so this holds only creation metadata. | ||
| */ | ||
| export declare const ApplicableMetadata: z.ZodObject<{ | ||
| initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| }, z.core.$strip>; | ||
| export type ApplicableMetadata = z.output<typeof ApplicableMetadata>; | ||
| /** | ||
| * A basket of fills bound for find-or-create of one target position, keyed by a | ||
| * deterministic positionKey computed client-side from (tradeAccountId, symbols). | ||
| * | ||
| * The client matcher is the lifecycle authority: it computes the final position | ||
| * `exposure`, `origin`, and `status` and the server blind-writes them (no | ||
| * server-side recompute). A flip is two ordered applicables sharing one | ||
| * positionKey: `{status:CLOSED}` then `{status:OPEN}`. | ||
| */ | ||
| export declare const ApplicablePosition: z.ZodObject<{ | ||
| positionKey: z.ZodString; | ||
| exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| origin: z.ZodEnum<{ | ||
| PARTIAL: "PARTIAL"; | ||
| PEAR: "PEAR"; | ||
| EXTERNAL: "EXTERNAL"; | ||
| }>; | ||
| status: z.ZodEnum<{ | ||
| OPEN: "OPEN"; | ||
| CLOSED: "CLOSED"; | ||
| }>; | ||
| closedReason: z.ZodOptional<z.ZodEnum<{ | ||
| NETTED: "NETTED"; | ||
| USER: "USER"; | ||
| LIQUIDATED: "LIQUIDATED"; | ||
| }>>; | ||
| fills: z.ZodArray<z.ZodObject<{ | ||
| exchangeFillId: z.ZodString; | ||
| cloid: z.ZodNullable<z.ZodString>; | ||
| connector: z.ZodEnum<{ | ||
| hyperliquid: "hyperliquid"; | ||
| binance: "binance"; | ||
| bybit: "bybit"; | ||
| okx: "okx"; | ||
| lighter: "lighter"; | ||
| }>; | ||
| symbol: z.ZodString; | ||
| side: z.ZodEnum<{ | ||
| BUY: "BUY"; | ||
| SELL: "SELL"; | ||
| }>; | ||
| quantity: z.ZodString; | ||
| price: z.ZodString; | ||
| usd: z.ZodString; | ||
| timestamp: z.ZodNumber; | ||
| reduceOnly: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| isExternal: z.ZodBoolean; | ||
| tradeFee: z.ZodString; | ||
| builderFee: z.ZodString; | ||
| closedReason: z.ZodOptional<z.ZodEnum<{ | ||
| NETTED: "NETTED"; | ||
| USER: "USER"; | ||
| LIQUIDATED: "LIQUIDATED"; | ||
| }>>; | ||
| liquidation: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
| mark: z.ZodString; | ||
| }, z.core.$strip>>>; | ||
| original: z.ZodOptional<z.ZodObject<{ | ||
| exchangeFillId: z.ZodString; | ||
| quantity: z.ZodString; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>; | ||
| metadata: z.ZodObject<{ | ||
| initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| }, z.core.$strip>; | ||
| }, z.core.$strip>; | ||
| export type ApplicablePosition = z.output<typeof ApplicablePosition>; | ||
| /** | ||
| * Cycle-level metadata for the unified sync request. | ||
| */ | ||
| export declare const SyncMeta: z.ZodObject<{ | ||
| externalMaxTs: z.ZodNullable<z.ZodNumber>; | ||
| }, z.core.$strip>; | ||
| export type SyncMeta = z.output<typeof SyncMeta>; | ||
| /** | ||
| * POST /sync/create request — the discover+apply phase of the cycle. | ||
| * - applicables: baskets keyed by positionKey, find-or-created during apply. | ||
| * - exchangePositions: the exchange snapshot, enforced source of truth at verify. | ||
| * - meta: cycle metadata (watermark). | ||
| * | ||
| */ | ||
| export declare const CreateApplicablesRequest: z.ZodObject<{ | ||
| applicables: z.ZodArray<z.ZodObject<{ | ||
| positionKey: z.ZodString; | ||
| exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| origin: z.ZodEnum<{ | ||
| PARTIAL: "PARTIAL"; | ||
| PEAR: "PEAR"; | ||
| EXTERNAL: "EXTERNAL"; | ||
| }>; | ||
| status: z.ZodEnum<{ | ||
| OPEN: "OPEN"; | ||
| CLOSED: "CLOSED"; | ||
| }>; | ||
| closedReason: z.ZodOptional<z.ZodEnum<{ | ||
| NETTED: "NETTED"; | ||
| USER: "USER"; | ||
| LIQUIDATED: "LIQUIDATED"; | ||
| }>>; | ||
| fills: z.ZodArray<z.ZodObject<{ | ||
| exchangeFillId: z.ZodString; | ||
| cloid: z.ZodNullable<z.ZodString>; | ||
| connector: z.ZodEnum<{ | ||
| hyperliquid: "hyperliquid"; | ||
| binance: "binance"; | ||
| bybit: "bybit"; | ||
| okx: "okx"; | ||
| lighter: "lighter"; | ||
| }>; | ||
| symbol: z.ZodString; | ||
| side: z.ZodEnum<{ | ||
| BUY: "BUY"; | ||
| SELL: "SELL"; | ||
| }>; | ||
| quantity: z.ZodString; | ||
| price: z.ZodString; | ||
| usd: z.ZodString; | ||
| timestamp: z.ZodNumber; | ||
| reduceOnly: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| isExternal: z.ZodBoolean; | ||
| tradeFee: z.ZodString; | ||
| builderFee: z.ZodString; | ||
| closedReason: z.ZodOptional<z.ZodEnum<{ | ||
| NETTED: "NETTED"; | ||
| USER: "USER"; | ||
| LIQUIDATED: "LIQUIDATED"; | ||
| }>>; | ||
| liquidation: z.ZodOptional<z.ZodNullable<z.ZodObject<{ | ||
| mark: z.ZodString; | ||
| }, z.core.$strip>>>; | ||
| original: z.ZodOptional<z.ZodObject<{ | ||
| exchangeFillId: z.ZodString; | ||
| quantity: z.ZodString; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>; | ||
| metadata: z.ZodObject<{ | ||
| initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>; | ||
| }, z.core.$strip>; | ||
| }, z.core.$strip>>; | ||
| exchangePositions: z.ZodArray<z.ZodObject<{ | ||
| symbol: z.ZodString; | ||
| size: z.ZodString; | ||
| side: z.ZodEnum<{ | ||
| BUY: "BUY"; | ||
| SELL: "SELL"; | ||
| }>; | ||
| entryPrice: z.ZodString; | ||
| markPrice: z.ZodString; | ||
| }, z.core.$strip>>; | ||
| meta: z.ZodObject<{ | ||
| externalMaxTs: z.ZodNullable<z.ZodNumber>; | ||
| }, z.core.$strip>; | ||
| }, z.core.$strip>; | ||
| export type CreateApplicablesRequest = z.output<typeof CreateApplicablesRequest>; | ||
| /** | ||
| * A single historical funding event for an instrument: the applied funding rate, | ||
| * the funding amount in USD notional, and the SIGNED funding per 1 unit of size | ||
| * (notional / szi). All signed (negative when the user paid). | ||
| */ | ||
| export declare const FundingPaymentEntry: z.ZodObject<{ | ||
| connector: z.ZodEnum<{ | ||
@@ -254,32 +434,32 @@ hyperliquid: "hyperliquid"; | ||
| }>; | ||
| symbol: z.ZodString; | ||
| price: z.ZodString; | ||
| quantity: z.ZodString; | ||
| side: z.ZodEnum<{ | ||
| BUY: "BUY"; | ||
| SELL: "SELL"; | ||
| }>; | ||
| reduceOnly: z.ZodBoolean; | ||
| instrumentId: z.ZodString; | ||
| fundingRate: z.ZodString; | ||
| notional: z.ZodString; | ||
| fundingPerUnit: z.ZodString; | ||
| timestamp: z.ZodNumber; | ||
| tradeFee: z.ZodString; | ||
| liquidation: z.ZodNullable<z.ZodObject<{ | ||
| mark: z.ZodString; | ||
| }, z.core.$strip>; | ||
| export type FundingPaymentEntry = z.output<typeof FundingPaymentEntry>; | ||
| /** | ||
| * POST /sync/funding/create request — funding events since the watermark plus the | ||
| * cycle watermark. Rows upsert idempotently on (account, connector, instrument, ts). | ||
| */ | ||
| export declare const CreateFundingPaymentsRequest: z.ZodObject<{ | ||
| payments: z.ZodArray<z.ZodObject<{ | ||
| connector: z.ZodEnum<{ | ||
| hyperliquid: "hyperliquid"; | ||
| binance: "binance"; | ||
| bybit: "bybit"; | ||
| okx: "okx"; | ||
| lighter: "lighter"; | ||
| }>; | ||
| instrumentId: z.ZodString; | ||
| fundingRate: z.ZodString; | ||
| notional: z.ZodString; | ||
| fundingPerUnit: z.ZodString; | ||
| timestamp: z.ZodNumber; | ||
| }, z.core.$strip>>; | ||
| original: z.ZodOptional<z.ZodObject<{ | ||
| exchangeFillId: z.ZodString; | ||
| quantity: z.ZodString; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>>; | ||
| export declare const SyncSinceRequest: z.ZodObject<{ | ||
| overlapMs: z.ZodNumber; | ||
| nowMs: z.ZodOptional<z.ZodNumber>; | ||
| bootstrapLookbackMs: z.ZodOptional<z.ZodNumber>; | ||
| meta: z.ZodObject<{ | ||
| externalMaxTs: z.ZodNullable<z.ZodNumber>; | ||
| }, z.core.$strip>; | ||
| }, z.core.$strip>; | ||
| export type ConfirmFillsRequest = z.output<typeof ConfirmFillsRequest>; | ||
| export type ReconcileFillsRequest = z.output<typeof ReconcileFillsRequest>; | ||
| export type CreateFillsRequest = z.output<typeof CreateFillsRequest>; | ||
| export type SyncSinceRequest = z.output<typeof SyncSinceRequest>; | ||
| export type UnknownExternalFill = z.output<typeof UnknownExternalFill>; | ||
| export type ReconcileReplacementExternalFill = z.output<typeof ReconcileReplacementExternalFill>; | ||
| export type ConfirmableExternalFill = z.output<typeof ConfirmableExternalFill>; | ||
| export type CreatableExternalFill = z.output<typeof CreatableExternalFill>; | ||
| export type CreateFundingPaymentsRequest = z.output<typeof CreateFundingPaymentsRequest>; |
+84
-32
| import { z } from 'zod'; | ||
| import { RefineMinimumOneKeyValuePair } from '../common/refinement'; | ||
| import { UnsignedDecimalString, Side } from '../common/schema'; | ||
| import { UnsignedDecimalString, Side, SignedDecimalString } from '../common/schema'; | ||
| import { Connector } from '../connector'; | ||
| import { InstrumentId } from '../instrument'; | ||
| import { PositionClosedReason, PositionStatus, PositionOrigin } from '../position/entities'; | ||
| const ExchangeFillId = z.string().trim().min(1, "Exchange fill ID must be non-empty"); | ||
| const MsTimestamp = z.number().int().positive().describe("Unix timestamp in milliseconds"); | ||
| const LiquidationMark = z.object({ mark: UnsignedDecimalString }).nullable(); | ||
| const OriginalFillRef = z.object({ | ||
| exchangeFillId: ExchangeFillId, | ||
| quantity: UnsignedDecimalString | ||
| }); | ||
| const UnknownExternalFill = z.object({ | ||
| exchangeFillId: z.string().trim().min(1, "Exchange fill ID must be non-empty"), | ||
| exchangeFillId: ExchangeFillId, | ||
| cloid: z.string().nullable(), | ||
@@ -16,10 +24,10 @@ connector: Connector, | ||
| reduceOnly: z.boolean(), | ||
| timestamp: z.number().int().positive().describe("Unix timestamp in milliseconds"), | ||
| timestamp: MsTimestamp, | ||
| tradeFee: UnsignedDecimalString, | ||
| builderFee: UnsignedDecimalString, | ||
| liquidation: z.object({ mark: UnsignedDecimalString }).nullable() | ||
| liquidation: LiquidationMark | ||
| }); | ||
| const ConfirmableExternalFill = z.object({ | ||
| type: z.literal("confirm"), | ||
| exchangeFillId: z.string().trim().min(1, "Exchange fill ID must be non-empty"), | ||
| exchangeFillId: ExchangeFillId, | ||
| cloid: z.string(), | ||
@@ -30,3 +38,3 @@ positionId: z.uuid().describe("Position ID"), | ||
| quantity: UnsignedDecimalString, | ||
| timestamp: z.number().int().positive().describe("Unix timestamp in milliseconds"), | ||
| timestamp: MsTimestamp, | ||
| tradeFee: UnsignedDecimalString, | ||
@@ -36,3 +44,3 @@ builderFee: UnsignedDecimalString | ||
| const ReconcileReplacementExternalFill = z.object({ | ||
| exchangeFillId: z.string().trim().min(1, "Exchange fill ID must be non-empty"), | ||
| exchangeFillId: ExchangeFillId, | ||
| cloid: z.string(), | ||
@@ -45,38 +53,82 @@ connector: Connector, | ||
| reduceOnly: z.boolean(), | ||
| timestamp: z.number().int().positive().describe("Unix timestamp in milliseconds"), | ||
| timestamp: MsTimestamp, | ||
| tradeFee: UnsignedDecimalString, | ||
| builderFee: UnsignedDecimalString, | ||
| liquidation: z.object({ mark: UnsignedDecimalString }).nullable() | ||
| liquidation: LiquidationMark | ||
| }); | ||
| const CreatableExternalFill = z.object({ | ||
| type: z.literal("create"), | ||
| exchangeFillId: z.string().trim().min(1, "Exchange fill ID must be non-empty"), | ||
| const ConfirmFillsRequest = z.record(z.uuid().describe("Position ID"), z.tuple([ConfirmableExternalFill]).rest(ConfirmableExternalFill)).superRefine(RefineMinimumOneKeyValuePair); | ||
| const ReconcileFillsRequest = z.record( | ||
| z.string().trim().min(1, "CLOID must be non-empty"), | ||
| z.tuple([ReconcileReplacementExternalFill, ReconcileReplacementExternalFill]).rest(ReconcileReplacementExternalFill) | ||
| ).superRefine(RefineMinimumOneKeyValuePair); | ||
| const SyncFillsSinceRequest = z.object({ | ||
| overlapMs: z.number().int().positive() | ||
| }); | ||
| const SyncFundingSinceRequest = z.object({ | ||
| overlapMs: z.number().int().positive() | ||
| }); | ||
| const ExternalPosition = z.object({ | ||
| symbol: InstrumentId, | ||
| size: UnsignedDecimalString.describe("BASE units, contractSize applied; always >= 0"), | ||
| side: Side.describe("sign of the net position"), | ||
| entryPrice: UnsignedDecimalString.describe("exchange-reported average entry"), | ||
| markPrice: UnsignedDecimalString | ||
| }); | ||
| const ApplicableFill = z.object({ | ||
| // Deterministic synthetic id (`synthetic-{positionKey}-{symbol}-{side}`) for synthetic fills, | ||
| // exchange-native id for real fills. | ||
| exchangeFillId: ExchangeFillId, | ||
| cloid: z.string().nullable(), | ||
| positionId: z.uuid().describe("Position ID"), | ||
| connector: Connector, | ||
| symbol: InstrumentId, | ||
| price: UnsignedDecimalString, | ||
| quantity: UnsignedDecimalString, | ||
| side: Side, | ||
| quantity: UnsignedDecimalString.describe("BASE units"), | ||
| price: UnsignedDecimalString.describe('"0" only on an unpriceable gone-close synthetic'), | ||
| usd: UnsignedDecimalString.describe('"0" only on an unpriceable gone-close synthetic'), | ||
| timestamp: MsTimestamp.describe("ms \u2014 apply replays in this order"), | ||
| reduceOnly: z.boolean(), | ||
| timestamp: z.number().int().positive().describe("Unix timestamp in milliseconds"), | ||
| synthetic: z.boolean(), | ||
| isExternal: z.boolean(), | ||
| tradeFee: UnsignedDecimalString, | ||
| liquidation: z.object({ mark: UnsignedDecimalString }).nullable(), | ||
| original: z.object({ | ||
| exchangeFillId: z.string().trim().min(1, "Exchange fill ID must be non-empty"), | ||
| quantity: UnsignedDecimalString | ||
| }).optional() | ||
| builderFee: UnsignedDecimalString, | ||
| closedReason: PositionClosedReason.optional().describe("e.g. NETTED for a synthetic close fill"), | ||
| liquidation: LiquidationMark.optional(), | ||
| original: OriginalFillRef.optional() | ||
| }); | ||
| const ConfirmFillsRequest = z.record(z.uuid().describe("Position ID"), z.tuple([ConfirmableExternalFill]).rest(ConfirmableExternalFill)).superRefine(RefineMinimumOneKeyValuePair); | ||
| const ReconcileFillsRequest = z.record( | ||
| z.string().trim().min(1, "CLOID must be non-empty"), | ||
| z.tuple([ReconcileReplacementExternalFill, ReconcileReplacementExternalFill]).rest(ReconcileReplacementExternalFill) | ||
| ).superRefine(RefineMinimumOneKeyValuePair); | ||
| const CreateFillsRequest = z.record(z.uuid().describe("Position ID"), z.tuple([CreatableExternalFill]).rest(CreatableExternalFill)).superRefine(RefineMinimumOneKeyValuePair); | ||
| const SyncSinceRequest = z.object({ | ||
| overlapMs: z.number().int().positive(), | ||
| nowMs: z.number().int().nonnegative().optional(), | ||
| bootstrapLookbackMs: z.number().int().positive().optional() | ||
| const ApplicableMetadata = z.object({ | ||
| initialExposureUSD: z.record(InstrumentId, SignedDecimalString).describe("opening cost basis from this position\u2019s own real fills; partial map allowed") | ||
| }); | ||
| const ApplicablePosition = z.object({ | ||
| positionKey: z.string().trim().min(1, "positionKey must be non-empty"), | ||
| exposure: z.record(InstrumentId, SignedDecimalString).describe("final position exposure (signed, BASE units)"), | ||
| origin: PositionOrigin, | ||
| status: PositionStatus, | ||
| closedReason: PositionClosedReason.optional().describe("set when status is CLOSED, e.g. NETTED"), | ||
| fills: z.array(ApplicableFill).min(1, "Applicable must carry at least one fill"), | ||
| metadata: ApplicableMetadata | ||
| }); | ||
| const SyncMeta = z.object({ | ||
| externalMaxTs: z.number().int().nonnegative().nullable().describe("watermark advance source") | ||
| }); | ||
| const CreateApplicablesRequest = z.object({ | ||
| applicables: z.array(ApplicablePosition), | ||
| exchangePositions: z.array(ExternalPosition), | ||
| meta: SyncMeta | ||
| }); | ||
| const OptionallySignedDecimalString = z.string().regex(/^[+-]?\d+(\.\d+)?$/, "Must be a valid signed decimal string"); | ||
| const FundingPaymentEntry = z.object({ | ||
| connector: Connector, | ||
| instrumentId: InstrumentId, | ||
| fundingRate: OptionallySignedDecimalString.describe("applied funding rate, optionally signed"), | ||
| notional: OptionallySignedDecimalString.describe("funding amount in USD notional, optionally signed"), | ||
| fundingPerUnit: OptionallySignedDecimalString.describe( | ||
| "signed funding per 1 unit of size (notional / szi); attribution coefficient" | ||
| ), | ||
| timestamp: MsTimestamp | ||
| }); | ||
| const CreateFundingPaymentsRequest = z.object({ | ||
| payments: z.array(FundingPaymentEntry), | ||
| meta: SyncMeta | ||
| }); | ||
| export { ConfirmFillsRequest, ConfirmableExternalFill, CreatableExternalFill, CreateFillsRequest, ReconcileFillsRequest, ReconcileReplacementExternalFill, SyncSinceRequest, UnknownExternalFill }; | ||
| export { ApplicableFill, ApplicableMetadata, ApplicablePosition, ConfirmFillsRequest, ConfirmableExternalFill, CreateApplicablesRequest, CreateFundingPaymentsRequest, ExternalPosition, FundingPaymentEntry, ReconcileFillsRequest, ReconcileReplacementExternalFill, SyncFillsSinceRequest, SyncFundingSinceRequest, SyncMeta, UnknownExternalFill }; |
| import { z } from 'zod'; | ||
| export declare const SyncFillsResponse: z.ZodObject<{}, z.core.$strip>; | ||
| export declare const SyncSinceResponse: z.ZodObject<{ | ||
| since: z.ZodISODateTime; | ||
| export declare const SyncFillsSinceResponse: z.ZodObject<{ | ||
| sinceMs: z.ZodNumber; | ||
| safeTs: z.ZodOptional<z.ZodNumber>; | ||
| neverSynced: z.ZodBoolean; | ||
| confirmedExchangeFillIds: z.ZodOptional<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>; | ||
| export declare const SyncFundingSinceResponse: z.ZodObject<{ | ||
| sinceMs: z.ZodNumber; | ||
| }, z.core.$strip>; | ||
| export type SyncFillsResponse = z.output<typeof SyncFillsResponse>; | ||
| export type SyncSinceResponse = z.output<typeof SyncSinceResponse>; | ||
| export type SyncFillsSinceResponse = z.output<typeof SyncFillsSinceResponse>; | ||
| export type SyncFundingSinceResponse = z.output<typeof SyncFundingSinceResponse>; |
| import { z } from 'zod'; | ||
| const SyncFillsResponse = z.object({}); | ||
| const SyncSinceResponse = z.object({ | ||
| since: z.iso.datetime(), | ||
| const SyncFillsSinceResponse = z.object({ | ||
| sinceMs: z.number().int().nonnegative(), | ||
| safeTs: z.number().int().nonnegative().optional(), | ||
| // True only when the account has no checkpoint and nothing to anchor on, so sync starts from | ||
| // genesis. Clients use this to detect an account that has never imported its trade history — | ||
| // `sinceMs === 0` alone is ambiguous (a clamped watermark also yields 0). | ||
| neverSynced: z.boolean(), | ||
| confirmedExchangeFillIds: z.array(z.string()).optional() | ||
| }); | ||
| const SyncFundingSinceResponse = z.object({ | ||
| sinceMs: z.number().int().nonnegative() | ||
| }); | ||
| export { SyncFillsResponse, SyncSinceResponse }; | ||
| export { SyncFillsResponse, SyncFillsSinceResponse, SyncFundingSinceResponse }; |
@@ -56,2 +56,3 @@ import { z } from 'zod'; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -256,2 +257,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -502,2 +504,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -786,2 +789,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -986,2 +990,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -1232,2 +1237,3 @@ price: z.ZodString; | ||
| isExternal: z.ZodBoolean; | ||
| synthetic: z.ZodBoolean; | ||
| quantity: z.ZodString; | ||
@@ -1234,0 +1240,0 @@ price: z.ZodString; |
+1
-1
| { | ||
| "name": "@pear-protocol/types", | ||
| "version": "1.5.0", | ||
| "version": "1.6.0", | ||
| "description": "Pear Protocol Types definitions", | ||
@@ -5,0 +5,0 @@ "private": false, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
702613
3.74%257
1.58%20443
3.13%