.orders

Provides methods to manage orders within the Northstake system. This includes creating new orders, retrieving order details, cancelling orders, and listing all orders.

cancelOrderById(id: string)**:

Cancels a submitted order

  const orderId= 'eaed56eb-0913-4893-9890-f81f49e475f0'
  await api.orders.cancelOrderById(orderId)



createNewOrder({orderType:OrderTypeEnum.Stake, asset: string, amount: number, targetWallet: string })**:

Create a new order


  const newOrder: Order = {
    orderType: 'stake',
    asset: 'ETH',
    amount: 32,
  }

  const {body:order} = await api.orders.createNewOrder(newOrder)

  console.log(`New ${newOrder.orderType} order id: ${order.orderId}`)

👋

See these recipes to learn more about creating orders via the Northstake SDK


getOrderDetailsById(id:string)**:

Get order details by order ID


  const orderId = '2134-4321-3345-34222'
  const  {body:orderDetails} = await api.orders.getOrderDetailsById(orderId)
  console.log(`
  Order details:
  id: ${orderDetails.orderId}
  type: ${orderDetails.type}
  asset: ${orderDetails.token}
  amount: ${orderDetails.amount}
  status: ${order.status}
`)

Get a list of all orders


const {body:orders} = await api.orders.listAllOrders()

for (const order of orders) {
  console.log(`
  
  Order details:
  id: ${order.orderId}
  type: ${order.type}
  asset: ${order.token}
  amount: ${order.amount}
  status: ${order.status}
`)