Skip to Content
API ReferenceNordUser (Trading)

NordUser (Trading & Account)

The NordUser class is for interacting with the Nord protocol as an authenticated user. It handles trading, balance management, and sub-account operations.

Trading Operations

placeOrder

Places an order on the exchange.

Signature:

placeOrder(params: PlaceOrderParams): Promise<PlaceOrderResponse>

Arguments (PlaceOrderParams):

NameTypeRequiredDescription
marketIdnumberYesTarget market identifier.
sideSideYesOrder side (Side.Bid or Side.Ask).
fillModeFillModeYesFillMode.Limit, FillMode.PostOnly, FillMode.ImmediateOrCancel, or FillMode.FillOrKill.
isReduceOnlybooleanYesIf true, order only decreases position.
sizeDecimal.ValueNoQuantity of base asset. Required for most orders.
priceDecimal.ValueNoLimit price. Required for Limit orders.
quoteSizeQuoteSizeNoQuote-sized order representation for market orders.
accountIdnumberNoSub-account ID executing the order.
clientOrderIdBigIntValueNoOptional client-specified identifier.

Response (PlaceOrderResponse):

FieldTypeDescription
actionIdbigintUnique identifier for the transaction action.
orderIdbigint(Optional) The ID assigned to the resting order if posted.
fillsReceipt_Trade[]Array of trade receipts if the order was filled.
reducedOrdersReducedOrder[]Orders that were shrunk or cancelled by in-engine reduce-only maintenance.

ReducedOrder Fields:

FieldTypeDescription
orderIdbigintThe order that was reduced.
remainingSizebigintSize remaining after reduction (0 if fully cancelled).
cancelledSizebigintSize that was removed.
pricebigintOrder price.

cancelOrder

Cancels an existing order.

Signature:

cancelOrder(orderId: BigIntValue, accountId?: number): Promise<CancelResult>

Arguments:

NameTypeRequiredDescription
orderIdBigIntValueYesThe ID of the order to cancel.
accountIdnumberNoThe sub-account ID that placed the order.

Response (CancelResult):

FieldTypeDescription
actionIdbigintAction identifier for the cancellation.
orderIdbigintThe cancelled order ID.
accountIdnumberThe account ID involved.

cancelOrderByClientId

Cancels an existing order using the client-provided identifier.

Signature:

cancelOrderByClientId(clientOrderId: BigIntValue, accountId?: number): Promise<CancelResult>

Arguments:

NameTypeRequiredDescription
clientOrderIdBigIntValueYesThe client-specified order identifier set when placing the order.
accountIdnumberNoThe sub-account ID that placed the order.

Response (CancelResult):

FieldTypeDescription
actionIdbigintAction identifier for the cancellation.
orderIdbigintThe cancelled order ID.
accountIdnumberThe account ID involved.
clientOrderIdbigintThe client order ID that was cancelled.

atomic

Executes multiple operations (place/cancel) atomically in a single transaction.

Signature:

atomic(userActions: UserAtomicSubaction[], providedAccountId?: number): Promise<AtomicResponse>

UserAtomicSubaction Fields:

FieldTypeDescription
kind"place" | "cancel" | "cancelByClientId"The type of sub-action.
marketIdnumber(Optional) Market ID.
orderIdBigIntValue(Optional) Order ID to cancel.
clientOrderIdBigIntValue(Optional) Client order ID to cancel (for cancelByClientId).
sideSide(Optional) Order side.
fillModeFillMode(Optional) Fill mode.
sizeDecimal.Value(Optional) Quantity.
priceDecimal.Value(Optional) Price.

Trigger Operations

[!CAUTION] Experimental Feature: Trigger orders (TP/SL) are currently unstable and may change. Use with caution in production.

addTrigger

Adds a stop-loss or take-profit trigger.

Arguments:

NameTypeRequiredDescription
marketIdnumberYesMarket to watch.
sideSideYesOrder side for the trigger.
kindTriggerKindYesTriggerKind.StopLoss or TriggerKind.TakeProfit.
triggerPriceDecimal.ValueYesPrice that activates the trigger.
limitPriceDecimal.ValueNoOptional limit price once triggered.
intentIntentYesIntent.Decrease (close/reduce position) or Intent.Increase (add to position).

removeTrigger

Removes a previously added trigger.

Signature:

removeTrigger(params: RemoveTriggerParams): Promise<void>

Arguments:

NameTypeRequiredDescription
marketIdnumberYesMarket identifier.
sideSideYesSide.Bid or Side.Ask.
kindTriggerKindYesTriggerKind.StopLoss or TriggerKind.TakeProfit.
intentIntentYesIntent.Decrease or Intent.Increase. Must match the intent used when adding.
triggerPriceDecimal.ValueNoTrigger price for exact-match removal.
limitsOrderLimitNoSame limit fields as on add-trigger for exact-match removal. If the trigger was added without size limits, omit here too.

Fund Management

deposit

Deposits SPL tokens to the exchange.

Arguments:

NameTypeRequiredDescription
amountnumberYesAmount to deposit.
tokenIdnumberYesToken identifier (e.g., 1 for USDC).
recipientPublicKeyNoRecipient address; defaults to user’s address.

Response: Returns { signature: string, buffer: PublicKey }.


withdraw

Withdraws tokens from the exchange to your wallet.

Arguments:

NameTypeRequiredDescription
amountnumberYesAmount to withdraw.
tokenIdnumberYesToken identifier.
destPubkeystringNoOptional destination registration pubkey (base58).

Information & State

fetchInfo

Refreshes the local state of the user, including balances, orders, and positions.

await user.fetchInfo(); console.log(user.balances);

getSolanaBalances

Checks token balances in your Solana wallet context (not on-exchange).

Arguments:

NameTypeDefaultDescription
includeZeroBalancesbooleantrueInclude tokens with 0 balance.
includeTokenAccountsbooleanfalseInclude specific token account addresses.

WebSocket Subscriptions

Nord.subscribe

Subscribe to real-time WebSocket events.

Signature:

Nord.subscribe(options: SubscribeOptions): void

Options:

NameTypeDescription
liquidationsbooleanSubscribe to liquidation events (backstop take-all and position liquidations).

Example:

nord.subscribe({ liquidations: true });

See WebSocket Examples for handling liquidation events.

Last updated on