openbook-dex / openbook-v2

openbook-v2 monorepo, contains solana program and ts client
Other
134 stars 72 forks source link

Abstract away details in `placeOrder` #183

Open metaproph3t opened 8 months ago

metaproph3t commented 8 months ago

Today, it's a bit cumbersome to specify all of the fields in PlaceOrderArgs and the other fields that placeOrder takes

It would be nice to have a placeOrder interface that looks something like:

public async placeOrder(
      market: PublicKey,
      side: Side,
      priceLots: BN,
      maxBaseLots: BN,
      maxQuoteLots: BN,
      orderType: OrderType,
      expiryTimestamp: BN = new BN(0),
      selfTradeBehavior: SelfTradeBehavior = SelfTradeBehavior.DecrementTake,
      limit: number = 255,
      userTokenAccount?: PublicKey,
      clientOrderId?: BN,
   ): Promise<BN>

that way, you would only need to specify 5 params instead of 15

wiseaidev commented 4 weeks ago

Solved this issue in openbook, you only need 3 params: Screenshot from 2024-06-11 08-12-09

Have a look at the ob_client module for more info about the refactor i did to the client code.