project-serum / serum-ts

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

How to retrieve the exchangeId when placing the order? Avoiding to fetch and loop from all of the open orders? #235

Open Danilo-Araujo-Silva opened 2 years ago

Danilo-Araujo-Silva commented 2 years ago

How about we return more information when placing an order instead of just the signature? For example the exchangeId of the order?

For now, we only have the option to place an order and receive a signature at the end. But we need to fetch all of the open orders, look in all of them using a predefined clientId, and then collect the exchangeId. How can we avoid this?

For example, maybe we could have something like:

const {clientId, exchangeId, signature, status} = await market.placeOrder(connection, {
  owner,
  payer,
  side: 'buy', // 'buy' or 'sell'
  price: 123.45,
  size: 17.0,
  orderType: 'limit', // 'limit', 'ioc', 'postOnly'
});