project-serum / serum-ts

Project Serum TypeScript monorepo
https://projectserum.com
Apache License 2.0
270 stars 245 forks source link

How can we retrieve just one specific open order? #230

Open Danilo-Araujo-Silva opened 2 years ago

Danilo-Araujo-Silva commented 2 years ago

How can we retrieve the information of just only one specific open order instead of loading all of them?

For example, we have this documentation here: https://github.com/project-serum/serum-ts/tree/master/packages/serum

But we only have an example to be retrieving the info for all open orders, so if we are working with several markets this would be very time-consuming.

Maybe we could have something like:

await market.loadOrdersForOwner({ connection: connection, onwer: owner.publicKey, clientId: clientId });
await market.loadOrdersForOwner({ connection: connection, onwer: owner.publicKey, exchangeId: exchangeId });

or

await market.loadOrdersForOwner(connection, owner.publicKey, clientId);
await market.loadOrdersForOwner(connection, owner.publicKey, undefined, exchangeId);
GiveMeSomething commented 2 years ago

Maybe you can rewrite this function in OpenOrder class to get all orders without filtering them by market. And then find your order using clientId or orderId. But hopefully they will provide us a way to actually filter it like you said 😄

static async findForMarketAndOwner()

p/s: For loadOrdersForOwner(), they ensured that your orders actually get into the Orderbook by filter orders in the OpenOrders with those in bids and asks. I think you can skip those in your custom function if you just need the order info