Executing offers
Last updated
Last updated
Offers are created with an associated account (a %%maker contract|maker-contract%% or EOA) and listed on Mangrove offer lists.
If the account is an EOA, no logic will be associated to the offer. These %%on-the-fly|on-the-fly-offer%% offers should have the promised liquidity on the EOA when the offer is matched during a market order.
If the account is a maker contract, it should implement the offer logic through the . It must at least implement the makerExecute
function, otherwise all offer executions will fail.
Here is the offer lifecycle, with the parts addressed in this section bolded:
A contract maker.eth
creates an offer.
Mangrove stores the offer info, including the address maker.eth
.
Account user.eth
sends a market order to Mangrove which matches that offer.
Mangrove transfers tokens from user.eth
to maker.eth
.
Mangrove calls the function makerExecute
of maker.eth
.
Mangrove transfers tokens from maker.eth
to user.eth
.
The offer is now out of its offer list, but may be updated at step 9 by maker.eth
.
If the transfer at step 6 is not a success, Mangrove reverts to the state prior to the transfer of step 4, and sends a %%bounty|bounty%% to user.eth
taken from the offer's %%provision|provision%%.
Mangrove calls the function makerPosthook
of maker.eth
.
Multiple offers per address
An account can post more than one offer. When it gets called through makerExecute
, it will receive the of the offer being executed as well as additional information.
Example scenario Suppose that an offer managed by a contract promises 100,000 DAI in exchange for 100,000 USDC.
Upon being called, the contract has 100,000 USDC available (just given to it by Mangrove) and may source DAI from anywhere on the chain. It needs to end execution with 100,000 DAI available and ready to be transferred by Mangrove through transferFrom
.
:::