@polyester/sdk 0.28.0 → 0.28.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/CHANGELOG.md +6 -0
- package/dist/catalogs/readers.js +2 -2
- package/dist/catalogs/readers.js.map +1 -1
- package/dist/gen/auth/v1/policies_pb.d.ts +9 -6
- package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/policies_pb.js +7 -4
- package/dist/gen/auth/v1/policies_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +6 -6
- package/dist/gen/orders/v1/orders_pb.js +1 -1
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +4 -3
- package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.d.ts +14 -13
- package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.js +1 -1
- package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +28 -28
- package/dist/services/orders/orders-input.schemas.d.ts +36 -36
- package/dist/services/orders/orders-modify.schemas.d.ts +19 -19
- package/dist/services/orders/orders-output.schemas.d.ts +14 -14
- package/dist/services/orders/orders-output.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.js.map +1 -1
- package/dist/services/orders/orders-risk.schemas.d.ts +11 -11
- package/dist/services/orders/orders-risk.schemas.js +9 -5
- package/dist/services/orders/orders-risk.schemas.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +2 -2
- package/dist/services/trades/trades.schemas.d.ts +1 -1
- package/dist/services/trailing-oneof-inputs.js +4 -9
- package/dist/services/trailing-oneof-inputs.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +3 -3
- package/dist/services/triggers/trigger-input.schemas.js +1 -1
- package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +21 -21
- package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.js +4 -4
- package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
- package/dist/shared/wire-bounds.js +1 -3
- package/dist/shared/wire-bounds.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { parseOptionalPositiveIntLike } from "../utils/numbers.js";
|
|
2
|
-
import "../shared/wire-bounds.js";
|
|
3
2
|
import { CatalogConversionError } from "../catalogs/types.js";
|
|
4
3
|
import { positiveDecimalInputToScaled } from "../shared/decimal-surface.js";
|
|
5
4
|
//#region src/services/trailing-oneof-inputs.ts
|
|
@@ -27,14 +26,10 @@ function parseSlippageInput(scales, slippage, options) {
|
|
|
27
26
|
case: void 0,
|
|
28
27
|
value: void 0
|
|
29
28
|
};
|
|
30
|
-
if (slippage.kind === "slippage") {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
case: options.ticksCase,
|
|
35
|
-
value: Number(ticks)
|
|
36
|
-
};
|
|
37
|
-
}
|
|
29
|
+
if (slippage.kind === "slippage") return {
|
|
30
|
+
case: options.ticksCase,
|
|
31
|
+
value: positiveDecimalInputToScaled(`${options.fieldName}.slippage`, slippage.slippage, scales.price())
|
|
32
|
+
};
|
|
38
33
|
const bps = parseOptionalPositiveIntLike(slippage.bps);
|
|
39
34
|
if (bps === void 0 || bps <= 0 || exceedsMax(bps, options.maxBps)) throw new CatalogConversionError(`${options.fieldName}.bps`, `${options.fieldName}Bps must be ${options.maxBps === void 0 ? "a positive integer" : `between 1 and ${options.maxBps}`}`);
|
|
40
35
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trailing-oneof-inputs.js","names":[],"sources":["../../src/services/trailing-oneof-inputs.ts"],"sourcesContent":["import { positiveDecimalInputToScaled, type SdkScales } from \"../shared/decimal-surface.js\";\nimport { CatalogConversionError } from \"../catalogs/types.js\";\nimport { parseOptionalPositiveIntLike } from \"../utils/numbers.js\";\
|
|
1
|
+
{"version":3,"file":"trailing-oneof-inputs.js","names":[],"sources":["../../src/services/trailing-oneof-inputs.ts"],"sourcesContent":["import { positiveDecimalInputToScaled, type SdkScales } from \"../shared/decimal-surface.js\";\nimport { CatalogConversionError } from \"../catalogs/types.js\";\nimport { parseOptionalPositiveIntLike } from \"../utils/numbers.js\";\n\ntype PositiveIntLikeInput = string | number;\n\n/** Product-wide cap for bps slippage inputs (market IOC, attached and standalone trailing stops). */\nexport const MAX_SLIPPAGE_BPS = 10_000;\n\nconst MAX_TRAILING_DISTANCE_BPS = 10_000;\n\n/**\n * Trailing distance and slippage inputs: absolute price distances and\n * slippages are decimal price strings (e.g. \"0.50\"), converted to wire ticks\n * via the price scale; basis points are integers.\n */\nexport type TrailingDistanceInput =\n | { kind: \"distance\"; distance: string }\n | { kind: \"bps\"; bps: PositiveIntLikeInput }\n | { kind: \"none\" };\n\nexport type SlippageInput =\n | { kind: \"slippage\"; slippage: string }\n | { kind: \"bps\"; bps: PositiveIntLikeInput }\n | { kind: \"none\" };\n\ntype UnsetOneof = { case: undefined; value: undefined };\n\ntype TrailingDistanceOneof =\n | { case: \"trailingDistanceTicks\"; value: bigint }\n | { case: \"trailingDistanceBps\"; value: number }\n | UnsetOneof;\n\ntype SlippageOneof<TicksCase extends string, BpsCase extends string> =\n | { case: TicksCase; value: bigint }\n | { case: BpsCase; value: number }\n | UnsetOneof;\n\ntype SlippageOptions<TicksCase extends string, BpsCase extends string> = {\n fieldName: string;\n ticksCase: TicksCase;\n bpsCase: BpsCase;\n maxBps?: number;\n};\n\nexport function parseTrailingDistanceInput(\n scales: SdkScales,\n distance: TrailingDistanceInput,\n fieldName: string,\n): TrailingDistanceOneof {\n if (distance.kind === \"none\") {\n return { case: undefined, value: undefined };\n }\n if (distance.kind === \"distance\") {\n return {\n case: \"trailingDistanceTicks\",\n value: positiveDecimalInputToScaled(\n `${fieldName}.distance`,\n distance.distance,\n scales.price(),\n ),\n };\n }\n\n const bps = parseOptionalPositiveIntLike(distance.bps);\n if (bps === undefined || bps > MAX_TRAILING_DISTANCE_BPS) {\n throw new CatalogConversionError(\n `${fieldName}.bps`,\n `${fieldName}Bps must be between 1 and ${MAX_TRAILING_DISTANCE_BPS}`,\n );\n }\n return { case: \"trailingDistanceBps\", value: bps };\n}\n\nexport function parseSlippageInput<const TicksCase extends string, const BpsCase extends string>(\n scales: SdkScales,\n slippage: SlippageInput | undefined,\n options: SlippageOptions<TicksCase, BpsCase>,\n): SlippageOneof<TicksCase, BpsCase> {\n if (!slippage || slippage.kind === \"none\") {\n return { case: undefined, value: undefined };\n }\n if (slippage.kind === \"slippage\") {\n return {\n case: options.ticksCase,\n value: positiveDecimalInputToScaled(\n `${options.fieldName}.slippage`,\n slippage.slippage,\n scales.price(),\n ),\n };\n }\n\n const bps = parseOptionalPositiveIntLike(slippage.bps);\n if (bps === undefined || bps <= 0 || exceedsMax(bps, options.maxBps)) {\n throw new CatalogConversionError(\n `${options.fieldName}.bps`,\n `${options.fieldName}Bps must be ${\n options.maxBps === undefined\n ? \"a positive integer\"\n : `between 1 and ${options.maxBps}`\n }`,\n );\n }\n return { case: options.bpsCase, value: bps };\n}\n\nfunction exceedsMax(value: number, max: number | undefined): boolean {\n return max !== undefined && value > max;\n}\n"],"mappings":";;;;;AAOA,MAAa,mBAAmB;AAEhC,MAAM,4BAA4B;AAoClC,SAAgB,2BACZ,QACA,UACA,WACqB;CACrB,IAAI,SAAS,SAAS,QAClB,OAAO;EAAE,MAAM,KAAA;EAAW,OAAO,KAAA;CAAU;CAE/C,IAAI,SAAS,SAAS,YAClB,OAAO;EACH,MAAM;EACN,OAAO,6BACH,GAAG,UAAU,YACb,SAAS,UACT,OAAO,MAAM,CACjB;CACJ;CAGJ,MAAM,MAAM,6BAA6B,SAAS,GAAG;CACrD,IAAI,QAAQ,KAAA,KAAa,MAAM,2BAC3B,MAAM,IAAI,uBACN,GAAG,UAAU,OACb,GAAG,UAAU,4BAA4B,2BAC7C;CAEJ,OAAO;EAAE,MAAM;EAAuB,OAAO;CAAI;AACrD;AAEA,SAAgB,mBACZ,QACA,UACA,SACiC;CACjC,IAAI,CAAC,YAAY,SAAS,SAAS,QAC/B,OAAO;EAAE,MAAM,KAAA;EAAW,OAAO,KAAA;CAAU;CAE/C,IAAI,SAAS,SAAS,YAClB,OAAO;EACH,MAAM,QAAQ;EACd,OAAO,6BACH,GAAG,QAAQ,UAAU,YACrB,SAAS,UACT,OAAO,MAAM,CACjB;CACJ;CAGJ,MAAM,MAAM,6BAA6B,SAAS,GAAG;CACrD,IAAI,QAAQ,KAAA,KAAa,OAAO,KAAK,WAAW,KAAK,QAAQ,MAAM,GAC/D,MAAM,IAAI,uBACN,GAAG,QAAQ,UAAU,OACrB,GAAG,QAAQ,UAAU,cACjB,QAAQ,WAAW,KAAA,IACb,uBACA,iBAAiB,QAAQ,UAEvC;CAEJ,OAAO;EAAE,MAAM,QAAQ;EAAS,OAAO;CAAI;AAC/C;AAEA,SAAS,WAAW,OAAe,KAAkC;CACjE,OAAO,QAAQ,KAAA,KAAa,QAAQ;AACxC"}
|
|
@@ -601,7 +601,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.UnionSchem
|
|
|
601
601
|
};
|
|
602
602
|
readonly activationPriceTicks: bigint;
|
|
603
603
|
readonly maxSlippage: {
|
|
604
|
-
value:
|
|
604
|
+
value: bigint;
|
|
605
605
|
case: "maxSlippageTicks";
|
|
606
606
|
} | {
|
|
607
607
|
value: number;
|
|
@@ -845,7 +845,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
|
|
|
845
845
|
declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
846
846
|
readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
847
847
|
readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
848
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "cancelled" | "
|
|
848
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
|
|
849
849
|
readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder" | undefined, TriggerType>]>;
|
|
850
850
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
|
|
851
851
|
readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|
|
@@ -1038,7 +1038,7 @@ declare function createModifyTriggerInputSchema(scales: SdkScales): v.SchemaWith
|
|
|
1038
1038
|
};
|
|
1039
1039
|
activationPriceTicks: bigint | undefined;
|
|
1040
1040
|
maxSlippage: {
|
|
1041
|
-
value:
|
|
1041
|
+
value: bigint;
|
|
1042
1042
|
case: "maxSlippageTicks";
|
|
1043
1043
|
} | {
|
|
1044
1044
|
value: number;
|
|
@@ -42,7 +42,7 @@ function parseTwapMilliseconds(value, fieldName, minimum) {
|
|
|
42
42
|
function parseMaxSlippagePatch(scales, slippage) {
|
|
43
43
|
if (slippage.kind === "none") return {
|
|
44
44
|
case: "maxSlippageTicks",
|
|
45
|
-
value:
|
|
45
|
+
value: 0n
|
|
46
46
|
};
|
|
47
47
|
return parseMaxSlippage(scales, slippage);
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-input.schemas.js","names":["TriggerSideCodec"],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/triggers/v1/triggers_pb.js\";\nimport * as ProtoOrders from \"../../gen/orders/v1/orders_pb.js\";\nimport * as v from \"valibot\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { positiveDecimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { PROTOBUF_INT64_MAX } from \"../../shared/wire-bounds.js\";\nimport {\n parseOptionalPositiveBigIntLike,\n parseOptionalPositiveIntLike,\n} from \"../../utils/numbers.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport {\n TRIGGER_EVENT_TYPE_VALUES,\n TRIGGER_STATUS_FILTER_VALUES,\n TRIGGER_TYPE_VALUES,\n TriggerEventTypeCodec,\n TriggerSideCodec,\n TriggerTypeCodec,\n TriggerStatusCodec,\n} from \"./triggers.codecs.js\";\nimport { BpsStringOrNumberInputSchema, NoneInputSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport {\n BaseTriggerFieldsSchema,\n ConditionalExecutionInputSchema,\n DecimalInputStringSchema,\n LimitConditionalExecutionInputSchema,\n TriggerSideInputSchema,\n TwapExecutionInputSchema,\n buildConditionalExecution,\n buildTriggerIntentBase,\n buildTwapExecution,\n MaxSlippageInputSchema,\n parseMaxSlippage,\n type MaxSlippageOneof,\n type TrailingDistanceOneof,\n} from \"./trigger-child-order.schemas.js\";\nimport { parseTrailingDistanceInput } from \"../trailing-oneof-inputs.js\";\n\nconst TriggerTypeSchema = v.picklist(TRIGGER_TYPE_VALUES);\nconst TriggerStatusFilterSchema = v.picklist(TRIGGER_STATUS_FILTER_VALUES);\nconst TriggerEventTypeSchema = v.picklist(TRIGGER_EVENT_TYPE_VALUES);\nconst TriggerIdInputSchema = idInputSchema(\"triggerId\");\n\nconst TriggerScopedInputEntries = {\n triggerId: TriggerIdInputSchema,\n ...AccountScopeInputEntries,\n};\n\nconst TriggerScopedInputSchema = v.pipe(\n v.strictObject(TriggerScopedInputEntries),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Absolute price distance, as a decimal price string (e.g. \"0.50\"). */\nconst PriceDistanceInputSchema = v.strictObject({\n kind: v.literal(\"distance\"),\n distance: DecimalInputStringSchema,\n});\n\nconst TrailingDistanceInputSchema = v.union([\n PriceDistanceInputSchema,\n BpsStringOrNumberInputSchema,\n]);\n\nconst ActivationPricePatchInputSchema = v.union([DecimalInputStringSchema, NoneInputSchema]);\n\nfunction parseTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof TrailingDistanceInputSchema>,\n): TrailingDistanceOneof {\n return parseTrailingDistanceInput(scales, distance, \"trailingDistance\");\n}\n\nfunction parseTwapMilliseconds(\n value: string | number,\n fieldName: \"durationMs\" | \"sliceIntervalMs\",\n minimum: bigint,\n): bigint {\n const parsed = parseOptionalPositiveBigIntLike(value);\n if (parsed === undefined || parsed < minimum || parsed > PROTOBUF_INT64_MAX) {\n throw new Error(\n `${fieldName} must be between ${minimum} and ${PROTOBUF_INT64_MAX} milliseconds`,\n );\n }\n return parsed;\n}\n\nfunction parseMaxSlippagePatch(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageInputSchema>,\n): MaxSlippageOneof {\n if (slippage.kind === \"none\") {\n return { case: \"maxSlippageTicks\", value: 0 };\n }\n return parseMaxSlippage(scales, slippage);\n}\n\nfunction createConditionalTriggerInputSchema<const TriggerType extends \"stop_loss\" | \"take_profit\">(\n scales: SdkScales,\n triggerType: TriggerType,\n) {\n const sharedEntries = {\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(triggerType),\n triggerPrice: DecimalInputStringSchema,\n };\n\n const sellInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"sell\"),\n execution: ConditionalExecutionInputSchema,\n });\n const buyInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"buy\"),\n execution: LimitConditionalExecutionInputSchema,\n });\n\n function transformInput(\n input: v.InferOutput<typeof sellInputSchema> | v.InferOutput<typeof buyInputSchema>,\n ) {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n const strategy = {\n triggerPriceTicks: positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n side: TriggerSideCodec.inputToProto[input.side],\n child: buildConditionalExecution(input.execution, scales),\n };\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy:\n triggerType === \"stop_loss\"\n ? ({ case: \"stopLoss\", value: strategy } as const)\n : ({ case: \"takeProfit\", value: strategy } as const),\n },\n };\n }\n\n return [\n v.pipe(\n sellInputSchema,\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input: v.InferOutput<typeof sellInputSchema>) => transformInput(input)),\n ),\n v.pipe(\n buyInputSchema,\n v.transform((input: v.InferOutput<typeof buyInputSchema>) => transformInput(input)),\n ),\n ] as const;\n}\n\nfunction createTrailingStopTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"trailing_stop\"),\n trailingDistance: TrailingDistanceInputSchema,\n activationPrice: v.optional(DecimalInputStringSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"Trailing-stop triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"trailingStop\",\n value: {\n trailingDistance: parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage: parseMaxSlippage(scales, input.maxSlippage),\n side: ProtoOrders.Side.SELL,\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createTwapTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"twap\"),\n side: TriggerSideInputSchema,\n durationMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => parseTwapMilliseconds(value, \"durationMs\", 1_000n)),\n ),\n sliceIntervalMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => parseTwapMilliseconds(value, \"sliceIntervalMs\", 100n)),\n ),\n execution: TwapExecutionInputSchema,\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.check(\n (input) => input.sliceIntervalMs <= input.durationMs,\n \"sliceIntervalMs cannot exceed durationMs\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"twap\",\n value: {\n side: input.side,\n durationMs: input.durationMs,\n sliceIntervalMs: input.sliceIntervalMs,\n execution: buildTwapExecution(input.execution, scales),\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createLadderTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"ladder\"),\n side: TriggerSideInputSchema,\n priceMin: DecimalInputStringSchema,\n priceMax: DecimalInputStringSchema,\n levels: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.pipe(v.number(), v.integer())]),\n v.transform((value) => {\n const levels = parseOptionalPositiveIntLike(value);\n if (!levels || levels < 2 || levels > 100) {\n throw new Error(\"levels must be between 2 and 100\");\n }\n return levels;\n }),\n ),\n postOnly: v.optional(v.boolean(), false),\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"ladder\",\n value: {\n side: input.side,\n priceMinTicks: positiveDecimalInputToScaled(\n \"priceMin\",\n input.priceMin,\n scales.price(),\n ),\n priceMaxTicks: positiveDecimalInputToScaled(\n \"priceMax\",\n input.priceMax,\n scales.price(),\n ),\n levels: input.levels,\n postOnly: input.postOnly,\n },\n } as const,\n },\n };\n }),\n v.check(\n (output) =>\n output.trigger.strategy.value.priceMinTicks <\n output.trigger.strategy.value.priceMaxTicks,\n \"priceMin must be less than priceMax\",\n ),\n );\n}\n\n/** Builds the create-trigger boundary schema using catalog scales keyed by symbol ID. */\nexport function createCreateTriggerInputSchema(scales: SdkScales) {\n return v.union([\n ...createConditionalTriggerInputSchema(scales, \"stop_loss\"),\n ...createConditionalTriggerInputSchema(scales, \"take_profit\"),\n createTrailingStopTriggerInputSchema(scales),\n createTwapTriggerInputSchema(scales),\n createLadderTriggerInputSchema(scales),\n ]);\n}\n\n/** Public input for creating a standalone trigger. */\nexport type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInputSchema>>;\n\n/** Public filters for listing triggers in an account scope. */\nexport const ListTriggersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n parentOrderId: v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"parentOrderId\") : undefined)),\n ),\n symbolId: v.optional(SymbolIdInputSchema),\n status: v.pipe(\n v.optional(v.array(TriggerStatusFilterSchema)),\n v.transform(\n (values) => values?.map((value) => TriggerStatusCodec.inputToProto[value]) ?? [],\n ),\n ),\n triggerType: v.pipe(\n v.optional(TriggerTypeSchema),\n v.transform((value) =>\n value\n ? TriggerTypeCodec.inputToProto[value]\n : Proto.TriggerType.TRIGGER_TYPE_UNSPECIFIED,\n ),\n ),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Public filters for listing triggers. */\nexport type ListTriggersInput = v.InferInput<typeof ListTriggersInputSchema>;\n\nexport const CancelTriggerInputSchema = TriggerScopedInputSchema;\nexport type CancelTriggerInput = v.InferInput<typeof CancelTriggerInputSchema>;\n\nexport const GetTriggerInputSchema = CancelTriggerInputSchema;\nexport type GetTriggerInput = v.InferInput<typeof GetTriggerInputSchema>;\n\nexport const PauseTriggerInputSchema = TriggerScopedInputSchema;\nexport type PauseTriggerInput = v.InferInput<typeof PauseTriggerInputSchema>;\n\nexport const ResumeTriggerInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: SymbolIdInputSchema,\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\nexport type ResumeTriggerInput = v.InferInput<typeof ResumeTriggerInputSchema>;\n\nexport function createModifyTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: SymbolIdInputSchema,\n triggerPrice: v.optional(DecimalInputStringSchema),\n limitPrice: v.optional(DecimalInputStringSchema),\n trailingDistance: v.optional(TrailingDistanceInputSchema),\n activationPrice: v.optional(ActivationPricePatchInputSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) =>\n input.triggerPrice !== undefined ||\n input.limitPrice !== undefined ||\n input.trailingDistance !== undefined ||\n input.activationPrice !== undefined ||\n input.maxSlippage !== undefined,\n \"At least one patch field is required\",\n ),\n v.transform(({ account, ...input }) => ({\n triggerId: input.triggerId,\n subaccountId: accountScopeToSubaccountId(account),\n symbolId: input.symbolId,\n triggerPriceTicks:\n input.triggerPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n limitPriceTicks:\n input.limitPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\"limitPrice\", input.limitPrice, scales.price()),\n trailingDistance:\n input.trailingDistance === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? undefined\n : typeof input.activationPrice !== \"string\"\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage:\n input.maxSlippage === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseMaxSlippagePatch(scales, input.maxSlippage),\n })),\n );\n}\n\n/**\n * A trigger patch. Omitted fields remain unchanged; `{ kind: \"none\" }` clears\n * `activationPrice` or `maxSlippage`.\n */\nexport type ModifyTriggerInput = v.InferInput<ReturnType<typeof createModifyTriggerInputSchema>>;\n\nexport const ListTriggerEventsInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000))),\n eventType: v.optional(TriggerEventTypeSchema),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n eventType:\n input.eventType === undefined\n ? undefined\n : TriggerEventTypeCodec.inputToProto[input.eventType],\n })),\n);\n\nexport type ListTriggerEventsInput = v.InferInput<typeof ListTriggerEventsInputSchema>;\n"],"mappings":";;;;;;;;;;;;;;;AA0CA,MAAM,oBAAoB,EAAE,SAAS,mBAAmB;AACxD,MAAM,4BAA4B,EAAE,SAAS,4BAA4B;AACzE,MAAM,yBAAyB,EAAE,SAAS,yBAAyB;AAGnE,MAAM,4BAA4B;CAC9B,WAHyB,cAAc,WAGT;CAC9B,GAAG;AACP;AAEA,MAAM,2BAA2B,EAAE,KAC/B,EAAE,aAAa,yBAAyB,GACxC,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;AAGA,MAAM,2BAA2B,EAAE,aAAa;CAC5C,MAAM,EAAE,QAAQ,UAAU;CAC1B,UAAU;AACd,CAAC;AAED,MAAM,8BAA8B,EAAE,MAAM,CACxC,0BACA,4BACJ,CAAC;AAED,MAAM,kCAAkC,EAAE,MAAM,CAAC,0BAA0B,eAAe,CAAC;AAE3F,SAAS,sBACL,QACA,UACqB;CACrB,OAAO,2BAA2B,QAAQ,UAAU,kBAAkB;AAC1E;AAEA,SAAS,sBACL,OACA,WACA,SACM;CACN,MAAM,SAAS,gCAAgC,KAAK;CACpD,IAAI,WAAW,KAAA,KAAa,SAAS,WAAW,SAAA,sBAC5C,MAAM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E,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAI,CAAC,CAAC;CACjF,WAAW,EAAE,SAAS,sBAAsB;CAC5C,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;CAChD,WACI,MAAM,cAAc,KAAA,IACd,KAAA,IACA,sBAAsB,aAAa,MAAM;AACvD,EAAE,CACN"}
|
|
1
|
+
{"version":3,"file":"trigger-input.schemas.js","names":["TriggerSideCodec"],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/triggers/v1/triggers_pb.js\";\nimport * as ProtoOrders from \"../../gen/orders/v1/orders_pb.js\";\nimport * as v from \"valibot\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { positiveDecimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { PROTOBUF_INT64_MAX } from \"../../shared/wire-bounds.js\";\nimport {\n parseOptionalPositiveBigIntLike,\n parseOptionalPositiveIntLike,\n} from \"../../utils/numbers.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport {\n TRIGGER_EVENT_TYPE_VALUES,\n TRIGGER_STATUS_FILTER_VALUES,\n TRIGGER_TYPE_VALUES,\n TriggerEventTypeCodec,\n TriggerSideCodec,\n TriggerTypeCodec,\n TriggerStatusCodec,\n} from \"./triggers.codecs.js\";\nimport { BpsStringOrNumberInputSchema, NoneInputSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport {\n BaseTriggerFieldsSchema,\n ConditionalExecutionInputSchema,\n DecimalInputStringSchema,\n LimitConditionalExecutionInputSchema,\n TriggerSideInputSchema,\n TwapExecutionInputSchema,\n buildConditionalExecution,\n buildTriggerIntentBase,\n buildTwapExecution,\n MaxSlippageInputSchema,\n parseMaxSlippage,\n type MaxSlippageOneof,\n type TrailingDistanceOneof,\n} from \"./trigger-child-order.schemas.js\";\nimport { parseTrailingDistanceInput } from \"../trailing-oneof-inputs.js\";\n\nconst TriggerTypeSchema = v.picklist(TRIGGER_TYPE_VALUES);\nconst TriggerStatusFilterSchema = v.picklist(TRIGGER_STATUS_FILTER_VALUES);\nconst TriggerEventTypeSchema = v.picklist(TRIGGER_EVENT_TYPE_VALUES);\nconst TriggerIdInputSchema = idInputSchema(\"triggerId\");\n\nconst TriggerScopedInputEntries = {\n triggerId: TriggerIdInputSchema,\n ...AccountScopeInputEntries,\n};\n\nconst TriggerScopedInputSchema = v.pipe(\n v.strictObject(TriggerScopedInputEntries),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Absolute price distance, as a decimal price string (e.g. \"0.50\"). */\nconst PriceDistanceInputSchema = v.strictObject({\n kind: v.literal(\"distance\"),\n distance: DecimalInputStringSchema,\n});\n\nconst TrailingDistanceInputSchema = v.union([\n PriceDistanceInputSchema,\n BpsStringOrNumberInputSchema,\n]);\n\nconst ActivationPricePatchInputSchema = v.union([DecimalInputStringSchema, NoneInputSchema]);\n\nfunction parseTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof TrailingDistanceInputSchema>,\n): TrailingDistanceOneof {\n return parseTrailingDistanceInput(scales, distance, \"trailingDistance\");\n}\n\nfunction parseTwapMilliseconds(\n value: string | number,\n fieldName: \"durationMs\" | \"sliceIntervalMs\",\n minimum: bigint,\n): bigint {\n const parsed = parseOptionalPositiveBigIntLike(value);\n if (parsed === undefined || parsed < minimum || parsed > PROTOBUF_INT64_MAX) {\n throw new Error(\n `${fieldName} must be between ${minimum} and ${PROTOBUF_INT64_MAX} milliseconds`,\n );\n }\n return parsed;\n}\n\nfunction parseMaxSlippagePatch(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageInputSchema>,\n): MaxSlippageOneof {\n if (slippage.kind === \"none\") {\n return { case: \"maxSlippageTicks\", value: 0n };\n }\n return parseMaxSlippage(scales, slippage);\n}\n\nfunction createConditionalTriggerInputSchema<const TriggerType extends \"stop_loss\" | \"take_profit\">(\n scales: SdkScales,\n triggerType: TriggerType,\n) {\n const sharedEntries = {\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(triggerType),\n triggerPrice: DecimalInputStringSchema,\n };\n\n const sellInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"sell\"),\n execution: ConditionalExecutionInputSchema,\n });\n const buyInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"buy\"),\n execution: LimitConditionalExecutionInputSchema,\n });\n\n function transformInput(\n input: v.InferOutput<typeof sellInputSchema> | v.InferOutput<typeof buyInputSchema>,\n ) {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n const strategy = {\n triggerPriceTicks: positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n side: TriggerSideCodec.inputToProto[input.side],\n child: buildConditionalExecution(input.execution, scales),\n };\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy:\n triggerType === \"stop_loss\"\n ? ({ case: \"stopLoss\", value: strategy } as const)\n : ({ case: \"takeProfit\", value: strategy } as const),\n },\n };\n }\n\n return [\n v.pipe(\n sellInputSchema,\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input: v.InferOutput<typeof sellInputSchema>) => transformInput(input)),\n ),\n v.pipe(\n buyInputSchema,\n v.transform((input: v.InferOutput<typeof buyInputSchema>) => transformInput(input)),\n ),\n ] as const;\n}\n\nfunction createTrailingStopTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"trailing_stop\"),\n trailingDistance: TrailingDistanceInputSchema,\n activationPrice: v.optional(DecimalInputStringSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"Trailing-stop triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"trailingStop\",\n value: {\n trailingDistance: parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage: parseMaxSlippage(scales, input.maxSlippage),\n side: ProtoOrders.Side.SELL,\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createTwapTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"twap\"),\n side: TriggerSideInputSchema,\n durationMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => parseTwapMilliseconds(value, \"durationMs\", 1_000n)),\n ),\n sliceIntervalMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => parseTwapMilliseconds(value, \"sliceIntervalMs\", 100n)),\n ),\n execution: TwapExecutionInputSchema,\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.check(\n (input) => input.sliceIntervalMs <= input.durationMs,\n \"sliceIntervalMs cannot exceed durationMs\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"twap\",\n value: {\n side: input.side,\n durationMs: input.durationMs,\n sliceIntervalMs: input.sliceIntervalMs,\n execution: buildTwapExecution(input.execution, scales),\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createLadderTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"ladder\"),\n side: TriggerSideInputSchema,\n priceMin: DecimalInputStringSchema,\n priceMax: DecimalInputStringSchema,\n levels: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.pipe(v.number(), v.integer())]),\n v.transform((value) => {\n const levels = parseOptionalPositiveIntLike(value);\n if (!levels || levels < 2 || levels > 100) {\n throw new Error(\"levels must be between 2 and 100\");\n }\n return levels;\n }),\n ),\n postOnly: v.optional(v.boolean(), false),\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"ladder\",\n value: {\n side: input.side,\n priceMinTicks: positiveDecimalInputToScaled(\n \"priceMin\",\n input.priceMin,\n scales.price(),\n ),\n priceMaxTicks: positiveDecimalInputToScaled(\n \"priceMax\",\n input.priceMax,\n scales.price(),\n ),\n levels: input.levels,\n postOnly: input.postOnly,\n },\n } as const,\n },\n };\n }),\n v.check(\n (output) =>\n output.trigger.strategy.value.priceMinTicks <\n output.trigger.strategy.value.priceMaxTicks,\n \"priceMin must be less than priceMax\",\n ),\n );\n}\n\n/** Builds the create-trigger boundary schema using catalog scales keyed by symbol ID. */\nexport function createCreateTriggerInputSchema(scales: SdkScales) {\n return v.union([\n ...createConditionalTriggerInputSchema(scales, \"stop_loss\"),\n ...createConditionalTriggerInputSchema(scales, \"take_profit\"),\n createTrailingStopTriggerInputSchema(scales),\n createTwapTriggerInputSchema(scales),\n createLadderTriggerInputSchema(scales),\n ]);\n}\n\n/** Public input for creating a standalone trigger. */\nexport type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInputSchema>>;\n\n/** Public filters for listing triggers in an account scope. */\nexport const ListTriggersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n parentOrderId: v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"parentOrderId\") : undefined)),\n ),\n symbolId: v.optional(SymbolIdInputSchema),\n status: v.pipe(\n v.optional(v.array(TriggerStatusFilterSchema)),\n v.transform(\n (values) => values?.map((value) => TriggerStatusCodec.inputToProto[value]) ?? [],\n ),\n ),\n triggerType: v.pipe(\n v.optional(TriggerTypeSchema),\n v.transform((value) =>\n value\n ? TriggerTypeCodec.inputToProto[value]\n : Proto.TriggerType.TRIGGER_TYPE_UNSPECIFIED,\n ),\n ),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Public filters for listing triggers. */\nexport type ListTriggersInput = v.InferInput<typeof ListTriggersInputSchema>;\n\nexport const CancelTriggerInputSchema = TriggerScopedInputSchema;\nexport type CancelTriggerInput = v.InferInput<typeof CancelTriggerInputSchema>;\n\nexport const GetTriggerInputSchema = CancelTriggerInputSchema;\nexport type GetTriggerInput = v.InferInput<typeof GetTriggerInputSchema>;\n\nexport const PauseTriggerInputSchema = TriggerScopedInputSchema;\nexport type PauseTriggerInput = v.InferInput<typeof PauseTriggerInputSchema>;\n\nexport const ResumeTriggerInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: SymbolIdInputSchema,\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\nexport type ResumeTriggerInput = v.InferInput<typeof ResumeTriggerInputSchema>;\n\nexport function createModifyTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: SymbolIdInputSchema,\n triggerPrice: v.optional(DecimalInputStringSchema),\n limitPrice: v.optional(DecimalInputStringSchema),\n trailingDistance: v.optional(TrailingDistanceInputSchema),\n activationPrice: v.optional(ActivationPricePatchInputSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) =>\n input.triggerPrice !== undefined ||\n input.limitPrice !== undefined ||\n input.trailingDistance !== undefined ||\n input.activationPrice !== undefined ||\n input.maxSlippage !== undefined,\n \"At least one patch field is required\",\n ),\n v.transform(({ account, ...input }) => ({\n triggerId: input.triggerId,\n subaccountId: accountScopeToSubaccountId(account),\n symbolId: input.symbolId,\n triggerPriceTicks:\n input.triggerPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n limitPriceTicks:\n input.limitPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\"limitPrice\", input.limitPrice, scales.price()),\n trailingDistance:\n input.trailingDistance === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? undefined\n : typeof input.activationPrice !== \"string\"\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage:\n input.maxSlippage === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseMaxSlippagePatch(scales, input.maxSlippage),\n })),\n );\n}\n\n/**\n * A trigger patch. Omitted fields remain unchanged; `{ kind: \"none\" }` clears\n * `activationPrice` or `maxSlippage`.\n */\nexport type ModifyTriggerInput = v.InferInput<ReturnType<typeof createModifyTriggerInputSchema>>;\n\nexport const ListTriggerEventsInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000))),\n eventType: v.optional(TriggerEventTypeSchema),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n eventType:\n input.eventType === undefined\n ? undefined\n : TriggerEventTypeCodec.inputToProto[input.eventType],\n })),\n);\n\nexport type ListTriggerEventsInput = v.InferInput<typeof ListTriggerEventsInputSchema>;\n"],"mappings":";;;;;;;;;;;;;;;AA0CA,MAAM,oBAAoB,EAAE,SAAS,mBAAmB;AACxD,MAAM,4BAA4B,EAAE,SAAS,4BAA4B;AACzE,MAAM,yBAAyB,EAAE,SAAS,yBAAyB;AAGnE,MAAM,4BAA4B;CAC9B,WAHyB,cAAc,WAGT;CAC9B,GAAG;AACP;AAEA,MAAM,2BAA2B,EAAE,KAC/B,EAAE,aAAa,yBAAyB,GACxC,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;AAGA,MAAM,2BAA2B,EAAE,aAAa;CAC5C,MAAM,EAAE,QAAQ,UAAU;CAC1B,UAAU;AACd,CAAC;AAED,MAAM,8BAA8B,EAAE,MAAM,CACxC,0BACA,4BACJ,CAAC;AAED,MAAM,kCAAkC,EAAE,MAAM,CAAC,0BAA0B,eAAe,CAAC;AAE3F,SAAS,sBACL,QACA,UACqB;CACrB,OAAO,2BAA2B,QAAQ,UAAU,kBAAkB;AAC1E;AAEA,SAAS,sBACL,OACA,WACA,SACM;CACN,MAAM,SAAS,gCAAgC,KAAK;CACpD,IAAI,WAAW,KAAA,KAAa,SAAS,WAAW,SAAA,sBAC5C,MAAM,IAAI,MACN,GAAG,UAAU,mBAAmB,QAAQ,OAAO,mBAAmB,cACtE;CAEJ,OAAO;AACX;AAEA,SAAS,sBACL,QACA,UACgB;CAChB,IAAI,SAAS,SAAS,QAClB,OAAO;EAAE,MAAM;EAAoB,OAAO;CAAG;CAEjD,OAAO,iBAAiB,QAAQ,QAAQ;AAC5C;AAEA,SAAS,o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AAG;CACH,cAAc,2BAA2B,OAAO;CAChD,WACI,MAAM,cAAc,KAAA,IACd,KAAA,IACA,sBAAsB,aAAa,MAAM;AACvD,EAAE,CACN"}
|
|
@@ -29,62 +29,62 @@ declare const CreateTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSche
|
|
|
29
29
|
type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;
|
|
30
30
|
declare const CancelTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
31
31
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
32
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "
|
|
32
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
|
|
33
33
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
34
34
|
}, undefined>, v.TransformAction<{
|
|
35
35
|
triggerId: string;
|
|
36
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
36
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
37
37
|
tsNs: bigint;
|
|
38
38
|
}, {
|
|
39
39
|
ts: number;
|
|
40
40
|
tsNs: string;
|
|
41
41
|
triggerId: string;
|
|
42
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
42
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
43
43
|
}>]>;
|
|
44
44
|
type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;
|
|
45
45
|
declare const ModifyTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
46
46
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
47
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "
|
|
47
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
|
|
48
48
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
49
49
|
}, undefined>, v.TransformAction<{
|
|
50
50
|
triggerId: string;
|
|
51
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
51
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
52
52
|
tsNs: bigint;
|
|
53
53
|
}, {
|
|
54
54
|
ts: number;
|
|
55
55
|
tsNs: string;
|
|
56
56
|
triggerId: string;
|
|
57
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
57
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
58
58
|
}>]>;
|
|
59
59
|
type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;
|
|
60
60
|
declare const PauseTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
61
61
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
62
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "
|
|
62
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
|
|
63
63
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
64
64
|
}, undefined>, v.TransformAction<{
|
|
65
65
|
triggerId: string;
|
|
66
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
66
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
67
67
|
tsNs: bigint;
|
|
68
68
|
}, {
|
|
69
69
|
ts: number;
|
|
70
70
|
tsNs: string;
|
|
71
71
|
triggerId: string;
|
|
72
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
72
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
73
73
|
}>]>;
|
|
74
74
|
type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;
|
|
75
75
|
declare const ResumeTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
76
76
|
readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
77
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "
|
|
77
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
|
|
78
78
|
readonly tsNs: v.BigintSchema<undefined>;
|
|
79
79
|
}, undefined>, v.TransformAction<{
|
|
80
80
|
triggerId: string;
|
|
81
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
81
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
82
82
|
tsNs: bigint;
|
|
83
83
|
}, {
|
|
84
84
|
ts: number;
|
|
85
85
|
tsNs: string;
|
|
86
86
|
triggerId: string;
|
|
87
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
87
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
88
88
|
}>]>;
|
|
89
89
|
type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;
|
|
90
90
|
type StopDetailsOutput = {
|
|
@@ -218,7 +218,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
218
218
|
readonly activationPriceTicks: v.BigintSchema<undefined>;
|
|
219
219
|
readonly maxSlippage: v.VariantSchema<"case", [v.ObjectSchema<{
|
|
220
220
|
readonly case: v.LiteralSchema<"maxSlippageTicks", undefined>;
|
|
221
|
-
readonly value: v.
|
|
221
|
+
readonly value: v.BigintSchema<undefined>;
|
|
222
222
|
}, undefined>, v.ObjectSchema<{
|
|
223
223
|
readonly case: v.LiteralSchema<"maxSlippageBps", undefined>;
|
|
224
224
|
readonly value: v.NumberSchema<undefined>;
|
|
@@ -239,7 +239,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
239
239
|
readonly value: v.ObjectSchema<{
|
|
240
240
|
readonly maxSlippage: v.VariantSchema<"case", [v.ObjectSchema<{
|
|
241
241
|
readonly case: v.LiteralSchema<"maxSlippageTicks", undefined>;
|
|
242
|
-
readonly value: v.
|
|
242
|
+
readonly value: v.BigintSchema<undefined>;
|
|
243
243
|
}, undefined>, v.ObjectSchema<{
|
|
244
244
|
readonly case: v.LiteralSchema<"maxSlippageBps", undefined>;
|
|
245
245
|
readonly value: v.NumberSchema<undefined>;
|
|
@@ -313,7 +313,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
313
313
|
readonly peakPriceTicks: v.BigintSchema<undefined>;
|
|
314
314
|
readonly troughPriceTicks: v.BigintSchema<undefined>;
|
|
315
315
|
readonly trailingDistanceBps: v.NumberSchema<undefined>;
|
|
316
|
-
readonly maxSlippageTicks: v.
|
|
316
|
+
readonly maxSlippageTicks: v.BigintSchema<undefined>;
|
|
317
317
|
readonly maxSlippageBps: v.NumberSchema<undefined>;
|
|
318
318
|
readonly triggerPriceSource: v.NumberSchema<undefined>;
|
|
319
319
|
readonly triggerDirection: v.NumberSchema<undefined>;
|
|
@@ -429,7 +429,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
429
429
|
activationPriceTicks: bigint;
|
|
430
430
|
maxSlippage: {
|
|
431
431
|
case: "maxSlippageTicks";
|
|
432
|
-
value:
|
|
432
|
+
value: bigint;
|
|
433
433
|
} | {
|
|
434
434
|
case: "maxSlippageBps";
|
|
435
435
|
value: number;
|
|
@@ -450,7 +450,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
450
450
|
value: {
|
|
451
451
|
maxSlippage: {
|
|
452
452
|
case: "maxSlippageTicks";
|
|
453
|
-
value:
|
|
453
|
+
value: bigint;
|
|
454
454
|
} | {
|
|
455
455
|
case: "maxSlippageBps";
|
|
456
456
|
value: number;
|
|
@@ -524,7 +524,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
524
524
|
peakPriceTicks: bigint;
|
|
525
525
|
troughPriceTicks: bigint;
|
|
526
526
|
trailingDistanceBps: number;
|
|
527
|
-
maxSlippageTicks:
|
|
527
|
+
maxSlippageTicks: bigint;
|
|
528
528
|
maxSlippageBps: number;
|
|
529
529
|
triggerPriceSource: number;
|
|
530
530
|
triggerDirection: number;
|
|
@@ -560,7 +560,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
560
560
|
triggerId: string;
|
|
561
561
|
subaccountId: string;
|
|
562
562
|
symbolId: number;
|
|
563
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
563
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
564
564
|
parentOrderId: string | undefined;
|
|
565
565
|
qty: string;
|
|
566
566
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -716,7 +716,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
716
716
|
triggerId: string;
|
|
717
717
|
subaccountId: string;
|
|
718
718
|
symbolId: number;
|
|
719
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
719
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
720
720
|
parentOrderId: string | undefined;
|
|
721
721
|
qty: string;
|
|
722
722
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -872,7 +872,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
|
|
|
872
872
|
triggerId: string;
|
|
873
873
|
subaccountId: string;
|
|
874
874
|
symbolId: number;
|
|
875
|
-
status: "unspecified" | "failed" | "cancelled" | "
|
|
875
|
+
status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
|
|
876
876
|
parentOrderId: string | undefined;
|
|
877
877
|
qty: string;
|
|
878
878
|
feeAsset: "unspecified" | "quote" | "base";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggers-output.schemas.d.ts","names":[],"sources":["../../../src/services/triggers/triggers-output.schemas.ts"],"mappings":";;;KAyBK;KAEA;KAEA;cAiBQ,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;KAc1B,sBAAsB,EAAE,mBAAmB;cAE1C,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAE1B,sBAAsB,EAAE,mBAAmB;cAE1C,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAE1B,sBAAsB,EAAE,mBAAmB;cAE1C,0BAAwB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KACzB,qBAAqB,EAAE,mBAAmB;cAEzC,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAC1B,sBAAsB,EAAE,mBAAmB;KA4R3C;EACR;EACA;EACA,oBAAoB;EACpB,kBAAkB;;KAGV;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBAAoB;EACpB,kBAAkB;;EAElB;;KAGQ;EACR;EACA;EACA;EACA;EACA;;EAEA;;KAGQ;EACR;EACA;EACA;EACA;EACA,oBAAoB;;EAEpB;;EAEA;;KAGQ,uBACN,oBACA,wBACA,oBACA;EACE;;;
|
|
1
|
+
{"version":3,"file":"triggers-output.schemas.d.ts","names":[],"sources":["../../../src/services/triggers/triggers-output.schemas.ts"],"mappings":";;;KAyBK;KAEA;KAEA;cAiBQ,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;KAc1B,sBAAsB,EAAE,mBAAmB;cAE1C,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAE1B,sBAAsB,EAAE,mBAAmB;cAE1C,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAE1B,sBAAsB,EAAE,mBAAmB;cAE1C,0BAAwB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KACzB,qBAAqB,EAAE,mBAAmB;cAEzC,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAC1B,sBAAsB,EAAE,mBAAmB;KA4R3C;EACR;EACA;EACA,oBAAoB;EACpB,kBAAkB;;KAGV;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBAAoB;EACpB,kBAAkB;;EAElB;;KAGQ;EACR;EACA;EACA;EACA;EACA;;EAEA;;KAGQ;EACR;EACA;EACA;EACA;EACA,oBAAoB;;EAEpB;;EAEA;;KAGQ,uBACN,oBACA,wBACA,oBACA;EACE;;;iBAuGQ,oBAAoB,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6CzC,UAAU,EAAE,YAAY,kBAAkB;iBAEtC,yBAAyB,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgC9C,eAAe,EAAE,YAAY,kBAAkB;KAE/C;EACR,QAAQ;EACR"}
|
|
@@ -64,7 +64,7 @@ const ConditionalConfigurationRawSchema = v.object({
|
|
|
64
64
|
const MaxSlippageRawSchema = v.variant("case", [
|
|
65
65
|
v.object({
|
|
66
66
|
case: v.literal("maxSlippageTicks"),
|
|
67
|
-
value: v.
|
|
67
|
+
value: v.bigint()
|
|
68
68
|
}),
|
|
69
69
|
v.object({
|
|
70
70
|
case: v.literal("maxSlippageBps"),
|
|
@@ -214,7 +214,7 @@ function transformTriggerConfiguration(configuration, scales) {
|
|
|
214
214
|
function formatMaxSlippage(maxSlippage, scales) {
|
|
215
215
|
return maxSlippage.case === "maxSlippageTicks" ? {
|
|
216
216
|
kind: "slippage",
|
|
217
|
-
slippage: scaledToDecimalOutput(
|
|
217
|
+
slippage: scaledToDecimalOutput(maxSlippage.value, scales.price())
|
|
218
218
|
} : maxSlippage.case === "maxSlippageBps" ? {
|
|
219
219
|
kind: "bps",
|
|
220
220
|
bps: maxSlippage.value
|
|
@@ -261,7 +261,7 @@ const TrailingDetailsRawSchema = v.object({
|
|
|
261
261
|
peakPriceTicks: v.bigint(),
|
|
262
262
|
troughPriceTicks: v.bigint(),
|
|
263
263
|
trailingDistanceBps: v.number(),
|
|
264
|
-
maxSlippageTicks: v.
|
|
264
|
+
maxSlippageTicks: v.bigint(),
|
|
265
265
|
maxSlippageBps: v.number(),
|
|
266
266
|
triggerPriceSource: v.number(),
|
|
267
267
|
triggerDirection: v.number(),
|
|
@@ -319,7 +319,7 @@ function transformTriggerDetails(details, scales, symbolId) {
|
|
|
319
319
|
activationPrice: details.value.activationPriceTicks > 0n ? scaledToDecimalOutput(details.value.activationPriceTicks, scales.price()) : void 0,
|
|
320
320
|
peakPrice: details.value.peakPriceTicks > 0n ? scaledToDecimalOutput(details.value.peakPriceTicks, scales.price()) : void 0,
|
|
321
321
|
troughPrice: details.value.troughPriceTicks > 0n ? scaledToDecimalOutput(details.value.troughPriceTicks, scales.price()) : void 0,
|
|
322
|
-
maxSlippage: details.value.maxSlippageTicks >
|
|
322
|
+
maxSlippage: details.value.maxSlippageTicks > 0n ? scaledToDecimalOutput(details.value.maxSlippageTicks, scales.price()) : void 0,
|
|
323
323
|
maxSlippageBps: details.value.maxSlippageBps,
|
|
324
324
|
triggerPriceSource: enumLabel(TriggerPriceSourceCodec.protoToOutput, details.value.triggerPriceSource),
|
|
325
325
|
triggerDirection: enumLabel(TriggerDirectionCodec.protoToOutput, details.value.triggerDirection),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggers-output.schemas.js","names":["TriggerSideCodec"],"sources":["../../../src/services/triggers/triggers-output.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n TimestampSchema,\n PublicIdSchema,\n} from \"../../shared/schemas.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { tsNsToMs, tsObjToMs } from \"../../utils/time.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n TriggerTypeCodec,\n TriggerStatusCodec,\n FeeAssetCodec,\n SelfTradePreventionModeCodec,\n TriggerPriceSourceCodec,\n TriggerDirectionCodec,\n LadderDistributionCodec,\n TriggerSideCodec,\n TriggerEventTypeCodec,\n TriggerCancelReasonCodec,\n TriggerFailureReasonCodec,\n} from \"./triggers.codecs.js\";\n\ntype TriggerPriceSourceLabel = \"last\" | \"index\" | \"mark\" | \"unspecified\";\n\ntype TriggerDirectionLabel = \"above\" | \"below\" | \"unspecified\";\n\ntype LadderDistributionLabel = \"linear\" | \"geometric\" | \"weighted_favorable\" | \"unspecified\";\n\nconst TriggerResultStatusSchema = enumLabelSchema(TriggerStatusCodec.protoToOutput);\n\nconst TriggerMutationResultBaseSchema = v.pipe(\n v.object({\n triggerId: PublicIdSchema,\n status: TriggerResultStatusSchema,\n tsNs: v.bigint(),\n }),\n v.transform(({ tsNs, ...result }) => ({\n ...result,\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n);\n\nexport const CreateTriggerResultSchema = v.pipe(\n v.object({\n triggerId: PublicIdSchema,\n clientTriggerId: v.string(),\n acceptedAt: OptionalTimestampMsSchema,\n acceptedAtTsNs: BigIntStringSchema,\n }),\n v.transform(({ acceptedAt, acceptedAtTsNs, ...result }) => ({\n ...result,\n acceptedAt: acceptedAt ?? tsNsToMs(BigInt(acceptedAtTsNs)),\n acceptedAtNs: acceptedAtTsNs,\n })),\n);\n\nexport type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;\n\nexport const CancelTriggerResultSchema = TriggerMutationResultBaseSchema;\n\nexport type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;\n\nexport const ModifyTriggerResultSchema = TriggerMutationResultBaseSchema;\n\nexport type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;\n\nexport const PauseTriggerResultSchema = TriggerMutationResultBaseSchema;\nexport type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;\n\nexport const ResumeTriggerResultSchema = TriggerMutationResultBaseSchema;\nexport type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;\n\nconst ConditionalExecutionRawSchema = v.variant(\"case\", [\n v.object({\n case: v.literal(\"marketIoc\"),\n value: v.object({}),\n }),\n v.object({\n case: v.literal(\"limitGtc\"),\n value: v.object({\n priceTicks: v.bigint(),\n postOnly: v.boolean(),\n }),\n }),\n v.object({\n case: v.literal(\"limitIoc\"),\n value: v.object({ priceTicks: v.bigint() }),\n }),\n v.object({\n case: v.literal(\"limitFok\"),\n value: v.object({ priceTicks: v.bigint() }),\n }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nconst ConditionalConfigurationRawSchema = v.object({\n triggerPriceTicks: v.bigint(),\n side: v.number(),\n child: v.optional(\n v.object({\n execution: ConditionalExecutionRawSchema,\n }),\n ),\n});\n\nconst MaxSlippageRawSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"maxSlippageTicks\"), value: v.number() }),\n v.object({ case: v.literal(\"maxSlippageBps\"), value: v.number() }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nconst TrailingConfigurationRawSchema = v.object({\n trailingDistance: v.variant(\"case\", [\n v.object({ case: v.literal(\"trailingDistanceTicks\"), value: v.bigint() }),\n v.object({ case: v.literal(\"trailingDistanceBps\"), value: v.number() }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n ]),\n activationPriceTicks: v.bigint(),\n maxSlippage: MaxSlippageRawSchema,\n side: v.number(),\n});\n\nconst TwapConfigurationRawSchema = v.object({\n side: v.number(),\n durationMs: v.bigint(),\n sliceIntervalMs: v.bigint(),\n execution: v.variant(\"case\", [\n v.object({\n case: v.literal(\"marketIoc\"),\n value: v.object({ maxSlippage: MaxSlippageRawSchema }),\n }),\n v.object({\n case: v.literal(\"limitGtc\"),\n value: v.object({ priceTicks: v.bigint() }),\n }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n ]),\n});\n\nconst LadderConfigurationRawSchema = v.object({\n side: v.number(),\n priceMinTicks: v.bigint(),\n priceMaxTicks: v.bigint(),\n levels: v.number(),\n postOnly: v.boolean(),\n});\n\nconst TriggerConfigurationRawSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"stopLoss\"), value: ConditionalConfigurationRawSchema }),\n v.object({ case: v.literal(\"takeProfit\"), value: ConditionalConfigurationRawSchema }),\n v.object({ case: v.literal(\"trailingStop\"), value: TrailingConfigurationRawSchema }),\n v.object({ case: v.literal(\"twap\"), value: TwapConfigurationRawSchema }),\n v.object({ case: v.literal(\"ladder\"), value: LadderConfigurationRawSchema }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nfunction transformConditionalExecution(\n execution: v.InferOutput<typeof ConditionalExecutionRawSchema>,\n scales: SdkScales,\n) {\n switch (execution.case) {\n case \"marketIoc\":\n return { type: \"market_ioc\" } as const;\n case \"limitGtc\":\n return {\n type: \"limit_gtc\",\n price: scaledToDecimalOutput(execution.value.priceTicks, scales.price()),\n postOnly: execution.value.postOnly,\n } as const;\n case \"limitIoc\":\n return {\n type: \"limit_ioc\",\n price: scaledToDecimalOutput(execution.value.priceTicks, scales.price()),\n } as const;\n case \"limitFok\":\n return {\n type: \"limit_fok\",\n price: scaledToDecimalOutput(execution.value.priceTicks, scales.price()),\n } as const;\n default:\n return { type: \"unspecified\" } as const;\n }\n}\n\nfunction transformTriggerConfiguration(\n configuration: v.InferOutput<typeof TriggerConfigurationRawSchema>,\n scales: SdkScales,\n) {\n switch (configuration.case) {\n case \"stopLoss\":\n case \"takeProfit\":\n return {\n type:\n configuration.case === \"stopLoss\"\n ? (\"stop_loss\" as const)\n : (\"take_profit\" as const),\n side: enumLabel(TriggerSideCodec.protoToOutput, configuration.value.side),\n triggerPrice: scaledToDecimalOutput(\n configuration.value.triggerPriceTicks,\n scales.price(),\n ),\n execution: transformConditionalExecution(\n configuration.value.child?.execution ?? { case: undefined },\n scales,\n ),\n };\n case \"trailingStop\":\n return {\n type: \"trailing_stop\" as const,\n side: enumLabel(TriggerSideCodec.protoToOutput, configuration.value.side),\n trailingDistance:\n configuration.value.trailingDistance.case === \"trailingDistanceTicks\"\n ? {\n kind: \"distance\" as const,\n distance: scaledToDecimalOutput(\n configuration.value.trailingDistance.value,\n scales.price(),\n ),\n }\n : configuration.value.trailingDistance.case === \"trailingDistanceBps\"\n ? {\n kind: \"bps\" as const,\n bps: configuration.value.trailingDistance.value,\n }\n : { kind: \"unspecified\" as const },\n activationPrice:\n configuration.value.activationPriceTicks > 0n\n ? scaledToDecimalOutput(\n configuration.value.activationPriceTicks,\n scales.price(),\n )\n : undefined,\n maxSlippage: formatMaxSlippage(configuration.value.maxSlippage, scales),\n };\n case \"twap\":\n return {\n type: \"twap\" as const,\n side: enumLabel(TriggerSideCodec.protoToOutput, configuration.value.side),\n durationMs: Number(configuration.value.durationMs),\n sliceIntervalMs: Number(configuration.value.sliceIntervalMs),\n execution:\n configuration.value.execution.case === \"marketIoc\"\n ? ({\n type: \"market_ioc\",\n maxSlippage: formatMaxSlippage(\n configuration.value.execution.value.maxSlippage,\n scales,\n ),\n } as const)\n : configuration.value.execution.case === \"limitGtc\"\n ? ({\n type: \"limit_gtc\",\n price: scaledToDecimalOutput(\n configuration.value.execution.value.priceTicks,\n scales.price(),\n ),\n } as const)\n : ({ type: \"unspecified\" } as const),\n };\n case \"ladder\":\n return {\n type: \"ladder\" as const,\n side: enumLabel(TriggerSideCodec.protoToOutput, configuration.value.side),\n priceMin: scaledToDecimalOutput(configuration.value.priceMinTicks, scales.price()),\n priceMax: scaledToDecimalOutput(configuration.value.priceMaxTicks, scales.price()),\n levels: configuration.value.levels,\n postOnly: configuration.value.postOnly,\n };\n default:\n return { type: \"unspecified\" as const };\n }\n}\n\nfunction formatMaxSlippage(\n maxSlippage: v.InferOutput<typeof MaxSlippageRawSchema>,\n scales: SdkScales,\n) {\n return maxSlippage.case === \"maxSlippageTicks\"\n ? {\n kind: \"slippage\" as const,\n slippage: scaledToDecimalOutput(BigInt(maxSlippage.value), scales.price()),\n }\n : maxSlippage.case === \"maxSlippageBps\"\n ? { kind: \"bps\" as const, bps: maxSlippage.value }\n : { kind: \"none\" as const };\n}\n\nconst TerminalReasonRawSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"cancelReason\"), value: v.number() }),\n v.object({ case: v.literal(\"failureReason\"), value: v.number() }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nfunction transformTerminalReason(reason: v.InferOutput<typeof TerminalReasonRawSchema>) {\n switch (reason.case) {\n case \"cancelReason\":\n return {\n cancelReason: enumLabel(TriggerCancelReasonCodec.protoToOutput, reason.value),\n failureReason: undefined,\n };\n case \"failureReason\":\n return {\n cancelReason: undefined,\n failureReason: enumLabel(TriggerFailureReasonCodec.protoToOutput, reason.value),\n };\n default:\n return { cancelReason: undefined, failureReason: undefined };\n }\n}\n\nconst StopDetailsRawSchema = v.object({\n triggerPriceTicks: v.bigint(),\n triggerPriceSource: v.number(),\n triggerDirection: v.number(),\n});\n\nconst TrailingDetailsRawSchema = v.object({\n trailingDistanceTicks: v.bigint(),\n activationPriceTicks: v.bigint(),\n peakPriceTicks: v.bigint(),\n troughPriceTicks: v.bigint(),\n trailingDistanceBps: v.number(),\n maxSlippageTicks: v.number(),\n maxSlippageBps: v.number(),\n triggerPriceSource: v.number(),\n triggerDirection: v.number(),\n triggerPriceTicks: v.optional(v.bigint()),\n});\n\nconst TwapDetailsRawSchema = v.object({\n twapDurationMs: v.bigint(),\n twapSliceIntervalMs: v.bigint(),\n sliceIdx: v.number(),\n sliceCount: v.number(),\n executedQtyScaled: v.bigint(),\n});\n\nconst LadderDetailsRawSchema = v.object({\n ladderPriceMinTicks: v.bigint(),\n ladderPriceMaxTicks: v.bigint(),\n ladderLevels: v.number(),\n ladderDistribution: v.number(),\n executedQtyScaled: v.bigint(),\n executedLevels: v.number(),\n});\n\nconst TriggerDetailsRawSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"stop\"), value: StopDetailsRawSchema }),\n v.object({ case: v.literal(\"trailing\"), value: TrailingDetailsRawSchema }),\n v.object({ case: v.literal(\"twapState\"), value: TwapDetailsRawSchema }),\n v.object({ case: v.literal(\"ladderState\"), value: LadderDetailsRawSchema }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nexport type StopDetailsOutput = {\n case: \"stop\";\n triggerPrice: string;\n triggerPriceSource: TriggerPriceSourceLabel;\n triggerDirection: TriggerDirectionLabel;\n};\n\nexport type TrailingDetailsOutput = {\n case: \"trailing\";\n trailingDistance: string | undefined;\n trailingDistanceBps: number;\n activationPrice: string | undefined;\n peakPrice: string | undefined;\n troughPrice: string | undefined;\n maxSlippage: string | undefined;\n maxSlippageBps: number;\n triggerPriceSource: TriggerPriceSourceLabel;\n triggerDirection: TriggerDirectionLabel;\n /** Current trailing threshold; absent until the trigger is armed. Moves with the peak or trough. */\n triggerPrice: string | undefined;\n};\n\nexport type TwapDetailsOutput = {\n case: \"twap\";\n twapDurationMs: number;\n twapSliceIntervalMs: number;\n sliceIdx: number;\n sliceCount: number;\n /** Cumulative filled child-order base quantity. */\n executedQty: string;\n};\n\nexport type LadderDetailsOutput = {\n case: \"ladder\";\n ladderPriceMin: string;\n ladderPriceMax: string;\n ladderLevels: number;\n ladderDistribution: LadderDistributionLabel;\n /** Cumulative filled child-order base quantity. */\n executedQty: string;\n /** Number of ladder levels with at least one fill. */\n executedLevels: number;\n};\n\nexport type TriggerDetailsOutput =\n | StopDetailsOutput\n | TrailingDetailsOutput\n | TwapDetailsOutput\n | LadderDetailsOutput\n | { case: undefined };\n\nfunction transformTriggerDetails(\n details: v.InferOutput<typeof TriggerDetailsRawSchema>,\n scales: SdkScales,\n symbolId: number,\n): TriggerDetailsOutput {\n switch (details.case) {\n case \"stop\":\n return {\n case: \"stop\",\n triggerPrice: scaledToDecimalOutput(\n details.value.triggerPriceTicks,\n scales.price(),\n ),\n triggerPriceSource: enumLabel(\n TriggerPriceSourceCodec.protoToOutput,\n details.value.triggerPriceSource,\n ),\n triggerDirection: enumLabel(\n TriggerDirectionCodec.protoToOutput,\n details.value.triggerDirection,\n ),\n };\n case \"trailing\":\n return {\n case: \"trailing\",\n trailingDistance:\n details.value.trailingDistanceTicks > 0n\n ? scaledToDecimalOutput(details.value.trailingDistanceTicks, scales.price())\n : undefined,\n trailingDistanceBps: details.value.trailingDistanceBps,\n activationPrice:\n details.value.activationPriceTicks > 0n\n ? scaledToDecimalOutput(details.value.activationPriceTicks, scales.price())\n : undefined,\n peakPrice:\n details.value.peakPriceTicks > 0n\n ? scaledToDecimalOutput(details.value.peakPriceTicks, scales.price())\n : undefined,\n troughPrice:\n details.value.troughPriceTicks > 0n\n ? scaledToDecimalOutput(details.value.troughPriceTicks, scales.price())\n : undefined,\n maxSlippage:\n details.value.maxSlippageTicks > 0\n ? scaledToDecimalOutput(\n BigInt(details.value.maxSlippageTicks),\n scales.price(),\n )\n : undefined,\n maxSlippageBps: details.value.maxSlippageBps,\n triggerPriceSource: enumLabel(\n TriggerPriceSourceCodec.protoToOutput,\n details.value.triggerPriceSource,\n ),\n triggerDirection: enumLabel(\n TriggerDirectionCodec.protoToOutput,\n details.value.triggerDirection,\n ),\n triggerPrice:\n details.value.triggerPriceTicks !== undefined &&\n details.value.triggerPriceTicks > 0n\n ? scaledToDecimalOutput(details.value.triggerPriceTicks, scales.price())\n : undefined,\n };\n case \"twapState\":\n return {\n case: \"twap\",\n twapDurationMs: Number(details.value.twapDurationMs),\n twapSliceIntervalMs: Number(details.value.twapSliceIntervalMs),\n sliceIdx: details.value.sliceIdx,\n sliceCount: details.value.sliceCount,\n executedQty: scaledToDecimalOutput(\n details.value.executedQtyScaled,\n scales.baseQty(symbolId),\n ),\n };\n case \"ladderState\":\n return {\n case: \"ladder\",\n ladderPriceMin: scaledToDecimalOutput(\n details.value.ladderPriceMinTicks,\n scales.price(),\n ),\n ladderPriceMax: scaledToDecimalOutput(\n details.value.ladderPriceMaxTicks,\n scales.price(),\n ),\n ladderLevels: details.value.ladderLevels,\n ladderDistribution: enumLabel(\n LadderDistributionCodec.protoToOutput,\n details.value.ladderDistribution,\n ),\n executedQty: scaledToDecimalOutput(\n details.value.executedQtyScaled,\n scales.baseQty(symbolId),\n ),\n executedLevels: details.value.executedLevels,\n };\n default:\n return { case: undefined };\n }\n}\n\n/** Builds the public trigger output schema using each record's symbol ID for quantity scaling. */\nexport function createTriggerSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n triggerId: v.bigint(),\n subaccountId: v.bigint(),\n symbolId: v.number(),\n status: v.number(),\n parentOrderId: v.optional(v.bigint()),\n qtyScaled: v.bigint(),\n feeAsset: v.number(),\n selfTradePreventionMode: v.number(),\n configuration: TriggerConfigurationRawSchema,\n clientTriggerId: v.string(),\n createdAt: v.optional(TimestampSchema),\n updatedAt: v.optional(TimestampSchema),\n armedAt: v.optional(TimestampSchema),\n completedAt: v.optional(TimestampSchema),\n terminalReason: TerminalReasonRawSchema,\n runtimeDetails: TriggerDetailsRawSchema,\n }),\n v.transform((t) => ({\n triggerId: formatId(t.triggerId),\n subaccountId: formatId(t.subaccountId),\n symbolId: t.symbolId,\n status: enumLabel(TriggerStatusCodec.protoToOutput, t.status),\n parentOrderId: t.parentOrderId ? formatId(t.parentOrderId) : undefined,\n qty: scaledToDecimalOutput(t.qtyScaled, scales.baseQty(t.symbolId)),\n feeAsset: enumLabel(FeeAssetCodec.protoToOutput, t.feeAsset),\n selfTradePreventionMode: enumLabel(\n SelfTradePreventionModeCodec.protoToOutput,\n t.selfTradePreventionMode,\n ),\n configuration: transformTriggerConfiguration(t.configuration, scales),\n clientTriggerId: t.clientTriggerId,\n createdTs: t.createdAt ? tsObjToMs(t.createdAt) : undefined,\n updatedTs: t.updatedAt ? tsObjToMs(t.updatedAt) : undefined,\n armedTs: t.armedAt ? tsObjToMs(t.armedAt) : undefined,\n completedTs: t.completedAt ? tsObjToMs(t.completedAt) : undefined,\n ...transformTerminalReason(t.terminalReason),\n runtimeDetails: transformTriggerDetails(t.runtimeDetails, scales, t.symbolId),\n })),\n );\n}\n\n/** A normalized standalone trigger record. */\nexport type Trigger = v.InferOutput<ReturnType<typeof createTriggerSchema>>;\n\nexport function createTriggerEventSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n triggerId: v.bigint(),\n subaccountId: v.bigint(),\n symbolId: v.number(),\n triggerType: v.number(),\n eventType: v.number(),\n tsNs: v.bigint(),\n childSeq: v.number(),\n childOrderId: v.bigint(),\n firePriceTicks: v.optional(v.bigint()),\n terminalReason: TerminalReasonRawSchema,\n }),\n v.transform((e) => ({\n triggerId: formatId(e.triggerId),\n subaccountId: formatId(e.subaccountId),\n symbolId: e.symbolId,\n triggerType: enumLabel(TriggerTypeCodec.protoToOutput, e.triggerType),\n eventType: enumLabel(TriggerEventTypeCodec.protoToOutput, e.eventType),\n ts: tsNsToMs(e.tsNs),\n childSeq: e.childSeq,\n childOrderId: e.childOrderId > 0n ? formatId(e.childOrderId) : undefined,\n firePrice:\n e.firePriceTicks !== undefined && e.firePriceTicks > 0n\n ? scaledToDecimalOutput(e.firePriceTicks, scales.price())\n : undefined,\n ...transformTerminalReason(e.terminalReason),\n })),\n );\n}\n\nexport type TriggerEvent = v.InferOutput<ReturnType<typeof createTriggerEventSchema>>;\n\nexport type ListTriggerEventsResult = {\n events: TriggerEvent[];\n nextPageToken: string;\n};\n"],"mappings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AAC,IACtD,KAAA;EACV,GAAG,wBAAwB,EAAE,cAAc;CAC/C,EAAE,CACN;AACJ"}
|
|
1
|
+
{"version":3,"file":"triggers-output.schemas.js","names":["TriggerSideCodec"],"sources":["../../../src/services/triggers/triggers-output.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n TimestampSchema,\n PublicIdSchema,\n} from \"../../shared/schemas.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { tsNsToMs, tsObjToMs } from \"../../utils/time.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n TriggerTypeCodec,\n TriggerStatusCodec,\n FeeAssetCodec,\n SelfTradePreventionModeCodec,\n TriggerPriceSourceCodec,\n TriggerDirectionCodec,\n LadderDistributionCodec,\n TriggerSideCodec,\n TriggerEventTypeCodec,\n TriggerCancelReasonCodec,\n TriggerFailureReasonCodec,\n} from \"./triggers.codecs.js\";\n\ntype TriggerPriceSourceLabel = \"last\" | \"index\" | \"mark\" | \"unspecified\";\n\ntype TriggerDirectionLabel = \"above\" | \"below\" | \"unspecified\";\n\ntype LadderDistributionLabel = \"linear\" | \"geometric\" | \"weighted_favorable\" | \"unspecified\";\n\nconst TriggerResultStatusSchema = enumLabelSchema(TriggerStatusCodec.protoToOutput);\n\nconst TriggerMutationResultBaseSchema = v.pipe(\n v.object({\n triggerId: PublicIdSchema,\n status: TriggerResultStatusSchema,\n tsNs: v.bigint(),\n }),\n v.transform(({ tsNs, ...result }) => ({\n ...result,\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n);\n\nexport const CreateTriggerResultSchema = v.pipe(\n v.object({\n triggerId: PublicIdSchema,\n clientTriggerId: v.string(),\n acceptedAt: OptionalTimestampMsSchema,\n acceptedAtTsNs: BigIntStringSchema,\n }),\n v.transform(({ acceptedAt, acceptedAtTsNs, ...result }) => ({\n ...result,\n acceptedAt: acceptedAt ?? tsNsToMs(BigInt(acceptedAtTsNs)),\n acceptedAtNs: acceptedAtTsNs,\n })),\n);\n\nexport type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;\n\nexport const CancelTriggerResultSchema = TriggerMutationResultBaseSchema;\n\nexport type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;\n\nexport const ModifyTriggerResultSchema = TriggerMutationResultBaseSchema;\n\nexport type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;\n\nexport const PauseTriggerResultSchema = TriggerMutationResultBaseSchema;\nexport type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;\n\nexport const ResumeTriggerResultSchema = TriggerMutationResultBaseSchema;\nexport type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;\n\nconst ConditionalExecutionRawSchema = v.variant(\"case\", [\n v.object({\n case: v.literal(\"marketIoc\"),\n value: v.object({}),\n }),\n v.object({\n case: v.literal(\"limitGtc\"),\n value: v.object({\n priceTicks: v.bigint(),\n postOnly: v.boolean(),\n }),\n }),\n v.object({\n case: v.literal(\"limitIoc\"),\n value: v.object({ priceTicks: v.bigint() }),\n }),\n v.object({\n case: v.literal(\"limitFok\"),\n value: v.object({ priceTicks: v.bigint() }),\n }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nconst ConditionalConfigurationRawSchema = v.object({\n triggerPriceTicks: v.bigint(),\n side: v.number(),\n child: v.optional(\n v.object({\n execution: ConditionalExecutionRawSchema,\n }),\n ),\n});\n\nconst MaxSlippageRawSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"maxSlippageTicks\"), value: v.bigint() }),\n v.object({ case: v.literal(\"maxSlippageBps\"), value: v.number() }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nconst TrailingConfigurationRawSchema = v.object({\n trailingDistance: v.variant(\"case\", [\n v.object({ case: v.literal(\"trailingDistanceTicks\"), value: v.bigint() }),\n v.object({ case: v.literal(\"trailingDistanceBps\"), value: v.number() }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n ]),\n activationPriceTicks: v.bigint(),\n maxSlippage: MaxSlippageRawSchema,\n side: v.number(),\n});\n\nconst TwapConfigurationRawSchema = v.object({\n side: v.number(),\n durationMs: v.bigint(),\n sliceIntervalMs: v.bigint(),\n execution: v.variant(\"case\", [\n v.object({\n case: v.literal(\"marketIoc\"),\n value: v.object({ maxSlippage: MaxSlippageRawSchema }),\n }),\n v.object({\n case: v.literal(\"limitGtc\"),\n value: v.object({ priceTicks: v.bigint() }),\n }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n ]),\n});\n\nconst LadderConfigurationRawSchema = v.object({\n side: v.number(),\n priceMinTicks: v.bigint(),\n priceMaxTicks: v.bigint(),\n levels: v.number(),\n postOnly: v.boolean(),\n});\n\nconst TriggerConfigurationRawSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"stopLoss\"), value: ConditionalConfigurationRawSchema }),\n v.object({ case: v.literal(\"takeProfit\"), value: ConditionalConfigurationRawSchema }),\n v.object({ case: v.literal(\"trailingStop\"), value: TrailingConfigurationRawSchema }),\n v.object({ case: v.literal(\"twap\"), value: TwapConfigurationRawSchema }),\n v.object({ case: v.literal(\"ladder\"), value: LadderConfigurationRawSchema }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nfunction transformConditionalExecution(\n execution: v.InferOutput<typeof ConditionalExecutionRawSchema>,\n scales: SdkScales,\n) {\n switch (execution.case) {\n case \"marketIoc\":\n return { type: \"market_ioc\" } as const;\n case \"limitGtc\":\n return {\n type: \"limit_gtc\",\n price: scaledToDecimalOutput(execution.value.priceTicks, scales.price()),\n postOnly: execution.value.postOnly,\n } as const;\n case \"limitIoc\":\n return {\n type: \"limit_ioc\",\n price: scaledToDecimalOutput(execution.value.priceTicks, scales.price()),\n } as const;\n case \"limitFok\":\n return {\n type: \"limit_fok\",\n price: scaledToDecimalOutput(execution.value.priceTicks, scales.price()),\n } as const;\n default:\n return { type: \"unspecified\" } as const;\n }\n}\n\nfunction transformTriggerConfiguration(\n configuration: v.InferOutput<typeof TriggerConfigurationRawSchema>,\n scales: SdkScales,\n) {\n switch (configuration.case) {\n case \"stopLoss\":\n case \"takeProfit\":\n return {\n type:\n configuration.case === \"stopLoss\"\n ? (\"stop_loss\" as const)\n : (\"take_profit\" as const),\n side: enumLabel(TriggerSideCodec.protoToOutput, configuration.value.side),\n triggerPrice: scaledToDecimalOutput(\n configuration.value.triggerPriceTicks,\n scales.price(),\n ),\n execution: transformConditionalExecution(\n configuration.value.child?.execution ?? { case: undefined },\n scales,\n ),\n };\n case \"trailingStop\":\n return {\n type: \"trailing_stop\" as const,\n side: enumLabel(TriggerSideCodec.protoToOutput, configuration.value.side),\n trailingDistance:\n configuration.value.trailingDistance.case === \"trailingDistanceTicks\"\n ? {\n kind: \"distance\" as const,\n distance: scaledToDecimalOutput(\n configuration.value.trailingDistance.value,\n scales.price(),\n ),\n }\n : configuration.value.trailingDistance.case === \"trailingDistanceBps\"\n ? {\n kind: \"bps\" as const,\n bps: configuration.value.trailingDistance.value,\n }\n : { kind: \"unspecified\" as const },\n activationPrice:\n configuration.value.activationPriceTicks > 0n\n ? scaledToDecimalOutput(\n configuration.value.activationPriceTicks,\n scales.price(),\n )\n : undefined,\n maxSlippage: formatMaxSlippage(configuration.value.maxSlippage, scales),\n };\n case \"twap\":\n return {\n type: \"twap\" as const,\n side: enumLabel(TriggerSideCodec.protoToOutput, configuration.value.side),\n durationMs: Number(configuration.value.durationMs),\n sliceIntervalMs: Number(configuration.value.sliceIntervalMs),\n execution:\n configuration.value.execution.case === \"marketIoc\"\n ? ({\n type: \"market_ioc\",\n maxSlippage: formatMaxSlippage(\n configuration.value.execution.value.maxSlippage,\n scales,\n ),\n } as const)\n : configuration.value.execution.case === \"limitGtc\"\n ? ({\n type: \"limit_gtc\",\n price: scaledToDecimalOutput(\n configuration.value.execution.value.priceTicks,\n scales.price(),\n ),\n } as const)\n : ({ type: \"unspecified\" } as const),\n };\n case \"ladder\":\n return {\n type: \"ladder\" as const,\n side: enumLabel(TriggerSideCodec.protoToOutput, configuration.value.side),\n priceMin: scaledToDecimalOutput(configuration.value.priceMinTicks, scales.price()),\n priceMax: scaledToDecimalOutput(configuration.value.priceMaxTicks, scales.price()),\n levels: configuration.value.levels,\n postOnly: configuration.value.postOnly,\n };\n default:\n return { type: \"unspecified\" as const };\n }\n}\n\nfunction formatMaxSlippage(\n maxSlippage: v.InferOutput<typeof MaxSlippageRawSchema>,\n scales: SdkScales,\n) {\n return maxSlippage.case === \"maxSlippageTicks\"\n ? {\n kind: \"slippage\" as const,\n slippage: scaledToDecimalOutput(maxSlippage.value, scales.price()),\n }\n : maxSlippage.case === \"maxSlippageBps\"\n ? { kind: \"bps\" as const, bps: maxSlippage.value }\n : { kind: \"none\" as const };\n}\n\nconst TerminalReasonRawSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"cancelReason\"), value: v.number() }),\n v.object({ case: v.literal(\"failureReason\"), value: v.number() }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nfunction transformTerminalReason(reason: v.InferOutput<typeof TerminalReasonRawSchema>) {\n switch (reason.case) {\n case \"cancelReason\":\n return {\n cancelReason: enumLabel(TriggerCancelReasonCodec.protoToOutput, reason.value),\n failureReason: undefined,\n };\n case \"failureReason\":\n return {\n cancelReason: undefined,\n failureReason: enumLabel(TriggerFailureReasonCodec.protoToOutput, reason.value),\n };\n default:\n return { cancelReason: undefined, failureReason: undefined };\n }\n}\n\nconst StopDetailsRawSchema = v.object({\n triggerPriceTicks: v.bigint(),\n triggerPriceSource: v.number(),\n triggerDirection: v.number(),\n});\n\nconst TrailingDetailsRawSchema = v.object({\n trailingDistanceTicks: v.bigint(),\n activationPriceTicks: v.bigint(),\n peakPriceTicks: v.bigint(),\n troughPriceTicks: v.bigint(),\n trailingDistanceBps: v.number(),\n maxSlippageTicks: v.bigint(),\n maxSlippageBps: v.number(),\n triggerPriceSource: v.number(),\n triggerDirection: v.number(),\n triggerPriceTicks: v.optional(v.bigint()),\n});\n\nconst TwapDetailsRawSchema = v.object({\n twapDurationMs: v.bigint(),\n twapSliceIntervalMs: v.bigint(),\n sliceIdx: v.number(),\n sliceCount: v.number(),\n executedQtyScaled: v.bigint(),\n});\n\nconst LadderDetailsRawSchema = v.object({\n ladderPriceMinTicks: v.bigint(),\n ladderPriceMaxTicks: v.bigint(),\n ladderLevels: v.number(),\n ladderDistribution: v.number(),\n executedQtyScaled: v.bigint(),\n executedLevels: v.number(),\n});\n\nconst TriggerDetailsRawSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"stop\"), value: StopDetailsRawSchema }),\n v.object({ case: v.literal(\"trailing\"), value: TrailingDetailsRawSchema }),\n v.object({ case: v.literal(\"twapState\"), value: TwapDetailsRawSchema }),\n v.object({ case: v.literal(\"ladderState\"), value: LadderDetailsRawSchema }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nexport type StopDetailsOutput = {\n case: \"stop\";\n triggerPrice: string;\n triggerPriceSource: TriggerPriceSourceLabel;\n triggerDirection: TriggerDirectionLabel;\n};\n\nexport type TrailingDetailsOutput = {\n case: \"trailing\";\n trailingDistance: string | undefined;\n trailingDistanceBps: number;\n activationPrice: string | undefined;\n peakPrice: string | undefined;\n troughPrice: string | undefined;\n maxSlippage: string | undefined;\n maxSlippageBps: number;\n triggerPriceSource: TriggerPriceSourceLabel;\n triggerDirection: TriggerDirectionLabel;\n /** Current trailing threshold; absent until the trigger is armed. Moves with the peak or trough. */\n triggerPrice: string | undefined;\n};\n\nexport type TwapDetailsOutput = {\n case: \"twap\";\n twapDurationMs: number;\n twapSliceIntervalMs: number;\n sliceIdx: number;\n sliceCount: number;\n /** Cumulative filled child-order base quantity. */\n executedQty: string;\n};\n\nexport type LadderDetailsOutput = {\n case: \"ladder\";\n ladderPriceMin: string;\n ladderPriceMax: string;\n ladderLevels: number;\n ladderDistribution: LadderDistributionLabel;\n /** Cumulative filled child-order base quantity. */\n executedQty: string;\n /** Number of ladder levels with at least one fill. */\n executedLevels: number;\n};\n\nexport type TriggerDetailsOutput =\n | StopDetailsOutput\n | TrailingDetailsOutput\n | TwapDetailsOutput\n | LadderDetailsOutput\n | { case: undefined };\n\nfunction transformTriggerDetails(\n details: v.InferOutput<typeof TriggerDetailsRawSchema>,\n scales: SdkScales,\n symbolId: number,\n): TriggerDetailsOutput {\n switch (details.case) {\n case \"stop\":\n return {\n case: \"stop\",\n triggerPrice: scaledToDecimalOutput(\n details.value.triggerPriceTicks,\n scales.price(),\n ),\n triggerPriceSource: enumLabel(\n TriggerPriceSourceCodec.protoToOutput,\n details.value.triggerPriceSource,\n ),\n triggerDirection: enumLabel(\n TriggerDirectionCodec.protoToOutput,\n details.value.triggerDirection,\n ),\n };\n case \"trailing\":\n return {\n case: \"trailing\",\n trailingDistance:\n details.value.trailingDistanceTicks > 0n\n ? scaledToDecimalOutput(details.value.trailingDistanceTicks, scales.price())\n : undefined,\n trailingDistanceBps: details.value.trailingDistanceBps,\n activationPrice:\n details.value.activationPriceTicks > 0n\n ? scaledToDecimalOutput(details.value.activationPriceTicks, scales.price())\n : undefined,\n peakPrice:\n details.value.peakPriceTicks > 0n\n ? scaledToDecimalOutput(details.value.peakPriceTicks, scales.price())\n : undefined,\n troughPrice:\n details.value.troughPriceTicks > 0n\n ? scaledToDecimalOutput(details.value.troughPriceTicks, scales.price())\n : undefined,\n maxSlippage:\n details.value.maxSlippageTicks > 0n\n ? scaledToDecimalOutput(details.value.maxSlippageTicks, scales.price())\n : undefined,\n maxSlippageBps: details.value.maxSlippageBps,\n triggerPriceSource: enumLabel(\n TriggerPriceSourceCodec.protoToOutput,\n details.value.triggerPriceSource,\n ),\n triggerDirection: enumLabel(\n TriggerDirectionCodec.protoToOutput,\n details.value.triggerDirection,\n ),\n triggerPrice:\n details.value.triggerPriceTicks !== undefined &&\n details.value.triggerPriceTicks > 0n\n ? scaledToDecimalOutput(details.value.triggerPriceTicks, scales.price())\n : undefined,\n };\n case \"twapState\":\n return {\n case: \"twap\",\n twapDurationMs: Number(details.value.twapDurationMs),\n twapSliceIntervalMs: Number(details.value.twapSliceIntervalMs),\n sliceIdx: details.value.sliceIdx,\n sliceCount: details.value.sliceCount,\n executedQty: scaledToDecimalOutput(\n details.value.executedQtyScaled,\n scales.baseQty(symbolId),\n ),\n };\n case \"ladderState\":\n return {\n case: \"ladder\",\n ladderPriceMin: scaledToDecimalOutput(\n details.value.ladderPriceMinTicks,\n scales.price(),\n ),\n ladderPriceMax: scaledToDecimalOutput(\n details.value.ladderPriceMaxTicks,\n scales.price(),\n ),\n ladderLevels: details.value.ladderLevels,\n ladderDistribution: enumLabel(\n LadderDistributionCodec.protoToOutput,\n details.value.ladderDistribution,\n ),\n executedQty: scaledToDecimalOutput(\n details.value.executedQtyScaled,\n scales.baseQty(symbolId),\n ),\n executedLevels: details.value.executedLevels,\n };\n default:\n return { case: undefined };\n }\n}\n\n/** Builds the public trigger output schema using each record's symbol ID for quantity scaling. */\nexport function createTriggerSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n triggerId: v.bigint(),\n subaccountId: v.bigint(),\n symbolId: v.number(),\n status: v.number(),\n parentOrderId: v.optional(v.bigint()),\n qtyScaled: v.bigint(),\n feeAsset: v.number(),\n selfTradePreventionMode: v.number(),\n configuration: TriggerConfigurationRawSchema,\n clientTriggerId: v.string(),\n createdAt: v.optional(TimestampSchema),\n updatedAt: v.optional(TimestampSchema),\n armedAt: v.optional(TimestampSchema),\n completedAt: v.optional(TimestampSchema),\n terminalReason: TerminalReasonRawSchema,\n runtimeDetails: TriggerDetailsRawSchema,\n }),\n v.transform((t) => ({\n triggerId: formatId(t.triggerId),\n subaccountId: formatId(t.subaccountId),\n symbolId: t.symbolId,\n status: enumLabel(TriggerStatusCodec.protoToOutput, t.status),\n parentOrderId: t.parentOrderId ? formatId(t.parentOrderId) : undefined,\n qty: scaledToDecimalOutput(t.qtyScaled, scales.baseQty(t.symbolId)),\n feeAsset: enumLabel(FeeAssetCodec.protoToOutput, t.feeAsset),\n selfTradePreventionMode: enumLabel(\n SelfTradePreventionModeCodec.protoToOutput,\n t.selfTradePreventionMode,\n ),\n configuration: transformTriggerConfiguration(t.configuration, scales),\n clientTriggerId: t.clientTriggerId,\n createdTs: t.createdAt ? tsObjToMs(t.createdAt) : undefined,\n updatedTs: t.updatedAt ? tsObjToMs(t.updatedAt) : undefined,\n armedTs: t.armedAt ? tsObjToMs(t.armedAt) : undefined,\n completedTs: t.completedAt ? tsObjToMs(t.completedAt) : undefined,\n ...transformTerminalReason(t.terminalReason),\n runtimeDetails: transformTriggerDetails(t.runtimeDetails, scales, t.symbolId),\n })),\n );\n}\n\n/** A normalized standalone trigger record. */\nexport type Trigger = v.InferOutput<ReturnType<typeof createTriggerSchema>>;\n\nexport function createTriggerEventSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n triggerId: v.bigint(),\n subaccountId: v.bigint(),\n symbolId: v.number(),\n triggerType: v.number(),\n eventType: v.number(),\n tsNs: v.bigint(),\n childSeq: v.number(),\n childOrderId: v.bigint(),\n firePriceTicks: v.optional(v.bigint()),\n terminalReason: TerminalReasonRawSchema,\n }),\n v.transform((e) => ({\n triggerId: formatId(e.triggerId),\n subaccountId: formatId(e.subaccountId),\n symbolId: e.symbolId,\n triggerType: enumLabel(TriggerTypeCodec.protoToOutput, e.triggerType),\n eventType: enumLabel(TriggerEventTypeCodec.protoToOutput, e.eventType),\n ts: tsNsToMs(e.tsNs),\n childSeq: e.childSeq,\n childOrderId: e.childOrderId > 0n ? formatId(e.childOrderId) : undefined,\n firePrice:\n e.firePriceTicks !== undefined && e.firePriceTicks > 0n\n ? scaledToDecimalOutput(e.firePriceTicks, scales.price())\n : undefined,\n ...transformTerminalReason(e.terminalReason),\n })),\n );\n}\n\nexport type TriggerEvent = v.InferOutput<ReturnType<typeof createTriggerEventSchema>>;\n\nexport type ListTriggerEventsResult = {\n events: TriggerEvent[];\n nextPageToken: string;\n};\n"],"mappings":";;;;;;;;;AA+BA,MAAM,4BAA4B,gBAAgB,mBAAmB,aAAa;AAElF,MAAM,kCAAkC,EAAE,KACtC,EAAE,OAAO;CACL,WAAW;CACX,QAAQ;CACR,MAAM,EAAE,OAAO;AACnB,CAAC,GACD,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc;CAClC,GAAG;CACH,IAAI,SAAS,IAAI;CACjB,MAAM,KAAK,SAAS;AACxB,EAAE,CACN;AAEA,MAAa,4BAA4B,EAAE,KACvC,EAAE,OAAO;CACL,WAAW;CACX,iBAAiB,EAAE,OAAO;CAC1B,YAAY;CACZ,gBAAgB;AACpB,CAAC,GACD,EAAE,WAAW,EAAE,YAAY,gBAAgB,GAAG,cAAc;CACxD,GAAG;CACH,YAAY,cAAc,SAAS,OAAO,cAAc,CAAC;CACzD,cAAc;AAClB,EAAE,CACN;AAIA,MAAa,4BAA4B;AAIzC,MAAa,4BAA4B;AAIzC,MAAa,2BAA2B;AAGxC,MAAa,4BAA4B;AAGzC,MAAM,gCAAgC,EAAE,QAAQ,QAAQ;CACpD,EAAE,OAAO;EACL,MAAM,EAAE,QAAQ,WAAW;EAC3B,OAAO,EAAE,OAAO,CAAC,CAAC;CACtB,CAAC;CACD,EAAE,OAAO;EACL,MAAM,EAAE,QAAQ,UAAU;EAC1B,OAAO,EAAE,OAAO;GACZ,YAAY,EAAE,OAAO;GACrB,UAAU,EAAE,QAAQ;EACxB,CAAC;CACL,CAAC;CACD,EAAE,OAAO;EACL,MAAM,EAAE,QAAQ,UAAU;EAC1B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;CAC9C,CAAC;CACD,EAAE,OAAO;EACL,MAAM,EAAE,QAAQ,UAAU;EAC1B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;CAC9C,CAAC;CACD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AA,KAAa,EAAE,iBAAiB,KAC/C,sBAAsB,EAAE,gBAAgB,OAAO,MAAM,CAAC,IACtD,KAAA;EACV,GAAG,wBAAwB,EAAE,cAAc;CAC/C,EAAE,CACN;AACJ"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
//#region src/shared/wire-bounds.ts
|
|
2
2
|
/** Largest value encodable by a protobuf `int64` field. */
|
|
3
3
|
const PROTOBUF_INT64_MAX = 9223372036854775807n;
|
|
4
|
-
/** Largest value encodable by a protobuf `int32` field. */
|
|
5
|
-
const PROTOBUF_INT32_MAX = 2147483647n;
|
|
6
4
|
/** Largest value encodable by a protobuf `uint32` field. */
|
|
7
5
|
const PROTOBUF_UINT32_MAX = 4294967295;
|
|
8
6
|
//#endregion
|
|
9
|
-
export {
|
|
7
|
+
export { PROTOBUF_INT64_MAX, PROTOBUF_UINT32_MAX };
|
|
10
8
|
|
|
11
9
|
//# sourceMappingURL=wire-bounds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-bounds.js","names":[],"sources":["../../src/shared/wire-bounds.ts"],"sourcesContent":["/** Largest value encodable by a protobuf `int64` field. */\nexport const PROTOBUF_INT64_MAX = 9_223_372_036_854_775_807n;\n\n/** Largest value encodable by a protobuf `int32` field. */\nexport const PROTOBUF_INT32_MAX = 2_147_483_647n;\n\n/** Largest value encodable by a protobuf `uint32` field. */\nexport const PROTOBUF_UINT32_MAX = 4_294_967_295;\n"],"mappings":";;AACA,MAAa,qBAAqB;;
|
|
1
|
+
{"version":3,"file":"wire-bounds.js","names":[],"sources":["../../src/shared/wire-bounds.ts"],"sourcesContent":["/** Largest value encodable by a protobuf `int64` field. */\nexport const PROTOBUF_INT64_MAX = 9_223_372_036_854_775_807n;\n\n/** Largest value encodable by a protobuf `int32` field. */\nexport const PROTOBUF_INT32_MAX = 2_147_483_647n;\n\n/** Largest value encodable by a protobuf `uint32` field. */\nexport const PROTOBUF_UINT32_MAX = 4_294_967_295;\n"],"mappings":";;AACA,MAAa,qBAAqB;;AAMlC,MAAa,sBAAsB"}
|