Principal hooks
Last updated
Last updated
Last look before trade
Input: 's recap data.
Output: data
to be passed to if the call does not throw.
Default behavior: returns "mgvOffer/proceed"
.
Usage: override to insert requirements so as to renege on trade prior to transferring funds, as lastLook
is the first hook being called during an 's execution
Managing taker's payment
Inputs:
Output: missingPut
is the amount of inbound tokens whose location are not yet determined at the end of this hook's execution.
Default behavior: leaves all inbound tokens allocated to the balance of the maker contract and returns 0.
Usage: override to change the location where taker's payment should be deposited. Override this only if this is important for outbound tokens delivery (for instance if inbound tokens are used to borrow).
Sourcing liquidity
Input:
Output: missingGet
is the amount of outbound tokens that still need to be brought to the balance of the maker contract at the end of this hook's execution.
Default behavior: returns the difference between the outbound token balance of the maker contract and amount
if positive and 0 otherwise.
Posthook after trade success
Input:
Output: a bytes32 makerData
that can be passed to the overridden hook and ignored otherwise.
Default behavior: reposts offer residual in case of a partial fill, adapting what the offer gives to match the original price of the offer.
Usage: this hook is only reached in the offer logic if trade was settled correctly by Mangrove. Override this hook to customize what should be done after the maker offer was taken (market makers would post an offer on the other side of the spread for instance).
Posthook after trade failure
Input:
Output: a bytes32 data
that can be passed to the overridden hook and ignored otherwise.
Default behavior: Skipped.
Usage: this hook is only reached in the offer logic if trade was not settled correctly by Mangrove. Override this hook to customize what should be done after the maker offer has failed. Note that if this hook is reached during offer logic's execution, maker contract has already emitted the following log:
Offer logic's incident log
amount
of token received by the logic and that can still be relocated at the beginning of this hook.
's recap data.
amount
of tokens that needs to be brought to the balance of the maker contract at the beginning of this hook's execution (in order to comply with the taker's order).
's recap data.
Usage: override this hook to define a more complex strategy for sourcing liquidity (for instance redeem from a lender, transfer outbound token from an EOA etc.). This hook is used to call the logic's if any.
's recap data.
maker_data
either the message returned by makerExecute
's if trade execution did not revert, or the revert reason (truncated to its first 32 bytes).
's recap data.
result
Mangrove recap of failed trade data