@polyester/sdk 0.4.2 → 0.4.4

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @polyester/sdk
2
2
 
3
+ ## 0.4.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#62](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/62) [`ee6f75a`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/ee6f75a64294ffad0c05dfdfe65b802699509b7b) Thanks [@huntabyte](https://github.com/huntabyte)! - fix: `orders.batchCreate()` no longer throws a `ValiError` when the server rejects an item without a structured error detail; the item is surfaced as `status: "rejected"` with `error` possibly undefined. Also documents that `orders.listOpen()` is paginated and must be drained via `nextPageToken`.
8
+
9
+ ## 0.4.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#60](https://github.com/Fabric-Labs/polyester-sdk-typescript/pull/60) [`f91caab`](https://github.com/Fabric-Labs/polyester-sdk-typescript/commit/f91caaba589ce689ffaa7d310f833373a8e61009) Thanks [@huntabyte](https://github.com/huntabyte)! - Declare the Multicall3 deployment (`0xF35A6AE5408fa1356064849D0BC3855f801aa6aC`, block 563457) on the Polychain testnet chain definition so viem clients can batch contract reads via multicall instead of issuing one `eth_call` per read.
14
+
3
15
  ## 0.4.2
4
16
 
5
17
  ### Patch Changes
@@ -157,6 +157,10 @@ const POLYESTER_TESTNET_ENVIRONMENT = createPolyesterEnvironment({
157
157
  blockExplorers: { default: {
158
158
  name: "Polyester Scan",
159
159
  url: "https://polyesterscan.com"
160
+ } },
161
+ contracts: { multicall3: {
162
+ address: "0xF35A6AE5408fa1356064849D0BC3855f801aa6aC",
163
+ blockCreated: 563457
160
164
  } }
161
165
  },
162
166
  accountAbstraction: {
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","names":[],"sources":["../src/environment.ts"],"sourcesContent":["import type { SafeVersion } from \"permissionless/accounts\";\nimport { ConfigurationError } from \"./shared/errors.js\";\nimport type { Address, Chain } from \"viem\";\nimport { checksumEvmAddress, evmUtf8ToBytes, isEvmAddress, keccak256Hex } from \"./utils/evm.js\";\n\nexport interface PolyesterEntryPointConfig {\n readonly address: Address;\n readonly version: \"0.7\";\n}\n\nexport interface PolyesterSafeDeploymentConfig {\n readonly version: SafeVersion;\n readonly safeModuleSetupAddress: Address;\n readonly safe4337ModuleAddress: Address;\n readonly safeProxyFactoryAddress: Address;\n readonly safeSingletonAddress: Address;\n readonly multiSendAddress: Address;\n readonly multiSendCallOnlyAddress?: Address;\n}\n\nexport interface PolyesterAccountAbstractionEnvironment {\n readonly bundlerUrl: string;\n readonly paymasterUrl: string;\n readonly entryPoint: PolyesterEntryPointConfig;\n readonly safe: PolyesterSafeDeploymentConfig;\n}\n\nexport interface PolyesterContractsEnvironment {\n readonly tradingGatewayAddress: Address;\n}\n\nexport interface PolyesterEnvironment {\n readonly name: string;\n readonly fingerprint: string;\n readonly apiUrl: string;\n readonly websocketUrl: string;\n readonly rpcUrl: string;\n readonly chain: Chain;\n readonly accountAbstraction: PolyesterAccountAbstractionEnvironment;\n readonly contracts: PolyesterContractsEnvironment;\n}\n\nexport interface CreatePolyesterEnvironmentParams {\n readonly name: string;\n readonly apiUrl: string;\n readonly websocketUrl: string;\n readonly rpcUrl: string;\n readonly chain: Chain;\n readonly accountAbstraction: {\n readonly bundlerUrl: string;\n readonly paymasterUrl: string;\n readonly entryPoint: PolyesterEntryPointConfig;\n readonly safe: PolyesterSafeDeploymentConfig;\n };\n readonly contracts: PolyesterContractsEnvironment;\n}\n\nconst LOCAL_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"::1\", \"[::1]\"]);\n\nfunction requireObject(value: unknown, label: string): asserts value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new ConfigurationError(`${label} must be an object.`);\n }\n}\n\nfunction requireNonEmptyString(value: unknown, label: string): asserts value is string {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new ConfigurationError(`${label} must be a non-empty string.`);\n }\n}\n\nfunction isLocalHost(hostname: string): boolean {\n return LOCAL_HOSTS.has(hostname);\n}\n\nfunction normalizeUrl(value: string, label: string, allowedProtocols: readonly string[]): string {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n throw new ConfigurationError(`${label} must be a valid URL.`);\n }\n\n if (!allowedProtocols.includes(url.protocol)) {\n throw new ConfigurationError(`${label} must use ${allowedProtocols.join(\" or \")}.`);\n }\n\n const insecureRemote =\n (url.protocol === \"http:\" || url.protocol === \"ws:\") && !isLocalHost(url.hostname);\n if (insecureRemote) {\n throw new ConfigurationError(`${label} must use a secure protocol for remote hosts.`);\n }\n\n url.hash = \"\";\n return url.toString().replace(/\\/+$/u, \"\");\n}\n\nfunction normalizeAddress(value: Address, label: string): Address {\n if (!isEvmAddress(value)) {\n throw new ConfigurationError(`${label} must be a valid address.`);\n }\n return checksumEvmAddress(value);\n}\n\nfunction normalizeEntryPoint(entryPoint: PolyesterEntryPointConfig): PolyesterEntryPointConfig {\n requireObject(entryPoint, \"accountAbstraction.entryPoint\");\n if (entryPoint.version !== \"0.7\") {\n throw new ConfigurationError(\"accountAbstraction.entryPoint.version must be 0.7.\");\n }\n return Object.freeze({\n address: normalizeAddress(entryPoint.address, \"accountAbstraction.entryPoint.address\"),\n version: entryPoint.version,\n });\n}\n\nfunction normalizeSafeConfig(safe: PolyesterSafeDeploymentConfig): PolyesterSafeDeploymentConfig {\n requireObject(safe, \"accountAbstraction.safe\");\n if (safe.version !== \"1.4.1\" && safe.version !== \"1.5.0\") {\n throw new ConfigurationError(\n 'accountAbstraction.safe.version must be either \"1.4.1\" or \"1.5.0\".',\n );\n }\n return Object.freeze({\n version: safe.version,\n safeModuleSetupAddress: normalizeAddress(\n safe.safeModuleSetupAddress,\n \"accountAbstraction.safe.safeModuleSetupAddress\",\n ),\n safe4337ModuleAddress: normalizeAddress(\n safe.safe4337ModuleAddress,\n \"accountAbstraction.safe.safe4337ModuleAddress\",\n ),\n safeProxyFactoryAddress: normalizeAddress(\n safe.safeProxyFactoryAddress,\n \"accountAbstraction.safe.safeProxyFactoryAddress\",\n ),\n safeSingletonAddress: normalizeAddress(\n safe.safeSingletonAddress,\n \"accountAbstraction.safe.safeSingletonAddress\",\n ),\n multiSendAddress: normalizeAddress(\n safe.multiSendAddress,\n \"accountAbstraction.safe.multiSendAddress\",\n ),\n multiSendCallOnlyAddress: safe.multiSendCallOnlyAddress\n ? normalizeAddress(\n safe.multiSendCallOnlyAddress,\n \"accountAbstraction.safe.multiSendCallOnlyAddress\",\n )\n : undefined,\n });\n}\n\nfunction normalizeChain(chain: Chain, rpcUrl: string): Chain {\n requireObject(chain, \"chain\");\n if (!Number.isInteger(chain.id) || chain.id <= 0) {\n throw new ConfigurationError(\"chain.id must be a positive integer.\");\n }\n requireNonEmptyString(chain.name, \"chain.name\");\n requireObject(chain.nativeCurrency, \"chain.nativeCurrency\");\n if (!Number.isInteger(chain.nativeCurrency.decimals) || chain.nativeCurrency.decimals < 0) {\n throw new ConfigurationError(\n \"chain.nativeCurrency.decimals must be a non-negative integer.\",\n );\n }\n requireNonEmptyString(chain.nativeCurrency.name, \"chain.nativeCurrency.name\");\n requireNonEmptyString(chain.nativeCurrency.symbol, \"chain.nativeCurrency.symbol\");\n requireObject(chain.rpcUrls, \"chain.rpcUrls\");\n requireObject(chain.rpcUrls.default, \"chain.rpcUrls.default\");\n if (!Array.isArray(chain.rpcUrls.default.http)) {\n throw new ConfigurationError(\"chain.rpcUrls.default.http must be an array.\");\n }\n\n // Shape parity with viem's defineChain: spread over undefined defaults.\n return Object.freeze({\n formatters: undefined,\n fees: undefined,\n serializers: undefined,\n ...chain,\n rpcUrls: {\n ...chain.rpcUrls,\n default: {\n ...chain.rpcUrls.default,\n http: [rpcUrl],\n },\n },\n });\n}\n\nfunction environmentFingerprint(input: {\n apiUrl: string;\n websocketUrl: string;\n rpcUrl: string;\n chainId: number;\n accountAbstraction: PolyesterAccountAbstractionEnvironment;\n contracts: PolyesterContractsEnvironment;\n}): string {\n return keccak256Hex(\n evmUtf8ToBytes(\n JSON.stringify({\n apiUrl: input.apiUrl,\n websocketUrl: input.websocketUrl,\n rpcUrl: input.rpcUrl,\n chainId: input.chainId,\n bundlerUrl: input.accountAbstraction.bundlerUrl,\n paymasterUrl: input.accountAbstraction.paymasterUrl,\n entryPoint: input.accountAbstraction.entryPoint,\n safe: input.accountAbstraction.safe,\n contracts: input.contracts,\n }),\n ),\n );\n}\n\n/**\n * Creates a complete SDK environment configuration from entrypoint and contract settings.\n */\nexport function createPolyesterEnvironment(\n params: CreatePolyesterEnvironmentParams,\n): PolyesterEnvironment {\n requireObject(params, \"Environment configuration\");\n requireNonEmptyString(params.name, \"name\");\n requireObject(params.accountAbstraction, \"accountAbstraction\");\n requireObject(params.contracts, \"contracts\");\n const apiUrl = normalizeUrl(params.apiUrl, \"apiUrl\", [\"https:\", \"http:\"]);\n const websocketUrl = normalizeUrl(params.websocketUrl, \"websocketUrl\", [\"wss:\", \"ws:\"]);\n const rpcUrl = normalizeUrl(params.rpcUrl, \"rpcUrl\", [\"https:\", \"http:\"]);\n const bundlerUrl = normalizeUrl(params.accountAbstraction.bundlerUrl, \"bundlerUrl\", [\n \"https:\",\n \"http:\",\n ]);\n const paymasterUrl = normalizeUrl(params.accountAbstraction.paymasterUrl, \"paymasterUrl\", [\n \"https:\",\n \"http:\",\n ]);\n const chain = normalizeChain(params.chain, rpcUrl);\n const accountAbstraction = Object.freeze({\n bundlerUrl,\n paymasterUrl,\n entryPoint: normalizeEntryPoint(params.accountAbstraction.entryPoint),\n safe: normalizeSafeConfig(params.accountAbstraction.safe),\n });\n const contracts = Object.freeze({\n tradingGatewayAddress: normalizeAddress(\n params.contracts.tradingGatewayAddress,\n \"contracts.tradingGatewayAddress\",\n ),\n });\n const fingerprint = environmentFingerprint({\n apiUrl,\n websocketUrl,\n rpcUrl,\n chainId: chain.id,\n accountAbstraction,\n contracts,\n });\n\n return Object.freeze({\n name: params.name,\n fingerprint,\n apiUrl,\n websocketUrl,\n rpcUrl,\n chain,\n accountAbstraction,\n contracts,\n });\n}\n\n/**\n * Parses a complete environment supplied to a public SDK client constructor.\n */\nexport function parsePolyesterEnvironment(environment: PolyesterEnvironment): PolyesterEnvironment {\n requireObject(environment, \"environment\");\n const parsed = createPolyesterEnvironment(environment);\n if (environment.fingerprint !== parsed.fingerprint) {\n throw new ConfigurationError(\n \"environment.fingerprint must match the environment configuration.\",\n );\n }\n return parsed;\n}\n\nexport const POLYESTER_TESTNET_ENVIRONMENT = createPolyesterEnvironment({\n name: \"polyester-testnet\",\n apiUrl: \"https://api-devnet.polyester.ai\",\n websocketUrl: \"wss://api-devnet.polyester.ai\",\n rpcUrl: \"https://rpc.polyester.tech\",\n chain: {\n id: 888168,\n name: \"Polyester Chain Testnet\",\n nativeCurrency: {\n decimals: 18,\n name: \"POL\",\n symbol: \"POL\",\n },\n rpcUrls: {\n default: {\n http: [\"https://rpc.polyester.tech\"],\n },\n },\n blockExplorers: {\n default: {\n name: \"Polyester Scan\",\n url: \"https://polyesterscan.com\",\n },\n },\n },\n accountAbstraction: {\n bundlerUrl: \"https://bundler.polyester.tech\",\n paymasterUrl: \"https://paymaster.polyester.tech\",\n entryPoint: {\n address: \"0x59a4B77766509c4507D79eFF8089474eC3daC174\",\n version: \"0.7\",\n },\n safe: {\n version: \"1.4.1\",\n safeModuleSetupAddress: \"0x80791683D9C079A37Debc67EaDdbFcBC6f0FF2bB\",\n safe4337ModuleAddress: \"0x0713FF3d4c1b4f177833a372b1e3cb977540EA11\",\n safeProxyFactoryAddress: \"0xF8F0F649Dd3bFa9095206691E9fb2356c26216dE\",\n safeSingletonAddress: \"0x92abEa238FEA8908c397cE65366ea9278f0AeC7A\",\n multiSendAddress: \"0x70C8a8CcB45a8E2589B0f019374fc923dA34E4c7\",\n multiSendCallOnlyAddress: \"0x375C86a08DA98d1944D7B3c736307A72186CcAf1\",\n },\n },\n contracts: {\n t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AAS,MAAM;EACf;EACA;CACJ,CAAC;CAED,OAAO,OAAO,OAAO;EACjB,MAAM,OAAO;EACb;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL;;;;AAKA,SAAgB,0BAA0B,aAAyD;CAC/F,cAAc,aAAa,aAAa;CACxC,MAAM,SAAS,2BAA2B,WAAW;CACrD,IAAI,YAAY,gBAAgB,OAAO,aACnC,MAAM,IAAI,mBACN,mEACJ;CAEJ,OAAO;AACX;AAEA,MAAa,gCAAgC,2BAA2B;CACpE,MAAM;CACN,QAAQ;CACR,cAAc;CACd,QAAQ;CACR,OAAO;EACH,IAAI;EACJ,MAAM;EACN,gBAAgB;GACZ,UAAU;GACV,MAAM;GACN,QAAQ;EACZ;EACA,SAAS,EACL,SAAS,EACL,MAAM,CAAC,4BAA4B,EACvC,EACJ;EACA,gBAAgB,EACZ,SAAS;GACL,MAAM;GACN,KAAK;EACT,EACJ;CACJ;CACA,oBAAoB;EAChB,YAAY;EACZ,cAAc;EACd,YAAY;GACR,SAAS;GACT,SAAS;EACb;EACA,MAAM;GACF,SAAS;GACT,wBAAwB;GACxB,uBAAuB;GACvB,yBAAyB;GACzB,sBAAsB;GACtB,kBAAkB;GAClB,0BAA0B;EAC9B;CACJ;CACA,WAAW,EACP,uBAAuB,6CAC3B;AACJ,CAAC"}
1
+ {"version":3,"file":"environment.js","names":[],"sources":["../src/environment.ts"],"sourcesContent":["import type { SafeVersion } from \"permissionless/accounts\";\nimport { ConfigurationError } from \"./shared/errors.js\";\nimport type { Address, Chain } from \"viem\";\nimport { checksumEvmAddress, evmUtf8ToBytes, isEvmAddress, keccak256Hex } from \"./utils/evm.js\";\n\nexport interface PolyesterEntryPointConfig {\n readonly address: Address;\n readonly version: \"0.7\";\n}\n\nexport interface PolyesterSafeDeploymentConfig {\n readonly version: SafeVersion;\n readonly safeModuleSetupAddress: Address;\n readonly safe4337ModuleAddress: Address;\n readonly safeProxyFactoryAddress: Address;\n readonly safeSingletonAddress: Address;\n readonly multiSendAddress: Address;\n readonly multiSendCallOnlyAddress?: Address;\n}\n\nexport interface PolyesterAccountAbstractionEnvironment {\n readonly bundlerUrl: string;\n readonly paymasterUrl: string;\n readonly entryPoint: PolyesterEntryPointConfig;\n readonly safe: PolyesterSafeDeploymentConfig;\n}\n\nexport interface PolyesterContractsEnvironment {\n readonly tradingGatewayAddress: Address;\n}\n\nexport interface PolyesterEnvironment {\n readonly name: string;\n readonly fingerprint: string;\n readonly apiUrl: string;\n readonly websocketUrl: string;\n readonly rpcUrl: string;\n readonly chain: Chain;\n readonly accountAbstraction: PolyesterAccountAbstractionEnvironment;\n readonly contracts: PolyesterContractsEnvironment;\n}\n\nexport interface CreatePolyesterEnvironmentParams {\n readonly name: string;\n readonly apiUrl: string;\n readonly websocketUrl: string;\n readonly rpcUrl: string;\n readonly chain: Chain;\n readonly accountAbstraction: {\n readonly bundlerUrl: string;\n readonly paymasterUrl: string;\n readonly entryPoint: PolyesterEntryPointConfig;\n readonly safe: PolyesterSafeDeploymentConfig;\n };\n readonly contracts: PolyesterContractsEnvironment;\n}\n\nconst LOCAL_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"::1\", \"[::1]\"]);\n\nfunction requireObject(value: unknown, label: string): asserts value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new ConfigurationError(`${label} must be an object.`);\n }\n}\n\nfunction requireNonEmptyString(value: unknown, label: string): asserts value is string {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new ConfigurationError(`${label} must be a non-empty string.`);\n }\n}\n\nfunction isLocalHost(hostname: string): boolean {\n return LOCAL_HOSTS.has(hostname);\n}\n\nfunction normalizeUrl(value: string, label: string, allowedProtocols: readonly string[]): string {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n throw new ConfigurationError(`${label} must be a valid URL.`);\n }\n\n if (!allowedProtocols.includes(url.protocol)) {\n throw new ConfigurationError(`${label} must use ${allowedProtocols.join(\" or \")}.`);\n }\n\n const insecureRemote =\n (url.protocol === \"http:\" || url.protocol === \"ws:\") && !isLocalHost(url.hostname);\n if (insecureRemote) {\n throw new ConfigurationError(`${label} must use a secure protocol for remote hosts.`);\n }\n\n url.hash = \"\";\n return url.toString().replace(/\\/+$/u, \"\");\n}\n\nfunction normalizeAddress(value: Address, label: string): Address {\n if (!isEvmAddress(value)) {\n throw new ConfigurationError(`${label} must be a valid address.`);\n }\n return checksumEvmAddress(value);\n}\n\nfunction normalizeEntryPoint(entryPoint: PolyesterEntryPointConfig): PolyesterEntryPointConfig {\n requireObject(entryPoint, \"accountAbstraction.entryPoint\");\n if (entryPoint.version !== \"0.7\") {\n throw new ConfigurationError(\"accountAbstraction.entryPoint.version must be 0.7.\");\n }\n return Object.freeze({\n address: normalizeAddress(entryPoint.address, \"accountAbstraction.entryPoint.address\"),\n version: entryPoint.version,\n });\n}\n\nfunction normalizeSafeConfig(safe: PolyesterSafeDeploymentConfig): PolyesterSafeDeploymentConfig {\n requireObject(safe, \"accountAbstraction.safe\");\n if (safe.version !== \"1.4.1\" && safe.version !== \"1.5.0\") {\n throw new ConfigurationError(\n 'accountAbstraction.safe.version must be either \"1.4.1\" or \"1.5.0\".',\n );\n }\n return Object.freeze({\n version: safe.version,\n safeModuleSetupAddress: normalizeAddress(\n safe.safeModuleSetupAddress,\n \"accountAbstraction.safe.safeModuleSetupAddress\",\n ),\n safe4337ModuleAddress: normalizeAddress(\n safe.safe4337ModuleAddress,\n \"accountAbstraction.safe.safe4337ModuleAddress\",\n ),\n safeProxyFactoryAddress: normalizeAddress(\n safe.safeProxyFactoryAddress,\n \"accountAbstraction.safe.safeProxyFactoryAddress\",\n ),\n safeSingletonAddress: normalizeAddress(\n safe.safeSingletonAddress,\n \"accountAbstraction.safe.safeSingletonAddress\",\n ),\n multiSendAddress: normalizeAddress(\n safe.multiSendAddress,\n \"accountAbstraction.safe.multiSendAddress\",\n ),\n multiSendCallOnlyAddress: safe.multiSendCallOnlyAddress\n ? normalizeAddress(\n safe.multiSendCallOnlyAddress,\n \"accountAbstraction.safe.multiSendCallOnlyAddress\",\n )\n : undefined,\n });\n}\n\nfunction normalizeChain(chain: Chain, rpcUrl: string): Chain {\n requireObject(chain, \"chain\");\n if (!Number.isInteger(chain.id) || chain.id <= 0) {\n throw new ConfigurationError(\"chain.id must be a positive integer.\");\n }\n requireNonEmptyString(chain.name, \"chain.name\");\n requireObject(chain.nativeCurrency, \"chain.nativeCurrency\");\n if (!Number.isInteger(chain.nativeCurrency.decimals) || chain.nativeCurrency.decimals < 0) {\n throw new ConfigurationError(\n \"chain.nativeCurrency.decimals must be a non-negative integer.\",\n );\n }\n requireNonEmptyString(chain.nativeCurrency.name, \"chain.nativeCurrency.name\");\n requireNonEmptyString(chain.nativeCurrency.symbol, \"chain.nativeCurrency.symbol\");\n requireObject(chain.rpcUrls, \"chain.rpcUrls\");\n requireObject(chain.rpcUrls.default, \"chain.rpcUrls.default\");\n if (!Array.isArray(chain.rpcUrls.default.http)) {\n throw new ConfigurationError(\"chain.rpcUrls.default.http must be an array.\");\n }\n\n // Shape parity with viem's defineChain: spread over undefined defaults.\n return Object.freeze({\n formatters: undefined,\n fees: undefined,\n serializers: undefined,\n ...chain,\n rpcUrls: {\n ...chain.rpcUrls,\n default: {\n ...chain.rpcUrls.default,\n http: [rpcUrl],\n },\n },\n });\n}\n\nfunction environmentFingerprint(input: {\n apiUrl: string;\n websocketUrl: string;\n rpcUrl: string;\n chainId: number;\n accountAbstraction: PolyesterAccountAbstractionEnvironment;\n contracts: PolyesterContractsEnvironment;\n}): string {\n return keccak256Hex(\n evmUtf8ToBytes(\n JSON.stringify({\n apiUrl: input.apiUrl,\n websocketUrl: input.websocketUrl,\n rpcUrl: input.rpcUrl,\n chainId: input.chainId,\n bundlerUrl: input.accountAbstraction.bundlerUrl,\n paymasterUrl: input.accountAbstraction.paymasterUrl,\n entryPoint: input.accountAbstraction.entryPoint,\n safe: input.accountAbstraction.safe,\n contracts: input.contracts,\n }),\n ),\n );\n}\n\n/**\n * Creates a complete SDK environment configuration from entrypoint and contract settings.\n */\nexport function createPolyesterEnvironment(\n params: CreatePolyesterEnvironmentParams,\n): PolyesterEnvironment {\n requireObject(params, \"Environment configuration\");\n requireNonEmptyString(params.name, \"name\");\n requireObject(params.accountAbstraction, \"accountAbstraction\");\n requireObject(params.contracts, \"contracts\");\n const apiUrl = normalizeUrl(params.apiUrl, \"apiUrl\", [\"https:\", \"http:\"]);\n const websocketUrl = normalizeUrl(params.websocketUrl, \"websocketUrl\", [\"wss:\", \"ws:\"]);\n const rpcUrl = normalizeUrl(params.rpcUrl, \"rpcUrl\", [\"https:\", \"http:\"]);\n const bundlerUrl = normalizeUrl(params.accountAbstraction.bundlerUrl, \"bundlerUrl\", [\n \"https:\",\n \"http:\",\n ]);\n const paymasterUrl = normalizeUrl(params.accountAbstraction.paymasterUrl, \"paymasterUrl\", [\n \"https:\",\n \"http:\",\n ]);\n const chain = normalizeChain(params.chain, rpcUrl);\n const accountAbstraction = Object.freeze({\n bundlerUrl,\n paymasterUrl,\n entryPoint: normalizeEntryPoint(params.accountAbstraction.entryPoint),\n safe: normalizeSafeConfig(params.accountAbstraction.safe),\n });\n const contracts = Object.freeze({\n tradingGatewayAddress: normalizeAddress(\n params.contracts.tradingGatewayAddress,\n \"contracts.tradingGatewayAddress\",\n ),\n });\n const fingerprint = environmentFingerprint({\n apiUrl,\n websocketUrl,\n rpcUrl,\n chainId: chain.id,\n accountAbstraction,\n contracts,\n });\n\n return Object.freeze({\n name: params.name,\n fingerprint,\n apiUrl,\n websocketUrl,\n rpcUrl,\n chain,\n accountAbstraction,\n contracts,\n });\n}\n\n/**\n * Parses a complete environment supplied to a public SDK client constructor.\n */\nexport function parsePolyesterEnvironment(environment: PolyesterEnvironment): PolyesterEnvironment {\n requireObject(environment, \"environment\");\n const parsed = createPolyesterEnvironment(environment);\n if (environment.fingerprint !== parsed.fingerprint) {\n throw new ConfigurationError(\n \"environment.fingerprint must match the environment configuration.\",\n );\n }\n return parsed;\n}\n\nexport const POLYESTER_TESTNET_ENVIRONMENT = createPolyesterEnvironment({\n name: \"polyester-testnet\",\n apiUrl: \"https://api-devnet.polyester.ai\",\n websocketUrl: \"wss://api-devnet.polyester.ai\",\n rpcUrl: \"https://rpc.polyester.tech\",\n chain: {\n id: 888168,\n name: \"Polyester Chain Testnet\",\n nativeCurrency: {\n decimals: 18,\n name: \"POL\",\n symbol: \"POL\",\n },\n rpcUrls: {\n default: {\n http: [\"https://rpc.polyester.tech\"],\n },\n },\n blockExplorers: {\n default: {\n name: \"Polyester Scan\",\n url: \"https://polyesterscan.com\",\n },\n },\n contracts: {\n multicall3: {\n address: \"0xF35A6AE5408fa1356064849D0BC3855f801aa6aC\",\n blockCreated: 563457,\n },\n },\n },\n accountAbstraction: {\n bundlerUrl: \"https://bundler.polyester.tech\",\n paymasterUrl: \"https://paymaster.polyester.tech\",\n entryPoint: {\n address: \"0x59a4B77766509c4507D79eFF8089474eC3daC174\",\n version: \"0.7\",\n },\n safe: {\n version: \"1.4.1\",\n safeModuleSetupAddress: \"0x80791683D9C079A37Debc67EaDdbFcBC6f0FF2bB\",\n safe4337ModuleAddress: \"0x0713FF3d4c1b4f177833a372b1e3cb977540EA11\",\n safeProxyFactoryAddress: \"0xF8F0F649Dd3bFa9095206691E9fb2356c26216dE\",\n safeSingletonAddress: \"0x92abEa238FEA8908c397cE65366ea9278f0AeC7A\",\n multiSendAddress: \"0x70C8a8CcB45a8E2589B0f019374fc923dA34E4c7\",\n multiSendCallOnlyAddress: \"0x375C86a08DA98d1944D7B3c736307A72186CcAf1\",\n },\n },\n contracts: {\n tradingGatewayAddress: \"0xD3fecf5D39131e23b6B0f872cA0a21c8A5a30932\",\n },\n});\n"],"mappings":";;;AAyDA,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAa;CAAa;CAAO;AAAO,CAAC;AAEtE,SAAS,cAAc,OAAgB,OAAyD;CAC5F,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,Q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Y,gBAAgB,OAAO,aACnC,MAAM,IAAI,mBACN,mEACJ;CAEJ,OAAO;AACX;AAEA,MAAa,gCAAgC,2BAA2B;CACpE,MAAM;CACN,QAAQ;CACR,cAAc;CACd,QAAQ;CACR,OAAO;EACH,IAAI;EACJ,MAAM;EACN,gBAAgB;GACZ,UAAU;GACV,MAAM;GACN,QAAQ;EACZ;EACA,SAAS,EACL,SAAS,EACL,MAAM,CAAC,4BAA4B,EACvC,EACJ;EACA,gBAAgB,EACZ,SAAS;GACL,MAAM;GACN,KAAK;EACT,EACJ;EACA,WAAW,EACP,YAAY;GACR,SAAS;GACT,cAAc;EAClB,EACJ;CACJ;CACA,oBAAoB;EAChB,YAAY;EACZ,cAAc;EACd,YAAY;GACR,SAAS;GACT,SAAS;EACb;EACA,MAAM;GACF,SAAS;GACT,wBAAwB;GACxB,uBAAuB;GACvB,yBAAyB;GACzB,sBAAsB;GACtB,kBAAkB;GAClB,0BAA0B;EAC9B;CACJ;CACA,WAAW,EACP,uBAAuB,6CAC3B;AACJ,CAAC"}
@@ -11,7 +11,7 @@ type TimestampInit = {
11
11
  };
12
12
  declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
13
13
  readonly symbolId: v.NumberSchema<undefined>;
14
- readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
14
+ readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">>]>;
15
15
  readonly tsSec: v.BigintSchema<undefined>;
16
16
  readonly open: v.BigintSchema<undefined>;
17
17
  readonly high: v.BigintSchema<undefined>;
@@ -21,7 +21,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
21
21
  readonly isClosed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
22
22
  }, undefined>, v.TransformAction<{
23
23
  symbolId: number;
24
- timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
24
+ timeframe: DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">;
25
25
  tsSec: bigint;
26
26
  open: bigint;
27
27
  high: bigint;
@@ -31,7 +31,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
31
31
  isClosed: boolean;
32
32
  }, {
33
33
  symbolId: number;
34
- timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
34
+ timeframe: DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">;
35
35
  time: number;
36
36
  open: string;
37
37
  high: string;
@@ -43,7 +43,7 @@ declare function createCandleRowSchema(scales: SdkScales): v.SchemaWithPipe<read
43
43
  declare const createCandleRowIntSchema: typeof createCandleRowSchema;
44
44
  declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
45
45
  readonly symbolId: v.NumberSchema<undefined>;
46
- readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
46
+ readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">>]>;
47
47
  readonly tsSec: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
48
48
  readonly open: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
49
49
  readonly high: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
@@ -59,7 +59,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
59
59
  readonly nextPageToken: v.OptionalSchema<v.StringSchema<undefined>, "">;
60
60
  }, undefined>, v.TransformAction<{
61
61
  symbolId: number;
62
- timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
62
+ timeframe: DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">;
63
63
  tsSec: bigint[];
64
64
  open: bigint[];
65
65
  high: bigint[];
@@ -75,7 +75,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
75
75
  nextPageToken: string;
76
76
  }, {
77
77
  symbolId: number;
78
- timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
78
+ timeframe: DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">;
79
79
  time: number[];
80
80
  open: string[];
81
81
  high: string[];
@@ -94,7 +94,7 @@ declare function createCandleColumnarSchema(scales: SdkScales): v.SchemaWithPipe
94
94
  }>]>;
95
95
  declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
96
96
  readonly symbolId: v.NumberSchema<undefined>;
97
- readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">>]>;
97
+ readonly timeframe: v.SchemaWithPipe<readonly [v.EnumSchema<typeof Timeframe$1, undefined>, v.TransformAction<Timeframe$1, DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">>]>;
98
98
  readonly tsSec: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
99
99
  readonly open: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
100
100
  readonly high: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
@@ -110,7 +110,7 @@ declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithP
110
110
  readonly nextPageToken: v.OptionalSchema<v.StringSchema<undefined>, "">;
111
111
  }, undefined>, v.TransformAction<{
112
112
  symbolId: number;
113
- timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
113
+ timeframe: DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">;
114
114
  tsSec: bigint[];
115
115
  open: bigint[];
116
116
  high: bigint[];
@@ -126,7 +126,7 @@ declare function createCandleColumnarIntSchema(scales: SdkScales): v.SchemaWithP
126
126
  nextPageToken: string;
127
127
  }, {
128
128
  symbolId: number;
129
- timeframe: DecodedEnum<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo">;
129
+ timeframe: DecodedEnum<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo">;
130
130
  tsSec: number[];
131
131
  open: string[];
132
132
  high: string[];
@@ -149,7 +149,7 @@ type CandleColumnar = v.InferOutput<ReturnType<typeof createCandleColumnarSchema
149
149
  type CandleColumnarInt = v.InferOutput<ReturnType<typeof createCandleColumnarIntSchema>>;
150
150
  declare function createListCandlesInputSchema(): v.SchemaWithPipe<readonly [v.ObjectSchema<{
151
151
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
152
- readonly timeframe: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["1s", "1m", "5m", "15m", "30m", "1h", "4h", "12h", "1d", "1w", "1mo"], undefined>, v.TransformAction<"1d" | "1h" | "1w" | "1m" | "1s" | "5m" | "15m" | "30m" | "4h" | "12h" | "1mo", Timeframe$1.SEC_1 | Timeframe$1.MIN_1 | Timeframe$1.MIN_5 | Timeframe$1.MIN_15 | Timeframe$1.MIN_30 | Timeframe$1.HOUR_1 | Timeframe$1.HOUR_4 | Timeframe$1.DAY_1 | Timeframe$1.HOUR_12 | Timeframe$1.WEEK_1 | Timeframe$1.MONTH_1>]>;
152
+ readonly timeframe: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["1s", "1m", "5m", "15m", "30m", "1h", "4h", "12h", "1d", "1w", "1mo"], undefined>, v.TransformAction<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo", Timeframe$1.SEC_1 | Timeframe$1.MIN_1 | Timeframe$1.MIN_5 | Timeframe$1.MIN_15 | Timeframe$1.MIN_30 | Timeframe$1.HOUR_1 | Timeframe$1.HOUR_4 | Timeframe$1.DAY_1 | Timeframe$1.HOUR_12 | Timeframe$1.WEEK_1 | Timeframe$1.MONTH_1>]>;
153
153
  readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 10000, undefined>]>, undefined>;
154
154
  readonly includeIncomplete: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
155
155
  readonly includeReference: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
@@ -13,7 +13,7 @@ type TimestampInit = {
13
13
  };
14
14
  declare const GetOrderbookHeatmapInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
15
15
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
16
- readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"1h" | "1m" | "1s" | "5m", HeatmapInterval>]>;
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 | 500 | 100 | 1000 | 50, HeatmapDepth>]>;
18
18
  readonly quantityMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["close", "peak"], undefined>, "close">, v.TransformAction<"close" | "peak", HeatmapQuantityMode>]>;
19
19
  readonly limit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 20000, undefined>]>;
@@ -122,7 +122,7 @@ declare function convertHeatmapDeltaBucket(bucket: OrderbookHeatmapDeltaBucketRa
122
122
  type OrderbookHeatmapDeltaBucket = ReturnType<typeof convertHeatmapDeltaBucket>;
123
123
  declare const OrderbookHeatmapLiveBucketRawSchema: v.ObjectSchema<{
124
124
  readonly symbolId: v.NumberSchema<undefined>;
125
- readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
125
+ readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1s" | "1m" | "5m" | "1h">>]>;
126
126
  readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
127
127
  readonly isFinal: v.BooleanSchema<undefined>;
128
128
  readonly bids: v.OptionalSchema<v.ObjectSchema<{
@@ -142,7 +142,7 @@ declare const OrderbookHeatmapLiveBucketRawSchema: v.ObjectSchema<{
142
142
  type OrderbookHeatmapLiveBucketRaw = v.InferOutput<typeof OrderbookHeatmapLiveBucketRawSchema>;
143
143
  declare function convertHeatmapLiveBucket(bucket: OrderbookHeatmapLiveBucketRaw, scales: SdkScales): {
144
144
  symbolId: number;
145
- interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
145
+ interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
146
146
  tsSec: number;
147
147
  isFinal: boolean;
148
148
  bids: {
@@ -226,7 +226,7 @@ declare function convertHeatmapDeltaChain(chain: OrderbookHeatmapDeltaChainRaw,
226
226
  type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;
227
227
  declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
228
228
  readonly symbolId: v.NumberSchema<undefined>;
229
- readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
229
+ readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1s" | "1m" | "5m" | "1h">>]>;
230
230
  readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 5 | 10 | 20 | 1 | "unspecified" | 200 | 500 | 100 | 1000 | 50>]>;
231
231
  readonly chain: v.OptionalSchema<v.ObjectSchema<{
232
232
  readonly baseKeyframe: v.OptionalSchema<v.ObjectSchema<{
@@ -267,7 +267,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
267
267
  readonly quantityMode: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"close" | "peak">>]>;
268
268
  readonly liveBucket: v.OptionalSchema<v.ObjectSchema<{
269
269
  readonly symbolId: v.NumberSchema<undefined>;
270
- readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1h" | "1m" | "1s" | "5m">>]>;
270
+ readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1s" | "1m" | "5m" | "1h">>]>;
271
271
  readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
272
272
  readonly isFinal: v.BooleanSchema<undefined>;
273
273
  readonly bids: v.OptionalSchema<v.ObjectSchema<{
@@ -286,7 +286,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
286
286
  }, undefined>, undefined>;
287
287
  }, undefined>, v.TransformAction<{
288
288
  symbolId: number;
289
- interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
289
+ interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
290
290
  depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 500 | 100 | 1000 | 50;
291
291
  chain?: {
292
292
  baseKeyframe?: {
@@ -327,7 +327,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
327
327
  quantityMode: DecodedEnum<"close" | "peak">;
328
328
  liveBucket?: {
329
329
  symbolId: number;
330
- interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
330
+ interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
331
331
  tsSec: number;
332
332
  isFinal: boolean;
333
333
  bids?: {
@@ -346,7 +346,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
346
346
  } | undefined;
347
347
  }, {
348
348
  symbolId: number;
349
- interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
349
+ interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
350
350
  depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 500 | 100 | 1000 | 50;
351
351
  chain: {
352
352
  baseKeyframe: {
@@ -387,7 +387,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
387
387
  quantityMode: DecodedEnum<"close" | "peak">;
388
388
  liveBucket: {
389
389
  symbolId: number;
390
- interval: DecodedEnum<"1h" | "1m" | "1s" | "5m">;
390
+ interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
391
391
  tsSec: number;
392
392
  isFinal: boolean;
393
393
  bids: {
@@ -30,7 +30,7 @@ declare function createMarketOverviewSchema(scales: SdkScales): v.SchemaWithPipe
30
30
  readonly bestAskTicks: v.BigintSchema<undefined>;
31
31
  readonly bestAskQtyScaled: v.BigintSchema<undefined>;
32
32
  readonly sparklines: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
33
- readonly interval: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SparklineInterval, undefined>, v.TransformAction<SparklineInterval, "unspecified" | "1h" | "24h" | "1w" | "1m">]>;
33
+ readonly interval: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SparklineInterval, undefined>, v.TransformAction<SparklineInterval, "unspecified" | "1m" | "1h" | "1w" | "24h">]>;
34
34
  readonly closeTicks: v.ArraySchema<v.BigintSchema<undefined>, undefined>;
35
35
  }, undefined>, undefined>, readonly []>;
36
36
  readonly indexPriceTicks: v.BigintSchema<undefined>;
@@ -50,7 +50,7 @@ declare function createMarketOverviewSchema(scales: SdkScales): v.SchemaWithPipe
50
50
  bestAskTicks: bigint;
51
51
  bestAskQtyScaled: bigint;
52
52
  sparklines: {
53
- interval: "unspecified" | "1h" | "24h" | "1w" | "1m";
53
+ interval: "unspecified" | "1m" | "1h" | "1w" | "24h";
54
54
  closeTicks: bigint[];
55
55
  }[];
56
56
  indexPriceTicks: bigint;
@@ -80,7 +80,7 @@ declare const ListMarketOverviewInputSchema: v.ObjectSchema<{
80
80
  readonly orderBy: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["change_24h_bps", "volume_24h_quote", "last_price", "date_added"], undefined>, "volume_24h_quote">, v.TransformAction<"change_24h_bps" | "volume_24h_quote" | "last_price" | "date_added", MarketOrderBy.ORDER_BY_CHANGE_24H_BPS | MarketOrderBy.ORDER_BY_VOLUME_24H_QUOTE | MarketOrderBy.ORDER_BY_LAST_PRICE | MarketOrderBy.ORDER_BY_DATE_ADDED>]>;
81
81
  readonly sort: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["asc", "desc"], undefined>, "desc">, v.TransformAction<"asc" | "desc", SortDirection.SORT_ASC | SortDirection.SORT_DESC>]>;
82
82
  readonly includeSparklines: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
83
- readonly sparklineIntervals: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["1h", "24h", "1w", "1m"], undefined>, undefined>, readonly ["24h"]>, v.TransformAction<("1h" | "24h" | "1w" | "1m")[], (SparklineInterval.SPARKLINE_1H | SparklineInterval.SPARKLINE_24H | SparklineInterval.SPARKLINE_1W | SparklineInterval.SPARKLINE_1M)[]>]>;
83
+ readonly sparklineIntervals: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["1h", "24h", "1w", "1m"], undefined>, undefined>, readonly ["24h"]>, v.TransformAction<("1m" | "1h" | "1w" | "24h")[], (SparklineInterval.SPARKLINE_1H | SparklineInterval.SPARKLINE_24H | SparklineInterval.SPARKLINE_1W | SparklineInterval.SPARKLINE_1M)[]>]>;
84
84
  }, undefined>;
85
85
  type ListMarketOverviewInput = v.InferInput<typeof ListMarketOverviewInputSchema>;
86
86
  //#endregion
@@ -2459,7 +2459,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2459
2459
  }, undefined>, v.ObjectSchema<{
2460
2460
  readonly case: v.LiteralSchema<"rejected", undefined>;
2461
2461
  readonly value: v.ObjectSchema<{
2462
- readonly error: v.ObjectSchema<{
2462
+ readonly error: v.OptionalSchema<v.ObjectSchema<{
2463
2463
  readonly code: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ErrorCode, undefined>, v.TransformAction<ErrorCode, "STALE_QUOTE" | "UNSPECIFIED" | "BAD_REQUEST" | "INVALID_ARGUMENT" | "INSUFFICIENT_FUNDS" | "UNKNOWN_SYMBOL" | "BAD_PRICE" | "BAD_QTY" | "MIN_NOTIONAL" | "QTY_STEP_SIZE" | "CONFLICT_DUPLICATE_CLIENT_ORDER_ID" | "UNAVAILABLE" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "UPSTREAM_ERROR" | "FEE_ASSET_NOT_ALLOWED" | "PAIR_DISABLED" | "ORDER_UNKNOWN" | "INTERNAL_ERROR" | "SUBACCOUNT_INACTIVE" | "POLICY_MARKET_DENY" | "POLICY_MAX_NOTIONAL" | "POLICY_TRADING_HALTED" | "POLICY_SPOT_TRADE_DENY" | "API_KEY_ROOT_SCOPE_ONLY" | "API_KEY_SUB_SCOPE_ONLY" | "API_KEY_SUBACCOUNT_MISMATCH" | "API_KEY_POLICY_REQUIRED" | "API_KEY_UNKNOWN" | "API_KEY_MARKET_DENY" | "PRICE_TICK_SIZE" | "MIN_QTY" | "POST_ONLY_LIMIT_ONLY" | "BATCH_TOO_LARGE" | "MODIFICATION_REQUIRES_REPLACE" | "CONFLICT_IDEMPOTENCY_KEY_REUSE" | "MARKET_PRICE_UNAVAILABLE" | "PAIR_NOT_LISTED_YET" | "PAIR_DELISTED" | "PAIR_CANCEL_ONLY" | "PAIR_POST_ONLY" | "PAIR_REDUCE_ONLY" | "RISK_LIMIT" | "MARKET_HALTED" | "ACCOUNT_UNKNOWN" | "POST_ONLY_CROSS" | "REDUCE_ONLY_BLOCKED" | "PRICE_BAND_VIOLATION" | "MARKET_CAP_VIOLATION" | "EMPTY_BOOK" | "FOK_INSUFFICIENT_LIQUIDITY" | "ORDER_ALREADY_TERMINAL" | "TRIGGER_PRICE_INVALID" | "TRIGGER_PRICE_SOURCE_UNSUPPORTED" | "TRAILING_DISTANCE_INVALID" | "TRIGGER_NOT_FOUND" | "TRIGGER_CANCEL_REJECTED" | "TRIGGER_STATUS_INVALID" | "TRIGGER_NOT_MODIFIABLE" | "CONFLICT_DUPLICATE_CLIENT_TRIGGER_ID" | "MAX_SLIPPAGE_INVALID" | "VALIDATION_ERROR" | "OVERLOADED" | "MAX_QUOTE_DEBIT_TOO_SMALL" | "RATE_LIMIT_EXCEEDED">]>;
2464
2464
  readonly violations: v.ArraySchema<v.ObjectSchema<{
2465
2465
  readonly fieldPath: v.StringSchema<undefined>;
@@ -2477,7 +2477,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2477
2477
  readonly scope: v.SchemaWithPipe<readonly [v.EnumSchema<typeof LimiterScope, undefined>, v.TransformAction<LimiterScope, "symbol" | "unspecified" | "client_ip" | "api_key" | "account" | "subaccount" | "connection" | "service" | "region" | "auth_subject">]>;
2478
2478
  readonly refillModel: v.SchemaWithPipe<readonly [v.EnumSchema<typeof RefillModel, undefined>, v.TransformAction<RefillModel, "unspecified" | "continuous" | "fixed_window" | "rolling_window">]>;
2479
2479
  }, undefined>, undefined>;
2480
- }, undefined>;
2480
+ }, undefined>, undefined>;
2481
2481
  }, undefined>;
2482
2482
  }, undefined>], undefined>;
2483
2483
  }, undefined>, undefined>;
@@ -2500,7 +2500,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2500
2500
  } | {
2501
2501
  case: "rejected";
2502
2502
  value: {
2503
- error: {
2503
+ error?: {
2504
2504
  code: "STALE_QUOTE" | "UNSPECIFIED" | "BAD_REQUEST" | "INVALID_ARGUMENT" | "INSUFFICIENT_FUNDS" | "UNKNOWN_SYMBOL" | "BAD_PRICE" | "BAD_QTY" | "MIN_NOTIONAL" | "QTY_STEP_SIZE" | "CONFLICT_DUPLICATE_CLIENT_ORDER_ID" | "UNAVAILABLE" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "UPSTREAM_ERROR" | "FEE_ASSET_NOT_ALLOWED" | "PAIR_DISABLED" | "ORDER_UNKNOWN" | "INTERNAL_ERROR" | "SUBACCOUNT_INACTIVE" | "POLICY_MARKET_DENY" | "POLICY_MAX_NOTIONAL" | "POLICY_TRADING_HALTED" | "POLICY_SPOT_TRADE_DENY" | "API_KEY_ROOT_SCOPE_ONLY" | "API_KEY_SUB_SCOPE_ONLY" | "API_KEY_SUBACCOUNT_MISMATCH" | "API_KEY_POLICY_REQUIRED" | "API_KEY_UNKNOWN" | "API_KEY_MARKET_DENY" | "PRICE_TICK_SIZE" | "MIN_QTY" | "POST_ONLY_LIMIT_ONLY" | "BATCH_TOO_LARGE" | "MODIFICATION_REQUIRES_REPLACE" | "CONFLICT_IDEMPOTENCY_KEY_REUSE" | "MARKET_PRICE_UNAVAILABLE" | "PAIR_NOT_LISTED_YET" | "PAIR_DELISTED" | "PAIR_CANCEL_ONLY" | "PAIR_POST_ONLY" | "PAIR_REDUCE_ONLY" | "RISK_LIMIT" | "MARKET_HALTED" | "ACCOUNT_UNKNOWN" | "POST_ONLY_CROSS" | "REDUCE_ONLY_BLOCKED" | "PRICE_BAND_VIOLATION" | "MARKET_CAP_VIOLATION" | "EMPTY_BOOK" | "FOK_INSUFFICIENT_LIQUIDITY" | "ORDER_ALREADY_TERMINAL" | "TRIGGER_PRICE_INVALID" | "TRIGGER_PRICE_SOURCE_UNSUPPORTED" | "TRAILING_DISTANCE_INVALID" | "TRIGGER_NOT_FOUND" | "TRIGGER_CANCEL_REJECTED" | "TRIGGER_STATUS_INVALID" | "TRIGGER_NOT_MODIFIABLE" | "CONFLICT_DUPLICATE_CLIENT_TRIGGER_ID" | "MAX_SLIPPAGE_INVALID" | "VALIDATION_ERROR" | "OVERLOADED" | "MAX_QUOTE_DEBIT_TOO_SMALL" | "RATE_LIMIT_EXCEEDED";
2505
2505
  violations: {
2506
2506
  fieldPath: string;
@@ -2518,7 +2518,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2518
2518
  scope: "symbol" | "unspecified" | "client_ip" | "api_key" | "account" | "subaccount" | "connection" | "service" | "region" | "auth_subject";
2519
2519
  refillModel: "unspecified" | "continuous" | "fixed_window" | "rolling_window";
2520
2520
  } | undefined;
2521
- };
2521
+ } | undefined;
2522
2522
  };
2523
2523
  };
2524
2524
  }[];
@@ -2541,7 +2541,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2541
2541
  } | {
2542
2542
  case: "rejected";
2543
2543
  value: {
2544
- error: {
2544
+ error?: {
2545
2545
  code: "STALE_QUOTE" | "UNSPECIFIED" | "BAD_REQUEST" | "INVALID_ARGUMENT" | "INSUFFICIENT_FUNDS" | "UNKNOWN_SYMBOL" | "BAD_PRICE" | "BAD_QTY" | "MIN_NOTIONAL" | "QTY_STEP_SIZE" | "CONFLICT_DUPLICATE_CLIENT_ORDER_ID" | "UNAVAILABLE" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "UPSTREAM_ERROR" | "FEE_ASSET_NOT_ALLOWED" | "PAIR_DISABLED" | "ORDER_UNKNOWN" | "INTERNAL_ERROR" | "SUBACCOUNT_INACTIVE" | "POLICY_MARKET_DENY" | "POLICY_MAX_NOTIONAL" | "POLICY_TRADING_HALTED" | "POLICY_SPOT_TRADE_DENY" | "API_KEY_ROOT_SCOPE_ONLY" | "API_KEY_SUB_SCOPE_ONLY" | "API_KEY_SUBACCOUNT_MISMATCH" | "API_KEY_POLICY_REQUIRED" | "API_KEY_UNKNOWN" | "API_KEY_MARKET_DENY" | "PRICE_TICK_SIZE" | "MIN_QTY" | "POST_ONLY_LIMIT_ONLY" | "BATCH_TOO_LARGE" | "MODIFICATION_REQUIRES_REPLACE" | "CONFLICT_IDEMPOTENCY_KEY_REUSE" | "MARKET_PRICE_UNAVAILABLE" | "PAIR_NOT_LISTED_YET" | "PAIR_DELISTED" | "PAIR_CANCEL_ONLY" | "PAIR_POST_ONLY" | "PAIR_REDUCE_ONLY" | "RISK_LIMIT" | "MARKET_HALTED" | "ACCOUNT_UNKNOWN" | "POST_ONLY_CROSS" | "REDUCE_ONLY_BLOCKED" | "PRICE_BAND_VIOLATION" | "MARKET_CAP_VIOLATION" | "EMPTY_BOOK" | "FOK_INSUFFICIENT_LIQUIDITY" | "ORDER_ALREADY_TERMINAL" | "TRIGGER_PRICE_INVALID" | "TRIGGER_PRICE_SOURCE_UNSUPPORTED" | "TRAILING_DISTANCE_INVALID" | "TRIGGER_NOT_FOUND" | "TRIGGER_CANCEL_REJECTED" | "TRIGGER_STATUS_INVALID" | "TRIGGER_NOT_MODIFIABLE" | "CONFLICT_DUPLICATE_CLIENT_TRIGGER_ID" | "MAX_SLIPPAGE_INVALID" | "VALIDATION_ERROR" | "OVERLOADED" | "MAX_QUOTE_DEBIT_TOO_SMALL" | "RATE_LIMIT_EXCEEDED";
2546
2546
  violations: {
2547
2547
  fieldPath: string;
@@ -2559,7 +2559,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2559
2559
  scope: "symbol" | "unspecified" | "client_ip" | "api_key" | "account" | "subaccount" | "connection" | "service" | "region" | "auth_subject";
2560
2560
  refillModel: "unspecified" | "continuous" | "fixed_window" | "rolling_window";
2561
2561
  } | undefined;
2562
- };
2562
+ } | undefined;
2563
2563
  };
2564
2564
  };
2565
2565
  }[];
@@ -2582,7 +2582,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2582
2582
  } | {
2583
2583
  case: "rejected";
2584
2584
  value: {
2585
- error: {
2585
+ error?: {
2586
2586
  code: "STALE_QUOTE" | "UNSPECIFIED" | "BAD_REQUEST" | "INVALID_ARGUMENT" | "INSUFFICIENT_FUNDS" | "UNKNOWN_SYMBOL" | "BAD_PRICE" | "BAD_QTY" | "MIN_NOTIONAL" | "QTY_STEP_SIZE" | "CONFLICT_DUPLICATE_CLIENT_ORDER_ID" | "UNAVAILABLE" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "UPSTREAM_ERROR" | "FEE_ASSET_NOT_ALLOWED" | "PAIR_DISABLED" | "ORDER_UNKNOWN" | "INTERNAL_ERROR" | "SUBACCOUNT_INACTIVE" | "POLICY_MARKET_DENY" | "POLICY_MAX_NOTIONAL" | "POLICY_TRADING_HALTED" | "POLICY_SPOT_TRADE_DENY" | "API_KEY_ROOT_SCOPE_ONLY" | "API_KEY_SUB_SCOPE_ONLY" | "API_KEY_SUBACCOUNT_MISMATCH" | "API_KEY_POLICY_REQUIRED" | "API_KEY_UNKNOWN" | "API_KEY_MARKET_DENY" | "PRICE_TICK_SIZE" | "MIN_QTY" | "POST_ONLY_LIMIT_ONLY" | "BATCH_TOO_LARGE" | "MODIFICATION_REQUIRES_REPLACE" | "CONFLICT_IDEMPOTENCY_KEY_REUSE" | "MARKET_PRICE_UNAVAILABLE" | "PAIR_NOT_LISTED_YET" | "PAIR_DELISTED" | "PAIR_CANCEL_ONLY" | "PAIR_POST_ONLY" | "PAIR_REDUCE_ONLY" | "RISK_LIMIT" | "MARKET_HALTED" | "ACCOUNT_UNKNOWN" | "POST_ONLY_CROSS" | "REDUCE_ONLY_BLOCKED" | "PRICE_BAND_VIOLATION" | "MARKET_CAP_VIOLATION" | "EMPTY_BOOK" | "FOK_INSUFFICIENT_LIQUIDITY" | "ORDER_ALREADY_TERMINAL" | "TRIGGER_PRICE_INVALID" | "TRIGGER_PRICE_SOURCE_UNSUPPORTED" | "TRAILING_DISTANCE_INVALID" | "TRIGGER_NOT_FOUND" | "TRIGGER_CANCEL_REJECTED" | "TRIGGER_STATUS_INVALID" | "TRIGGER_NOT_MODIFIABLE" | "CONFLICT_DUPLICATE_CLIENT_TRIGGER_ID" | "MAX_SLIPPAGE_INVALID" | "VALIDATION_ERROR" | "OVERLOADED" | "MAX_QUOTE_DEBIT_TOO_SMALL" | "RATE_LIMIT_EXCEEDED";
2587
2587
  violations: {
2588
2588
  fieldPath: string;
@@ -2600,7 +2600,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2600
2600
  scope: "symbol" | "unspecified" | "client_ip" | "api_key" | "account" | "subaccount" | "connection" | "service" | "region" | "auth_subject";
2601
2601
  refillModel: "unspecified" | "continuous" | "fixed_window" | "rolling_window";
2602
2602
  } | undefined;
2603
- };
2603
+ } | undefined;
2604
2604
  };
2605
2605
  };
2606
2606
  }[];
@@ -2629,7 +2629,7 @@ declare function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols:
2629
2629
  scope: "symbol" | "unspecified" | "client_ip" | "api_key" | "account" | "subaccount" | "connection" | "service" | "region" | "auth_subject";
2630
2630
  refillModel: "unspecified" | "continuous" | "fixed_window" | "rolling_window";
2631
2631
  } | undefined;
2632
- };
2632
+ } | undefined;
2633
2633
  } | {
2634
2634
  submittedMaxQuoteDebit?: string | undefined;
2635
2635
  resolvedBaseQty: string;
@@ -1 +1 @@
1
- {"version":3,"file":"orders-batch.schemas.d.ts","names":[],"sources":["../../../src/services/orders/orders-batch.schemas.ts"],"mappings":";;;;;;;;cAuDa,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;KAc1B,sBAAsB,EAAE,kBAAkB;cAEzC,4BAA0B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;KAgB3B,uBAAuB,EAAE,mBAAmB;iBAExC,mCAAmC,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqClC,8BAA8B,EAAE,mBAAmB;cAEzD,6BAA2B,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;KAsBrB,wBAAwB,EAAE,kBAAkB;cAE3C,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgB7B,yBAAyB,EAAE,kBAAkB;cAEnD,8BAA4B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAQtB,yBAAyB,EAAE,mBAAmB;cAE7C,+BAA6B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkB9B,0BAA0B,EAAE,mBAAmB"}
@@ -68,7 +68,7 @@ const BatchCreateOrderResultRawSchema = v.object({
68
68
  })
69
69
  }), v.object({
70
70
  case: v.literal("rejected"),
71
- value: v.object({ error: OrderErrorDetailSchema })
71
+ value: v.object({ error: v.optional(OrderErrorDetailSchema) })
72
72
  })])
73
73
  });
74
74
  function createBatchCreateOrdersResultSchema(scales, symbols) {
@@ -1 +1 @@
1
- {"version":3,"file":"orders-batch.schemas.js","names":["ProtoWrite.RiskPolicySchema","ProtoWrite.BatchReplaceItemAdmissionStatus","ProtoWrite.BatchReplaceAdmissionStatus","ProtoRead.BatchReplacePhase","ProtoRead.OrderStatus"],"sources":["../../../src/services/orders/orders-batch.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 AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { OptionalPublicIdSchema, PublicIdSchema, idInputSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { SideSchema } from \"../shared.js\";\nimport {\n positiveDecimalInputToScaled,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n BatchReplaceAdmissionStatusCodec,\n BatchReplaceItemAdmissionStatusCodec,\n BatchReplacePhaseCodec,\n OrderStatusCodec,\n OrderSideCodec,\n} from \"./orders.codecs.js\";\nimport { createOrderIntentInputSchema } from \"./orders-input.schemas.js\";\nimport { createRequiredRiskPolicyInputSchema } from \"./orders-risk.schemas.js\";\nimport {\n ClientOrderIdInputSchema,\n OrderRequestIdInputSchema,\n} from \"./orders-identifiers.schemas.js\";\nimport { OrderErrorDetailSchema } from \"./order-errors.schemas.js\";\n\nconst BatchCountSchema = v.pipe(v.number(), v.integer(), v.minValue(0));\nconst BatchItemIndexSchema = v.pipe(v.number(), v.integer(), v.minValue(0));\nconst PositivePublicIdSchema = v.pipe(\n v.bigint(),\n v.gtValue(0n),\n v.transform((value) => formatId(value)),\n);\nconst OptionalSymbolInputSchema = v.optional(v.pipe(v.string(), v.trim(), v.maxLength(32)));\nconst OptionalSideInputSchema = v.pipe(\n v.optional(SideSchema),\n v.transform((side) => (side ? OrderSideCodec.inputToProto[side] : undefined)),\n);\n\nconst CancelAllAfterTimeoutInputSchema = v.pipe(\n v.number(),\n v.integer(),\n v.check(\n (timeoutSec) => timeoutSec === 0 || (timeoutSec >= 10 && timeoutSec <= 120),\n \"timeoutSec must be 0 to disable or between 10 and 120 seconds to arm\",\n ),\n);\n\nexport const CancelAllAfterInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n timeoutSec: CancelAllAfterTimeoutInputSchema,\n symbol: OptionalSymbolInputSchema,\n side: OptionalSideInputSchema,\n requestId: v.optional(OrderRequestIdInputSchema),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type CancelAllAfterInput = v.InferInput<typeof CancelAllAfterInputSchema>;\n\nexport const CancelAllAfterResultSchema = v.pipe(\n v.object({\n status: v.picklist([\"armed\", \"disabled\"]),\n effectiveTimeoutSec: v.pipe(v.number(), v.integer(), v.minValue(0)),\n expiresAtTsNs: v.bigint(),\n tsNs: v.bigint(),\n }),\n v.transform(({ expiresAtTsNs, tsNs, ...result }) => ({\n ...result,\n expiresAt: tsNsToMs(expiresAtTsNs),\n expiresAtNs: expiresAtTsNs.toString(),\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n);\n\nexport type CancelAllAfterResult = v.InferOutput<typeof CancelAllAfterResultSchema>;\n\nexport function createBatchCreateOrdersInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n requestId: v.optional(OrderRequestIdInputSchema),\n items: v.pipe(\n v.array(createOrderIntentInputSchema(scales)),\n v.minLength(1, \"At least one order is required.\"),\n v.maxLength(20, \"Batch create accepts at most 20 orders.\"),\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n );\n}\n\nexport type BatchCreateOrdersInput = v.InferInput<\n ReturnType<typeof createBatchCreateOrdersInputSchema>\n>;\n\nconst BatchCreateOrderResultRawSchema = v.object({\n clientOrderId: v.string(),\n outcome: v.variant(\"case\", [\n v.object({\n case: v.literal(\"accepted\"),\n value: v.object({\n orderId: PublicIdSchema,\n takeProfitTriggerId: OptionalPublicIdSchema,\n stopLossTriggerId: OptionalPublicIdSchema,\n trailingStopTriggerId: OptionalPublicIdSchema,\n resolvedBaseQtyScaled: v.bigint(),\n submittedMaxQuoteDebitScaled: v.optional(v.bigint()),\n }),\n }),\n v.object({\n case: v.literal(\"rejected\"),\n value: v.object({\n error: OrderErrorDetailSchema,\n }),\n }),\n ]),\n});\n\nexport function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols: string[]) {\n return v.pipe(\n v.object({\n results: v.array(BatchCreateOrderResultRawSchema),\n acceptedCount: BatchCountSchema,\n rejectedCount: BatchCountSchema,\n tsNs: v.bigint(),\n }),\n v.check(\n (response) =>\n response.acceptedCount + response.rejectedCount === response.results.length,\n \"Batch create result counts do not match the returned results.\",\n ),\n v.check(\n (response) => response.results.length === symbols.length,\n \"Batch create result count does not match the submitted item count.\",\n ),\n v.transform(({ tsNs, ...response }) => ({\n ...response,\n results: response.results.map(({ clientOrderId, outcome }, index) => {\n if (outcome.case === \"rejected\") {\n return {\n status: \"rejected\" as const,\n clientOrderId,\n error: outcome.value.error,\n };\n }\n const { resolvedBaseQtyScaled, submittedMaxQuoteDebitScaled, ...accepted } =\n outcome.value;\n const symbol = symbols[index]!;\n return {\n status: \"accepted\" as const,\n clientOrderId,\n ...accepted,\n resolvedBaseQty: scaledToDecimalOutput(\n resolvedBaseQtyScaled,\n scales.baseQty(symbol),\n ),\n ...(submittedMaxQuoteDebitScaled === undefined\n ? {}\n : {\n submittedMaxQuoteDebit: scaledToDecimalOutput(\n submittedMaxQuoteDebitScaled,\n scales.quoteAmount(symbol),\n ),\n }),\n };\n }),\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n );\n}\n\nexport type BatchCreateOrdersResult = v.InferOutput<\n ReturnType<typeof createBatchCreateOrdersResultSchema>\n>;\nexport type BatchCreateOrderResult = BatchCreateOrdersResult[\"results\"][number];\n\nconst DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\nconst BATCH_REPLACE_ITEM_INPUT_KEYS = new Set([\n \"orderId\",\n \"clientOrderId\",\n \"newPrice\",\n \"newQty\",\n \"risk\",\n \"clearRisk\",\n \"newClientOrderId\",\n]);\n\nexport function assertKnownBatchReplaceOrderItemInputKeys(input: object): void {\n for (const key of Object.keys(input)) {\n if (!BATCH_REPLACE_ITEM_INPUT_KEYS.has(key)) {\n throw new Error(`Unknown key \"${key}\" in batch replace order item.`);\n }\n }\n}\n\nconst BatchReplaceTargetInputSchema = v.union([\n v.pipe(\n v.object({\n orderId: v.pipe(\n idInputSchema(\"items.orderId\"),\n v.check((value) => value > 0n, \"items.orderId must be greater than zero\"),\n ),\n clientOrderId: v.optional(v.never()),\n }),\n v.transform(({ orderId }) => ({\n key: { case: \"orderId\" as const, value: orderId },\n })),\n ),\n v.pipe(\n v.object({\n orderId: v.optional(v.never()),\n clientOrderId: ClientOrderIdInputSchema,\n }),\n v.transform(({ clientOrderId }) => ({\n key: { case: \"clientOrderId\" as const, value: clientOrderId },\n })),\n ),\n]);\n\nfunction createBatchReplaceOrderItemInputSchema(scales: SdkScales, symbolId: number) {\n const patchSchema = v.union([\n v.object({\n newPrice: DecimalInputStringSchema,\n newQty: v.optional(DecimalInputStringSchema),\n risk: v.optional(createRequiredRiskPolicyInputSchema(scales)),\n clearRisk: v.optional(v.literal(false)),\n }),\n v.object({\n newPrice: v.optional(DecimalInputStringSchema),\n newQty: DecimalInputStringSchema,\n risk: v.optional(createRequiredRiskPolicyInputSchema(scales)),\n clearRisk: v.optional(v.literal(false)),\n }),\n v.object({\n newPrice: v.optional(v.never()),\n newQty: v.optional(v.never()),\n risk: createRequiredRiskPolicyInputSchema(scales),\n clearRisk: v.optional(v.literal(false)),\n }),\n v.object({\n newPrice: v.optional(v.never()),\n newQty: v.optional(v.never()),\n risk: v.optional(v.never()),\n clearRisk: v.literal(true),\n }),\n ]);\n return v.pipe(\n v.intersect([\n BatchReplaceTargetInputSchema,\n patchSchema,\n v.object({\n newClientOrderId: v.optional(ClientOrderIdInputSchema),\n }),\n ]),\n v.transform((input) => ({\n key: input.key,\n newPriceTicks:\n input.newPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"items.newPrice\",\n input.newPrice,\n scales.price(),\n ),\n newQtyScaled:\n input.newQty === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"items.newQty\",\n input.newQty,\n scales.baseQty(symbolId),\n ),\n newAttachedRisk:\n input.clearRisk === true ? create(ProtoWrite.RiskPolicySchema) : input.risk,\n newClientOrderId: input.newClientOrderId ?? \"\",\n })),\n );\n}\n\nexport function createBatchReplaceOrdersInputSchema(scales: SdkScales, symbolId: number) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n symbolId: v.pipe(v.literal(symbolId), v.integer(), v.minValue(1)),\n requestId: v.optional(OrderRequestIdInputSchema),\n items: v.pipe(\n v.array(createBatchReplaceOrderItemInputSchema(scales, symbolId)),\n v.minLength(1, \"At least one replacement is required.\"),\n v.maxLength(50, \"Batch replace accepts at most 50 replacements.\"),\n ),\n }),\n v.check((input) => {\n const targets = input.items.map(\n (item) => `${item.key.case}:${item.key.value.toString()}`,\n );\n return new Set(targets).size === targets.length;\n }, \"Each batch replace target must be unique.\"),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n );\n}\n\nexport type BatchReplaceOrdersInput = {\n account?: v.InferInput<typeof AccountScopeInputEntries.account>;\n symbolId: number;\n requestId?: string;\n items: Array<{\n orderId?: string;\n clientOrderId?: string;\n newPrice?: string;\n newQty?: string;\n risk?: v.InferInput<ReturnType<typeof createRequiredRiskPolicyInputSchema>>;\n clearRisk?: boolean;\n newClientOrderId?: string;\n }>;\n};\n\nconst BatchReplaceAdmissionItemSchema = v.pipe(\n v.object({\n itemIndex: BatchItemIndexSchema,\n status: v.pipe(\n v.enum(ProtoWrite.BatchReplaceItemAdmissionStatus),\n v.transform((status) =>\n requiredEnumLabel(\n BatchReplaceItemAdmissionStatusCodec.protoToOutput,\n status,\n \"BatchReplaceAdmissionItemSchema\",\n \"status\",\n ),\n ),\n ),\n oldOrderId: OptionalPublicIdSchema,\n replacementOrderId: OptionalPublicIdSchema,\n clientOrderId: v.string(),\n code: v.string(),\n error: v.optional(OrderErrorDetailSchema),\n }),\n v.transform((item) => ({\n ...item,\n code: item.code || undefined,\n })),\n);\n\nexport type BatchReplaceAdmissionItem = v.InferOutput<typeof BatchReplaceAdmissionItemSchema>;\n\nexport const BatchReplaceOrdersResultSchema = v.pipe(\n v.object({\n batchRequestId: PositivePublicIdSchema,\n status: v.pipe(\n v.enum(ProtoWrite.BatchReplaceAdmissionStatus),\n v.transform((status) =>\n requiredEnumLabel(\n BatchReplaceAdmissionStatusCodec.protoToOutput,\n status,\n \"BatchReplaceOrdersResultSchema\",\n \"status\",\n ),\n ),\n ),\n results: v.array(BatchReplaceAdmissionItemSchema),\n acceptedCount: BatchCountSchema,\n rejectedCount: BatchCountSchema,\n acceptedTsNs: v.bigint(),\n }),\n v.check(\n (response) => response.acceptedCount + response.rejectedCount === response.results.length,\n \"Batch replace result counts do not match the returned results.\",\n ),\n v.check(\n (response) => response.results.every((item, index) => item.itemIndex === index),\n \"Batch replace results must preserve request item order.\",\n ),\n v.transform(({ acceptedTsNs, ...response }) => ({\n ...response,\n acceptedTs: tsNsToMs(acceptedTsNs),\n acceptedTsNs: acceptedTsNs.toString(),\n })),\n);\n\nexport type BatchReplaceOrdersResult = v.InferOutput<typeof BatchReplaceOrdersResultSchema>;\n\nexport const GetBatchReplaceStatusInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n batchRequestId: v.pipe(\n idInputSchema(\"batchRequestId\"),\n v.check((value) => value > 0n, \"batchRequestId must be greater than zero\"),\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetBatchReplaceStatusInput = v.InferInput<typeof GetBatchReplaceStatusInputSchema>;\n\nconst BatchReplaceStatusItemSchema = v.pipe(\n v.object({\n itemIndex: BatchItemIndexSchema,\n phase: v.pipe(\n v.enum(ProtoRead.BatchReplacePhase),\n v.transform((phase) =>\n requiredEnumLabel(\n BatchReplacePhaseCodec.protoToOutput,\n phase,\n \"BatchReplaceStatusItemSchema\",\n \"phase\",\n ),\n ),\n ),\n oldOrderId: OptionalPublicIdSchema,\n replacementOrderId: OptionalPublicIdSchema,\n orderStatus: v.pipe(\n v.enum(ProtoRead.OrderStatus),\n v.transform((status) =>\n requiredEnumLabel(\n OrderStatusCodec.protoToOutput,\n status,\n \"BatchReplaceStatusItemSchema\",\n \"order status\",\n ),\n ),\n ),\n code: v.string(),\n updatedTsNs: v.bigint(),\n }),\n v.transform(({ updatedTsNs, ...item }) => ({\n ...item,\n code: item.code || undefined,\n updatedTs: tsNsToMs(updatedTsNs),\n updatedTsNs: updatedTsNs.toString(),\n })),\n);\n\nexport const GetBatchReplaceStatusResultSchema = v.pipe(\n v.object({\n batchRequestId: PositivePublicIdSchema,\n admissionStatus: v.pipe(\n v.enum(ProtoWrite.BatchReplaceAdmissionStatus),\n v.transform((status) =>\n requiredEnumLabel(\n BatchReplaceAdmissionStatusCodec.protoToOutput,\n status,\n \"GetBatchReplaceStatusResultSchema\",\n \"admission status\",\n ),\n ),\n ),\n items: v.array(BatchReplaceStatusItemSchema),\n acceptedCount: BatchCountSchema,\n rejectedCount: BatchCountSchema,\n acceptedTsNs: v.bigint(),\n updatedTsNs: v.bigint(),\n }),\n v.check(\n (response) => response.acceptedCount + response.rejectedCount === response.items.length,\n \"Batch replace status counts do not match the returned items.\",\n ),\n v.check(\n (response) => response.items.every((item, index) => item.itemIndex === index),\n \"Batch replace status items must preserve request item order.\",\n ),\n v.transform(({ acceptedTsNs, updatedTsNs, ...response }) => ({\n ...response,\n acceptedTs: tsNsToMs(acceptedTsNs),\n acceptedTsNs: acceptedTsNs.toString(),\n updatedTs: tsNsToMs(updatedTsNs),\n updatedTsNs: updatedTsNs.toString(),\n })),\n);\n\nexport type GetBatchReplaceStatusResult = v.InferOutput<typeof GetBatchReplaceStatusResultSchema>;\n\nconst BatchCancelOrderInputSchema = v.union([\n v.pipe(\n v.strictObject({\n orderId: v.pipe(\n idInputSchema(\"items.orderId\"),\n v.check((value) => value > 0n, \"items.orderId must be greater than zero\"),\n ),\n clientOrderId: v.optional(v.never()),\n symbolId: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1))),\n }),\n v.transform(({ orderId, symbolId }) => ({ orderId, symbolId })),\n ),\n v.pipe(\n v.strictObject({\n orderId: v.optional(v.never()),\n clientOrderId: ClientOrderIdInputSchema,\n symbolId: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1))),\n }),\n v.transform(({ clientOrderId, symbolId }) => ({ clientOrderId, symbolId })),\n ),\n]);\n\nexport type BatchCancelOrderInput = v.InferInput<typeof BatchCancelOrderInputSchema>;\n\nexport const BatchCancelOrdersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n requestId: v.optional(OrderRequestIdInputSchema),\n items: v.pipe(\n v.array(BatchCancelOrderInputSchema),\n v.minLength(1, \"At least one order is required.\"),\n v.maxLength(50, \"Batch cancel accepts at most 50 orders.\"),\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type BatchCancelOrdersInput = v.InferInput<typeof BatchCancelOrdersInputSchema>;\n\nconst BatchCancelOrderResultSchema = v.object({\n status: v.picklist([\"accepted\", \"rejected\"]),\n orderId: OptionalPublicIdSchema,\n clientOrderId: v.string(),\n code: v.string(),\n error: v.optional(OrderErrorDetailSchema),\n});\n\nexport type BatchCancelOrderResult = v.InferOutput<typeof BatchCancelOrderResultSchema>;\n\nexport const BatchCancelOrdersResultSchema = v.pipe(\n v.object({\n results: v.array(BatchCancelOrderResultSchema),\n acceptedCount: BatchCountSchema,\n rejectedCount: BatchCountSchema,\n tsNs: v.bigint(),\n }),\n v.check(\n (response) => response.acceptedCount + response.rejectedCount === response.results.length,\n \"Batch cancel result counts do not match the returned results.\",\n ),\n v.transform(({ tsNs, ...response }) => ({\n ...response,\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n);\n\nexport type B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,EAAE,SAAS,CAAC,CAAC,CAAC;AACvE,CAAC,GACD,EAAE,WAAW,EAAE,eAAe,gBAAgB;CAAE;CAAe;AAAS,EAAE,CAC9E,CACJ,CAAC;AAID,MAAa,+BAA+B,EAAE,KAC1C,EAAE,aAAa;CACX,GAAG;CACH,WAAW,EAAE,SAAS,yBAAyB;CAC/C,OAAO,EAAE,KACL,EAAE,MAAM,2BAA2B,GACnC,EAAE,UAAU,GAAG,iCAAiC,GAChD,EAAE,UAAU,IAAI,yCAAyC,CAC7D;AACJ,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;AAIA,MAAM,+BAA+B,EAAE,OAAO;CAC1C,QAAQ,EAAE,SAAS,CAAC,YAAY,UAAU,CAAC;CAC3C,SAAS;CACT,eAAe,EAAE,OAAO;CACxB,MAAM,EAAE,OAAO;CACf,OAAO,EAAE,SAAS,sBAAsB;AAC5C,CAAC;AAID,MAAa,gCAAgC,EAAE,KAC3C,EAAE,OAAO;CACL,SAAS,EAAE,MAAM,4BAA4B;CAC7C,eAAe;CACf,eAAe;CACf,MAAM,EAAE,OAAO;AACnB,CAAC,GACD,EAAE,OACG,aAAa,SAAS,gBAAgB,SAAS,kBAAkB,SAAS,QAAQ,QACnF,+DACJ,GACA,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB;CACpC,GAAG;CACH,IAAI,SAAS,IAAI;CACjB,MAAM,KAAK,SAAS;AACxB,EAAE,CACN"}
1
+ {"version":3,"file":"orders-batch.schemas.js","names":["ProtoWrite.RiskPolicySchema","ProtoWrite.BatchReplaceItemAdmissionStatus","ProtoWrite.BatchReplaceAdmissionStatus","ProtoRead.BatchReplacePhase","ProtoRead.OrderStatus"],"sources":["../../../src/services/orders/orders-batch.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 AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { OptionalPublicIdSchema, PublicIdSchema, idInputSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { SideSchema } from \"../shared.js\";\nimport {\n positiveDecimalInputToScaled,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n BatchReplaceAdmissionStatusCodec,\n BatchReplaceItemAdmissionStatusCodec,\n BatchReplacePhaseCodec,\n OrderStatusCodec,\n OrderSideCodec,\n} from \"./orders.codecs.js\";\nimport { createOrderIntentInputSchema } from \"./orders-input.schemas.js\";\nimport { createRequiredRiskPolicyInputSchema } from \"./orders-risk.schemas.js\";\nimport {\n ClientOrderIdInputSchema,\n OrderRequestIdInputSchema,\n} from \"./orders-identifiers.schemas.js\";\nimport { OrderErrorDetailSchema } from \"./order-errors.schemas.js\";\n\nconst BatchCountSchema = v.pipe(v.number(), v.integer(), v.minValue(0));\nconst BatchItemIndexSchema = v.pipe(v.number(), v.integer(), v.minValue(0));\nconst PositivePublicIdSchema = v.pipe(\n v.bigint(),\n v.gtValue(0n),\n v.transform((value) => formatId(value)),\n);\nconst OptionalSymbolInputSchema = v.optional(v.pipe(v.string(), v.trim(), v.maxLength(32)));\nconst OptionalSideInputSchema = v.pipe(\n v.optional(SideSchema),\n v.transform((side) => (side ? OrderSideCodec.inputToProto[side] : undefined)),\n);\n\nconst CancelAllAfterTimeoutInputSchema = v.pipe(\n v.number(),\n v.integer(),\n v.check(\n (timeoutSec) => timeoutSec === 0 || (timeoutSec >= 10 && timeoutSec <= 120),\n \"timeoutSec must be 0 to disable or between 10 and 120 seconds to arm\",\n ),\n);\n\nexport const CancelAllAfterInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n timeoutSec: CancelAllAfterTimeoutInputSchema,\n symbol: OptionalSymbolInputSchema,\n side: OptionalSideInputSchema,\n requestId: v.optional(OrderRequestIdInputSchema),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type CancelAllAfterInput = v.InferInput<typeof CancelAllAfterInputSchema>;\n\nexport const CancelAllAfterResultSchema = v.pipe(\n v.object({\n status: v.picklist([\"armed\", \"disabled\"]),\n effectiveTimeoutSec: v.pipe(v.number(), v.integer(), v.minValue(0)),\n expiresAtTsNs: v.bigint(),\n tsNs: v.bigint(),\n }),\n v.transform(({ expiresAtTsNs, tsNs, ...result }) => ({\n ...result,\n expiresAt: tsNsToMs(expiresAtTsNs),\n expiresAtNs: expiresAtTsNs.toString(),\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n);\n\nexport type CancelAllAfterResult = v.InferOutput<typeof CancelAllAfterResultSchema>;\n\nexport function createBatchCreateOrdersInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n requestId: v.optional(OrderRequestIdInputSchema),\n items: v.pipe(\n v.array(createOrderIntentInputSchema(scales)),\n v.minLength(1, \"At least one order is required.\"),\n v.maxLength(20, \"Batch create accepts at most 20 orders.\"),\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n );\n}\n\nexport type BatchCreateOrdersInput = v.InferInput<\n ReturnType<typeof createBatchCreateOrdersInputSchema>\n>;\n\nconst BatchCreateOrderResultRawSchema = v.object({\n clientOrderId: v.string(),\n outcome: v.variant(\"case\", [\n v.object({\n case: v.literal(\"accepted\"),\n value: v.object({\n orderId: PublicIdSchema,\n takeProfitTriggerId: OptionalPublicIdSchema,\n stopLossTriggerId: OptionalPublicIdSchema,\n trailingStopTriggerId: OptionalPublicIdSchema,\n resolvedBaseQtyScaled: v.bigint(),\n submittedMaxQuoteDebitScaled: v.optional(v.bigint()),\n }),\n }),\n v.object({\n case: v.literal(\"rejected\"),\n value: v.object({\n // The server may reject without a structured detail (e.g. capacity\n // limits); surface the rejection instead of failing the parse.\n error: v.optional(OrderErrorDetailSchema),\n }),\n }),\n ]),\n});\n\nexport function createBatchCreateOrdersResultSchema(scales: SdkScales, symbols: string[]) {\n return v.pipe(\n v.object({\n results: v.array(BatchCreateOrderResultRawSchema),\n acceptedCount: BatchCountSchema,\n rejectedCount: BatchCountSchema,\n tsNs: v.bigint(),\n }),\n v.check(\n (response) =>\n response.acceptedCount + response.rejectedCount === response.results.length,\n \"Batch create result counts do not match the returned results.\",\n ),\n v.check(\n (response) => response.results.length === symbols.length,\n \"Batch create result count does not match the submitted item count.\",\n ),\n v.transform(({ tsNs, ...response }) => ({\n ...response,\n results: response.results.map(({ clientOrderId, outcome }, index) => {\n if (outcome.case === \"rejected\") {\n return {\n status: \"rejected\" as const,\n clientOrderId,\n error: outcome.value.error,\n };\n }\n const { resolvedBaseQtyScaled, submittedMaxQuoteDebitScaled, ...accepted } =\n outcome.value;\n const symbol = symbols[index]!;\n return {\n status: \"accepted\" as const,\n clientOrderId,\n ...accepted,\n resolvedBaseQty: scaledToDecimalOutput(\n resolvedBaseQtyScaled,\n scales.baseQty(symbol),\n ),\n ...(submittedMaxQuoteDebitScaled === undefined\n ? {}\n : {\n submittedMaxQuoteDebit: scaledToDecimalOutput(\n submittedMaxQuoteDebitScaled,\n scales.quoteAmount(symbol),\n ),\n }),\n };\n }),\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n );\n}\n\nexport type BatchCreateOrdersResult = v.InferOutput<\n ReturnType<typeof createBatchCreateOrdersResultSchema>\n>;\nexport type BatchCreateOrderResult = BatchCreateOrdersResult[\"results\"][number];\n\nconst DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\nconst BATCH_REPLACE_ITEM_INPUT_KEYS = new Set([\n \"orderId\",\n \"clientOrderId\",\n \"newPrice\",\n \"newQty\",\n \"risk\",\n \"clearRisk\",\n \"newClientOrderId\",\n]);\n\nexport function assertKnownBatchReplaceOrderItemInputKeys(input: object): void {\n for (const key of Object.keys(input)) {\n if (!BATCH_REPLACE_ITEM_INPUT_KEYS.has(key)) {\n throw new Error(`Unknown key \"${key}\" in batch replace order item.`);\n }\n }\n}\n\nconst BatchReplaceTargetInputSchema = v.union([\n v.pipe(\n v.object({\n orderId: v.pipe(\n idInputSchema(\"items.orderId\"),\n v.check((value) => value > 0n, \"items.orderId must be greater than zero\"),\n ),\n clientOrderId: v.optional(v.never()),\n }),\n v.transform(({ orderId }) => ({\n key: { case: \"orderId\" as const, value: orderId },\n })),\n ),\n v.pipe(\n v.object({\n orderId: v.optional(v.never()),\n clientOrderId: ClientOrderIdInputSchema,\n }),\n v.transform(({ clientOrderId }) => ({\n key: { case: \"clientOrderId\" as const, value: clientOrderId },\n })),\n ),\n]);\n\nfunction createBatchReplaceOrderItemInputSchema(scales: SdkScales, symbolId: number) {\n const patchSchema = v.union([\n v.object({\n newPrice: DecimalInputStringSchema,\n newQty: v.optional(DecimalInputStringSchema),\n risk: v.optional(createRequiredRiskPolicyInputSchema(scales)),\n clearRisk: v.optional(v.literal(false)),\n }),\n v.object({\n newPrice: v.optional(DecimalInputStringSchema),\n newQty: DecimalInputStringSchema,\n risk: v.optional(createRequiredRiskPolicyInputSchema(scales)),\n clearRisk: v.optional(v.literal(false)),\n }),\n v.object({\n newPrice: v.optional(v.never()),\n newQty: v.optional(v.never()),\n risk: createRequiredRiskPolicyInputSchema(scales),\n clearRisk: v.optional(v.literal(false)),\n }),\n v.object({\n newPrice: v.optional(v.never()),\n newQty: v.optional(v.never()),\n risk: v.optional(v.never()),\n clearRisk: v.literal(true),\n }),\n ]);\n return v.pipe(\n v.intersect([\n BatchReplaceTargetInputSchema,\n patchSchema,\n v.object({\n newClientOrderId: v.optional(ClientOrderIdInputSchema),\n }),\n ]),\n v.transform((input) => ({\n key: input.key,\n newPriceTicks:\n input.newPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"items.newPrice\",\n input.newPrice,\n scales.price(),\n ),\n newQtyScaled:\n input.newQty === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"items.newQty\",\n input.newQty,\n scales.baseQty(symbolId),\n ),\n newAttachedRisk:\n input.clearRisk === true ? create(ProtoWrite.RiskPolicySchema) : input.risk,\n newClientOrderId: input.newClientOrderId ?? \"\",\n })),\n );\n}\n\nexport function createBatchReplaceOrdersInputSchema(scales: SdkScales, symbolId: number) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n symbolId: v.pipe(v.literal(symbolId), v.integer(), v.minValue(1)),\n requestId: v.optional(OrderRequestIdInputSchema),\n items: v.pipe(\n v.array(createBatchReplaceOrderItemInputSchema(scales, symbolId)),\n v.minLength(1, \"At least one replacement is required.\"),\n v.maxLength(50, \"Batch replace accepts at most 50 replacements.\"),\n ),\n }),\n v.check((input) => {\n const targets = input.items.map(\n (item) => `${item.key.case}:${item.key.value.toString()}`,\n );\n return new Set(targets).size === targets.length;\n }, \"Each batch replace target must be unique.\"),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n );\n}\n\nexport type BatchReplaceOrdersInput = {\n account?: v.InferInput<typeof AccountScopeInputEntries.account>;\n symbolId: number;\n requestId?: string;\n items: Array<{\n orderId?: string;\n clientOrderId?: string;\n newPrice?: string;\n newQty?: string;\n risk?: v.InferInput<ReturnType<typeof createRequiredRiskPolicyInputSchema>>;\n clearRisk?: boolean;\n newClientOrderId?: string;\n }>;\n};\n\nconst BatchReplaceAdmissionItemSchema = v.pipe(\n v.object({\n itemIndex: BatchItemIndexSchema,\n status: v.pipe(\n v.enum(ProtoWrite.BatchReplaceItemAdmissionStatus),\n v.transform((status) =>\n requiredEnumLabel(\n BatchReplaceItemAdmissionStatusCodec.protoToOutput,\n status,\n \"BatchReplaceAdmissionItemSchema\",\n \"status\",\n ),\n ),\n ),\n oldOrderId: OptionalPublicIdSchema,\n replacementOrderId: OptionalPublicIdSchema,\n clientOrderId: v.string(),\n code: v.string(),\n error: v.optional(OrderErrorDetailSchema),\n }),\n v.transform((item) => ({\n ...item,\n code: item.code || undefined,\n })),\n);\n\nexport type BatchReplaceAdmissionItem = v.InferOutput<typeof BatchReplaceAdmissionItemSchema>;\n\nexport const BatchReplaceOrdersResultSchema = v.pipe(\n v.object({\n batchRequestId: PositivePublicIdSchema,\n status: v.pipe(\n v.enum(ProtoWrite.BatchReplaceAdmissionStatus),\n v.transform((status) =>\n requiredEnumLabel(\n BatchReplaceAdmissionStatusCodec.protoToOutput,\n status,\n \"BatchReplaceOrdersResultSchema\",\n \"status\",\n ),\n ),\n ),\n results: v.array(BatchReplaceAdmissionItemSchema),\n acceptedCount: BatchCountSchema,\n rejectedCount: BatchCountSchema,\n acceptedTsNs: v.bigint(),\n }),\n v.check(\n (response) => response.acceptedCount + response.rejectedCount === response.results.length,\n \"Batch replace result counts do not match the returned results.\",\n ),\n v.check(\n (response) => response.results.every((item, index) => item.itemIndex === index),\n \"Batch replace results must preserve request item order.\",\n ),\n v.transform(({ acceptedTsNs, ...response }) => ({\n ...response,\n acceptedTs: tsNsToMs(acceptedTsNs),\n acceptedTsNs: acceptedTsNs.toString(),\n })),\n);\n\nexport type BatchReplaceOrdersResult = v.InferOutput<typeof BatchReplaceOrdersResultSchema>;\n\nexport const GetBatchReplaceStatusInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n batchRequestId: v.pipe(\n idInputSchema(\"batchRequestId\"),\n v.check((value) => value > 0n, \"batchRequestId must be greater than zero\"),\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetBatchReplaceStatusInput = v.InferInput<typeof GetBatchReplaceStatusInputSchema>;\n\nconst BatchReplaceStatusItemSchema = v.pipe(\n v.object({\n itemIndex: BatchItemIndexSchema,\n phase: v.pipe(\n v.enum(ProtoRead.BatchReplacePhase),\n v.transform((phase) =>\n requiredEnumLabel(\n BatchReplacePhaseCodec.protoToOutput,\n phase,\n \"BatchReplaceStatusItemSchema\",\n \"phase\",\n ),\n ),\n ),\n oldOrderId: OptionalPublicIdSchema,\n replacementOrderId: OptionalPublicIdSchema,\n orderStatus: v.pipe(\n v.enum(ProtoRead.OrderStatus),\n v.transform((status) =>\n requiredEnumLabel(\n OrderStatusCodec.protoToOutput,\n status,\n \"BatchReplaceStatusItemSchema\",\n \"order status\",\n ),\n ),\n ),\n code: v.string(),\n updatedTsNs: v.bigint(),\n }),\n v.transform(({ updatedTsNs, ...item }) => ({\n ...item,\n code: item.code || undefined,\n updatedTs: tsNsToMs(updatedTsNs),\n updatedTsNs: updatedTsNs.toString(),\n })),\n);\n\nexport const GetBatchReplaceStatusResultSchema = v.pipe(\n v.object({\n batchRequestId: PositivePublicIdSchema,\n admissionStatus: v.pipe(\n v.enum(ProtoWrite.BatchReplaceAdmissionStatus),\n v.transform((status) =>\n requiredEnumLabel(\n BatchReplaceAdmissionStatusCodec.protoToOutput,\n status,\n \"GetBatchReplaceStatusResultSchema\",\n \"admission status\",\n ),\n ),\n ),\n items: v.array(BatchReplaceStatusItemSchema),\n acceptedCount: BatchCountSchema,\n rejectedCount: BatchCountSchema,\n acceptedTsNs: v.bigint(),\n updatedTsNs: v.bigint(),\n }),\n v.check(\n (response) => response.acceptedCount + response.rejectedCount === response.items.length,\n \"Batch replace status counts do not match the returned items.\",\n ),\n v.check(\n (response) => response.items.every((item, index) => item.itemIndex === index),\n \"Batch replace status items must preserve request item order.\",\n ),\n v.transform(({ acceptedTsNs, updatedTsNs, ...response }) => ({\n ...response,\n acceptedTs: tsNsToMs(acceptedTsNs),\n acceptedTsNs: acceptedTsNs.toString(),\n updatedTs: tsNsToMs(updatedTsNs),\n updatedTsNs: updatedTsNs.toString(),\n })),\n);\n\nexport type GetBatchReplaceStatusResult = v.InferOutput<typeof GetBatchReplaceStatusResultSchema>;\n\nconst BatchCancelOrderInputSchema = v.union([\n v.pipe(\n v.strictObject({\n orderId: v.pipe(\n idInputSchema(\"items.orderId\"),\n v.check((value) => value > 0n, \"items.orderId must be greater than zero\"),\n ),\n clientOrderId: v.optional(v.never()),\n symbolId: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1))),\n }),\n v.transform(({ orderId, symbolId }) => ({ orderId, symbolId })),\n ),\n v.pipe(\n v.strictObject({\n orderId: v.optional(v.never()),\n clientOrderId: ClientOrderIdInputSchema,\n symbolId: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1))),\n }),\n v.transform(({ clientOrderId, symbolId }) => ({ clientOrderId, symbolId })),\n ),\n]);\n\nexport type BatchCancelOrderInput = v.InferInput<typeof BatchCancelOrderInputSchema>;\n\nexport const BatchCancelOrdersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n requestId: v.optional(OrderRequestIdInputSchema),\n items: v.pipe(\n v.array(BatchCancelOrderInputSchema),\n v.minLength(1, \"At least one order is required.\"),\n v.maxLength(50, \"Batch cancel accepts at most 50 orders.\"),\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type BatchCancelOrdersInput = v.InferInput<typeof BatchCancelOrdersInputSchema>;\n\nconst BatchCancelOrderResultSchema = v.object({\n status: v.picklist([\"accepted\", \"rejected\"]),\n orderId: OptionalPublicIdSchema,\n clientOrderId: v.string(),\n code: v.string(),\n error: v.optional(OrderErrorDetailSchema),\n});\n\nexport type BatchCancelOrderResult = v.InferOutput<typeof BatchCancelOrderResultSchema>;\n\nexport const BatchCancelOrdersResultSchema = v.pipe(\n v.object({\n results: v.array(BatchCancelOrderResultSchema),\n acceptedCount: BatchCountSchema,\n rejectedCount: BatchCountSchema,\n tsNs: v.bigint(),\n }),\n v.check(\n (response) => response.acceptedCount + response.rejectedCount === response.results.length,\n \"Batch cancel result counts do not match the returned results.\",\n ),\n v.transform(({ tsNs, ...response }) => ({\n ...response,\n ts: tsNsToMs(tsNs),\n tsNs: tsNs.toString(),\n })),\n);\n\nexport type BatchCancelOrdersResult = v.InferOutput<typeof BatchCancelOrdersResultSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiCA,MAAM,mBAAmB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,CAAC;AACtE,MAAM,uBAAuB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,CAAC;AAC1E,MAAM,yBAAyB,EAAE,KAC7B,EAAE,OAAO,GACT,EAAE,QAAQ,EAAE,GACZ,EAAE,WAAW,UAAU,SAAS,KAAK,CAAC,CAC1C;AACA,MAAM,4BAA4B,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;AAC1F,MAAM,0BAA0B,EAAE,KAC9B,EAAE,SAAS,UAAU,GACrB,EAAE,WAAW,SAAU,OAAO,eAAe,aAAa,QAAQ,KAAA,CAAU,CAChF;AAEA,MAAM,mCAAmC,EAAE,KACvC,EAAE,OAAO,GACT,EAAE,QAAQ,GACV,EAAE,OACG,eAAe,eAAe,KAAM,cAAc,MAAM,cAAc,KACvE,sEACJ,CACJ;AAEA,MAAa,4BAA4B,EAAE,KACvC,EAAE,aAAa;CACX,GAAG;CACH,YAAY;CACZ,QAAQ;CACR,MAAM;CACN,WAAW,EAAE,SAAS,yBAAyB;AACnD,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;AAIA,MAAa,6BAA6B,EAAE,KACxC,EAAE,OAAO;CACL,QAAQ,EAAE,SAAS,CAAC,SAAS,UAAU,CAAC;CACxC,qBAAqB,EAAE,KAAK,EAAE,OAAO,GAAG,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AAE,aAAa;CACX,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;CAC7B,eAAe;CACf,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;AACvE,CAAC,GACD,EAAE,WAAW,EAAE,eAAe,gBAAgB;CAAE;CAAe;AAAS,EAAE,CAC9E,CACJ,CAAC;AAID,MAAa,+BAA+B,EAAE,KAC1C,EAAE,aAAa;CACX,GAAG;CACH,WAAW,EAAE,SAAS,yBAAyB;CAC/C,OAAO,EAAE,KACL,EAAE,MAAM,2BAA2B,GACnC,EAAE,UAAU,GAAG,iCAAiC,GAChD,EAAE,UAAU,IAAI,yCAAyC,CAC7D;AACJ,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;AAIA,MAAM,+BAA+B,EAAE,OAAO;CAC1C,QAAQ,EAAE,SAAS,CAAC,YAAY,UAAU,CAAC;CAC3C,SAAS;CACT,eAAe,EAAE,OAAO;CACxB,MAAM,EAAE,OAAO;CACf,OAAO,EAAE,SAAS,sBAAsB;AAC5C,CAAC;AAID,MAAa,gCAAgC,EAAE,KAC3C,EAAE,OAAO;CACL,SAAS,EAAE,MAAM,4BAA4B;CAC7C,eAAe;CACf,eAAe;CACf,MAAM,EAAE,OAAO;AACnB,CAAC,GACD,EAAE,OACG,aAAa,SAAS,gBAAgB,SAAS,kBAAkB,SAAS,QAAQ,QACnF,+DACJ,GACA,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB;CACpC,GAAG;CACH,IAAI,SAAS,IAAI;CACjB,MAAM,KAAK,SAAS;AACxB,EAAE,CACN"}
@@ -40,7 +40,7 @@ type OpenOrdersInput = v.InferInput<typeof OpenOrdersInputSchema>;
40
40
  declare const OrderHistoryInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
41
41
  readonly includeAttachedRisk: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
42
42
  readonly includeAttachedRiskState: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
43
- readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"FILLED" | "CANCELED" | "REJECTED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
43
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"REJECTED" | "FILLED" | "CANCELED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
44
44
  readonly startTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
45
45
  readonly endTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
46
46
  readonly symbolId: v.OptionalSchema<v.ArraySchema<v.NumberSchema<undefined>, undefined>, undefined>;
@@ -21,7 +21,7 @@ declare class OrdersService {
21
21
  #private;
22
22
  constructor(transport: Transport, realtime: PolyesterRealtime, resolver: SubaccountResolver | undefined, scales: SdkScales);
23
23
  /**
24
- * Returns open orders for the resolved root account or subaccount, with optional symbol, trigger ID, side, pagination, and attached-risk inclusion filters. Results include the next page token returned by GetOpenOrders.
24
+ * Returns open orders for the resolved root account or subaccount, with optional symbol, trigger ID, side, pagination, and attached-risk inclusion filters. Results are paginated with a server-determined page size: a single call is not the full set of open orders — keep calling with the returned nextPageToken until it is empty.
25
25
  */
26
26
  listOpen(input?: v.InferInput<typeof OpenOrdersInputSchema>, options?: PolyesterRequestOptions): Promise<{
27
27
  orders: Order[];
@@ -60,7 +60,7 @@ var OrdersService = class {
60
60
  this.#batchCreateOrdersInputSchema = createBatchCreateOrdersInputSchema(scales);
61
61
  }
62
62
  /**
63
- * Returns open orders for the resolved root account or subaccount, with optional symbol, trigger ID, side, pagination, and attached-risk inclusion filters. Results include the next page token returned by GetOpenOrders.
63
+ * Returns open orders for the resolved root account or subaccount, with optional symbol, trigger ID, side, pagination, and attached-risk inclusion filters. Results are paginated with a server-determined page size: a single call is not the full set of open orders — keep calling with the returned nextPageToken until it is empty.
64
64
  */
65
65
  async listOpen(input = {}, options) {
66
66
  await this.#scales.ready();
@@ -1 +1 @@
1
- {"version":3,"file":"orders.js","names":["#readClient","ProtoRead.OrdersReadService","#writeClient","ProtoWrite.OrdersService","#realtime","#resolver","#scales","#orderSchema","#orderDetailsSchema","#newOrderInputSchema","#modifyOrderInputSchema","#batchCreateOrdersInputSchema","ProtoRead.OrderSchema"],"sources":["../../../src/services/orders/orders.ts"],"sourcesContent":["import * as ProtoRead from \"../../gen/orders/v1/orders_read_pb.js\";\nimport * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport { publicationHandlerErrorContext } from \"../../shared/subscription-errors.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport { createReadyGate, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { getOrderErrorDetail } from \"../../utils/connect-order-errors.js\";\nimport { formatConnectError, isResourceNotFoundError } from \"../../utils/errors.js\";\nimport {\n OpenOrdersInputSchema,\n OrderHistoryInputSchema,\n type NewOrderInput,\n createNewOrderInputSchema,\n CancelOrderInputSchema,\n CancelOrderResultSchema,\n type CancelOrderResult,\n CancelAllOrdersInputSchema,\n CancelAllOrdersResponseSchema,\n type CancelAllOrdersResponse,\n type Order,\n GetOrderDetailsInputSchema,\n createCreateOrderResultSchema,\n createPreviewOrderResultSchema,\n type PreviewOrderResult,\n type ModifyOrderInput,\n assertKnownModifyOrderInputKeys,\n createModifyOrderInputSchema,\n ModifyOrderResultSchema,\n type CreateOrderResult,\n type ModifyOrderResult,\n type OrderDetails,\n createOrderSchema,\n createOrderDetailsSchema,\n CancelAllAfterInputSchema,\n CancelAllAfterResultSchema,\n type CancelAllAfterInput,\n type CancelAllAfterResult,\n BatchCancelOrdersInputSchema,\n BatchCancelOrdersResultSchema,\n type BatchCancelOrdersInput,\n type BatchCancelOrdersResult,\n createBatchCreateOrdersResultSchema,\n type BatchCreateOrdersInput,\n type BatchCreateOrdersResult,\n BatchReplaceOrdersResultSchema,\n type BatchReplaceOrdersInput,\n type BatchReplaceOrdersResult,\n GetBatchReplaceStatusInputSchema,\n GetBatchReplaceStatusResultSchema,\n type GetBatchReplaceStatusInput,\n type GetBatchReplaceStatusResult,\n assertKnownBatchReplaceOrderItemInputKeys,\n createBatchCreateOrdersInputSchema,\n createBatchReplaceOrdersInputSchema,\n} from \"./orders.schemas.js\";\n\nfunction hasKnownOrderSymbol(scales: SdkScales, order: { symbolId: number }): boolean {\n try {\n scales.baseQty(order.symbolId);\n return true;\n } catch {\n return false;\n }\n}\n\nconst MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE = \"order not found\";\n\nfunction isOrderNotFoundError(error: unknown): boolean {\n return (\n isResourceNotFoundError(error) ||\n getOrderErrorDetail(error)?.code === \"NOT_FOUND\" ||\n formatConnectError(error, \"\").toLowerCase() === MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE\n );\n}\n\ninterface SubscribeOrdersInput extends BaseSubscribeInput<Order> {\n accountId: string;\n}\n\nfunction createMutationRequestId(): string {\n return (\n globalThis.crypto?.randomUUID?.() ??\n `req_${Date.now()}_${Math.random().toString(16).slice(2)}`\n );\n}\n\nfunction assertBatchResultCount(operation: string, requested: number, returned: number): void {\n if (requested !== returned) {\n throw new Error(\n `${operation} returned ${returned} results for ${requested} requested items.`,\n );\n }\n}\n\n/**\n * Manages account-scoped spot orders across read, write, and realtime order update surfaces.\n */\nexport class OrdersService {\n #readClient: Client<typeof ProtoRead.OrdersReadService>;\n #writeClient: Client<typeof ProtoWrite.OrdersService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n #scales: SdkScales;\n #orderSchema: ReturnType<typeof createOrderSchema>;\n #orderDetailsSchema: ReturnType<typeof createOrderDetailsSchema>;\n #newOrderInputSchema: ReturnType<typeof createNewOrderInputSchema>;\n #modifyOrderInputSchema: ReturnType<typeof createModifyOrderInputSchema>;\n #batchCreateOrdersInputSchema: ReturnType<typeof createBatchCreateOrdersInputSchema>;\n\n constructor(\n transport: Transport,\n realtime: PolyesterRealtime,\n resolver: SubaccountResolver | undefined,\n scales: SdkScales,\n ) {\n this.#readClient = createClient(ProtoRead.OrdersReadService, transport);\n this.#writeClient = createClient(ProtoWrite.OrdersService, transport);\n this.#realtime = realtime;\n this.#resolver = resolver;\n this.#scales = scales;\n this.#orderSchema = createOrderSchema(scales);\n this.#orderDetailsSchema = createOrderDetailsSchema(scales);\n this.#newOrderInputSchema = createNewOrderInputSchema(scales);\n this.#modifyOrderInputSchema = createModifyOrderInputSchema(scales);\n this.#batchCreateOrdersInputSchema = createBatchCreateOrdersInputSchema(scales);\n }\n\n /**\n * Returns open orders for the resolved root account or subaccount, with optional symbol, trigger ID, side, pagination, and attached-risk inclusion filters. Results include the next page token returned by GetOpenOrders.\n */\n async listOpen(\n input: v.InferInput<typeof OpenOrdersInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ orders: Order[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(OpenOrdersInputSchema, resolved);\n const res = await this.#readClient.getOpenOrders(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n orders: parse(\n v.array(this.#orderSchema),\n res.orders.filter((order) => hasKnownOrderSymbol(this.#scales, order)),\n ),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Returns historical orders for the resolved account scope, supporting symbol, trigger ID, side, status, time range, pagination, and attached-risk filters. Results are paginated with the backend nextPageToken.\n */\n async listHistory(\n input: v.InferInput<typeof OrderHistoryInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ orders: Order[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(OrderHistoryInputSchema, resolved);\n const res = await this.#readClient.getOrderHistory(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n orders: parse(\n v.array(this.#orderSchema),\n res.orders.filter((order) => hasKnownOrderSymbol(this.#scales, order)),\n ),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Evaluates one complete order intent against current market, policy, risk, and balance state without creating an order, reserving funds, or claiming its client order ID.\n */\n async preview(\n input: NewOrderInput,\n options?: PolyesterRequestOptions,\n ): Promise<PreviewOrderResult> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(this.#newOrderInputSchema, resolved);\n const response = await this.#writeClient.previewOrder(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(createPreviewOrderResultSchema(this.#scales, input.symbol), response);\n }\n\n /**\n * Places a spot order with an explicit market-IOC, limit-GTC, limit-IOC, or limit-FOK execution policy and optional attached risk controls. clientOrderId is the caller-controlled idempotency key and should be reused only for the same logical order.\n */\n async create(\n input: NewOrderInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateOrderResult> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(this.#newOrderInputSchema, resolved);\n const requestPayload = removeUndefined(validatedInput);\n const res = await this.#writeClient.createOrder(\n requestPayload,\n toConnectCallOptions(options),\n );\n return parse(createCreateOrderResultSchema(this.#scales, input.symbol), res);\n }\n\n /**\n * Places 1–20 spot orders in one best-effort request. Results preserve item order and report admission as accepted or rejected; accepted orders still require lifecycle reconciliation. Supply a clientOrderId for each item and a stable requestId when an ambiguous batch may be retried.\n */\n async batchCreate(\n input: BatchCreateOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchCreateOrdersResult> {\n await this.#scales.ready();\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(this.#batchCreateOrdersInputSchema, resolved);\n const response = await this.#writeClient.batchCreateOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(\n createBatchCreateOrdersResultSchema(\n this.#scales,\n input.items.map((item) => item.symbol),\n ),\n response,\n );\n assertBatchResultCount(\"batchCreate\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Requests cancellation of one order in the resolved account scope by order id or client order id, with optional symbol routing. The response acknowledges the cancellation request, not the order's final lifecycle state; reconcile through order reads or realtime before releasing local state. A missing target remains a {@link ResourceNotFoundError}; callers performing desired-state cleanup may treat that error as success when the order could already have filled or left the book.\n */\n async cancel(\n input: v.InferInput<typeof CancelOrderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CancelOrderResult> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n\n const validated = parse(CancelOrderInputSchema, resolved);\n\n const res = await this.#writeClient.cancelOrder(\n {\n key: validated.key,\n symbolId: validated.symbolId,\n subaccountId: validated.subaccountId,\n },\n toConnectCallOptions(options),\n );\n return parse(CancelOrderResultSchema, res);\n }\n\n /**\n * Cancels 1–50 explicit orders in one best-effort request. Results preserve item order and acknowledge cancellation admission rather than final order state. Supply a stable requestId when an ambiguous batch may be retried.\n */\n async batchCancel(\n input: BatchCancelOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchCancelOrdersResult> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(BatchCancelOrdersInputSchema, resolved);\n const response = await this.#writeClient.batchCancelOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(BatchCancelOrdersResultSchema, response);\n assertBatchResultCount(\"batchCancel\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Applies a price, quantity, client id, or attached-risk patch to one open order using the backend modify behavior policy. A requestId is generated when omitted; provide a stable value when retrying the same logical modification.\n */\n async modify(\n input: ModifyOrderInput,\n options?: PolyesterMutationOptions,\n ): Promise<ModifyOrderResult> {\n await this.#scales.ready();\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n assertKnownModifyOrderInputKeys(resolved);\n const validated = parse(this.#modifyOrderInputSchema, resolved);\n const res = await this.#writeClient.modifyOrder(\n removeUndefined(validated),\n toConnectCallOptions(options),\n );\n return parse(ModifyOrderResultSchema, res);\n }\n\n /**\n * Replaces 1–50 same-symbol orders and returns an index-stable durable admission receipt. Reuse requestId only when retrying the same logical batch; use the returned batchRequestId for later status reads.\n */\n async batchReplace(\n input: BatchReplaceOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchReplaceOrdersResult> {\n await this.#scales.ready();\n for (const item of input.items) {\n assertKnownBatchReplaceOrderItemInputKeys(item);\n }\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(\n createBatchReplaceOrdersInputSchema(this.#scales, input.symbolId),\n resolved,\n );\n const response = await this.#writeClient.batchReplaceOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(BatchReplaceOrdersResultSchema, response);\n assertBatchResultCount(\"batchReplace\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Reads the durable per-item execution status for a batch replacement receipt.\n */\n async getBatchReplaceStatus(\n input: GetBatchReplaceStatusInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetBatchReplaceStatusResult> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(GetBatchReplaceStatusInputSchema, resolved);\n const response = await this.#readClient.getBatchReplaceStatus(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(GetBatchReplaceStatusResultSchema, response);\n }\n\n /**\n * Cancels all matching open orders for the resolved account scope, optionally narrowed by symbol and side, with dry-run preview. A requestId is generated when omitted; provide a stable value when retrying the same logical bulk cancellation.\n */\n async cancelAll(\n input: v.InferInput<typeof CancelAllOrdersInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CancelAllOrdersResponse> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const validated = parse(CancelAllOrdersInputSchema, resolved);\n const res = await this.#writeClient.cancelAllOrders(\n removeUndefined(validated),\n toConnectCallOptions(options),\n );\n return parse(CancelAllOrdersResponseSchema, res);\n }\n\n /**\n * Arms, refreshes, or disables the account dead-man switch. timeoutSec 0 disables it; 10–120 arms it. Generate a new requestId for each deliberate heartbeat, but reuse the same ID when retrying one ambiguous heartbeat.\n */\n async cancelAllAfter(\n input: CancelAllAfterInput,\n options?: PolyesterMutationOptions,\n ): Promise<CancelAllAfterResult> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(CancelAllAfterInputSchema, resolved);\n const response = await this.#writeClient.cancelAllAfter(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(CancelAllAfterResultSchema, response);\n }\n\n /**\n * Fetches one order by id or client order id and returns its order, trades, and transfer details when found. Returns null when the requested order is not found.\n */\n async getDetails(\n input: v.InferInput<typeof GetOrderDetailsInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderDetails | null> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(GetOrderDetailsInputSchema, resolved);\n let res: ProtoRead.GetOrderResponse;\n try {\n res = await this.#readClient.getOrder(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n } catch (error) {\n if (isOrderNotFoundError(error)) return null;\n throw error;\n }\n if (!res.order) return null;\n return parse(this.#orderDetailsSchema, res);\n }\n\n /**\n * Subscribes to private order updates on private:spot:orders:{accountId}:proto and emits parsed order records until the returned unsubscribe function is called.\n */\n subscribe(input: SubscribeOrdersInput): () => void {\n const channel = `private:spot:orders:${input.accountId}:proto`;\n const gate = createReadyGate(\n () => this.#scales.ready(),\n (error) => input.onError?.(publicationHandlerErrorContext(channel, error)),\n );\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoRead.OrderSchema,\n onPublication: (data) => {\n gate.run(() => {\n const order = parse(this.#orderSchema, data);\n input.onEvent(order);\n });\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,SAAS,oBAAoB,QAAmB,OAAsC;CAClF,IAAI;EACA,OAAO,QAAQ,MAAM,QAAQ;EAC7B,OAAO;CACX,QAAQ;EACJ,OAAO;CACX;AACJ;AAEA,MAAM,wCAAwC;AAE9C,SAAS,qBAAqB,OAAyB;CACnD,OACI,wBAAwB,KAAK,KAC7B,oBAAoB,KAAK,CAAC,EAAE,SAAS,eACrC,mBAAmB,OAAO,EAAE,CAAC,CAAC,YAAY,MAAM;AAExD;AAMA,SAAS,0BAAkC;CACvC,OACI,WAAW,QAAQ,aAAa,KAChC,OAAO,KAAK,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;AAE/D;AAEA,SAAS,uBAAuB,WAAmB,WAAmB,UAAwB;CAC1F,IAAI,cAAc,UACd,MAAM,IAAI,MACN,GAAG,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,SACzB,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACJ,SAAS,OAAO;GACZ,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,MAAM;EACV;EACA,IAAI,CAAC,IAAI,OAAO,OAAO;EACvB,OAAO,MAAM,KAAKQ,qBAAqB,GAAG;CAC9C;;;;CAKA,UAAU,OAAyC;EAC/C,MAAM,UAAU,uBAAuB,MAAM,UAAU;EACvD,MAAM,OAAO,sBACH,KAAKF,QAAQ,MAAM,IACxB,UAAU,MAAM,UAAU,+BAA+B,SAAS,KAAK,CAAC,CAC7E;EACA,OAAO,KAAKF,UAAU,oBAAoB;GACtC;GACA,QAAQQ;GACR,gBAAgB,SAAS;IACrB,KAAK,UAAU;KACX,MAAM,QAAQ,MAAM,KAAKL,cAAc,IAAI;KAC3C,MAAM,QAAQ,KAAK;IACvB,CAAC;GACL;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
1
+ {"version":3,"file":"orders.js","names":["#readClient","ProtoRead.OrdersReadService","#writeClient","ProtoWrite.OrdersService","#realtime","#resolver","#scales","#orderSchema","#orderDetailsSchema","#newOrderInputSchema","#modifyOrderInputSchema","#batchCreateOrdersInputSchema","ProtoRead.OrderSchema"],"sources":["../../../src/services/orders/orders.ts"],"sourcesContent":["import * as ProtoRead from \"../../gen/orders/v1/orders_read_pb.js\";\nimport * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport { publicationHandlerErrorContext } from \"../../shared/subscription-errors.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport { createReadyGate, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { getOrderErrorDetail } from \"../../utils/connect-order-errors.js\";\nimport { formatConnectError, isResourceNotFoundError } from \"../../utils/errors.js\";\nimport {\n OpenOrdersInputSchema,\n OrderHistoryInputSchema,\n type NewOrderInput,\n createNewOrderInputSchema,\n CancelOrderInputSchema,\n CancelOrderResultSchema,\n type CancelOrderResult,\n CancelAllOrdersInputSchema,\n CancelAllOrdersResponseSchema,\n type CancelAllOrdersResponse,\n type Order,\n GetOrderDetailsInputSchema,\n createCreateOrderResultSchema,\n createPreviewOrderResultSchema,\n type PreviewOrderResult,\n type ModifyOrderInput,\n assertKnownModifyOrderInputKeys,\n createModifyOrderInputSchema,\n ModifyOrderResultSchema,\n type CreateOrderResult,\n type ModifyOrderResult,\n type OrderDetails,\n createOrderSchema,\n createOrderDetailsSchema,\n CancelAllAfterInputSchema,\n CancelAllAfterResultSchema,\n type CancelAllAfterInput,\n type CancelAllAfterResult,\n BatchCancelOrdersInputSchema,\n BatchCancelOrdersResultSchema,\n type BatchCancelOrdersInput,\n type BatchCancelOrdersResult,\n createBatchCreateOrdersResultSchema,\n type BatchCreateOrdersInput,\n type BatchCreateOrdersResult,\n BatchReplaceOrdersResultSchema,\n type BatchReplaceOrdersInput,\n type BatchReplaceOrdersResult,\n GetBatchReplaceStatusInputSchema,\n GetBatchReplaceStatusResultSchema,\n type GetBatchReplaceStatusInput,\n type GetBatchReplaceStatusResult,\n assertKnownBatchReplaceOrderItemInputKeys,\n createBatchCreateOrdersInputSchema,\n createBatchReplaceOrdersInputSchema,\n} from \"./orders.schemas.js\";\n\nfunction hasKnownOrderSymbol(scales: SdkScales, order: { symbolId: number }): boolean {\n try {\n scales.baseQty(order.symbolId);\n return true;\n } catch {\n return false;\n }\n}\n\nconst MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE = \"order not found\";\n\nfunction isOrderNotFoundError(error: unknown): boolean {\n return (\n isResourceNotFoundError(error) ||\n getOrderErrorDetail(error)?.code === \"NOT_FOUND\" ||\n formatConnectError(error, \"\").toLowerCase() === MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE\n );\n}\n\ninterface SubscribeOrdersInput extends BaseSubscribeInput<Order> {\n accountId: string;\n}\n\nfunction createMutationRequestId(): string {\n return (\n globalThis.crypto?.randomUUID?.() ??\n `req_${Date.now()}_${Math.random().toString(16).slice(2)}`\n );\n}\n\nfunction assertBatchResultCount(operation: string, requested: number, returned: number): void {\n if (requested !== returned) {\n throw new Error(\n `${operation} returned ${returned} results for ${requested} requested items.`,\n );\n }\n}\n\n/**\n * Manages account-scoped spot orders across read, write, and realtime order update surfaces.\n */\nexport class OrdersService {\n #readClient: Client<typeof ProtoRead.OrdersReadService>;\n #writeClient: Client<typeof ProtoWrite.OrdersService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n #scales: SdkScales;\n #orderSchema: ReturnType<typeof createOrderSchema>;\n #orderDetailsSchema: ReturnType<typeof createOrderDetailsSchema>;\n #newOrderInputSchema: ReturnType<typeof createNewOrderInputSchema>;\n #modifyOrderInputSchema: ReturnType<typeof createModifyOrderInputSchema>;\n #batchCreateOrdersInputSchema: ReturnType<typeof createBatchCreateOrdersInputSchema>;\n\n constructor(\n transport: Transport,\n realtime: PolyesterRealtime,\n resolver: SubaccountResolver | undefined,\n scales: SdkScales,\n ) {\n this.#readClient = createClient(ProtoRead.OrdersReadService, transport);\n this.#writeClient = createClient(ProtoWrite.OrdersService, transport);\n this.#realtime = realtime;\n this.#resolver = resolver;\n this.#scales = scales;\n this.#orderSchema = createOrderSchema(scales);\n this.#orderDetailsSchema = createOrderDetailsSchema(scales);\n this.#newOrderInputSchema = createNewOrderInputSchema(scales);\n this.#modifyOrderInputSchema = createModifyOrderInputSchema(scales);\n this.#batchCreateOrdersInputSchema = createBatchCreateOrdersInputSchema(scales);\n }\n\n /**\n * Returns open orders for the resolved root account or subaccount, with optional symbol, trigger ID, side, pagination, and attached-risk inclusion filters. Results are paginated with a server-determined page size: a single call is not the full set of open orders — keep calling with the returned nextPageToken until it is empty.\n */\n async listOpen(\n input: v.InferInput<typeof OpenOrdersInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ orders: Order[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(OpenOrdersInputSchema, resolved);\n const res = await this.#readClient.getOpenOrders(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n orders: parse(\n v.array(this.#orderSchema),\n res.orders.filter((order) => hasKnownOrderSymbol(this.#scales, order)),\n ),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Returns historical orders for the resolved account scope, supporting symbol, trigger ID, side, status, time range, pagination, and attached-risk filters. Results are paginated with the backend nextPageToken.\n */\n async listHistory(\n input: v.InferInput<typeof OrderHistoryInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ orders: Order[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(OrderHistoryInputSchema, resolved);\n const res = await this.#readClient.getOrderHistory(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n orders: parse(\n v.array(this.#orderSchema),\n res.orders.filter((order) => hasKnownOrderSymbol(this.#scales, order)),\n ),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Evaluates one complete order intent against current market, policy, risk, and balance state without creating an order, reserving funds, or claiming its client order ID.\n */\n async preview(\n input: NewOrderInput,\n options?: PolyesterRequestOptions,\n ): Promise<PreviewOrderResult> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(this.#newOrderInputSchema, resolved);\n const response = await this.#writeClient.previewOrder(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(createPreviewOrderResultSchema(this.#scales, input.symbol), response);\n }\n\n /**\n * Places a spot order with an explicit market-IOC, limit-GTC, limit-IOC, or limit-FOK execution policy and optional attached risk controls. clientOrderId is the caller-controlled idempotency key and should be reused only for the same logical order.\n */\n async create(\n input: NewOrderInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateOrderResult> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(this.#newOrderInputSchema, resolved);\n const requestPayload = removeUndefined(validatedInput);\n const res = await this.#writeClient.createOrder(\n requestPayload,\n toConnectCallOptions(options),\n );\n return parse(createCreateOrderResultSchema(this.#scales, input.symbol), res);\n }\n\n /**\n * Places 1–20 spot orders in one best-effort request. Results preserve item order and report admission as accepted or rejected; accepted orders still require lifecycle reconciliation. Supply a clientOrderId for each item and a stable requestId when an ambiguous batch may be retried.\n */\n async batchCreate(\n input: BatchCreateOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchCreateOrdersResult> {\n await this.#scales.ready();\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(this.#batchCreateOrdersInputSchema, resolved);\n const response = await this.#writeClient.batchCreateOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(\n createBatchCreateOrdersResultSchema(\n this.#scales,\n input.items.map((item) => item.symbol),\n ),\n response,\n );\n assertBatchResultCount(\"batchCreate\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Requests cancellation of one order in the resolved account scope by order id or client order id, with optional symbol routing. The response acknowledges the cancellation request, not the order's final lifecycle state; reconcile through order reads or realtime before releasing local state. A missing target remains a {@link ResourceNotFoundError}; callers performing desired-state cleanup may treat that error as success when the order could already have filled or left the book.\n */\n async cancel(\n input: v.InferInput<typeof CancelOrderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CancelOrderResult> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n\n const validated = parse(CancelOrderInputSchema, resolved);\n\n const res = await this.#writeClient.cancelOrder(\n {\n key: validated.key,\n symbolId: validated.symbolId,\n subaccountId: validated.subaccountId,\n },\n toConnectCallOptions(options),\n );\n return parse(CancelOrderResultSchema, res);\n }\n\n /**\n * Cancels 1–50 explicit orders in one best-effort request. Results preserve item order and acknowledge cancellation admission rather than final order state. Supply a stable requestId when an ambiguous batch may be retried.\n */\n async batchCancel(\n input: BatchCancelOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchCancelOrdersResult> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(BatchCancelOrdersInputSchema, resolved);\n const response = await this.#writeClient.batchCancelOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(BatchCancelOrdersResultSchema, response);\n assertBatchResultCount(\"batchCancel\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Applies a price, quantity, client id, or attached-risk patch to one open order using the backend modify behavior policy. A requestId is generated when omitted; provide a stable value when retrying the same logical modification.\n */\n async modify(\n input: ModifyOrderInput,\n options?: PolyesterMutationOptions,\n ): Promise<ModifyOrderResult> {\n await this.#scales.ready();\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n assertKnownModifyOrderInputKeys(resolved);\n const validated = parse(this.#modifyOrderInputSchema, resolved);\n const res = await this.#writeClient.modifyOrder(\n removeUndefined(validated),\n toConnectCallOptions(options),\n );\n return parse(ModifyOrderResultSchema, res);\n }\n\n /**\n * Replaces 1–50 same-symbol orders and returns an index-stable durable admission receipt. Reuse requestId only when retrying the same logical batch; use the returned batchRequestId for later status reads.\n */\n async batchReplace(\n input: BatchReplaceOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchReplaceOrdersResult> {\n await this.#scales.ready();\n for (const item of input.items) {\n assertKnownBatchReplaceOrderItemInputKeys(item);\n }\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(\n createBatchReplaceOrdersInputSchema(this.#scales, input.symbolId),\n resolved,\n );\n const response = await this.#writeClient.batchReplaceOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(BatchReplaceOrdersResultSchema, response);\n assertBatchResultCount(\"batchReplace\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Reads the durable per-item execution status for a batch replacement receipt.\n */\n async getBatchReplaceStatus(\n input: GetBatchReplaceStatusInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetBatchReplaceStatusResult> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(GetBatchReplaceStatusInputSchema, resolved);\n const response = await this.#readClient.getBatchReplaceStatus(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(GetBatchReplaceStatusResultSchema, response);\n }\n\n /**\n * Cancels all matching open orders for the resolved account scope, optionally narrowed by symbol and side, with dry-run preview. A requestId is generated when omitted; provide a stable value when retrying the same logical bulk cancellation.\n */\n async cancelAll(\n input: v.InferInput<typeof CancelAllOrdersInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CancelAllOrdersResponse> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const validated = parse(CancelAllOrdersInputSchema, resolved);\n const res = await this.#writeClient.cancelAllOrders(\n removeUndefined(validated),\n toConnectCallOptions(options),\n );\n return parse(CancelAllOrdersResponseSchema, res);\n }\n\n /**\n * Arms, refreshes, or disables the account dead-man switch. timeoutSec 0 disables it; 10–120 arms it. Generate a new requestId for each deliberate heartbeat, but reuse the same ID when retrying one ambiguous heartbeat.\n */\n async cancelAllAfter(\n input: CancelAllAfterInput,\n options?: PolyesterMutationOptions,\n ): Promise<CancelAllAfterResult> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(CancelAllAfterInputSchema, resolved);\n const response = await this.#writeClient.cancelAllAfter(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(CancelAllAfterResultSchema, response);\n }\n\n /**\n * Fetches one order by id or client order id and returns its order, trades, and transfer details when found. Returns null when the requested order is not found.\n */\n async getDetails(\n input: v.InferInput<typeof GetOrderDetailsInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderDetails | null> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(GetOrderDetailsInputSchema, resolved);\n let res: ProtoRead.GetOrderResponse;\n try {\n res = await this.#readClient.getOrder(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n } catch (error) {\n if (isOrderNotFoundError(error)) return null;\n throw error;\n }\n if (!res.order) return null;\n return parse(this.#orderDetailsSchema, res);\n }\n\n /**\n * Subscribes to private order updates on private:spot:orders:{accountId}:proto and emits parsed order records until the returned unsubscribe function is called.\n */\n subscribe(input: SubscribeOrdersInput): () => void {\n const channel = `private:spot:orders:${input.accountId}:proto`;\n const gate = createReadyGate(\n () => this.#scales.ready(),\n (error) => input.onError?.(publicationHandlerErrorContext(channel, error)),\n );\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoRead.OrderSchema,\n onPublication: (data) => {\n gate.run(() => {\n const order = parse(this.#orderSchema, data);\n input.onEvent(order);\n });\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,SAAS,oBAAoB,QAAmB,OAAsC;CAClF,IAAI;EACA,OAAO,QAAQ,MAAM,QAAQ;EAC7B,OAAO;CACX,QAAQ;EACJ,OAAO;CACX;AACJ;AAEA,MAAM,wCAAwC;AAE9C,SAAS,qBAAqB,OAAyB;CACnD,OACI,wBAAwB,KAAK,KAC7B,oBAAoB,KAAK,CAAC,EAAE,SAAS,eACrC,mBAAmB,OAAO,EA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AAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,4BAA4B,QAAQ;CACrD;;;;CAKA,MAAM,WACF,OACA,SAC4B;EAC5B,MAAM,KAAKI,QAAQ,MAAM;EACzB,MAAM,WAAW,0BAA0B,OAAO,KAAKD,SAAS;EAChE,MAAM,iBAAiB,MAAM,4BAA4B,QAAQ;EACjE,IAAI;EACJ,IAAI;GACA,MAAM,MAAM,KAAKL,YAAY,SACzB,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACJ,SAAS,OAAO;GACZ,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,MAAM;EACV;EACA,IAAI,CAAC,IAAI,OAAO,OAAO;EACvB,OAAO,MAAM,KAAKQ,qBAAqB,GAAG;CAC9C;;;;CAKA,UAAU,OAAyC;EAC/C,MAAM,UAAU,uBAAuB,MAAM,UAAU;EACvD,MAAM,OAAO,sBACH,KAAKF,QAAQ,MAAM,IACxB,UAAU,MAAM,UAAU,+BAA+B,SAAS,KAAK,CAAC,CAC7E;EACA,OAAO,KAAKF,UAAU,oBAAoB;GACtC;GACA,QAAQQ;GACR,gBAAgB,SAAS;IACrB,KAAK,UAAU;KACX,MAAM,QAAQ,MAAM,KAAKL,cAAc,IAAI;KAC3C,MAAM,QAAQ,KAAK;IACvB,CAAC;GACL;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
@@ -243,7 +243,7 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
243
243
  seconds: bigint;
244
244
  nanos: number;
245
245
  } | undefined, number | undefined>]>;
246
- readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
246
+ readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
247
247
  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" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
248
248
  readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
249
249
  readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -787,7 +787,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
787
787
  declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
788
788
  readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
789
789
  readonly symbol: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>;
790
- readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
790
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
791
791
  readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
792
792
  readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
793
793
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
@@ -31,62 +31,62 @@ declare const CreateTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSche
31
31
  type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;
32
32
  declare const CancelTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
33
33
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
34
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
34
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
35
35
  readonly tsNs: v.BigintSchema<undefined>;
36
36
  }, undefined>, v.TransformAction<{
37
37
  triggerId: string;
38
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
38
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
39
39
  tsNs: bigint;
40
40
  }, {
41
41
  ts: number;
42
42
  tsNs: string;
43
43
  triggerId: string;
44
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
44
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
45
45
  }>]>;
46
46
  type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;
47
47
  declare const ModifyTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
48
48
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
49
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
49
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
50
50
  readonly tsNs: v.BigintSchema<undefined>;
51
51
  }, undefined>, v.TransformAction<{
52
52
  triggerId: string;
53
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
53
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
54
54
  tsNs: bigint;
55
55
  }, {
56
56
  ts: number;
57
57
  tsNs: string;
58
58
  triggerId: string;
59
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
59
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
60
60
  }>]>;
61
61
  type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;
62
62
  declare const PauseTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
63
63
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
64
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
64
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
65
65
  readonly tsNs: v.BigintSchema<undefined>;
66
66
  }, undefined>, v.TransformAction<{
67
67
  triggerId: string;
68
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
68
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
69
69
  tsNs: bigint;
70
70
  }, {
71
71
  ts: number;
72
72
  tsNs: string;
73
73
  triggerId: string;
74
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
74
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
75
75
  }>]>;
76
76
  type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;
77
77
  declare const ResumeTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
78
78
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
79
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
79
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
80
80
  readonly tsNs: v.BigintSchema<undefined>;
81
81
  }, undefined>, v.TransformAction<{
82
82
  triggerId: string;
83
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
83
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
84
84
  tsNs: bigint;
85
85
  }, {
86
86
  ts: number;
87
87
  tsNs: string;
88
88
  triggerId: string;
89
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
89
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
90
90
  }>]>;
91
91
  type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;
92
92
  type StopDetailsOutput = {
@@ -507,7 +507,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
507
507
  subaccountId: string;
508
508
  symbolId: number;
509
509
  symbol: string;
510
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
510
+ status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
511
511
  parentOrderId: string | undefined;
512
512
  qty: string;
513
513
  feeAsset: "unspecified" | "quote" | "base";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyester/sdk",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "private": false,
5
5
  "description": "TypeScript SDK providing access to APIs on Polyester Exchange.",
6
6
  "homepage": "https://github.com/Fabric-Labs/polyester-sdk-typescript#readme",