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.

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.

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"The type of sub-action.
marketIdnumber(Optional) Market ID.
orderIdBigIntValue(Optional) Order ID to cancel.
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.

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.
Last updated on