import { AuthApiTransports } from "../../shared/transports.js"; import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../shared/request-options.js"; import { SubaccountResolver } from "../subaccount-resolver.js"; import { PolyesterRealtime } from "../../realtime/types.js"; import { BaseSubscribeInput } from "../../shared/types.js"; import { SdkScales } from "../../shared/decimal-surface.js"; import { Order, OrderDetails } from "./orders-output.schemas.js"; import { CancelAllOrdersInputSchema, CancelAllOrdersResponse, CancelOrderInputSchema, CancelOrderResult, CreateOrderResult, GetOrderDetailsInputSchema, NewOrderInput, OpenOrdersInputSchema, OrderHistoryInputSchema, PreviewOrderResult } from "./orders-input.schemas.js"; import { ModifyOrderInput, ModifyOrderResult } from "./orders-modify.schemas.js"; import { BatchCancelOrdersInput, BatchCancelOrdersResult, BatchCreateOrdersInput, BatchCreateOrdersResult, BatchReplaceOrdersInput, BatchReplaceOrdersResult, CancelAllAfterInput, CancelAllAfterResult, GetBatchReplaceStatusInput, GetBatchReplaceStatusResult } from "./orders-batch.schemas.js"; import "./orders.schemas.js"; import * as v from "valibot"; //#region src/services/orders/orders.d.ts interface SubscribeOrdersInput extends BaseSubscribeInput { /** The account's base58 public ID, the root account's or a sub-account's. */ accountId: string; /** * The account's full live view: open orders, orders not yet on the book, and * recently ended orders. Sent when the subscription starts and whenever the * server replaces its state; replace local order state with it. When omitted, * each snapshot order goes to `onEvent` instead. */ onSnapshot?: (orders: Order[]) => void; /** * Orders that left the live view and remain only in history. Not cancellations. * Without `onSnapshot`, also the orders a resync snapshot no longer contains. */ onRemoved?: (orderIds: string[]) => void; /** * `true` while the account's live view is behind; `false` once it caught up. * `orderIds`, when set, names the only orders whose rows show an earlier state; * the rest of the view is current. A later call replaces the earlier one. */ onStale?: (stale: boolean, orderIds?: string[]) => void; } /** * Manages account-scoped spot orders across read, write, and realtime order update surfaces. */ declare class OrdersService { #private; constructor(transports: AuthApiTransports, realtime: PolyesterRealtime, resolver: SubaccountResolver | undefined, scales: SdkScales); /** * Returns open orders for the resolved root account or subaccount, with optional symbol IDs, 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. */ listOpen(input?: v.InferInput, options?: PolyesterRequestOptions): Promise<{ orders: Order[]; nextPageToken: string; }>; /** * Returns historical orders for the resolved account scope, supporting symbol IDs, trigger ID, side, status, time range, pagination, and attached-risk filters. A page may hold fewer orders than requested, or none: keep calling with the returned nextPageToken until it is empty. */ listHistory(input?: v.InferInput, options?: PolyesterRequestOptions): Promise<{ orders: Order[]; nextPageToken: string; }>; /** * 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. */ preview(input: NewOrderInput, options?: PolyesterRequestOptions): Promise; /** * 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 an account-scoped correlation, lookup, and cancellation identifier. Reuse while retained returns CONFLICT_DUPLICATE_CLIENT_ORDER_ID, including after rejection or completion; it does not replay the earlier result. After an ambiguous timeout, reconcile through get using clientOrderId; an immediate lookup miss does not prove admission failed. Without clientOrderId, the outcome may remain unknown. */ create(input: NewOrderInput, options?: PolyesterMutationOptions): Promise; /** * 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. requestId is the idempotency boundary for the ordered batch and is generated when omitted; supply and reuse it when an ambiguous batch may be retried. Reusing the account-scoped requestId with the same payload within 15 minutes returns each decided item's original result and result time and retries items still unresolved, never admitting an item twice; a different payload during that window returns CONFLICT_IDEMPOTENCY_KEY_REUSE. After 15 minutes the ID is free and a repeat can place its orders again, so read the items back instead of repeating an older batch. Per-item clientOrderId values are optional correlation identifiers and must be unique when supplied. */ batchCreate(input: BatchCreateOrdersInput, options?: PolyesterMutationOptions): Promise; /** * 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. */ cancel(input: v.InferInput, options?: PolyesterMutationOptions): Promise; /** * 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. */ batchCancel(input: BatchCancelOrdersInput, options?: PolyesterMutationOptions): Promise; /** * Applies a price, quantity, client id, or attached-risk patch to one open order. The symbol ID routes policy checks and quantity scaling. A requestId is generated when omitted; provide a stable value when retrying the same logical modification. */ modify(input: ModifyOrderInput, options?: PolyesterMutationOptions): Promise; /** * 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. An AMENDED actionTaken is cancel-only with no successor; keep tracking oldOrderId until its terminal state is confirmed. * * The receipt answers admission, before each admitted item's change completes. Until then, the next change of the same order is rejected with the retryable item `code` `ORDER_MODIFY_IN_PROGRESS`, or `ORDER_PLACEMENT_PENDING` when it names the returned `replacementOrderId`. Resend only those items, in a new batch under a fresh `requestId`, after a short jittered backoff (for example 50 ms doubling to 1 s). The rejected batch's `requestId` replays its rejection, admitted items must never be resent, and a batch whose outcome you did not receive is reconciled under its own `requestId`, never resent under a new one. */ batchReplace(input: BatchReplaceOrdersInput, options?: PolyesterMutationOptions): Promise; /** * Reads the admission and each item's current execution phase for an accepted batch * replacement. Status is retained for 60 seconds from acceptance and is readable as soon as * `batchReplace` returns. A `ServiceUnavailableError` means the status is not established * yet: retry the same request within the window. A `ResourceNotFoundError` means no batch is * retained under this ID (none was accepted, or the window ended), never that the replacement * was rejected: reconcile the individual orders and never resubmit an accepted batch. An * item's `updatedTsNs` can be a later recovery time, so do not use it to identify a refusal. * For cancel-only AMENDED items, orderStatus describes oldOrderId and replacementOrderId is * undefined. */ getBatchReplaceStatus(input: GetBatchReplaceStatusInput, options?: PolyesterRequestOptions): Promise; /** * Cancels all matching open orders for the resolved account scope, optionally narrowed by up to 100 symbol IDs and side, with dry-run preview. A requestId is generated when omitted; reuse it with the same criteria for retries. Completed results are retained for at least two minutes; use a fresh key for each new cancellation. * `canceledOrders` lists up to 200 of the orders whose cancellation was requested, oldest first; `truncated` is true when `totalCanceled` counts more. Read each order's final state from `orders.subscribe` or the order reads. * A retry with the same requestId and criteria returns the original counts with `listingStatus: "not_retained_read_open_orders"` and an empty `canceledOrders`, which does not mean nothing was canceled; read open orders instead. */ cancelAll(input: v.InferInput, options?: PolyesterMutationOptions): Promise; /** * Arms, refreshes, or disables the account dead-man switch, optionally scoped by symbol ID and side. timeoutSec 0 disables it; 10–120 arms it. An armed switch returns its recorded `effectiveScope`. Generate a new requestId for each deliberate heartbeat, but reuse the same ID when retrying one ambiguous heartbeat. */ cancelAllAfter(input: CancelAllAfterInput, options?: PolyesterMutationOptions): Promise; /** * Fetches one physical order and a bounded page of lineage executions through its generation. * Pass nextPageToken as pageToken with the same orderId to continue; deduplicate transfers by txId. * Set includeExecutionHistory to false for state-only polling, omitting limit and pageToken. * Execution pages are eventually consistent and need not reconcile with cumulative order quantities. * `executionsComplete` is true once the trades across every page add up to the filled quantity; while false, read again for the rest. * Returns null when the requested order is not found. */ getDetails(input: v.InferInput, options?: PolyesterRequestOptions): Promise; /** * Streams an account's orders over the private WebSocket until the returned unsubscribe * function is called. Each changed order arrives complete through `onEvent`; keep the * copy with the higher `version`, since equal versions are identical. Gaps, expired * tokens, and reconnects resume from the last applied position automatically. * Throws ValidationError when `accountId` is not a base58 public ID. */ subscribe(input: SubscribeOrdersInput): () => void; } //#endregion export { OrdersService, SubscribeOrdersInput }; //# sourceMappingURL=orders.d.ts.map