project-serum / serum-ts

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

How to place several orders in just one single transaction? #229

Open Danilo-Araujo-Silva opened 2 years ago

Danilo-Araujo-Silva commented 2 years ago

How can we place several orders in just one transaction? Guaranteeing this way that it returns success only if all of them succeeded?

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 placing a single order at a time, how can we achieve the proposed above? This is very needed for some cases.

Maybe we could have something like:

await market.placeOrder(connection,
[
  {
    owner,
    payer,
    side: 'buy', // 'buy' or 'sell'
    price: 123.45,
    size: 17.0,
    orderType: 'limit', // 'limit', 'ioc', 'postOnly'
  },
  {
    owner,
    payer,
    side: 'buy', // 'buy' or 'sell'
    price: 123.45,
    size: 17.0,
    orderType: 'limit', // 'limit', 'ioc', 'postOnly'
  },
  ...
]);