Executing offers

How to write offer execution logic

Offer Logic

The logic associated with an offer must be implemented through a makerExecute callback function. (See data structures for SingleOrder type).

function makerExecute(MgvLib.SingleOrder calldata order)
external returns (bytes32 makerData);

Inputs

  • order is a data structure containing a recap of the taker order and Mangrove's current configuration state. The protocol guarantees that order.gives/order.wants will match the price of the offer that is being executed up to a small precision.

Outputs

  • makerData is an arbitrary bytes32 that will be passed to makerPosthoook in the makerData field.

Offer post-hook

The logic associated with an offer may include a makerPosthook callback function. Its intended use is to update offers in the offer list containing the offer that was just executed.

function makerPosthook(
    MgvLib.SingleOrder calldata order,
    MgvLib.OrderResult calldata result
  ) external;

Inputs

  • order same as in makerExecute.

  • result A struct containing:

    • the return value of makerExecute

    • additional data sent by Mangrove, more info available here.

Outputs

None.

Last updated