Orders
Provides methods to manage orders on behalf of a single managed user within the Northstake system. This includes creating new orders, retrieving order details, cancelling orders, and listing all orders.
For more inspiration, check out these recipes involving managed users
π₯Register new managed userOpen Recipe
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
ποΈ
Depositing and staking an asset
Open Recipe
ποΈ
Staking ETH with own/pregenerated validator key
Open Recipe
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}
`)
Updated 5 months ago