mangrovedao/mangrove.js

API does not call `MangroveOrder` in a coherent manner

jkrivine opened this issue · 2 comments

Expected behavior should be:

  • 1 for IOC with partialfill allowed use direct calls to marketOrder
  • 2 for IOC with no partialfill (aka Fill or Kill) call MangroveOrder.take with no provision and partialFillNotAllowed:true, restingOrder:false
  • 3 for GTC call MangroveOrder.take with some provisions and partialFillNotAllowed:false and restingOrder:true

Currently it is not possible to use the API for point 2

I suggest changing TradeParams to something like:

  export type TradeParams = {
    slippage?: number;
  } & ({ advanced?: AdvancedOrderParams } | { offerId?: number }) &
    (
      | { volume: Bigish; price: Bigish | null }
      | { total: Bigish; price: Bigish | null }
      | { wants: Bigish; gives: Bigish; fillWants?: boolean }
    );

  export type AdvancedOrderParams = {
    partialFillNotAllowed?: boolean;
    restingOrder?: restingOrderParams
  };

export type RestingOrderParams = {
    timeToLive?: number;
    provision: Bigish;
}

This has been solved. It is now possible to create an FoK order