Orders
For more inspiration, check out these recipes involving managed users
cancelOrderForUser(userId: string, orderId: string)**:
Cancel a submitted order by ID for a particular managed user
const userId = 'northstake_user_guuid'
const orderId= '123_321'
await api.managedUsersOrders.cancelOrderForUser(userId, 'order-id')
createOrderForUser(userId: string, order: CreateNewOrderRequest)**:
Create an order on behalf of a managed user
const userId = 'northstake_user_guuid'
const newOrder: Order = {
orderType: 'stake',
asset: 'ETH',
amount: 32,
}
const {body:order} = await api.managedUsersOrders.createOrderForUser(userId, newOrder)
console.log(`
Order ID: ${order.orderId}
Order Type: ${order.type}
Asset: ${order.token}
Amount: ${order.amount}
`)
See these recipes to learn more about creating orders via the Northstake SDK
getAllOrdersForUser(userId: string)**:
Get all orders for a particular managed user
const userId = 'northstake_user_guuid'
const orders = await api.managedUsersOrders.getAllOrdersForUser(userId)
for (const order of orders) {
console.log(`
Order ID: ${order.orderId}
Order Type: ${order.type}
Asset: ${order.token}
Amount: ${order.amount}
`)
}getOrderDetailsForUser(userId: string, orderID: string)**:
Get details of an order by ID for a particular managed user
const userId = 'northstake_user_guuid'
const orderId = '123-321'
const {body:orderDetails} = await api.managedUsersOrders.getOrderDetailsForUser(userId, orderId )
console.log(`
Order ID: ${orderDetails.orderId}
Order Type: ${orderDetails.type}
Asset: ${orderDetails.token}
Amount: ${orderDetails.amount}
`)
