@polyester/sdk 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/core-client.js +1 -1
- package/dist/gen/fees/v1/fees_pb.d.ts +4 -2
- package/dist/gen/fees/v1/fees_pb.d.ts.map +1 -1
- package/dist/gen/fees/v1/fees_pb.js +9 -1
- package/dist/gen/fees/v1/fees_pb.js.map +1 -1
- package/dist/gen/index.d.ts +4 -1
- package/dist/gen/index.js +4 -1
- package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts +4 -2
- package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts.map +1 -1
- package/dist/gen/ratelimit/v1/ratelimit_pb.js +13 -1
- package/dist/gen/ratelimit/v1/ratelimit_pb.js.map +1 -1
- package/dist/gen/vip/v1/vip_pb.d.ts +4 -2
- package/dist/gen/vip/v1/vip_pb.d.ts.map +1 -1
- package/dist/gen/vip/v1/vip_pb.js +12 -1
- package/dist/gen/vip/v1/vip_pb.js.map +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
- package/dist/services/address-book/address-book.schemas.js +2 -1
- package/dist/services/address-book/address-book.schemas.js.map +1 -1
- package/dist/services/candles/candles.d.ts.map +1 -1
- package/dist/services/candles/candles.js +2 -1
- package/dist/services/candles/candles.js.map +1 -1
- package/dist/services/candles/candles.schemas.d.ts +1 -1
- package/dist/services/candles/candles.schemas.d.ts.map +1 -1
- package/dist/services/candles/candles.schemas.js +3 -2
- package/dist/services/candles/candles.schemas.js.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.d.ts.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.js +5 -5
- package/dist/services/chain-analytics/chain-analytics.schemas.js.map +1 -1
- package/dist/services/deposit/deposit.schemas.d.ts +3 -3
- package/dist/services/deposit/deposit.schemas.d.ts.map +1 -1
- package/dist/services/deposit/deposit.schemas.js +4 -4
- package/dist/services/deposit/deposit.schemas.js.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.d.ts +2 -2
- package/dist/services/guard-signer/guard-signer.schemas.d.ts.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.js +2 -1
- package/dist/services/guard-signer/guard-signer.schemas.js.map +1 -1
- package/dist/services/heatmap/heatmap.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.js +2 -1
- package/dist/services/heatmap/heatmap.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.js +2 -1
- package/dist/services/heatmap/heatmap.schemas.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +2 -2
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.js +3 -2
- package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +2 -1
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-data/market-data.schemas.d.ts +1 -1
- package/dist/services/market-data/market-data.schemas.js +2 -2
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-overview/market-overview.schemas.d.ts +1 -1
- package/dist/services/market-overview/market-overview.schemas.js +2 -2
- package/dist/services/market-overview/market-overview.schemas.js.map +1 -1
- package/dist/services/orders/orders-modify.schemas.js +1 -1
- package/dist/services/orders/orders-risk.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-risk.schemas.js +3 -4
- package/dist/services/orders/orders-risk.schemas.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +9 -9
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +17 -8
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/shared.js +4 -2
- package/dist/services/shared.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +4 -4
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +2 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +3 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
- package/dist/services/trailing-oneof-inputs.js +3 -1
- package/dist/services/trailing-oneof-inputs.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.js +3 -3
- package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
- package/dist/shared/decimal-surface.d.ts.map +1 -1
- package/dist/shared/decimal-surface.js.map +1 -1
- package/dist/shared/schemas.js +4 -4
- package/dist/shared/schemas.js.map +1 -1
- package/dist/utils/numbers.js +1 -10
- package/dist/utils/numbers.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders-risk.schemas.js","names":["ProtoWrite.RiskMarketIocSchema","ProtoWrite.RiskLimitGtcSchema","ProtoRead.AttachedRiskLegState_Status"],"sources":["../../../src/services/orders/orders-risk.schemas.ts"],"sourcesContent":["import * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport * as ProtoRead from \"../../gen/orders/v1/orders_read_pb.js\";\nimport { create } from \"@bufbuild/protobuf\";\nimport * as v from \"valibot\";\nimport {\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n PriceDistanceInputSchema,\n PriceSlippageInputSchema,\n} from \"../shared.js\";\nimport {\n positiveDecimalInputToScaled,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport { parseSlippageInput, parseTrailingDistanceInput } from \"../trailing-oneof-inputs.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { AttachedRiskLegStatusCodec } from \"./orders.codecs.js\";\n\nconst DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nfunction attachedTriggerInputSchema(scales: SdkScales, fieldPrefix: \"takeProfit\" | \"stopLoss\") {\n return v.pipe(\n v.strictObject({\n triggerPrice: DecimalInputStringSchema,\n execution: v.variant(\"type\", [\n v.strictObject({\n type: v.literal(\"market_ioc\"),\n }),\n v.strictObject({\n type: v.literal(\"limit_gtc\"),\n price: DecimalInputStringSchema,\n }),\n ]),\n }),\n v.transform((input) => {\n const execution: ProtoWrite.RiskExecution[\"execution\"] =\n input.execution.type === \"market_ioc\"\n ? {\n case: \"marketIoc\",\n value: create(ProtoWrite.RiskMarketIocSchema),\n }\n : {\n case: \"limitGtc\",\n value: create(ProtoWrite.RiskLimitGtcSchema, {\n priceTicks: positiveDecimalInputToScaled(\n `${fieldPrefix}.execution.price`,\n input.execution.price,\n scales.price(),\n ),\n }),\n };\n return {\n triggerPriceTicks: positiveDecimalInputToScaled(\n `${fieldPrefix}.triggerPrice`,\n input.triggerPrice,\n scales.price(),\n ),\n child: { execution },\n };\n }),\n );\n}\n\nconst TrailingDistanceSchema = v.union([PriceDistanceInputSchema, BpsStringOrNumberInputSchema]);\n\nconst MaxSlippageSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nexport const MarketMaxSlippageSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nconst MAX_BPS = 10_000;\nconst UNSET_TRAILING_STOP_MAX_SLIPPAGE: ProtoWrite.TrailingStopPolicy[\"maxSlippage\"] = {\n case: undefined,\n value: undefined,\n};\n\nfunction parseTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof TrailingDistanceSchema>,\n): ProtoWrite.TrailingStopPolicy[\"trailingDistance\"] {\n return parseTrailingDistanceInput(scales, distance, \"trailingStop.trailingDistance\");\n}\n\nfunction parseMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageSchema>,\n): ProtoWrite.TrailingStopPolicy[\"maxSlippage\"] {\n return parseSlippageInput(scales, slippage, {\n fieldName: \"trailingStop.maxSlippage\",\n ticksCase: \"maxSlippageTicks\",\n bpsCase: \"maxSlippageBps\",\n maxBps: MAX_BPS,\n });\n}\n\nexport function parseMarketMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MarketMaxSlippageSchema> | undefined,\n): ProtoWrite.MarketIoc[\"maxSlippage\"] {\n return parseSlippageInput(scales, slippage, {\n fieldName: \"execution.maxSlippage\",\n ticksCase: \"maxSlippageTicks\",\n bpsCase: \"maxSlippageBps\",\n maxBps: MAX_BPS,\n });\n}\n\nfunction createTrailingStopInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n trailingDistance: TrailingDistanceSchema,\n maxSlippage: v.optional(MaxSlippageSchema),\n activationPrice: v.optional(DecimalInputStringSchema),\n }),\n v.transform((input) => ({\n trailingDistance: parseTrailingDistance(scales, input.trailingDistance),\n maxSlippage: input.maxSlippage\n ? parseMaxSlippage(scales, input.maxSlippage)\n : UNSET_TRAILING_STOP_MAX_SLIPPAGE,\n activationPriceTicks:\n input.activationPrice === undefined\n ? 0n\n : positiveDecimalInputToScaled(\n \"trailingStop.activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n })),\n );\n}\n\nfunction createRiskPolicyObjectInputSchema(scales: SdkScales) {\n const TakeProfitInputSchema = attachedTriggerInputSchema(scales, \"takeProfit\");\n const StopLossInputSchema = attachedTriggerInputSchema(scales, \"stopLoss\");\n const TrailingStopInputSchema = createTrailingStopInputSchema(scales);\n const InactiveOcoInputSchema = v.optional(\n v.literal(false, \"oco requires takeProfit and exactly one stop leg\"),\n );\n return v.union([\n v.strictObject({\n takeProfit: TakeProfitInputSchema,\n stopLoss: StopLossInputSchema,\n trailingStop: v.optional(v.never()),\n oco: v.optional(v.boolean()),\n }),\n v.strictObject({\n takeProfit: TakeProfitInputSchema,\n stopLoss: v.optional(v.never()),\n trailingStop: TrailingStopInputSchema,\n oco: v.optional(v.boolean()),\n }),\n v.strictObject({\n takeProfit: TakeProfitInputSchema,\n stopLoss: v.optional(v.never()),\n trailingStop: v.optional(v.never()),\n oco: InactiveOcoInputSchema,\n }),\n v.strictObject({\n takeProfit: v.optional(v.never()),\n stopLoss: StopLossInputSchema,\n trailingStop: v.optional(v.never()),\n oco: InactiveOcoInputSchema,\n }),\n v.strictObject({\n takeProfit: v.optional(v.never()),\n stopLoss: v.optional(v.never()),\n trailingStop: TrailingStopInputSchema,\n oco: InactiveOcoInputSchema,\n }),\n ]);\n}\n\ntype RiskPolicyObjectInput = v.InferOutput<ReturnType<typeof createRiskPolicyObjectInputSchema>>;\n\nfunction transformRiskPolicyInput(input: RiskPolicyObjectInput) {\n const stopLeg = input.stopLoss\n ? ({ case: \"stopLoss\", value: input.stopLoss } as const)\n : input.trailingStop\n ? ({ case: \"trailingStop\", value: input.trailingStop } as const)\n : ({ case: undefined, value: undefined } as const);\n return {\n takeProfit: input.takeProfit,\n stopLeg,\n oco: input.oco ?? false,\n };\n}\n\nexport function createRiskPolicyInputSchema(scales: SdkScales) {\n return v.pipe(\n v.optional(createRiskPolicyObjectInputSchema(scales)),\n v.transform((input) => (input ? transformRiskPolicyInput(input) : undefined)),\n );\n}\n\nexport function createRequiredRiskPolicyInputSchema(scales: SdkScales) {\n return v.pipe(\n createRiskPolicyObjectInputSchema(scales),\n v.transform((input) => transformRiskPolicyInput(input)),\n );\n}\n\nexport type TakeProfitInput = v.InferInput<ReturnType<typeof attachedTriggerInputSchema>>;\nexport type StopLossInput = v.InferInput<ReturnType<typeof attachedTriggerInputSchema>>;\nexport type TrailingStopInput = v.InferInput<ReturnType<typeof createTrailingStopInputSchema>>;\nexport type RiskPolicyInput = v.InferInput<ReturnType<typeof createRiskPolicyInputSchema>>;\n\ntype TrailingDistance =\n | { kind: \"distance\"; distance: string }\n | { kind: \"bps\"; bps: number }\n | { kind: \"none\" };\ntype TrailingMaxSlippage = { kind: \"slippage\"; slippage: string } | { kind: \"bps\"; bps: number };\nexport type MarketMaxSlippage =\n | { kind: \"slippage\"; slippage: string }\n | { kind: \"bps\"; bps: number };\n\nconst ReadRiskExecutionSchema = v.object({\n execution: 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 }),\n }),\n ]),\n});\n\nconst ReadTakeProfitPolicySchema = v.object({\n triggerPriceTicks: v.bigint(),\n child: ReadRiskExecutionSchema,\n});\n\nconst ReadStopLossPolicySchema = v.object({\n triggerPriceTicks: v.bigint(),\n child: ReadRiskExecutionSchema,\n});\n\nconst ReadTrailingStopPolicySchema = v.object({\n trailingDistance: v.object({\n case: v.optional(\n v.union([\n v.literal(\"trailingDistanceTicks\"),\n v.literal(\"trailingDistanceBps\"),\n v.undefined(),\n ]),\n ),\n value: v.optional(v.union([v.bigint(), v.number(), v.undefined()])),\n }),\n maxSlippage: v.object({\n case: v.union([v.literal(\"maxSlippageTicks\"), v.literal(\"maxSlippageBps\"), v.undefined()]),\n value: v.optional(v.union([v.number(), v.undefined()])),\n }),\n activationPriceTicks: v.bigint(),\n});\n\nconst ReadAttachedRiskLegStateSchema = v.object({\n status: v.enum(ProtoRead.AttachedRiskLegState_Status),\n armedTsNs: v.bigint(),\n terminalTsNs: v.bigint(),\n triggerId: v.optional(v.bigint()),\n childOrderId: v.optional(v.bigint()),\n});\n\nconst ReadAttachedRiskTakeProfitSchema = v.object({\n policy: v.optional(ReadTakeProfitPolicySchema),\n state: v.optional(ReadAttachedRiskLegStateSchema),\n});\n\nconst ReadAttachedRiskStopLossSchema = v.object({\n policy: v.optional(ReadStopLossPolicySchema),\n state: v.optional(ReadAttachedRiskLegStateSchema),\n});\n\nconst ReadAttachedRiskTrailingStopSchema = v.object({\n policy: v.optional(ReadTrailingStopPolicySchema),\n state: v.optional(ReadAttachedRiskLegStateSchema),\n});\n\nexport const ReadAttachedRiskSchema = v.object({\n takeProfit: v.optional(ReadAttachedRiskTakeProfitSchema),\n stopLoss: v.optional(ReadAttachedRiskStopLossSchema),\n trailingStop: v.optional(ReadAttachedRiskTrailingStopSchema),\n oco: v.optional(v.boolean(), false),\n});\n\nfunction formatRiskExecution(\n scales: SdkScales,\n child: v.InferOutput<typeof ReadRiskExecutionSchema>,\n) {\n if (child.execution.case === \"marketIoc\") {\n return { type: \"market_ioc\" } as const;\n }\n return {\n type: \"limit_gtc\",\n price: scaledToDecimalOutput(child.execution.value.priceTicks, scales.price()),\n } as const;\n}\n\nfunction formatRiskLeg(\n scales: SdkScales,\n leg:\n | v.InferOutput<typeof ReadTakeProfitPolicySchema>\n | v.InferOutput<typeof ReadStopLossPolicySchema>,\n) {\n return {\n triggerPrice: scaledToDecimalOutput(leg.triggerPriceTicks, scales.price()),\n execution: formatRiskExecution(scales, leg.child),\n };\n}\n\nfunction formatRiskLegState(state: v.InferOutput<typeof ReadAttachedRiskLegStateSchema>) {\n return {\n status: requiredEnumLabel(\n AttachedRiskLegStatusCodec.protoToOutput,\n state.status,\n \"AttachedRiskLegStateSchema\",\n \"status\",\n ),\n armedTs: state.armedTsNs > 0n ? tsNsToMs(state.armedTsNs) : undefined,\n armedTsNs: state.armedTsNs > 0n ? state.armedTsNs.toString() : undefined,\n terminalTs: state.terminalTsNs > 0n ? tsNsToMs(state.terminalTsNs) : undefined,\n terminalTsNs: state.terminalTsNs > 0n ? state.terminalTsNs.toString() : undefined,\n triggerId:\n state.triggerId !== undefined && state.triggerId > 0n\n ? formatId(state.triggerId)\n : undefined,\n childOrderId:\n state.childOrderId !== undefined && state.childOrderId > 0n\n ? formatId(state.childOrderId)\n : undefined,\n };\n}\n\nfunction formatTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof ReadTrailingStopPolicySchema>[\"trailingDistance\"],\n): TrailingDistance {\n if (distance.case === \"trailingDistanceTicks\" && typeof distance.value === \"bigint\") {\n return {\n kind: \"distance\",\n distance: scaledToDecimalOutput(distance.value, scales.price()),\n };\n }\n if (distance.case === \"trailingDistanceBps\" && typeof distance.value === \"number\") {\n return { kind: \"bps\", bps: distance.value };\n }\n return { kind: \"none\" };\n}\n\nfunction formatTrailingMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof ReadTrailingStopPolicySchema>[\"maxSlippage\"],\n): TrailingMaxSlippage | undefined {\n if (slippage.case === \"maxSlippageTicks\" && typeof slippage.value === \"number\") {\n return {\n kind: \"slippage\",\n slippage: scaledToDecimalOutput(BigInt(slippage.value), scales.price()),\n };\n }\n if (slippage.case === \"maxSlippageBps\" && typeof slippage.value === \"number\") {\n return { kind: \"bps\", bps: slippage.value };\n }\n return undefined;\n}\n\nexport function formatMarketMaxSlippage(\n scales: SdkScales,\n ticks: number,\n bps: number,\n): MarketMaxSlippage | undefined {\n if (ticks > 0) {\n return { kind: \"slippage\", slippage: scaledToDecimalOutput(BigInt(ticks), scales.price()) };\n }\n if (bps > 0) {\n return { kind: \"bps\", bps };\n }\n return undefined;\n}\n\nexport function formatAttachedRisk(\n scales: SdkScales,\n risk: v.InferOutput<typeof ReadAttachedRiskSchema> | undefined,\n) {\n if (!risk) return undefined;\n\n const takeProfit =\n risk.takeProfit?.policy || risk.takeProfit?.state\n ? {\n ...(risk.takeProfit.policy\n ? formatRiskLeg(scales, risk.takeProfit.policy)\n : undefined),\n state: risk.takeProfit.state\n ? formatRiskLegState(risk.takeProfit.state)\n : undefined,\n }\n : undefined;\n const stopLoss =\n risk.stopLoss?.policy || risk.stopLoss?.state\n ? {\n ...(risk.stopLoss.policy\n ? formatRiskLeg(scales, risk.stopLoss.policy)\n : undefined),\n state: risk.stopLoss.state ? formatRiskLegState(risk.stopLoss.state) : undefined,\n }\n : undefined;\n const trailingStop =\n risk.trailingStop?.policy || risk.trailingStop?.state\n ? {\n ...(risk.trailingStop.policy\n ? {\n trailingDistance: formatTrailingDistance(\n scales,\n risk.trailingStop.policy.trailingDistance,\n ),\n maxSlippage: formatTrailingMaxSlippage(\n scales,\n risk.trailingStop.policy.maxSlippage,\n ),\n activationPrice:\n risk.trailingStop.policy.activationPriceTicks > 0n\n ? scaledToDecimalOutput(\n risk.trailingStop.policy.activationPriceTicks,\n scales.price(),\n )\n : undefined,\n }\n : undefined),\n state: risk.trailingStop.state\n ? formatRiskLegState(risk.trailingStop.state)\n : undefined,\n }\n : undefined;\n\n if (!takeProfit && !stopLoss && !trailingStop) return undefined;\n\n return {\n takeProfit,\n stopLoss,\n trailingStop,\n oco: risk.oco,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,2BAA2B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAE5E,SAAS,2BAA2B,QAAmB,aAAwC;CAC3F,OAAO,EAAE,KACL,EAAE,aAAa;EACX,cAAc;EACd,WAAW,EAAE,QAAQ,QAAQ,CACzB,EAAE,aAAa,EACX,MAAM,EAAE,QAAQ,YAAY,EAChC,CAAC,GACD,EAAE,aAAa;GACX,MAAM,EAAE,QAAQ,WAAW;GAC3B,OAAO;EACX,CAAC,CACL,CAAC;CACL,CAAC,GACD,EAAE,WAAW,UAAU;EACnB,MAAM,YACF,MAAM,UAAU,SAAS,eACnB;GACI,MAAM;GACN,OAAO,OAAOA,mBAA8B;EAChD,IACA;GACI,MAAM;GACN,OAAO,OAAOC,oBAA+B,EACzC,YAAY,6BACR,GAAG,YAAY,mBACf,MAAM,UAAU,OAChB,OAAO,MAAM,CACjB,EACJ,CAAC;EACL;EACV,OAAO;GACH,mBAAmB,6BACf,GAAG,YAAY,gBACf,MAAM,cACN,OAAO,MAAM,CACjB;GACA,OAAO,EAAE,UAAU;EACvB;CACJ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ACA,KAAA;CACV,MAAM,WACF,KAAK,UAAU,UAAU,KAAK,UAAU,QAClC;EACI,GAAI,KAAK,SAAS,SACZ,cAAc,QAAQ,KAAK,SAAS,MAAM,IAC1C,KAAA;EACN,OAAO,KAAK,SAAS,QAAQ,mBAAmB,KAAK,SAAS,KAAK,IAAI,KAAA;CAC3E,IACA,KAAA;CACV,MAAM,eACF,KAAK,cAAc,UAAU,KAAK,cAAc,QAC1C;EACI,GAAI,KAAK,aAAa,SAChB;GACI,kBAAkB,uBACd,QACA,KAAK,aAAa,OAAO,gBAC7B;GACA,aAAa,0BACT,QACA,KAAK,aAAa,OAAO,WAC7B;GACA,iBACI,KAAK,aAAa,OAAO,uBAAuB,KAC1C,sBACI,KAAK,aAAa,OAAO,sBACzB,OAAO,MAAM,CACjB,IACA,KAAA;EACd,IACA,KAAA;EACN,OAAO,KAAK,aAAa,QACnB,mBAAmB,KAAK,aAAa,KAAK,IAC1C,KAAA;CACV,IACA,KAAA;CAEV,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,cAAc,OAAO,KAAA;CAEtD,OAAO;EACH;EACA;EACA;EACA,KAAK,KAAK;CACd;AACJ"}
|
|
1
|
+
{"version":3,"file":"orders-risk.schemas.js","names":["ProtoWrite.RiskMarketIocSchema","ProtoWrite.RiskLimitGtcSchema","ProtoRead.AttachedRiskLegState_Status"],"sources":["../../../src/services/orders/orders-risk.schemas.ts"],"sourcesContent":["import * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport * as ProtoRead from \"../../gen/orders/v1/orders_read_pb.js\";\nimport { create } from \"@bufbuild/protobuf\";\nimport * as v from \"valibot\";\nimport {\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n PriceDistanceInputSchema,\n PriceSlippageInputSchema,\n} from \"../shared.js\";\nimport {\n positiveDecimalInputToScaled,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n MAX_SLIPPAGE_BPS,\n parseSlippageInput,\n parseTrailingDistanceInput,\n} from \"../trailing-oneof-inputs.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { AttachedRiskLegStatusCodec } from \"./orders.codecs.js\";\n\nconst DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nfunction attachedTriggerInputSchema(scales: SdkScales, fieldPrefix: \"takeProfit\" | \"stopLoss\") {\n return v.pipe(\n v.strictObject({\n triggerPrice: DecimalInputStringSchema,\n execution: v.variant(\"type\", [\n v.strictObject({\n type: v.literal(\"market_ioc\"),\n }),\n v.strictObject({\n type: v.literal(\"limit_gtc\"),\n price: DecimalInputStringSchema,\n }),\n ]),\n }),\n v.transform((input) => {\n const execution: ProtoWrite.RiskExecution[\"execution\"] =\n input.execution.type === \"market_ioc\"\n ? {\n case: \"marketIoc\",\n value: create(ProtoWrite.RiskMarketIocSchema),\n }\n : {\n case: \"limitGtc\",\n value: create(ProtoWrite.RiskLimitGtcSchema, {\n priceTicks: positiveDecimalInputToScaled(\n `${fieldPrefix}.execution.price`,\n input.execution.price,\n scales.price(),\n ),\n }),\n };\n return {\n triggerPriceTicks: positiveDecimalInputToScaled(\n `${fieldPrefix}.triggerPrice`,\n input.triggerPrice,\n scales.price(),\n ),\n child: { execution },\n };\n }),\n );\n}\n\nconst TrailingDistanceSchema = v.union([PriceDistanceInputSchema, BpsStringOrNumberInputSchema]);\n\nconst MaxSlippageSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nexport const MarketMaxSlippageSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nconst UNSET_TRAILING_STOP_MAX_SLIPPAGE: ProtoWrite.TrailingStopPolicy[\"maxSlippage\"] = {\n case: undefined,\n value: undefined,\n};\n\nfunction parseTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof TrailingDistanceSchema>,\n): ProtoWrite.TrailingStopPolicy[\"trailingDistance\"] {\n return parseTrailingDistanceInput(scales, distance, \"trailingStop.trailingDistance\");\n}\n\nfunction parseMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageSchema>,\n): ProtoWrite.TrailingStopPolicy[\"maxSlippage\"] {\n return parseSlippageInput(scales, slippage, {\n fieldName: \"trailingStop.maxSlippage\",\n ticksCase: \"maxSlippageTicks\",\n bpsCase: \"maxSlippageBps\",\n maxBps: MAX_SLIPPAGE_BPS,\n });\n}\n\nexport function parseMarketMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MarketMaxSlippageSchema> | undefined,\n): ProtoWrite.MarketIoc[\"maxSlippage\"] {\n return parseSlippageInput(scales, slippage, {\n fieldName: \"execution.maxSlippage\",\n ticksCase: \"maxSlippageTicks\",\n bpsCase: \"maxSlippageBps\",\n maxBps: MAX_SLIPPAGE_BPS,\n });\n}\n\nfunction createTrailingStopInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n trailingDistance: TrailingDistanceSchema,\n maxSlippage: v.optional(MaxSlippageSchema),\n activationPrice: v.optional(DecimalInputStringSchema),\n }),\n v.transform((input) => ({\n trailingDistance: parseTrailingDistance(scales, input.trailingDistance),\n maxSlippage: input.maxSlippage\n ? parseMaxSlippage(scales, input.maxSlippage)\n : UNSET_TRAILING_STOP_MAX_SLIPPAGE,\n activationPriceTicks:\n input.activationPrice === undefined\n ? 0n\n : positiveDecimalInputToScaled(\n \"trailingStop.activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n })),\n );\n}\n\nfunction createRiskPolicyObjectInputSchema(scales: SdkScales) {\n const TakeProfitInputSchema = attachedTriggerInputSchema(scales, \"takeProfit\");\n const StopLossInputSchema = attachedTriggerInputSchema(scales, \"stopLoss\");\n const TrailingStopInputSchema = createTrailingStopInputSchema(scales);\n const InactiveOcoInputSchema = v.optional(\n v.literal(false, \"oco requires takeProfit and exactly one stop leg\"),\n );\n return v.union([\n v.strictObject({\n takeProfit: TakeProfitInputSchema,\n stopLoss: StopLossInputSchema,\n trailingStop: v.optional(v.never()),\n oco: v.optional(v.boolean()),\n }),\n v.strictObject({\n takeProfit: TakeProfitInputSchema,\n stopLoss: v.optional(v.never()),\n trailingStop: TrailingStopInputSchema,\n oco: v.optional(v.boolean()),\n }),\n v.strictObject({\n takeProfit: TakeProfitInputSchema,\n stopLoss: v.optional(v.never()),\n trailingStop: v.optional(v.never()),\n oco: InactiveOcoInputSchema,\n }),\n v.strictObject({\n takeProfit: v.optional(v.never()),\n stopLoss: StopLossInputSchema,\n trailingStop: v.optional(v.never()),\n oco: InactiveOcoInputSchema,\n }),\n v.strictObject({\n takeProfit: v.optional(v.never()),\n stopLoss: v.optional(v.never()),\n trailingStop: TrailingStopInputSchema,\n oco: InactiveOcoInputSchema,\n }),\n ]);\n}\n\ntype RiskPolicyObjectInput = v.InferOutput<ReturnType<typeof createRiskPolicyObjectInputSchema>>;\n\nfunction transformRiskPolicyInput(input: RiskPolicyObjectInput) {\n const stopLeg = input.stopLoss\n ? ({ case: \"stopLoss\", value: input.stopLoss } as const)\n : input.trailingStop\n ? ({ case: \"trailingStop\", value: input.trailingStop } as const)\n : ({ case: undefined, value: undefined } as const);\n return {\n takeProfit: input.takeProfit,\n stopLeg,\n oco: input.oco ?? false,\n };\n}\n\nexport function createRiskPolicyInputSchema(scales: SdkScales) {\n return v.pipe(\n v.optional(createRiskPolicyObjectInputSchema(scales)),\n v.transform((input) => (input ? transformRiskPolicyInput(input) : undefined)),\n );\n}\n\nexport function createRequiredRiskPolicyInputSchema(scales: SdkScales) {\n return v.pipe(\n createRiskPolicyObjectInputSchema(scales),\n v.transform((input) => transformRiskPolicyInput(input)),\n );\n}\n\nexport type TakeProfitInput = v.InferInput<ReturnType<typeof attachedTriggerInputSchema>>;\nexport type StopLossInput = v.InferInput<ReturnType<typeof attachedTriggerInputSchema>>;\nexport type TrailingStopInput = v.InferInput<ReturnType<typeof createTrailingStopInputSchema>>;\nexport type RiskPolicyInput = v.InferInput<ReturnType<typeof createRiskPolicyInputSchema>>;\n\ntype TrailingDistance =\n | { kind: \"distance\"; distance: string }\n | { kind: \"bps\"; bps: number }\n | { kind: \"none\" };\ntype TrailingMaxSlippage = { kind: \"slippage\"; slippage: string } | { kind: \"bps\"; bps: number };\nexport type MarketMaxSlippage =\n | { kind: \"slippage\"; slippage: string }\n | { kind: \"bps\"; bps: number };\n\nconst ReadRiskExecutionSchema = v.object({\n execution: 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 }),\n }),\n ]),\n});\n\nconst ReadTakeProfitPolicySchema = v.object({\n triggerPriceTicks: v.bigint(),\n child: ReadRiskExecutionSchema,\n});\n\nconst ReadStopLossPolicySchema = v.object({\n triggerPriceTicks: v.bigint(),\n child: ReadRiskExecutionSchema,\n});\n\nconst ReadTrailingStopPolicySchema = v.object({\n trailingDistance: v.object({\n case: v.optional(\n v.union([\n v.literal(\"trailingDistanceTicks\"),\n v.literal(\"trailingDistanceBps\"),\n v.undefined(),\n ]),\n ),\n value: v.optional(v.union([v.bigint(), v.number(), v.undefined()])),\n }),\n maxSlippage: v.object({\n case: v.union([v.literal(\"maxSlippageTicks\"), v.literal(\"maxSlippageBps\"), v.undefined()]),\n value: v.optional(v.union([v.number(), v.undefined()])),\n }),\n activationPriceTicks: v.bigint(),\n});\n\nconst ReadAttachedRiskLegStateSchema = v.object({\n status: v.enum(ProtoRead.AttachedRiskLegState_Status),\n armedTsNs: v.bigint(),\n terminalTsNs: v.bigint(),\n triggerId: v.optional(v.bigint()),\n childOrderId: v.optional(v.bigint()),\n});\n\nconst ReadAttachedRiskTakeProfitSchema = v.object({\n policy: v.optional(ReadTakeProfitPolicySchema),\n state: v.optional(ReadAttachedRiskLegStateSchema),\n});\n\nconst ReadAttachedRiskStopLossSchema = v.object({\n policy: v.optional(ReadStopLossPolicySchema),\n state: v.optional(ReadAttachedRiskLegStateSchema),\n});\n\nconst ReadAttachedRiskTrailingStopSchema = v.object({\n policy: v.optional(ReadTrailingStopPolicySchema),\n state: v.optional(ReadAttachedRiskLegStateSchema),\n});\n\nexport const ReadAttachedRiskSchema = v.object({\n takeProfit: v.optional(ReadAttachedRiskTakeProfitSchema),\n stopLoss: v.optional(ReadAttachedRiskStopLossSchema),\n trailingStop: v.optional(ReadAttachedRiskTrailingStopSchema),\n oco: v.optional(v.boolean(), false),\n});\n\nfunction formatRiskExecution(\n scales: SdkScales,\n child: v.InferOutput<typeof ReadRiskExecutionSchema>,\n) {\n if (child.execution.case === \"marketIoc\") {\n return { type: \"market_ioc\" } as const;\n }\n return {\n type: \"limit_gtc\",\n price: scaledToDecimalOutput(child.execution.value.priceTicks, scales.price()),\n } as const;\n}\n\nfunction formatRiskLeg(\n scales: SdkScales,\n leg:\n | v.InferOutput<typeof ReadTakeProfitPolicySchema>\n | v.InferOutput<typeof ReadStopLossPolicySchema>,\n) {\n return {\n triggerPrice: scaledToDecimalOutput(leg.triggerPriceTicks, scales.price()),\n execution: formatRiskExecution(scales, leg.child),\n };\n}\n\nfunction formatRiskLegState(state: v.InferOutput<typeof ReadAttachedRiskLegStateSchema>) {\n return {\n status: requiredEnumLabel(\n AttachedRiskLegStatusCodec.protoToOutput,\n state.status,\n \"AttachedRiskLegStateSchema\",\n \"status\",\n ),\n armedTs: state.armedTsNs > 0n ? tsNsToMs(state.armedTsNs) : undefined,\n armedTsNs: state.armedTsNs > 0n ? state.armedTsNs.toString() : undefined,\n terminalTs: state.terminalTsNs > 0n ? tsNsToMs(state.terminalTsNs) : undefined,\n terminalTsNs: state.terminalTsNs > 0n ? state.terminalTsNs.toString() : undefined,\n triggerId:\n state.triggerId !== undefined && state.triggerId > 0n\n ? formatId(state.triggerId)\n : undefined,\n childOrderId:\n state.childOrderId !== undefined && state.childOrderId > 0n\n ? formatId(state.childOrderId)\n : undefined,\n };\n}\n\nfunction formatTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof ReadTrailingStopPolicySchema>[\"trailingDistance\"],\n): TrailingDistance {\n if (distance.case === \"trailingDistanceTicks\" && typeof distance.value === \"bigint\") {\n return {\n kind: \"distance\",\n distance: scaledToDecimalOutput(distance.value, scales.price()),\n };\n }\n if (distance.case === \"trailingDistanceBps\" && typeof distance.value === \"number\") {\n return { kind: \"bps\", bps: distance.value };\n }\n return { kind: \"none\" };\n}\n\nfunction formatTrailingMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof ReadTrailingStopPolicySchema>[\"maxSlippage\"],\n): TrailingMaxSlippage | undefined {\n if (slippage.case === \"maxSlippageTicks\" && typeof slippage.value === \"number\") {\n return {\n kind: \"slippage\",\n slippage: scaledToDecimalOutput(BigInt(slippage.value), scales.price()),\n };\n }\n if (slippage.case === \"maxSlippageBps\" && typeof slippage.value === \"number\") {\n return { kind: \"bps\", bps: slippage.value };\n }\n return undefined;\n}\n\nexport function formatMarketMaxSlippage(\n scales: SdkScales,\n ticks: number,\n bps: number,\n): MarketMaxSlippage | undefined {\n if (ticks > 0) {\n return { kind: \"slippage\", slippage: scaledToDecimalOutput(BigInt(ticks), scales.price()) };\n }\n if (bps > 0) {\n return { kind: \"bps\", bps };\n }\n return undefined;\n}\n\nexport function formatAttachedRisk(\n scales: SdkScales,\n risk: v.InferOutput<typeof ReadAttachedRiskSchema> | undefined,\n) {\n if (!risk) return undefined;\n\n const takeProfit =\n risk.takeProfit?.policy || risk.takeProfit?.state\n ? {\n ...(risk.takeProfit.policy\n ? formatRiskLeg(scales, risk.takeProfit.policy)\n : undefined),\n state: risk.takeProfit.state\n ? formatRiskLegState(risk.takeProfit.state)\n : undefined,\n }\n : undefined;\n const stopLoss =\n risk.stopLoss?.policy || risk.stopLoss?.state\n ? {\n ...(risk.stopLoss.policy\n ? formatRiskLeg(scales, risk.stopLoss.policy)\n : undefined),\n state: risk.stopLoss.state ? formatRiskLegState(risk.stopLoss.state) : undefined,\n }\n : undefined;\n const trailingStop =\n risk.trailingStop?.policy || risk.trailingStop?.state\n ? {\n ...(risk.trailingStop.policy\n ? {\n trailingDistance: formatTrailingDistance(\n scales,\n risk.trailingStop.policy.trailingDistance,\n ),\n maxSlippage: formatTrailingMaxSlippage(\n scales,\n risk.trailingStop.policy.maxSlippage,\n ),\n activationPrice:\n risk.trailingStop.policy.activationPriceTicks > 0n\n ? scaledToDecimalOutput(\n risk.trailingStop.policy.activationPriceTicks,\n scales.price(),\n )\n : undefined,\n }\n : undefined),\n state: risk.trailingStop.state\n ? formatRiskLegState(risk.trailingStop.state)\n : undefined,\n }\n : undefined;\n\n if (!takeProfit && !stopLoss && !trailingStop) return undefined;\n\n return {\n takeProfit,\n stopLoss,\n trailingStop,\n oco: risk.oco,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,2BAA2B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAE5E,SAAS,2BAA2B,QAAmB,aAAwC;CAC3F,OAAO,EAAE,KACL,EAAE,aAAa;EACX,cAAc;EACd,WAAW,EAAE,QAAQ,QAAQ,CACzB,EAAE,aAAa,EACX,MAAM,EAAE,QAAQ,YAAY,EAChC,CAAC,GACD,EAAE,aAAa;GACX,MAAM,EAAE,QAAQ,WAAW;GAC3B,OAAO;EACX,CAAC,CACL,CAAC;CACL,CAAC,GACD,EAAE,WAAW,UAAU;EACnB,MAAM,YACF,MAAM,UAAU,SAAS,eACnB;GACI,MAAM;GACN,OAAO,OAAOA,mBAA8B;EAChD,IACA;GACI,MAAM;GACN,OAAO,OAAOC,oBAA+B,EACzC,YAAY,6BACR,GAAG,YAAY,mBACf,MAAM,UAAU,OAChB,OAAO,MAAM,CACjB,EACJ,CAAC;EACL;EACV,OAAO;GACH,mBAAmB,6BACf,GAAG,YAAY,gBACf,MAAM,cACN,O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K,WAAW,KAAK,IACxC,KAAA;CACV,IACA,KAAA;CACV,MAAM,WACF,KAAK,UAAU,UAAU,KAAK,UAAU,QAClC;EACI,GAAI,KAAK,SAAS,SACZ,cAAc,QAAQ,KAAK,SAAS,MAAM,IAC1C,KAAA;EACN,OAAO,KAAK,SAAS,QAAQ,mBAAmB,KAAK,SAAS,KAAK,IAAI,KAAA;CAC3E,IACA,KAAA;CACV,MAAM,eACF,KAAK,cAAc,UAAU,KAAK,cAAc,QAC1C;EACI,GAAI,KAAK,aAAa,SAChB;GACI,kBAAkB,uBACd,QACA,KAAK,aAAa,OAAO,gBAC7B;GACA,aAAa,0BACT,QACA,KAAK,aAAa,OAAO,WAC7B;GACA,iBACI,KAAK,aAAa,OAAO,uBAAuB,KAC1C,sBACI,KAAK,aAAa,OAAO,sBACzB,OAAO,MAAM,CACjB,IACA,KAAA;EACd,IACA,KAAA;EACN,OAAO,KAAK,aAAa,QACnB,mBAAmB,KAAK,aAAa,KAAK,IAC1C,KAAA;CACV,IACA,KAAA;CAEV,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,cAAc,OAAO,KAAA;CAEtD,OAAO;EACH;EACA;EACA;EACA,KAAK,KAAK;CACd;AACJ"}
|
|
@@ -41,7 +41,7 @@ declare const SubaccountPolicySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
41
41
|
readonly actions: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.EnumSchema<typeof PolicyAction, undefined>, undefined>, readonly []>, v.TransformAction<v.EnumValues<typeof PolicyAction>[], DecodedEnum<"trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book">[]>]>;
|
|
42
42
|
readonly isTemplate: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
43
43
|
readonly sourceTemplateId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
|
|
44
|
-
readonly maxOrderNotional: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint,
|
|
44
|
+
readonly maxOrderNotional: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
45
45
|
readonly maxOpenOrders: v.NumberSchema<undefined>;
|
|
46
46
|
readonly tradingHalted: v.BooleanSchema<undefined>;
|
|
47
47
|
readonly locked: v.BooleanSchema<undefined>;
|
|
@@ -82,7 +82,7 @@ declare const SubaccountPolicySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
82
82
|
actions: DecodedEnum<"trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book">[];
|
|
83
83
|
isTemplate: boolean;
|
|
84
84
|
sourceTemplateId?: string | undefined;
|
|
85
|
-
maxOrderNotional:
|
|
85
|
+
maxOrderNotional: string;
|
|
86
86
|
maxOpenOrders: number;
|
|
87
87
|
tradingHalted: boolean;
|
|
88
88
|
locked: boolean;
|
|
@@ -114,7 +114,7 @@ declare const SubaccountPolicySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
114
114
|
expiresAt?: number | undefined;
|
|
115
115
|
createdAt: number;
|
|
116
116
|
revision: string;
|
|
117
|
-
maxOrderSize:
|
|
117
|
+
maxOrderSize: string;
|
|
118
118
|
}>]>;
|
|
119
119
|
type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;
|
|
120
120
|
declare const CreateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
@@ -125,8 +125,8 @@ declare const CreateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
125
125
|
}, undefined>, undefined>, readonly []>;
|
|
126
126
|
readonly spotMarketScope: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["all", "allowlist"], undefined>, v.TransformAction<"all" | "allowlist", MarketScope_Value.ALL | MarketScope_Value.ALLOWLIST>]>;
|
|
127
127
|
readonly actions: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["trade-spot", "internal-transfer", "external-withdraw", "read-balances", "read-spot", "read-internal-transfers", "read-address-book", "manage-address-book"], undefined>, undefined>, readonly []>, v.TransformAction<("trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book")[], (PolicyAction.TRADE_SPOT | PolicyAction.INTERNAL_TRANSFER | PolicyAction.EXTERNAL_WITHDRAW | PolicyAction.READ_BALANCES | PolicyAction.READ_SPOT | PolicyAction.READ_INTERNAL_TRANSFERS | PolicyAction.READ_ADDRESS_BOOK | PolicyAction.MANAGE_ADDRESS_BOOK)[]>]>;
|
|
128
|
-
readonly maxOrderSize: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.
|
|
129
|
-
readonly maxOpenOrders: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, null>, v.TransformAction<number | null, number>]>;
|
|
128
|
+
readonly maxOrderSize: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, bigint>]>, undefined>, null>, v.TransformAction<bigint | null, bigint>]>;
|
|
129
|
+
readonly maxOpenOrders: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, null>, v.TransformAction<number | null, number>]>;
|
|
130
130
|
readonly tradingHalted: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
131
131
|
readonly policyLocked: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
132
132
|
readonly reviewAt: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>, undefined>;
|
|
@@ -176,8 +176,8 @@ declare const UpdateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
176
176
|
}, undefined>, undefined>, undefined>;
|
|
177
177
|
readonly spotMarketScope: v.OptionalSchema<v.PicklistSchema<readonly ["all", "allowlist"], undefined>, undefined>;
|
|
178
178
|
readonly actions: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["trade-spot", "internal-transfer", "external-withdraw", "read-balances", "read-spot", "read-internal-transfers", "read-address-book", "manage-address-book"], undefined>, undefined>, undefined>;
|
|
179
|
-
readonly maxOrderSize: v.OptionalSchema<v.NullableSchema<v.
|
|
180
|
-
readonly maxOpenOrders: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
179
|
+
readonly maxOrderSize: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, bigint>]>, undefined>, undefined>;
|
|
180
|
+
readonly maxOpenOrders: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, undefined>;
|
|
181
181
|
readonly tradingHalted: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
182
182
|
readonly policyLocked: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
183
183
|
readonly reviewAt: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>, undefined>;
|
|
@@ -192,7 +192,7 @@ declare const UpdateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
192
192
|
}[] | undefined;
|
|
193
193
|
spotMarketScope?: "all" | "allowlist" | undefined;
|
|
194
194
|
actions?: ("trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book")[] | undefined;
|
|
195
|
-
maxOrderSize?:
|
|
195
|
+
maxOrderSize?: bigint | null | undefined;
|
|
196
196
|
maxOpenOrders?: number | null | undefined;
|
|
197
197
|
tradingHalted?: boolean | undefined;
|
|
198
198
|
policyLocked?: boolean | undefined;
|
|
@@ -208,7 +208,7 @@ declare const UpdateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
208
208
|
}[] | undefined;
|
|
209
209
|
spotMarketScope?: "all" | "allowlist" | undefined;
|
|
210
210
|
actions?: ("trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book")[] | undefined;
|
|
211
|
-
maxOrderSize?:
|
|
211
|
+
maxOrderSize?: bigint | null | undefined;
|
|
212
212
|
maxOpenOrders?: number | null | undefined;
|
|
213
213
|
tradingHalted?: boolean | undefined;
|
|
214
214
|
policyLocked?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccount-policies.schemas.d.ts","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"subaccount-policies.schemas.d.ts","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"mappings":";;;;cA0Ca,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;cASjC,gCAA8B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;cAgB9B,wBAAsB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCvB,mBAAmB,EAAE,mBAAmB;cAkEvC,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOlC,8BAA8B,EAAE,kBAAkB;cA6DjD,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BlC,8BAA8B,EAAE,kBAAkB;cASjD,kCAAgC,EAAA;;;;KAQjC,6BAA6B,EAAE,kBAAkB"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { idToBigInt } from "../../../utils/base58-id.js";
|
|
2
|
-
import {
|
|
2
|
+
import { toIntOrZero } from "../../../utils/numbers.js";
|
|
3
3
|
import { tsObjToMs, tsObjToNsString } from "../../../utils/time.js";
|
|
4
|
-
import {
|
|
4
|
+
import { PROTOBUF_UINT32_MAX } from "../../../shared/wire-bounds.js";
|
|
5
|
+
import { BigIntStringSchema, OptionalNumberToIntOrZeroSchema, OptionalPublicIdSchema, OptionalTimestampMsSchema, PublicIdSchema, TimestampMsSchema, TimestampSchema, idInputSchema, optionalSubaccountIdInputSchema, positiveBigintStringInputSchema } from "../../../shared/schemas.js";
|
|
5
6
|
import { PolicyActionEnumSchema, PolicyMarketScopeEnumSchema, ProtoPolicyActionEnumSchema, ProtoPolicyMarketScopeEnumSchema, SpotMarketRuleSchema } from "../shared.js";
|
|
6
7
|
import { PolicyActionCodec, PolicyMarketScopeCodec, policyActionLabelFor, policyMarketScopeLabelFor } from "../shared.codecs.js";
|
|
7
8
|
import { buildProtoPatch, defineProtoPatchFields } from "../../../utils/proto-patch.js";
|
|
8
9
|
import { toTimestamp } from "../../../utils/timestamp.js";
|
|
9
10
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../../shared/account-scope.js";
|
|
11
|
+
import { decimalInputToScaled, scaledToDecimalOutput } from "../../../shared/decimal-surface.js";
|
|
10
12
|
import * as v from "valibot";
|
|
11
13
|
//#region src/services/policies/subaccount-policies/subaccount-policies.schemas.ts
|
|
12
14
|
const ListSubaccountPoliciesInputSchema = v.pipe(v.strictObject(AccountScopeInputEntries), v.transform(({ account }) => ({ subaccountId: accountScopeToSubaccountId(account) })));
|
|
@@ -29,7 +31,7 @@ const SubaccountPolicySchema = v.pipe(v.object({
|
|
|
29
31
|
actions: v.pipe(v.optional(v.array(ProtoPolicyActionEnumSchema), []), v.transform((v) => v.map((action) => policyActionLabelFor(action)))),
|
|
30
32
|
isTemplate: v.optional(v.boolean(), false),
|
|
31
33
|
sourceTemplateId: OptionalPublicIdSchema,
|
|
32
|
-
maxOrderNotional: v.pipe(v.bigint(), v.transform((
|
|
34
|
+
maxOrderNotional: v.pipe(v.bigint(), v.transform((value) => scaledToDecimalOutput(value, 6))),
|
|
33
35
|
maxOpenOrders: v.number(),
|
|
34
36
|
tradingHalted: v.boolean(),
|
|
35
37
|
locked: v.boolean(),
|
|
@@ -44,13 +46,20 @@ const SubaccountPolicySchema = v.pipe(v.object({
|
|
|
44
46
|
updatedAt: tsObjToMs(updatedAt),
|
|
45
47
|
updatedAtNs: tsObjToNsString(updatedAt)
|
|
46
48
|
})));
|
|
49
|
+
/**
|
|
50
|
+
* Max spot order notional as a decimal USDT string (e.g. `"100000.5"`). The wire
|
|
51
|
+
* field is canonical quote microunits, so `"100000"` caps orders at 100,000 USDT.
|
|
52
|
+
* `"0"` means no cap.
|
|
53
|
+
*/
|
|
54
|
+
const MaxOrderSizeInputSchema = v.pipe(v.string(), v.transform((value) => decimalInputToScaled("maxOrderSize", value, 6)));
|
|
55
|
+
const OptionalMaxOrderSizeInputSchema = v.pipe(v.optional(v.nullable(MaxOrderSizeInputSchema), null), v.transform((value) => value ?? 0n));
|
|
47
56
|
const SubaccountPolicyInputBaseSchema = v.strictObject({
|
|
48
57
|
name: v.string(),
|
|
49
58
|
description: v.optional(v.string(), ""),
|
|
50
59
|
spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),
|
|
51
60
|
spotMarketScope: v.pipe(PolicyMarketScopeEnumSchema, v.transform((v) => PolicyMarketScopeCodec.inputToProto[v])),
|
|
52
61
|
actions: v.pipe(v.optional(v.array(PolicyActionEnumSchema), []), v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action]))),
|
|
53
|
-
maxOrderSize:
|
|
62
|
+
maxOrderSize: OptionalMaxOrderSizeInputSchema,
|
|
54
63
|
maxOpenOrders: OptionalNumberToIntOrZeroSchema,
|
|
55
64
|
tradingHalted: v.optional(v.boolean(), false),
|
|
56
65
|
policyLocked: v.optional(v.boolean(), false),
|
|
@@ -85,8 +94,8 @@ const SubaccountPolicyPatchSchema = v.strictObject({
|
|
|
85
94
|
spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),
|
|
86
95
|
spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),
|
|
87
96
|
actions: v.optional(v.array(PolicyActionEnumSchema)),
|
|
88
|
-
maxOrderSize: v.optional(v.nullable(
|
|
89
|
-
maxOpenOrders: v.optional(v.nullable(v.number())),
|
|
97
|
+
maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),
|
|
98
|
+
maxOpenOrders: v.optional(v.nullable(v.pipe(v.number(), v.maxValue(PROTOBUF_UINT32_MAX)))),
|
|
90
99
|
tradingHalted: v.optional(v.boolean()),
|
|
91
100
|
policyLocked: v.optional(v.boolean()),
|
|
92
101
|
reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),
|
|
@@ -115,7 +124,7 @@ const SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields()({
|
|
|
115
124
|
},
|
|
116
125
|
maxOrderSize: {
|
|
117
126
|
path: "max_order_notional",
|
|
118
|
-
encode: (value) => ({ maxOrderNotional:
|
|
127
|
+
encode: (value) => ({ maxOrderNotional: value ?? 0n })
|
|
119
128
|
},
|
|
120
129
|
maxOpenOrders: {
|
|
121
130
|
path: "max_open_orders",
|
|
@@ -175,7 +184,7 @@ const DEFAULT_SUBACCOUNT_POLICY = {
|
|
|
175
184
|
"read-address-book",
|
|
176
185
|
"read-spot"
|
|
177
186
|
],
|
|
178
|
-
maxOrderSize: 0,
|
|
187
|
+
maxOrderSize: "0",
|
|
179
188
|
maxOpenOrders: 0,
|
|
180
189
|
tradingHalted: false,
|
|
181
190
|
createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyActionEnumSchema,\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToBigIntOrZeroSchema,\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { toTimestamp } from \"../../../utils/timestamp.js\";\nimport { toBigIntOrZero, toIntOrZero } from \"../../../utils/numbers.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(PolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalNumberToBigIntOrZeroSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return toTimestamp({\n seconds: BigInt(Math.floor(value / 1000)),\n nanos: (value % 1000) * 1_000_000,\n });\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(PolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(v.number())),\n maxOpenOrders: v.optional(v.nullable(v.number())),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: toBigIntOrZero(value) }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: toIntOrZero(value) }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n spotMarketScope: \"all\",\n actions: [\"read-balances\", \"read-internal-transfers\", \"read-address-book\", \"read-spot\"],\n maxOrderSize: 0,\n maxOpenOrders: 0,\n tradingHalted: false,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;AAqCA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,C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,CAAU,CAC9E;AACJ,CAAC;AAID,MAAM,uCAAuC,KAAK,IAAI;AAEtD,MAAa,4BAA8C;CACvD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,aAAa,CAAC;CACd,iBAAiB;CACjB,SAAS;EAAC;EAAiB;EAA2B;EAAqB;CAAW;CACtF,cAAc;CACd,eAAe;CACf,eAAe;CACf,WAAW;CACX,WAAW;CACX,cAAc,OAAO,oCAAoC,IAAI,SAAA,CAAY,SAAS;CAClF,YAAY;CACZ,kBAAkB,KAAA;CAClB,QAAQ;CACR,UAAU,KAAA;CACV,WAAW,KAAA;CACX,UAAU;AACd"}
|
|
1
|
+
{"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyActionEnumSchema,\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { toTimestamp } from \"../../../utils/timestamp.js\";\nimport { toIntOrZero } from \"../../../utils/numbers.js\";\nimport {\n QUOTE_NOTIONAL_SCALE,\n decimalInputToScaled,\n scaledToDecimalOutput,\n} from \"../../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../../shared/wire-bounds.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((value) => scaledToDecimalOutput(value, QUOTE_NOTIONAL_SCALE)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\n/**\n * Max spot order notional as a decimal USDT string (e.g. `\"100000.5\"`). The wire\n * field is canonical quote microunits, so `\"100000\"` caps orders at 100,000 USDT.\n * `\"0\"` means no cap.\n */\nconst MaxOrderSizeInputSchema = v.pipe(\n v.string(),\n v.transform((value) => decimalInputToScaled(\"maxOrderSize\", value, QUOTE_NOTIONAL_SCALE)),\n);\n\nconst OptionalMaxOrderSizeInputSchema = v.pipe(\n v.optional(v.nullable(MaxOrderSizeInputSchema), null),\n v.transform((value) => value ?? 0n),\n);\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(PolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalMaxOrderSizeInputSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return toTimestamp({\n seconds: BigInt(Math.floor(value / 1000)),\n nanos: (value % 1000) * 1_000_000,\n });\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(PolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),\n maxOpenOrders: v.optional(v.nullable(v.pipe(v.number(), v.maxValue(PROTOBUF_UINT32_MAX)))),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: value ?? 0n }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: toIntOrZero(value) }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n spotMarketScope: \"all\",\n actions: [\"read-balances\", \"read-internal-transfers\", \"read-address-book\", \"read-spot\"],\n maxOrderSize: \"0\",\n maxOpenOrders: 0,\n tradingHalted: false,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;;;AA0CA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;CACrD,GAAG;AACP,CAAC,GACD,EAAE,WAAW,EAAE,UAAU,eAAe;CACpC,UAAU,WAAW,UAAU,UAAU;CACzC,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;;;AAOA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,IAAI;CACJ,MAAM,EAAE,OAAO;CACf,aAAa,EAAE,OAAO;CACtB,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,GAAG,CAAC,CAAC;CACzD,iBAAiB,EAAE,KACf,kCACA,EAAE,WAAW,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c;CACd,eAAe;CACf,eAAe;CACf,WAAW;CACX,WAAW;CACX,cAAc,OAAO,oCAAoC,IAAI,SAAA,CAAY,SAAS;CAClF,YAAY;CACZ,kBAAkB,KAAA;CAClB,QAAQ;CACR,UAAU,KAAA;CACV,WAAW,KAAA;CACX,UAAU;AACd"}
|
package/dist/services/shared.js
CHANGED
|
@@ -2,8 +2,10 @@ import { PROTOBUF_UINT32_MAX } from "../shared/wire-bounds.js";
|
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
//#region src/services/shared.ts
|
|
4
4
|
const SideSchema = v.picklist(["buy", "sell"]);
|
|
5
|
+
/** A positive identifier that fits its protobuf `uint32` field. */
|
|
6
|
+
const PositiveUint32InputSchema = v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(PROTOBUF_UINT32_MAX));
|
|
5
7
|
/** A positive spot-market identifier that fits its protobuf `uint32` field. */
|
|
6
|
-
const SymbolIdInputSchema =
|
|
8
|
+
const SymbolIdInputSchema = PositiveUint32InputSchema;
|
|
7
9
|
const PositiveStringInputSchema = v.pipe(v.string(), v.trim(), v.minLength(1));
|
|
8
10
|
const PositiveStringOrNumberInputSchema = v.union([PositiveStringInputSchema, v.pipe(v.number(), v.gtValue(0))]);
|
|
9
11
|
/** Absolute price distance, as a decimal price string (e.g. "0.50"). */
|
|
@@ -22,6 +24,6 @@ const BpsStringOrNumberInputSchema = v.strictObject({
|
|
|
22
24
|
});
|
|
23
25
|
const NoneInputSchema = v.strictObject({ kind: v.literal("none") });
|
|
24
26
|
//#endregion
|
|
25
|
-
export { BpsStringOrNumberInputSchema, NoneInputSchema, PositiveStringInputSchema, PositiveStringOrNumberInputSchema, PriceDistanceInputSchema, PriceSlippageInputSchema, SideSchema, SymbolIdInputSchema };
|
|
27
|
+
export { BpsStringOrNumberInputSchema, NoneInputSchema, PositiveStringInputSchema, PositiveStringOrNumberInputSchema, PositiveUint32InputSchema, PriceDistanceInputSchema, PriceSlippageInputSchema, SideSchema, SymbolIdInputSchema };
|
|
26
28
|
|
|
27
29
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","names":[],"sources":["../../src/services/shared.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PROTOBUF_UINT32_MAX } from \"../shared/wire-bounds.js\";\n\nexport const SideSchema = v.picklist([\"buy\", \"sell\"]);\n\n/** A positive
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../../src/services/shared.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PROTOBUF_UINT32_MAX } from \"../shared/wire-bounds.js\";\n\nexport const SideSchema = v.picklist([\"buy\", \"sell\"]);\n\n/** A positive identifier that fits its protobuf `uint32` field. */\nexport const PositiveUint32InputSchema = v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(PROTOBUF_UINT32_MAX),\n);\n\n/** A positive spot-market identifier that fits its protobuf `uint32` field. */\nexport const SymbolIdInputSchema = PositiveUint32InputSchema;\n\nexport const PositiveStringInputSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nexport const PositiveStringOrNumberInputSchema = v.union([\n PositiveStringInputSchema,\n v.pipe(v.number(), v.gtValue(0)),\n]);\n\n/** Absolute price distance, as a decimal price string (e.g. \"0.50\"). */\nexport const PriceDistanceInputSchema = v.strictObject({\n kind: v.literal(\"distance\"),\n distance: PositiveStringInputSchema,\n});\n\n/** Absolute price slippage, as a decimal price string (e.g. \"0.25\"). */\nexport const PriceSlippageInputSchema = v.strictObject({\n kind: v.literal(\"slippage\"),\n slippage: PositiveStringInputSchema,\n});\n\nexport const BpsStringOrNumberInputSchema = v.strictObject({\n kind: v.literal(\"bps\"),\n bps: PositiveStringOrNumberInputSchema,\n});\n\nexport const NoneInputSchema = v.strictObject({\n kind: v.literal(\"none\"),\n});\n"],"mappings":";;;AAGA,MAAa,aAAa,EAAE,SAAS,CAAC,OAAO,MAAM,CAAC;;AAGpD,MAAa,4BAA4B,EAAE,KACvC,EAAE,OAAO,GACT,EAAE,QAAQ,GACV,EAAE,QAAQ,CAAC,GACX,EAAE,SAAS,mBAAmB,CAClC;;AAGA,MAAa,sBAAsB;AAEnC,MAAa,4BAA4B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAEpF,MAAa,oCAAoC,EAAE,MAAM,CACrD,2BACA,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CACnC,CAAC;;AAGD,MAAa,2BAA2B,EAAE,aAAa;CACnD,MAAM,EAAE,QAAQ,UAAU;CAC1B,UAAU;AACd,CAAC;;AAGD,MAAa,2BAA2B,EAAE,aAAa;CACnD,MAAM,EAAE,QAAQ,UAAU;CAC1B,UAAU;AACd,CAAC;AAED,MAAa,+BAA+B,EAAE,aAAa;CACvD,MAAM,EAAE,QAAQ,KAAK;CACrB,KAAK;AACT,CAAC;AAED,MAAa,kBAAkB,EAAE,aAAa,EAC1C,MAAM,EAAE,QAAQ,MAAM,EAC1B,CAAC"}
|
|
@@ -216,7 +216,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
216
216
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
217
217
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
218
218
|
readonly role: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountRole$1, undefined>, v.TransformAction<SubaccountRole$1, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
219
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "
|
|
219
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "cancelled" | "accepted" | "declined">]>;
|
|
220
220
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
221
221
|
readonly seconds: v.BigintSchema<undefined>;
|
|
222
222
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -243,7 +243,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
243
243
|
granteeAccountId: string;
|
|
244
244
|
inviterAccountId: string;
|
|
245
245
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
246
|
-
status: "unspecified" | "pending" | "
|
|
246
|
+
status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
|
|
247
247
|
createdAt?: number | undefined;
|
|
248
248
|
respondedAt?: number | undefined;
|
|
249
249
|
granteeUsername: string;
|
|
@@ -261,7 +261,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
261
261
|
granteeAccountId: string;
|
|
262
262
|
inviterAccountId: string;
|
|
263
263
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
264
|
-
status: "unspecified" | "pending" | "
|
|
264
|
+
status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
|
|
265
265
|
createdAt?: number | undefined;
|
|
266
266
|
respondedAt?: number | undefined;
|
|
267
267
|
granteeUsername: string;
|
|
@@ -284,7 +284,7 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
284
284
|
nanos: number;
|
|
285
285
|
} | undefined, number | undefined>]>;
|
|
286
286
|
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
|
|
287
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "failed" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "
|
|
287
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "revoked" | "failed" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
288
288
|
readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
|
|
289
289
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
290
290
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -19,7 +19,7 @@ type CreateTradingWithdrawRequestBase = {
|
|
|
19
19
|
payloadSignature?: Uint8Array;
|
|
20
20
|
};
|
|
21
21
|
declare function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
22
|
-
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
22
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
23
23
|
readonly quantity: v.StringSchema<undefined>;
|
|
24
24
|
readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
25
25
|
readonly destinationAddress: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|
|
@@ -40,7 +40,7 @@ declare function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScal
|
|
|
40
40
|
} | undefined;
|
|
41
41
|
}, CreateTradingWithdrawRequestBase>]>;
|
|
42
42
|
declare function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
43
|
-
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
43
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
44
44
|
readonly quantity: v.StringSchema<undefined>;
|
|
45
45
|
readonly destinationChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>]>;
|
|
46
46
|
readonly destinationAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;KAiBY;EACR,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA,OAAO;EACP;EACA;;KAGC;EACD;EACA,SAAS;EACT,mBAAmB;;iBAoCP,gDAAgD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;GA+BhF;iBAEe,sDAAsD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;GAqCtF;KAEW,sCAAsC,EAAE,WAChD,kBAAkB;KAOV,4CAA4C,EAAE,WACtD,kBAAkB;cAOT,mCAAiC,EAAA;;;KAIlC,8BAA8B,EAAE,mBAAmB;cAOlD,wCAAsC,EAAA,yBAAA,EAAA;;;;;;;;;;KAgBvC,mCAAmC,EAAE,kBACtC;cA4CE,yCAAuC,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,oCAAoC,EAAE,mBACvC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PositiveUint32InputSchema } from "../shared.js";
|
|
1
2
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
2
3
|
import { quantityInputToE18 } from "../../shared/decimal-surface.js";
|
|
3
4
|
import { toU128 } from "../../utils/u128.js";
|
|
@@ -32,7 +33,7 @@ function createTradingWithdrawPayload(input) {
|
|
|
32
33
|
function createCreateTradingWithdrawToFundingInputSchema(scales) {
|
|
33
34
|
return v.pipe(v.strictObject({
|
|
34
35
|
...AccountScopeInputEntries,
|
|
35
|
-
assetId:
|
|
36
|
+
assetId: PositiveUint32InputSchema,
|
|
36
37
|
quantity: v.string(),
|
|
37
38
|
idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),
|
|
38
39
|
destinationAddress: v.optional(v.pipe(v.string(), v.trim()), ""),
|
|
@@ -61,7 +62,7 @@ function createCreateTradingWithdrawToFundingInputSchema(scales) {
|
|
|
61
62
|
function createCreateTradingWithdrawToExternalChainInputSchema(scales) {
|
|
62
63
|
return v.pipe(v.strictObject({
|
|
63
64
|
...AccountScopeInputEntries,
|
|
64
|
-
assetId:
|
|
65
|
+
assetId: PositiveUint32InputSchema,
|
|
65
66
|
quantity: v.string(),
|
|
66
67
|
destinationChainId: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)),
|
|
67
68
|
destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { quantityInputToE18, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { toU128, type U128Value } from \"../../utils/u128.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n payloadSignature?: Uint8Array;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n const nonce = BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0] ?? BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n"],"mappings":";;;;;;;AAcA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QAAQ;EACT,MAAM,QAAQ,OAAO,KAAK,IAAI,CAAC;EAC/B,OAAO,UAAU,KAAK,KAAK;CAC/B;CAEA,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAK,IAAI,CAAC;CAC3C,OAAO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EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC,GACD,EAAE,WAAW,WAAW;CACpB,oBAAoB,OAAO,MAAM,kBAAkB;CACnD,oBAAoB,MAAM;AAC9B,EAAE,CACN;AASA,MAAM,uCAAuC,EAAE,KAC3C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,IAAI;CACrB,MAAM,EAAE,QAAA,CAA+C;CACvD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAC5E,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,uCAAuC,cAAc,OAAO;AACtE,EAAE,CACN;AAEA,MAAM,GAAA,IACyC,+BAC3C,GAAG,wCACH,uCAAuC;AAE3C,MAAM,yCAAyC,EAAE,KAC7C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,KAAK;CACtB,MAAM,EAAE,SAAS;;;;;;;CAOjB,CAAC;CACD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,OAAO;AAC1C,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,oCAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0C,EAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { quantityInputToE18, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { toU128, type U128Value } from \"../../utils/u128.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n payloadSignature?: Uint8Array;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n const nonce = BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0] ?? BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n"],"mappings":";;;;;;;;AAeA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QAAQ;EACT,MAAM,QAAQ,OAAO,KAAK,IAAI,CAAC;EAC/B,OAAO,UAAU,KAAK,KAAK;CAC/B;CAEA,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAK,IAAI,CAAC;CAC3C,OAAO,UAAU,KAAK,KAAK;AAC/B;AAEA,SAAS,6BAA6B,OAOE;CACpC,OAAO;EACH,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,oBAAoB,MAAM;EAC1B,WAAW,OAAO,MAAM,cAAc;EACtC,eAAe,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI,wBAAwB;EAC9E,OAAO,OAAO,YAAY,CAAC;EAC3B,oBAAoB,MAAM;EAC1B,gBAAgB,MAAM;CAC1B;AACJ;AAEA,SAAgB,gDAAgD,QAAmB;CAC/E,OAAO,EAAE,KACL,EAAE,aAAa;EACX,GAAG;E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AE3C,MAAM,yCAAyC,EAAE,KAC7C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,KAAK;CACtB,MAAM,EAAE,SAAS;;;;;;;CAOjB,CAAC;CACD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,OAAO;AAC1C,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,oCAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0C,EAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC"}
|
|
@@ -3,6 +3,8 @@ import { PROTOBUF_INT32_MAX } from "../shared/wire-bounds.js";
|
|
|
3
3
|
import { CatalogConversionError } from "../catalogs/types.js";
|
|
4
4
|
import { positiveDecimalInputToScaled } from "../shared/decimal-surface.js";
|
|
5
5
|
//#region src/services/trailing-oneof-inputs.ts
|
|
6
|
+
/** Product-wide cap for bps slippage inputs (market IOC, attached and standalone trailing stops). */
|
|
7
|
+
const MAX_SLIPPAGE_BPS = 1e4;
|
|
6
8
|
function parseTrailingDistanceInput(scales, distance, fieldName) {
|
|
7
9
|
if (distance.kind === "none") return {
|
|
8
10
|
case: void 0,
|
|
@@ -43,6 +45,6 @@ function exceedsMax(value, max) {
|
|
|
43
45
|
return max !== void 0 && value > max;
|
|
44
46
|
}
|
|
45
47
|
//#endregion
|
|
46
|
-
export { parseSlippageInput, parseTrailingDistanceInput };
|
|
48
|
+
export { MAX_SLIPPAGE_BPS, parseSlippageInput, parseTrailingDistanceInput };
|
|
47
49
|
|
|
48
50
|
//# sourceMappingURL=trailing-oneof-inputs.js.map
|
|
@@ -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\";\nimport { PROTOBUF_INT32_MAX } from \"../shared/wire-bounds.js\";\n\ntype PositiveIntLikeInput = string | number;\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: number }\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 > Number(PROTOBUF_INT32_MAX)) {\n throw new CatalogConversionError(\n `${fieldName}.bps`,\n `${fieldName}Bps must be a positive integer no greater than ${PROTOBUF_INT32_MAX}`,\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 const ticks = positiveDecimalInputToScaled(\n `${options.fieldName}.slippage`,\n slippage.slippage,\n scales.price(),\n );\n if (ticks > PROTOBUF_INT32_MAX) {\n throw new CatalogConversionError(\n `${options.fieldName}.slippage`,\n `${options.fieldName}.slippage exceeds the maximum supported price distance: ${slippage.slippage}`,\n );\n }\n return { case: options.ticksCase, value: Number(ticks) };\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":"
|
|
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\";\nimport { PROTOBUF_INT32_MAX } from \"../shared/wire-bounds.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\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: number }\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 > Number(PROTOBUF_INT32_MAX)) {\n throw new CatalogConversionError(\n `${fieldName}.bps`,\n `${fieldName}Bps must be a positive integer no greater than ${PROTOBUF_INT32_MAX}`,\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 const ticks = positiveDecimalInputToScaled(\n `${options.fieldName}.slippage`,\n slippage.slippage,\n scales.price(),\n );\n if (ticks > PROTOBUF_INT32_MAX) {\n throw new CatalogConversionError(\n `${options.fieldName}.slippage`,\n `${options.fieldName}.slippage exceeds the maximum supported price distance: ${slippage.slippage}`,\n );\n }\n return { case: options.ticksCase, value: Number(ticks) };\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":";;;;;;AAQA,MAAa,mBAAmB;AAoChC,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,OAAA,WAAyB,GACpD,MAAM,IAAI,uBACN,GAAG,UAAU,OACb,GAAG,UAAU,iDAAiD,oBAClE;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,YAAY;EAC9B,MAAM,QAAQ,6BACV,GAAG,QAAQ,UAAU,YACrB,SAAS,UACT,OAAO,MAAM,CACjB;EACA,IAAI,QAAA,aACA,MAAM,IAAI,uBACN,GAAG,QAAQ,UAAU,YACrB,GAAG,QAAQ,UAAU,0DAA0D,SAAS,UAC5F;EAEJ,OAAO;GAAE,MAAM,QAAQ;GAAW,OAAO,OAAO,KAAK;EAAE;CAC3D;CAEA,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-input.schemas.d.ts","names":[],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"trigger-input.schemas.d.ts","names":[],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"mappings":";;;;;;iBA6VgB,+BAA+B,QAAQ,YAAS,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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