@polyester/sdk 0.14.2 → 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 +14 -0
- package/dist/core-client.js +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/lifecycle/lifecycle.schemas.d.ts +42 -42
- 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-input.schemas.d.ts +1 -1
- package/dist/services/orders/orders-modify.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +6 -6
- 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 +5 -5
- 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 +2 -2
- 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/services/triggers/triggers-output.schemas.d.ts +18 -18
- 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
|
@@ -17,7 +17,7 @@ declare const SignProtectedActionInputSchema: v.SchemaWithPipe<readonly [v.Stric
|
|
|
17
17
|
readonly action: v.PicklistSchema<readonly ["fundingSetExternalWhitelistRequired", "fundingAddExternalWhitelist", "fundingRemoveExternalWhitelist", "fundingAddInternalWhitelist", "fundingRemoveInternalWhitelist", "fundingSetInternalWhitelistRequired"], undefined>;
|
|
18
18
|
readonly args: v.OptionalSchema<v.VariantSchema<"case", [v.StrictObjectSchema<{
|
|
19
19
|
readonly case: v.LiteralSchema<"externalWhitelist", undefined>;
|
|
20
|
-
readonly polychainChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
20
|
+
readonly polychainChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
21
21
|
readonly addresses: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
22
22
|
}, undefined>, v.StrictObjectSchema<{
|
|
23
23
|
readonly case: v.LiteralSchema<"internalWhitelist", undefined>;
|
|
@@ -83,7 +83,7 @@ declare const BatchSignProtectedActionInputSchema: v.SchemaWithPipe<readonly [v.
|
|
|
83
83
|
readonly action: v.PicklistSchema<readonly ["fundingSetExternalWhitelistRequired", "fundingAddExternalWhitelist", "fundingRemoveExternalWhitelist", "fundingAddInternalWhitelist", "fundingRemoveInternalWhitelist", "fundingSetInternalWhitelistRequired"], undefined>;
|
|
84
84
|
readonly args: v.OptionalSchema<v.VariantSchema<"case", [v.StrictObjectSchema<{
|
|
85
85
|
readonly case: v.LiteralSchema<"externalWhitelist", undefined>;
|
|
86
|
-
readonly polychainChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
86
|
+
readonly polychainChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
87
87
|
readonly addresses: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
88
88
|
}, undefined>, v.StrictObjectSchema<{
|
|
89
89
|
readonly case: v.LiteralSchema<"internalWhitelist", undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-signer.schemas.d.ts","names":[],"sources":["../../../src/services/guard-signer/guard-signer.schemas.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"guard-signer.schemas.d.ts","names":[],"sources":["../../../src/services/guard-signer/guard-signer.schemas.ts"],"mappings":";;;cAaa,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;KAS7B,yBAAyB,EAAE,kBAAkB;cAoD5C,gCAA8B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAa/B,2BAA2B,EAAE,kBAAkB;cAE9C,qCAAmC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsBpC,gCAAgC,EAAE,kBACnC;cAGE,yBAAuB,EAAA;;;;;;;KAQxB,oBAAoB,EAAE,mBAAmB;cAExC,qBAAmB,EAAA,yBAAA,EAAA;;;;;;;;;;;EAS4B;;;;;;;KAKhD,gBAAgB,EAAE,mBAAmB;cAEpC,2BAAyB,EAAA;;;;;;;;;;;;IAPsB;;;;;;;;KAWhD,sBAAsB,EAAE,mBAAmB;cAE1C,qCAAmC,EAAA;;;KAIpC,gCAAgC,EAAE,mBACnC;cAGE,qCAAmC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;IArBY;;;;;;;;;;;;IAAA;;;;;;;;;;;;IAAA;;;;;;;;KAgChD,gCAAgC,EAAE,mBACnC;cAGE,qCAAmC,EAAA;;;KAIpC,gCAAgC,EAAE,mBACnC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PositiveUint32InputSchema } from "../shared.js";
|
|
1
2
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
2
3
|
import { PROTECTED_ACTION_VALUES, ProtectedActionCodec } from "./guard-signer.codecs.js";
|
|
3
4
|
import * as v from "valibot";
|
|
@@ -9,7 +10,7 @@ const GuardSignerScopedInputSchema = v.pipe(v.strictObject({ ...AccountScopeInpu
|
|
|
9
10
|
const ProtectedActionArgsInputSchema = v.variant("case", [
|
|
10
11
|
v.strictObject({
|
|
11
12
|
case: v.literal("externalWhitelist"),
|
|
12
|
-
polychainChainId:
|
|
13
|
+
polychainChainId: PositiveUint32InputSchema,
|
|
13
14
|
addresses: v.pipe(v.array(WhitelistAddressSchema), v.minLength(1))
|
|
14
15
|
}),
|
|
15
16
|
v.strictObject({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-signer.schemas.js","names":[],"sources":["../../../src/services/guard-signer/guard-signer.schemas.ts"],"sourcesContent":["import { bytesToHex } from \"@noble/hashes/utils.js\";\nimport * as v from \"valibot\";\nimport { PROTECTED_ACTION_VALUES, ProtectedActionCodec } from \"./guard-signer.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\n\nconst HexAddressSchema = v.pipe(v.string(), v.trim(), v.regex(/^0x[0-9a-fA-F]{40}$/));\n\nconst WhitelistAddressSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nexport const GuardSignerScopedInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GuardSignerScopedInput = v.InferInput<typeof GuardSignerScopedInputSchema>;\n\nconst ProtectedActionArgsInputSchema = v.variant(\"case\", [\n v.strictObject({\n case: v.literal(\"externalWhitelist\"),\n polychainChainId:
|
|
1
|
+
{"version":3,"file":"guard-signer.schemas.js","names":[],"sources":["../../../src/services/guard-signer/guard-signer.schemas.ts"],"sourcesContent":["import { bytesToHex } from \"@noble/hashes/utils.js\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport * as v from \"valibot\";\nimport { PROTECTED_ACTION_VALUES, ProtectedActionCodec } from \"./guard-signer.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\n\nconst HexAddressSchema = v.pipe(v.string(), v.trim(), v.regex(/^0x[0-9a-fA-F]{40}$/));\n\nconst WhitelistAddressSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nexport const GuardSignerScopedInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GuardSignerScopedInput = v.InferInput<typeof GuardSignerScopedInputSchema>;\n\nconst ProtectedActionArgsInputSchema = v.variant(\"case\", [\n v.strictObject({\n case: v.literal(\"externalWhitelist\"),\n polychainChainId: PositiveUint32InputSchema,\n addresses: v.pipe(v.array(WhitelistAddressSchema), v.minLength(1)),\n }),\n v.strictObject({\n case: v.literal(\"internalWhitelist\"),\n addresses: v.pipe(v.array(WhitelistAddressSchema), v.minLength(1)),\n }),\n v.strictObject({\n case: v.literal(\"whitelistRequirement\"),\n required: v.boolean(),\n }),\n]);\n\nfunction toProtectedActionArgs(args: v.InferOutput<typeof ProtectedActionArgsInputSchema>) {\n if (args.case === \"externalWhitelist\") {\n return {\n args: {\n case: \"externalWhitelist\" as const,\n value: {\n polychainChainId: args.polychainChainId,\n addresses: args.addresses,\n },\n },\n };\n }\n\n if (args.case === \"internalWhitelist\") {\n return {\n args: {\n case: \"internalWhitelist\" as const,\n value: {\n addresses: args.addresses,\n },\n },\n };\n }\n\n return {\n args: {\n case: \"whitelistRequirement\" as const,\n value: {\n required: args.required,\n },\n },\n };\n}\n\nexport const SignProtectedActionInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n action: v.picklist(PROTECTED_ACTION_VALUES),\n args: v.optional(ProtectedActionArgsInputSchema),\n }),\n v.transform(({ account, action, args }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n action: ProtectedActionCodec.inputToProto[action],\n args: args ? toProtectedActionArgs(args) : undefined,\n })),\n);\n\nexport type SignProtectedActionInput = v.InferInput<typeof SignProtectedActionInputSchema>;\n\nexport const BatchSignProtectedActionInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n actions: v.pipe(\n v.array(\n v.strictObject({\n action: v.picklist(PROTECTED_ACTION_VALUES),\n args: v.optional(ProtectedActionArgsInputSchema),\n }),\n ),\n v.minLength(1, \"At least one protected action is required.\"),\n ),\n }),\n v.transform(({ account, actions }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n actions: actions.map(({ action, args }) => ({\n action: ProtectedActionCodec.inputToProto[action],\n args: args ? toProtectedActionArgs(args) : undefined,\n })),\n })),\n);\n\nexport type BatchSignProtectedActionInput = v.InferInput<\n typeof BatchSignProtectedActionInputSchema\n>;\n\nexport const GuardSignerStatusSchema = v.object({\n signerAddress: v.string(),\n onchainSignerAddress: v.string(),\n initialized: v.boolean(),\n nonce: v.string(),\n nonceSpace: v.bigint(),\n});\n\nexport type GuardSignerStatus = v.InferOutput<typeof GuardSignerStatusSchema>;\n\nexport const GuardApprovalSchema = v.pipe(\n v.object({\n nonceSpace: v.bigint(),\n deadlineUnix: v.bigint(),\n signature: v.instance(Uint8Array),\n }),\n v.transform((approval) => ({\n nonceSpace: approval.nonceSpace.toString(),\n deadlineUnix: approval.deadlineUnix.toString(),\n signature: `0x${bytesToHex(approval.signature)}` as `0x${string}`,\n raw: approval,\n })),\n);\n\nexport type GuardApproval = v.InferOutput<typeof GuardApprovalSchema>;\n\nexport const BatchGuardApprovalsSchema = v.object({\n approvals: v.array(GuardApprovalSchema),\n});\n\nexport type BatchGuardApprovals = v.InferOutput<typeof BatchGuardApprovalsSchema>;\n\nexport const CreateGuardSignerWalletResultSchema = v.object({\n signerAddress: HexAddressSchema,\n});\n\nexport type CreateGuardSignerWalletResult = v.InferOutput<\n typeof CreateGuardSignerWalletResultSchema\n>;\n\nexport const RotateGuardSignerWalletResultSchema = v.pipe(\n v.object({\n newSignerAddress: HexAddressSchema,\n approval: v.optional(GuardApprovalSchema),\n }),\n v.transform((result) => ({\n newSignerAddress: result.newSignerAddress,\n approval: result.approval ?? null,\n })),\n);\n\nexport type RotateGuardSignerWalletResult = v.InferOutput<\n typeof RotateGuardSignerWalletResultSchema\n>;\n\nexport const ExportGuardSignerWalletResultSchema = v.object({\n privateKey: v.pipe(v.string(), v.trim(), v.regex(/^0x[0-9a-fA-F]{64}$/)),\n});\n\nexport type ExportGuardSignerWalletResult = v.InferOutput<\n typeof ExportGuardSignerWalletResultSchema\n>;\n"],"mappings":";;;;;;AASA,MAAM,mBAAmB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,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,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,kBAAkB,OAAO;CACzB,UAAU,OAAO,YAAY;AACjC,EAAE,CACN;AAMA,MAAa,sCAAsC,EAAE,OAAO,EACxD,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,qBAAqB,CAAC,EAC3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heatmap.d.ts","names":[],"sources":["../../../src/services/heatmap/heatmap.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"heatmap.d.ts","names":[],"sources":["../../../src/services/heatmap/heatmap.ts"],"mappings":";;;;;;;;UA6BiB;EACb,oBACI,OAAO,0BACP,UAAU,0BACX,QAAQ;;UAGL,kCAAkC,mBAAmB;EAC3D;EACA,UAAU;;;;;cAWD,0BAA0B;;EAOvB,YAAA,YAAY,qBAAqB,UAAU,mBAAmB,QAAQ;;;;EAW5E,oBACF,OAAO,0BACP,UAAU,0BACX,QAAQ;;;;EA4BX,cAAc,OAAO"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parse } from "../../shared/validation.js";
|
|
2
2
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
|
+
import { SymbolIdInputSchema } from "../shared.js";
|
|
3
4
|
import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
|
|
4
5
|
import { HeatmapLiveBucketSchema, HeatmapService as HeatmapService$1, HeatmapTimeRangeSchema } from "../../gen/marketdata/v1/heatmap_pb.js";
|
|
5
6
|
import { HEATMAP_INTERVAL_VALUES } from "./heatmap.codecs.js";
|
|
@@ -9,7 +10,7 @@ import { createClient } from "@connectrpc/connect";
|
|
|
9
10
|
import * as v from "valibot";
|
|
10
11
|
//#region src/services/heatmap/heatmap.ts
|
|
11
12
|
const SubscribeHeatmapLiveParamsSchema = v.object({
|
|
12
|
-
symbolId:
|
|
13
|
+
symbolId: SymbolIdInputSchema,
|
|
13
14
|
interval: v.picklist(HEATMAP_INTERVAL_VALUES)
|
|
14
15
|
});
|
|
15
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heatmap.js","names":["#client","HeatmapRpc","#realtime","#scales","#responseSchema","#liveBucketSchema","ProtoHeatmapLiveBucketSchema"],"sources":["../../../src/services/heatmap/heatmap.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n HeatmapService as HeatmapRpc,\n HeatmapLiveBucketSchema as ProtoHeatmapLiveBucketSchema,\n HeatmapTimeRangeSchema,\n} from \"../../gen/marketdata/v1/heatmap_pb.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\nimport { HEATMAP_INTERVAL_VALUES, type HeatmapIntervalValue } from \"./heatmap.codecs.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n GetOrderbookHeatmapInputSchema,\n createOrderbookHeatmapLiveBucketSchema,\n createOrderbookHeatmapResponseSchema,\n type GetOrderbookHeatmapInput,\n type OrderbookHeatmapLiveBucket,\n type OrderbookHeatmapResponse,\n} from \"./heatmap.schemas.js\";\n\nexport interface OrderbookHeatmapProvider {\n getOrderbookHeatmap(\n input: GetOrderbookHeatmapInput,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookHeatmapResponse>;\n}\n\ninterface SubscribeHeatmapLiveInput extends BaseSubscribeInput<OrderbookHeatmapLiveBucket> {\n symbolId: number;\n interval: HeatmapIntervalValue;\n}\n\nconst SubscribeHeatmapLiveParamsSchema = v.object({\n symbolId:
|
|
1
|
+
{"version":3,"file":"heatmap.js","names":["#client","HeatmapRpc","#realtime","#scales","#responseSchema","#liveBucketSchema","ProtoHeatmapLiveBucketSchema"],"sources":["../../../src/services/heatmap/heatmap.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport { SymbolIdInputSchema } from \"../shared.js\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n HeatmapService as HeatmapRpc,\n HeatmapLiveBucketSchema as ProtoHeatmapLiveBucketSchema,\n HeatmapTimeRangeSchema,\n} from \"../../gen/marketdata/v1/heatmap_pb.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\nimport { HEATMAP_INTERVAL_VALUES, type HeatmapIntervalValue } from \"./heatmap.codecs.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n GetOrderbookHeatmapInputSchema,\n createOrderbookHeatmapLiveBucketSchema,\n createOrderbookHeatmapResponseSchema,\n type GetOrderbookHeatmapInput,\n type OrderbookHeatmapLiveBucket,\n type OrderbookHeatmapResponse,\n} from \"./heatmap.schemas.js\";\n\nexport interface OrderbookHeatmapProvider {\n getOrderbookHeatmap(\n input: GetOrderbookHeatmapInput,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookHeatmapResponse>;\n}\n\ninterface SubscribeHeatmapLiveInput extends BaseSubscribeInput<OrderbookHeatmapLiveBucket> {\n symbolId: number;\n interval: HeatmapIntervalValue;\n}\n\nconst SubscribeHeatmapLiveParamsSchema = v.object({\n symbolId: SymbolIdInputSchema,\n interval: v.picklist(HEATMAP_INTERVAL_VALUES),\n});\n\n/**\n * Reads historical order book heatmap chains and streams live heatmap buckets.\n */\nexport class HeatmapService implements OrderbookHeatmapProvider {\n #client: Client<typeof HeatmapRpc>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n #responseSchema: ReturnType<typeof createOrderbookHeatmapResponseSchema>;\n #liveBucketSchema: ReturnType<typeof createOrderbookHeatmapLiveBucketSchema>;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(HeatmapRpc, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n this.#responseSchema = createOrderbookHeatmapResponseSchema(scales);\n this.#liveBucketSchema = createOrderbookHeatmapLiveBucketSchema(scales);\n }\n\n /**\n * Fetches order book heatmap data for a symbol, interval, depth, and quantity mode using either an absolute time range or cursor pagination. The response includes a keyframe anchor, delta buckets, pagination metadata, and live-anchor fields when available.\n */\n async getOrderbookHeatmap(\n input: GetOrderbookHeatmapInput,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookHeatmapResponse> {\n const parsed = parse(GetOrderbookHeatmapInputSchema, input);\n await this.#scales.ready();\n\n const res = await this.#client.getOrderbookHeatmap(\n {\n symbolId: parsed.symbolId,\n interval: parsed.interval,\n depth: parsed.depth,\n quantityMode: parsed.quantityMode,\n limit: parsed.limit,\n pageToken: parsed.pageToken,\n timeRange:\n parsed.timeRange != null\n ? create(HeatmapTimeRangeSchema, {\n startTime: parsed.timeRange.startTime,\n endTime: parsed.timeRange.endTime,\n })\n : undefined,\n },\n toConnectCallOptions(options),\n );\n return parse(this.#responseSchema, res);\n }\n\n /**\n * Subscribes to live heatmap buckets on public:spot:market:heatmap:{interval}:{symbolId}:proto and emits parsed bid/ask delta buckets for the selected interval.\n */\n subscribeLive(input: SubscribeHeatmapLiveInput): () => void {\n const params = parse(SubscribeHeatmapLiveParamsSchema, {\n symbolId: input.symbolId,\n interval: input.interval,\n });\n const channel = `public:spot:market:heatmap:${params.interval}:${params.symbolId}:proto`;\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: ProtoHeatmapLiveBucketSchema,\n ready: () => this.#scales.ready(),\n onPublication: (data) => {\n const bucket = parse(this.#liveBucketSchema, data);\n input.onEvent(bucket);\n },\n onConnected: input.onOpen,\n onDisconnected: input.onClose,\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAyCA,MAAM,mCAAmC,EAAE,OAAO;CAC9C,UAAU;CACV,UAAU,EAAE,SAAS,uBAAuB;AAChD,CAAC;;;;AAKD,IAAa,iBAAb,MAAgE;CAC5D;CACA;CACA;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,kBAAY,WAAW,SAAS;EAC5D,KAAKC,YAAY;EACjB,KAAKC,UAAU;EACf,KAAKC,kBAAkB,qCAAqC,MAAM;EAClE,KAAKC,oBAAoB,uCAAuC,MAAM;CAC1E;;;;CAKA,MAAM,oBACF,OACA,SACiC;EACjC,MAAM,SAAS,MAAM,gCAAgC,KAAK;EAC1D,MAAM,KAAKF,QAAQ,MAAM;EAEzB,MAAM,MAAM,MAAM,KAAKH,QAAQ,oBAC3B;GACI,UAAU,OAAO;GACjB,UAAU,OAAO;GACjB,OAAO,OAAO;GACd,cAAc,OAAO;GACrB,OAAO,OAAO;GACd,WAAW,OAAO;GAClB,WACI,OAAO,aAAa,OACd,OAAO,wBAAwB;IAC3B,WAAW,OAAO,UAAU;IAC5B,SAAS,OAAO,UAAU;GAC9B,CAAC,IACD,KAAA;EACd,GACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,KAAKI,iBAAiB,GAAG;CAC1C;;;;CAKA,cAAc,OAA8C;EACxD,MAAM,SAAS,MAAM,kCAAkC;GACnD,UAAU,MAAM;GAChB,UAAU,MAAM;EACpB,CAAC;EACD,MAAM,UAAU,8BAA8B,OAAO,SAAS,GAAG,OAAO,SAAS;EACjF,OAAO,8BAA8B,KAAKF,WAAW;GACjD;GACA,QAAQI;GACR,aAAa,KAAKH,QAAQ,MAAM;GAChC,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAM,KAAKE,mBAAmB,IAAI;IACjD,MAAM,QAAQ,MAAM;GACxB;GACA,aAAa,MAAM;GACnB,gBAAgB,MAAM;GACtB,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|
|
@@ -12,7 +12,7 @@ type TimestampInit = {
|
|
|
12
12
|
nanos: number;
|
|
13
13
|
};
|
|
14
14
|
declare const GetOrderbookHeatmapInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
15
|
-
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
15
|
+
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
16
16
|
readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"1s" | "1m" | "5m" | "1h", HeatmapInterval>]>;
|
|
17
17
|
readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<5 | 10 | 20 | 1 | 200 | 1000 | 500 | 100 | 50, HeatmapDepth>]>;
|
|
18
18
|
readonly quantityMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["close", "peak"], undefined>, "close">, v.TransformAction<"close" | "peak", HeatmapQuantityMode>]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heatmap.schemas.d.ts","names":[],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"heatmap.schemas.d.ts","names":[],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"mappings":";;;;;KAsBK;EACD,Y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
|
|
1
1
|
import { requiredEnumLabel } from "../../shared/proto-enum-codec.js";
|
|
2
2
|
import { OptionalTimestampSecondsInputSchema } from "../../shared/schemas.js";
|
|
3
|
+
import { SymbolIdInputSchema } from "../shared.js";
|
|
3
4
|
import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
4
5
|
import { HEATMAP_DEPTH_VALUES, HEATMAP_INTERVAL_VALUES, HEATMAP_QUANTITY_MODE_VALUES, HeatmapDepthCodec, HeatmapIntervalCodec, HeatmapQuantityModeCodec } from "./heatmap.codecs.js";
|
|
5
6
|
import * as v from "valibot";
|
|
@@ -14,7 +15,7 @@ function timestampFromTsSec(tsSec) {
|
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
const GetOrderbookHeatmapInputSchema = v.pipe(v.object({
|
|
17
|
-
symbolId:
|
|
18
|
+
symbolId: SymbolIdInputSchema,
|
|
18
19
|
interval: IntervalInputSchema,
|
|
19
20
|
depth: DepthInputSchema,
|
|
20
21
|
quantityMode: QuantityModeInputSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heatmap.schemas.js","names":[],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport type {\n HeatmapDepth,\n HeatmapInterval,\n HeatmapQuantityMode,\n} from \"../../gen/marketdata/v1/heatmap_pb.js\";\nimport { OptionalTimestampSecondsInputSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n HEATMAP_DEPTH_VALUES,\n HEATMAP_INTERVAL_VALUES,\n HEATMAP_QUANTITY_MODE_VALUES,\n HeatmapDepthCodec,\n HeatmapIntervalCodec,\n HeatmapQuantityModeCodec,\n type HeatmapIntervalValue,\n type HeatmapQuantityModeValue,\n} from \"./heatmap.codecs.js\";\n\ntype HeatmapTimeRangeInit = {\n startTime?: TimestampInit;\n endTime?: TimestampInit;\n};\n\ntype TimestampInit = { seconds: bigint; nanos: number };\n\nconst IntervalInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_INTERVAL_VALUES), \"1s\"),\n v.transform((value): HeatmapInterval => HeatmapIntervalCodec.inputToProto[value]),\n);\n\nconst DepthInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_DEPTH_VALUES), 50),\n v.transform((value): HeatmapDepth => HeatmapDepthCodec.inputToProto[value]),\n);\n\nconst QuantityModeInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_QUANTITY_MODE_VALUES), \"close\"),\n v.transform((value): HeatmapQuantityMode => HeatmapQuantityModeCodec.inputToProto[value]),\n);\n\nfunction timestampFromTsSec(tsSec: bigint): TimestampInit {\n return { seconds: tsSec, nanos: 0 };\n}\n\nexport const GetOrderbookHeatmapInputSchema = v.pipe(\n v.object({\n symbolId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n interval: IntervalInputSchema,\n depth: DepthInputSchema,\n quantityMode: QuantityModeInputSchema,\n limit: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(20_000)),\n startTsSec: OptionalTimestampSecondsInputSchema,\n endTsSec: OptionalTimestampSecondsInputSchema,\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.check(\n (value) => value.pageToken !== \"\" || value.startTsSec != null || value.endTsSec != null,\n \"pageToken, startTsSec, or endTsSec is required\",\n ),\n v.transform((value) => {\n const timeRange: HeatmapTimeRangeInit | undefined =\n value.pageToken !== \"\"\n ? undefined\n : {\n startTime:\n value.startTsSec != null\n ? timestampFromTsSec(value.startTsSec)\n : undefined,\n endTime:\n value.endTsSec != null ? timestampFromTsSec(value.endTsSec) : undefined,\n };\n\n return {\n symbolId: value.symbolId,\n interval: value.interval,\n depth: value.depth,\n quantityMode: value.quantityMode,\n limit: value.limit,\n pageToken: value.pageToken,\n timeRange,\n };\n }),\n);\n\nfunction requiredIntervalLabelFor(value: number): DecodedEnum<HeatmapIntervalValue> {\n return requiredEnumLabel(\n HeatmapIntervalCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"interval\",\n );\n}\n\nfunction requiredQuantityModeLabelFor(value: number): DecodedEnum<HeatmapQuantityModeValue> {\n return requiredEnumLabel(\n HeatmapQuantityModeCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"quantity mode\",\n );\n}\n\nconst TimestampSecondsSchema = v.pipe(\n v.bigint(),\n v.transform((value) => Number(value)),\n);\n\nconst Uint64StringSchema = v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n);\n\nconst OrderbookHeatmapLevelsRawSchema = v.object({\n priceTicks: v.array(v.bigint()),\n qtyScaled: v.array(v.bigint()),\n});\n\ntype OrderbookHeatmapLevelsRaw = v.InferOutput<typeof OrderbookHeatmapLevelsRawSchema>;\n\nfunction convertHeatmapLevels(\n levels: OrderbookHeatmapLevelsRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n price: levels.priceTicks.map((tick) => scaledToDecimalOutput(tick, priceScale)),\n qty: levels.qtyScaled.map((qty) => scaledToDecimalOutput(qty, qtyScale)),\n };\n}\n\nexport type OrderbookHeatmapLevels = ReturnType<typeof convertHeatmapLevels>;\n\nexport type OrderbookHeatmapDeltaLevels = OrderbookHeatmapLevels;\n\nconst OrderbookHeatmapKeyframeRawSchema = v.object({\n tsSec: TimestampSecondsSchema,\n bestBidTicks: v.bigint(),\n bestAskTicks: v.bigint(),\n midTicks: v.bigint(),\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n bookSeq: Uint64StringSchema,\n});\n\ntype OrderbookHeatmapKeyframeRaw = v.InferOutput<typeof OrderbookHeatmapKeyframeRawSchema>;\n\nfunction convertHeatmapKeyframe(\n keyframe: OrderbookHeatmapKeyframeRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n tsSec: keyframe.tsSec,\n bestBid: scaledToDecimalOutput(keyframe.bestBidTicks, priceScale),\n bestAsk: scaledToDecimalOutput(keyframe.bestAskTicks, priceScale),\n mid: scaledToDecimalOutput(keyframe.midTicks, priceScale),\n bids: keyframe.bids ? convertHeatmapLevels(keyframe.bids, priceScale, qtyScale) : undefined,\n asks: keyframe.asks ? convertHeatmapLevels(keyframe.asks, priceScale, qtyScale) : undefined,\n bookSeq: keyframe.bookSeq,\n };\n}\n\nexport type OrderbookHeatmapKeyframe = ReturnType<typeof convertHeatmapKeyframe>;\n\nconst OrderbookHeatmapDeltaBucketRawSchema = v.object({\n tsSec: TimestampSecondsSchema,\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n updatesInBucket: v.number(),\n bookSeqStart: Uint64StringSchema,\n bookSeqEnd: Uint64StringSchema,\n});\n\ntype OrderbookHeatmapDeltaBucketRaw = v.InferOutput<typeof OrderbookHeatmapDeltaBucketRawSchema>;\n\nfunction convertHeatmapDeltaBucket(\n bucket: OrderbookHeatmapDeltaBucketRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n tsSec: bucket.tsSec,\n bids: bucket.bids ? convertHeatmapLevels(bucket.bids, priceScale, qtyScale) : undefined,\n asks: bucket.asks ? convertHeatmapLevels(bucket.asks, priceScale, qtyScale) : undefined,\n updatesInBucket: bucket.updatesInBucket,\n bookSeqStart: bucket.bookSeqStart,\n bookSeqEnd: bucket.bookSeqEnd,\n };\n}\n\nexport type OrderbookHeatmapDeltaBucket = ReturnType<typeof convertHeatmapDeltaBucket>;\n\nconst OrderbookHeatmapLiveBucketRawSchema = v.object({\n symbolId: v.number(),\n interval: v.pipe(v.number(), v.transform(requiredIntervalLabelFor)),\n tsSec: TimestampSecondsSchema,\n isFinal: v.boolean(),\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n updatesInBucket: v.number(),\n bookSeqStart: Uint64StringSchema,\n bookSeqEnd: Uint64StringSchema,\n quantityMode: v.pipe(v.number(), v.transform(requiredQuantityModeLabelFor)),\n effectiveBinTicks: v.bigint(),\n});\n\ntype OrderbookHeatmapLiveBucketRaw = v.InferOutput<typeof OrderbookHeatmapLiveBucketRawSchema>;\n\nfunction convertHeatmapLiveBucket(bucket: OrderbookHeatmapLiveBucketRaw, scales: SdkScales) {\n const priceScale = scales.price();\n const qtyScale = scales.baseQty(bucket.symbolId);\n return {\n symbolId: bucket.symbolId,\n interval: bucket.interval,\n tsSec: bucket.tsSec,\n isFinal: bucket.isFinal,\n bids: bucket.bids ? convertHeatmapLevels(bucket.bids, priceScale, qtyScale) : undefined,\n asks: bucket.asks ? convertHeatmapLevels(bucket.asks, priceScale, qtyScale) : undefined,\n updatesInBucket: bucket.updatesInBucket,\n bookSeqStart: bucket.bookSeqStart,\n bookSeqEnd: bucket.bookSeqEnd,\n quantityMode: bucket.quantityMode,\n effectiveBinSize: scaledToDecimalOutput(bucket.effectiveBinTicks, priceScale),\n };\n}\n\nexport type OrderbookHeatmapLiveBucket = ReturnType<typeof convertHeatmapLiveBucket>;\n\nexport function createOrderbookHeatmapLiveBucketSchema(scales: SdkScales) {\n return v.pipe(\n OrderbookHeatmapLiveBucketRawSchema,\n v.transform((bucket) => convertHeatmapLiveBucket(bucket, scales)),\n );\n}\n\nconst OrderbookHeatmapDeltaChainRawSchema = v.object({\n baseKeyframe: v.optional(OrderbookHeatmapKeyframeRawSchema),\n deltas: v.optional(v.array(OrderbookHeatmapDeltaBucketRawSchema), []),\n});\n\ntype OrderbookHeatmapDeltaChainRaw = v.InferOutput<typeof OrderbookHeatmapDeltaChainRawSchema>;\n\nfunction convertHeatmapDeltaChain(\n chain: OrderbookHeatmapDeltaChainRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n baseKeyframe: chain.baseKeyframe\n ? convertHeatmapKeyframe(chain.baseKeyframe, priceScale, qtyScale)\n : undefined,\n deltas: chain.deltas.map((bucket) =>\n convertHeatmapDeltaBucket(bucket, priceScale, qtyScale),\n ),\n };\n}\n\nexport type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;\n\nconst OrderbookHeatmapResponseRawSchema = v.object({\n symbolId: v.number(),\n interval: v.pipe(v.number(), v.transform(requiredIntervalLabelFor)),\n depth: v.pipe(\n v.number(),\n v.transform((value) =>\n requiredEnumLabel(\n HeatmapDepthCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"depth\",\n ),\n ),\n ),\n chain: v.optional(OrderbookHeatmapDeltaChainRawSchema),\n lastPersistedTsSec: TimestampSecondsSchema,\n liveFromBookSeqEnd: Uint64StringSchema,\n hasLiveAnchor: v.boolean(),\n nextPageToken: v.optional(v.string(), \"\"),\n serverTimeSec: TimestampSecondsSchema,\n quantityMode: v.pipe(v.number(), v.transform(requiredQuantityModeLabelFor)),\n liveBucket: v.optional(OrderbookHeatmapLiveBucketRawSchema),\n});\n\nexport function createOrderbookHeatmapResponseSchema(scales: SdkScales) {\n return v.pipe(\n OrderbookHeatmapResponseRawSchema,\n v.transform((res) => {\n const priceScale = scales.price();\n const qtyScale = scales.baseQty(res.symbolId);\n return {\n symbolId: res.symbolId,\n interval: res.interval,\n depth: res.depth,\n chain: res.chain\n ? convertHeatmapDeltaChain(res.chain, priceScale, qtyScale)\n : undefined,\n lastPersistedTsSec: res.lastPersistedTsSec,\n liveFromBookSeqEnd: res.liveFromBookSeqEnd,\n hasLiveAnchor: res.hasLiveAnchor,\n nextPageToken: res.nextPageToken,\n serverTimeSec: res.serverTimeSec,\n quantityMode: res.quantityMode,\n liveBucket: res.liveBucket\n ? convertHeatmapLiveBucket(res.liveBucket, scales)\n : undefined,\n };\n }),\n );\n}\n\nexport type GetOrderbookHeatmapInput = v.InferInput<typeof GetOrderbookHeatmapInputSchema>;\nexport type ParsedGetOrderbookHeatmapInput = v.InferOutput<typeof GetOrderbookHeatmapInputSchema>;\nexport type OrderbookHeatmapResponse = v.InferOutput<\n ReturnType<typeof createOrderbookHeatmapResponseSchema>\n>;\nexport type ParsedHeatmapTimeRange = HeatmapTimeRangeInit;\n"],"mappings":";;;;;;AA4BA,MAAM,sBAAsB,EAAE,KAC1B,EAAE,SAAS,EAAE,SAAS,uBAAuB,GAAG,IAAI,GACpD,EAAE,WAAW,UAA2B,qBAAqB,aAAa,MAAM,CACpF;AAEA,MAAM,mBAAmB,EAAE,KACvB,EAAE,SAAS,EAAE,SAAS,oBAAoB,GAAG,EAAE,GAC/C,EAAE,WAAW,UAAwB,kBAAkB,aAAa,MAAM,CAC9E;AAEA,MAAM,0BAA0B,EAAE,KAC9B,EAAE,SAAS,EAAE,SAAS,4BAA4B,GAAG,OAAO,GAC5D,EAAE,WAAW,UAA+B,yBAAyB,aAAa,MAAM,CAC5F;AAEA,SAAS,mBAAmB,OAA8B;CACtD,OAAO;EAAE,SAAS;EAAO,OAAO;CAAE;AACtC;AAEA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,OAAO;CACL,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC;CACtD,UAAU;CACV,OAAO;CACP,cAAc;CACd,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAM,CAAC;CACvE,YAAY;CACZ,UAAU;CACV,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC,GACD,EAAE,OACG,UAAU,MAAM,cAAc,MAAM,MAAM,cAAc,QAAQ,MAAM,YAAY,MACnF,gDACJ,GACA,EAAE,WAAW,UAAU;CACnB,MAAM,YACF,MAAM,cAAc,KACd,KAAA,IACA;EACI,WACI,MAAM,cAAc,OACd,mBAAmB,MAAM,UAAU,IACnC,KAAA;EACV,SACI,MAAM,YAAY,OAAO,mBA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QAAQ;EACjB,MAAM,aAAa,OAAO,MAAM;EAChC,MAAM,WAAW,OAAO,QAAQ,IAAI,QAAQ;EAC5C,OAAO;GACH,UAAU,IAAI;GACd,UAAU,IAAI;GACd,OAAO,IAAI;GACX,OAAO,IAAI,QACL,yBAAyB,IAAI,OAAO,YAAY,QAAQ,IACxD,KAAA;GACN,oBAAoB,IAAI;GACxB,oBAAoB,IAAI;GACxB,eAAe,IAAI;GACnB,eAAe,IAAI;GACnB,eAAe,IAAI;GACnB,cAAc,IAAI;GAClB,YAAY,IAAI,aACV,yBAAyB,IAAI,YAAY,MAAM,IAC/C,KAAA;EACV;CACJ,CAAC,CACL;AACJ"}
|
|
1
|
+
{"version":3,"file":"heatmap.schemas.js","names":[],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { SymbolIdInputSchema } from \"../shared.js\";\nimport type {\n HeatmapDepth,\n HeatmapInterval,\n HeatmapQuantityMode,\n} from \"../../gen/marketdata/v1/heatmap_pb.js\";\nimport { OptionalTimestampSecondsInputSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n HEATMAP_DEPTH_VALUES,\n HEATMAP_INTERVAL_VALUES,\n HEATMAP_QUANTITY_MODE_VALUES,\n HeatmapDepthCodec,\n HeatmapIntervalCodec,\n HeatmapQuantityModeCodec,\n type HeatmapIntervalValue,\n type HeatmapQuantityModeValue,\n} from \"./heatmap.codecs.js\";\n\ntype HeatmapTimeRangeInit = {\n startTime?: TimestampInit;\n endTime?: TimestampInit;\n};\n\ntype TimestampInit = { seconds: bigint; nanos: number };\n\nconst IntervalInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_INTERVAL_VALUES), \"1s\"),\n v.transform((value): HeatmapInterval => HeatmapIntervalCodec.inputToProto[value]),\n);\n\nconst DepthInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_DEPTH_VALUES), 50),\n v.transform((value): HeatmapDepth => HeatmapDepthCodec.inputToProto[value]),\n);\n\nconst QuantityModeInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_QUANTITY_MODE_VALUES), \"close\"),\n v.transform((value): HeatmapQuantityMode => HeatmapQuantityModeCodec.inputToProto[value]),\n);\n\nfunction timestampFromTsSec(tsSec: bigint): TimestampInit {\n return { seconds: tsSec, nanos: 0 };\n}\n\nexport const GetOrderbookHeatmapInputSchema = v.pipe(\n v.object({\n symbolId: SymbolIdInputSchema,\n interval: IntervalInputSchema,\n depth: DepthInputSchema,\n quantityMode: QuantityModeInputSchema,\n limit: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(20_000)),\n startTsSec: OptionalTimestampSecondsInputSchema,\n endTsSec: OptionalTimestampSecondsInputSchema,\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.check(\n (value) => value.pageToken !== \"\" || value.startTsSec != null || value.endTsSec != null,\n \"pageToken, startTsSec, or endTsSec is required\",\n ),\n v.transform((value) => {\n const timeRange: HeatmapTimeRangeInit | undefined =\n value.pageToken !== \"\"\n ? undefined\n : {\n startTime:\n value.startTsSec != null\n ? timestampFromTsSec(value.startTsSec)\n : undefined,\n endTime:\n value.endTsSec != null ? timestampFromTsSec(value.endTsSec) : undefined,\n };\n\n return {\n symbolId: value.symbolId,\n interval: value.interval,\n depth: value.depth,\n quantityMode: value.quantityMode,\n limit: value.limit,\n pageToken: value.pageToken,\n timeRange,\n };\n }),\n);\n\nfunction requiredIntervalLabelFor(value: number): DecodedEnum<HeatmapIntervalValue> {\n return requiredEnumLabel(\n HeatmapIntervalCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"interval\",\n );\n}\n\nfunction requiredQuantityModeLabelFor(value: number): DecodedEnum<HeatmapQuantityModeValue> {\n return requiredEnumLabel(\n HeatmapQuantityModeCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"quantity mode\",\n );\n}\n\nconst TimestampSecondsSchema = v.pipe(\n v.bigint(),\n v.transform((value) => Number(value)),\n);\n\nconst Uint64StringSchema = v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n);\n\nconst OrderbookHeatmapLevelsRawSchema = v.object({\n priceTicks: v.array(v.bigint()),\n qtyScaled: v.array(v.bigint()),\n});\n\ntype OrderbookHeatmapLevelsRaw = v.InferOutput<typeof OrderbookHeatmapLevelsRawSchema>;\n\nfunction convertHeatmapLevels(\n levels: OrderbookHeatmapLevelsRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n price: levels.priceTicks.map((tick) => scaledToDecimalOutput(tick, priceScale)),\n qty: levels.qtyScaled.map((qty) => scaledToDecimalOutput(qty, qtyScale)),\n };\n}\n\nexport type OrderbookHeatmapLevels = ReturnType<typeof convertHeatmapLevels>;\n\nexport type OrderbookHeatmapDeltaLevels = OrderbookHeatmapLevels;\n\nconst OrderbookHeatmapKeyframeRawSchema = v.object({\n tsSec: TimestampSecondsSchema,\n bestBidTicks: v.bigint(),\n bestAskTicks: v.bigint(),\n midTicks: v.bigint(),\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n bookSeq: Uint64StringSchema,\n});\n\ntype OrderbookHeatmapKeyframeRaw = v.InferOutput<typeof OrderbookHeatmapKeyframeRawSchema>;\n\nfunction convertHeatmapKeyframe(\n keyframe: OrderbookHeatmapKeyframeRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n tsSec: keyframe.tsSec,\n bestBid: scaledToDecimalOutput(keyframe.bestBidTicks, priceScale),\n bestAsk: scaledToDecimalOutput(keyframe.bestAskTicks, priceScale),\n mid: scaledToDecimalOutput(keyframe.midTicks, priceScale),\n bids: keyframe.bids ? convertHeatmapLevels(keyframe.bids, priceScale, qtyScale) : undefined,\n asks: keyframe.asks ? convertHeatmapLevels(keyframe.asks, priceScale, qtyScale) : undefined,\n bookSeq: keyframe.bookSeq,\n };\n}\n\nexport type OrderbookHeatmapKeyframe = ReturnType<typeof convertHeatmapKeyframe>;\n\nconst OrderbookHeatmapDeltaBucketRawSchema = v.object({\n tsSec: TimestampSecondsSchema,\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n updatesInBucket: v.number(),\n bookSeqStart: Uint64StringSchema,\n bookSeqEnd: Uint64StringSchema,\n});\n\ntype OrderbookHeatmapDeltaBucketRaw = v.InferOutput<typeof OrderbookHeatmapDeltaBucketRawSchema>;\n\nfunction convertHeatmapDeltaBucket(\n bucket: OrderbookHeatmapDeltaBucketRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n tsSec: bucket.tsSec,\n bids: bucket.bids ? convertHeatmapLevels(bucket.bids, priceScale, qtyScale) : undefined,\n asks: bucket.asks ? convertHeatmapLevels(bucket.asks, priceScale, qtyScale) : undefined,\n updatesInBucket: bucket.updatesInBucket,\n bookSeqStart: bucket.bookSeqStart,\n bookSeqEnd: bucket.bookSeqEnd,\n };\n}\n\nexport type OrderbookHeatmapDeltaBucket = ReturnType<typeof convertHeatmapDeltaBucket>;\n\nconst OrderbookHeatmapLiveBucketRawSchema = v.object({\n symbolId: v.number(),\n interval: v.pipe(v.number(), v.transform(requiredIntervalLabelFor)),\n tsSec: TimestampSecondsSchema,\n isFinal: v.boolean(),\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n updatesInBucket: v.number(),\n bookSeqStart: Uint64StringSchema,\n bookSeqEnd: Uint64StringSchema,\n quantityMode: v.pipe(v.number(), v.transform(requiredQuantityModeLabelFor)),\n effectiveBinTicks: v.bigint(),\n});\n\ntype OrderbookHeatmapLiveBucketRaw = v.InferOutput<typeof OrderbookHeatmapLiveBucketRawSchema>;\n\nfunction convertHeatmapLiveBucket(bucket: OrderbookHeatmapLiveBucketRaw, scales: SdkScales) {\n const priceScale = scales.price();\n const qtyScale = scales.baseQty(bucket.symbolId);\n return {\n symbolId: bucket.symbolId,\n interval: bucket.interval,\n tsSec: bucket.tsSec,\n isFinal: bucket.isFinal,\n bids: bucket.bids ? convertHeatmapLevels(bucket.bids, priceScale, qtyScale) : undefined,\n asks: bucket.asks ? convertHeatmapLevels(bucket.asks, priceScale, qtyScale) : undefined,\n updatesInBucket: bucket.updatesInBucket,\n bookSeqStart: bucket.bookSeqStart,\n bookSeqEnd: bucket.bookSeqEnd,\n quantityMode: bucket.quantityMode,\n effectiveBinSize: scaledToDecimalOutput(bucket.effectiveBinTicks, priceScale),\n };\n}\n\nexport type OrderbookHeatmapLiveBucket = ReturnType<typeof convertHeatmapLiveBucket>;\n\nexport function createOrderbookHeatmapLiveBucketSchema(scales: SdkScales) {\n return v.pipe(\n OrderbookHeatmapLiveBucketRawSchema,\n v.transform((bucket) => convertHeatmapLiveBucket(bucket, scales)),\n );\n}\n\nconst OrderbookHeatmapDeltaChainRawSchema = v.object({\n baseKeyframe: v.optional(OrderbookHeatmapKeyframeRawSchema),\n deltas: v.optional(v.array(OrderbookHeatmapDeltaBucketRawSchema), []),\n});\n\ntype OrderbookHeatmapDeltaChainRaw = v.InferOutput<typeof OrderbookHeatmapDeltaChainRawSchema>;\n\nfunction convertHeatmapDeltaChain(\n chain: OrderbookHeatmapDeltaChainRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n baseKeyframe: chain.baseKeyframe\n ? convertHeatmapKeyframe(chain.baseKeyframe, priceScale, qtyScale)\n : undefined,\n deltas: chain.deltas.map((bucket) =>\n convertHeatmapDeltaBucket(bucket, priceScale, qtyScale),\n ),\n };\n}\n\nexport type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;\n\nconst OrderbookHeatmapResponseRawSchema = v.object({\n symbolId: v.number(),\n interval: v.pipe(v.number(), v.transform(requiredIntervalLabelFor)),\n depth: v.pipe(\n v.number(),\n v.transform((value) =>\n requiredEnumLabel(\n HeatmapDepthCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"depth\",\n ),\n ),\n ),\n chain: v.optional(OrderbookHeatmapDeltaChainRawSchema),\n lastPersistedTsSec: TimestampSecondsSchema,\n liveFromBookSeqEnd: Uint64StringSchema,\n hasLiveAnchor: v.boolean(),\n nextPageToken: v.optional(v.string(), \"\"),\n serverTimeSec: TimestampSecondsSchema,\n quantityMode: v.pipe(v.number(), v.transform(requiredQuantityModeLabelFor)),\n liveBucket: v.optional(OrderbookHeatmapLiveBucketRawSchema),\n});\n\nexport function createOrderbookHeatmapResponseSchema(scales: SdkScales) {\n return v.pipe(\n OrderbookHeatmapResponseRawSchema,\n v.transform((res) => {\n const priceScale = scales.price();\n const qtyScale = scales.baseQty(res.symbolId);\n return {\n symbolId: res.symbolId,\n interval: res.interval,\n depth: res.depth,\n chain: res.chain\n ? convertHeatmapDeltaChain(res.chain, priceScale, qtyScale)\n : undefined,\n lastPersistedTsSec: res.lastPersistedTsSec,\n liveFromBookSeqEnd: res.liveFromBookSeqEnd,\n hasLiveAnchor: res.hasLiveAnchor,\n nextPageToken: res.nextPageToken,\n serverTimeSec: res.serverTimeSec,\n quantityMode: res.quantityMode,\n liveBucket: res.liveBucket\n ? convertHeatmapLiveBucket(res.liveBucket, scales)\n : undefined,\n };\n }),\n );\n}\n\nexport type GetOrderbookHeatmapInput = v.InferInput<typeof GetOrderbookHeatmapInputSchema>;\nexport type ParsedGetOrderbookHeatmapInput = v.InferOutput<typeof GetOrderbookHeatmapInputSchema>;\nexport type OrderbookHeatmapResponse = v.InferOutput<\n ReturnType<typeof createOrderbookHeatmapResponseSchema>\n>;\nexport type ParsedHeatmapTimeRange = HeatmapTimeRangeInit;\n"],"mappings":";;;;;;;AA6BA,MAAM,sBAAsB,EAAE,KAC1B,EAAE,SAAS,EAAE,SAAS,uBAAuB,GAAG,IAAI,GACpD,EAAE,WAAW,UAA2B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I;GACnB,cAAc,IAAI;GAClB,YAAY,IAAI,aACV,yBAAyB,IAAI,YAAY,MAAM,IAC/C,KAAA;EACV;CACJ,CAAC,CACL;AACJ"}
|
|
@@ -60,7 +60,7 @@ declare function createCreateInternalTransferInputSchema(scales: SdkScales): v.S
|
|
|
60
60
|
readonly case: "destinationSmartAccountAddress";
|
|
61
61
|
readonly value: string;
|
|
62
62
|
}>]>;
|
|
63
|
-
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
63
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
64
64
|
readonly quantity: v.StringSchema<undefined>;
|
|
65
65
|
readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
66
66
|
readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
|
|
@@ -118,7 +118,7 @@ declare function createCreateInternalTransferResultSchema(): v.SchemaWithPipe<re
|
|
|
118
118
|
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
119
119
|
readonly transferId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
120
120
|
readonly acceptedAtTsNs: v.BigintSchema<undefined>;
|
|
121
|
-
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
121
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
122
122
|
readonly assetCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
123
123
|
readonly uAssetId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
124
124
|
readonly amountE18: v.ObjectSchema<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-transfers.schemas.d.ts","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"internal-transfers.schemas.d.ts","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"mappings":";;;;cA0Ba,wCAAsC,EAAA,yBAAA,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoCvC,8BAA8B,EAAE,kBACjC;iBAGK,wCAAwC,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAAA;;;;;;;;;;;;;;;KA0B7D,8BAA8B,EAAE,WACxC,kBAAkB;cAYT,2CAAyC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;KAa1C,sCAAsC,EAAE,mBACzC;iBAGK,4CAAwC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoB5C,+BAA+B,EAAE,YACzC,kBAAkB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { tsNsToMs } from "../../utils/time.js";
|
|
2
2
|
import { idInputSchema } from "../../shared/schemas.js";
|
|
3
|
+
import { PositiveUint32InputSchema } from "../shared.js";
|
|
3
4
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
4
5
|
import { quantityInputToE18, scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
5
6
|
import { fromU128, toU128 } from "../../utils/u128.js";
|
|
@@ -44,7 +45,7 @@ function createCreateInternalTransferInputSchema(scales) {
|
|
|
44
45
|
return v.pipe(v.strictObject({
|
|
45
46
|
...AccountScopeInputEntries,
|
|
46
47
|
destination: InternalTransferDestinationInputSchema,
|
|
47
|
-
assetId:
|
|
48
|
+
assetId: PositiveUint32InputSchema,
|
|
48
49
|
quantity: v.string(),
|
|
49
50
|
idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1))
|
|
50
51
|
}), v.transform(({ account, quantity, ...input }) => ({
|
|
@@ -73,7 +74,7 @@ function createCreateInternalTransferResultSchema() {
|
|
|
73
74
|
requestId: NonEmptyResponseStringSchema,
|
|
74
75
|
transferId: NonEmptyResponseStringSchema,
|
|
75
76
|
acceptedAtTsNs: v.bigint(),
|
|
76
|
-
assetId:
|
|
77
|
+
assetId: PositiveUint32InputSchema,
|
|
77
78
|
assetCode: NonEmptyResponseStringSchema,
|
|
78
79
|
uAssetId: NonEmptyResponseStringSchema,
|
|
79
80
|
amountE18: U128Schema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-transfers.schemas.js","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"sourcesContent":["import type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport * as v from \"valibot\";\nimport type * as Proto from \"../../gen/transfer/v1/internal_transfer_pb.js\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport {\n E18_SCALE,\n quantityInputToE18,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport { InternalTransferDestinationCodec } from \"./internal-transfers.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { fromU128, toU128 } from \"../../utils/u128.js\";\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\nconst IdSchema = idInputSchema;\n\nexport const InternalTransferDestinationInputSchema = v.pipe(\n v.variant(\"type\", [\n v.strictObject({\n type: v.literal(\"account\"),\n accountId: IdSchema(\"accountId\"),\n }),\n v.strictObject({\n type: v.literal(\"subaccount\"),\n subaccountId: IdSchema(\"subaccountId\"),\n }),\n v.strictObject({\n type: v.literal(\"smartAccountAddress\"),\n address: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n ]),\n v.transform((destination) => {\n switch (destination.type) {\n case \"account\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.account,\n value: destination.accountId,\n } as const;\n case \"subaccount\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.subaccount,\n value: destination.subaccountId,\n } as const;\n case \"smartAccountAddress\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.smartAccountAddress,\n value: destination.address,\n } as const;\n }\n }),\n);\n\nexport type InternalTransferDestination = v.InferInput<\n typeof InternalTransferDestinationInputSchema\n>;\n\nexport function createCreateInternalTransferInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n destination: InternalTransferDestinationInputSchema,\n assetId:
|
|
1
|
+
{"version":3,"file":"internal-transfers.schemas.js","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"sourcesContent":["import type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport * as v from \"valibot\";\nimport type * as Proto from \"../../gen/transfer/v1/internal_transfer_pb.js\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport {\n E18_SCALE,\n quantityInputToE18,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport { InternalTransferDestinationCodec } from \"./internal-transfers.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { fromU128, toU128 } from \"../../utils/u128.js\";\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\nconst IdSchema = idInputSchema;\n\nexport const InternalTransferDestinationInputSchema = v.pipe(\n v.variant(\"type\", [\n v.strictObject({\n type: v.literal(\"account\"),\n accountId: IdSchema(\"accountId\"),\n }),\n v.strictObject({\n type: v.literal(\"subaccount\"),\n subaccountId: IdSchema(\"subaccountId\"),\n }),\n v.strictObject({\n type: v.literal(\"smartAccountAddress\"),\n address: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n ]),\n v.transform((destination) => {\n switch (destination.type) {\n case \"account\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.account,\n value: destination.accountId,\n } as const;\n case \"subaccount\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.subaccount,\n value: destination.subaccountId,\n } as const;\n case \"smartAccountAddress\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.smartAccountAddress,\n value: destination.address,\n } as const;\n }\n }),\n);\n\nexport type InternalTransferDestination = v.InferInput<\n typeof InternalTransferDestinationInputSchema\n>;\n\nexport function createCreateInternalTransferInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n destination: InternalTransferDestinationInputSchema,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform(\n ({ account, quantity, ...input }) =>\n ({\n ...input,\n amountE18: toU128(\n quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity,\n }),\n ),\n subaccountId: accountScopeToSubaccountId(account),\n }) satisfies MessageInitShape<typeof Proto.CreateInternalTransferRequestSchema>,\n ),\n );\n}\n\nexport type CreateInternalTransferInput = v.InferInput<\n ReturnType<typeof createCreateInternalTransferInputSchema>\n>;\nexport type CreateInternalTransferRequest = v.InferOutput<\n ReturnType<typeof createCreateInternalTransferInputSchema>\n>;\n\nconst NonEmptyResponseStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\nconst OptionalResponseStringSchema = v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? value : undefined)),\n);\n\nexport const ResolvedInternalTransferDestinationSchema = v.pipe(\n v.object({\n rootAccountPublicId: OptionalResponseStringSchema,\n subaccountPublicId: OptionalResponseStringSchema,\n smartAccountAddress: OptionalResponseStringSchema,\n }),\n v.transform(({ rootAccountPublicId, subaccountPublicId, smartAccountAddress }) => ({\n rootAccountId: rootAccountPublicId,\n subaccountId: subaccountPublicId,\n smartAccountAddress,\n })),\n);\n\nexport type ResolvedInternalTransferDestination = v.InferOutput<\n typeof ResolvedInternalTransferDestinationSchema\n>;\n\nexport function createCreateInternalTransferResultSchema() {\n return v.pipe(\n v.object({\n requestId: NonEmptyResponseStringSchema,\n transferId: NonEmptyResponseStringSchema,\n acceptedAtTsNs: v.bigint(),\n assetId: PositiveUint32InputSchema,\n assetCode: NonEmptyResponseStringSchema,\n uAssetId: NonEmptyResponseStringSchema,\n amountE18: U128Schema,\n destination: v.optional(ResolvedInternalTransferDestinationSchema),\n }),\n v.transform(({ acceptedAtTsNs, amountE18, ...result }) => ({\n ...result,\n acceptedAtUnixMs: tsNsToMs(acceptedAtTsNs),\n quantity: scaledToDecimalOutput(fromU128(amountE18), E18_SCALE),\n })),\n );\n}\n\nexport type CreateInternalTransferResult = v.InferOutput<\n ReturnType<typeof createCreateInternalTransferResultSchema>\n>;\n"],"mappings":";;;;;;;;;AAmBA,MAAM,aAAa,EAAE,OAAO;CACxB,IAAI,EAAE,OAAO;CACb,IAAI,EAAE,OAAO;AACjB,CAAC;AAED,MAAM,WAAW;AAEjB,MAAa,yCAAyC,EAAE,KACpD,EAAE,QAAQ,QAAQ;CACd,EAAE,aAAa;EACX,MAAM,EAAE,QAAQ,SAAS;EACzB,WAAW,SAAS,WAAW;CACnC,CAAC;CACD,EAAE,aAAa;EACX,MAAM,EAAE,QAAQ,YAAY;EAC5B,cAAc,SAAS,cAAc;CACzC,CAAC;CACD,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