Overview of Mangrove's ecosystem
The illustration below depicts a bird's-eye view of the Mangrove ecosystem. The main actors are depicted as well as their most important interactions.
The Mangrove contract is depicted in the middle, with the three most important actors interacting with Mangrove around it:
Offer makers add liquidity promises to Mangrove.
Takers use Mangrove to find liquidity by executing offers published on Mangrove.
Governance adjusts Mangrove parameters such as setting fees or opening and closing markets.
Takers
As a taker on Mangrove you take offers published by makers as liquidity promises. Offers can be taken using general market orders or sniped individually.
Takers may typically operate via a web front-end or with the help of the TypeScript SDK for developing off-chain apps to interact with Mangrove ecosystem.
Makers
Makers own offers, which live in offer lists in the Mangrove order book.
As a maker you have the choice of posting two kinds of offers:
- On-the-fly offers posted directly from an EOA. Such offers have no logic attached, and the promised liquidity should be available on the EAO, when the offer is matched during a trade.
- Smart offers posted via a smart contract - called a maker contract. When a smart offer is matched by a taker order during trade execution, the maker contract will be called and given the opportunity to execute its offer logic.
Smart offers
Smart offers are where Mangrove really distinguishes itself from other DEX's, so we shall discuss them in a bit more detail in this overview.
The offer logic of the maker contract is called twice by the Mangrove protocol during trade execution - when the smart offer is taken and after the smart offer was taken.
When a smart offer is taken
Mangrove calls the offer logic of the maker contract a first time, via the callback function makerExecute
, when an offer is matched by a taker order. This happens immediately prior to trade settlement allowing makers to source liquidity reactively and just-in-time for the trade. It also allows makers to renege on the offer to trade by incorporating defensive code (called last look) in the maker contract (e.g., because the market conditions changed).
This implies that offers posted to Mangrove need not be fully provisioned. As a maker, your liquidity can be shared, borrowed, lent and, at the same time, be displayed in Mangrove's order book - ready to be sourced when, and only when, your offer is taken.
After a smart offer is taken
Mangrove calls the offer logic of the maker contract a second time, via the callback function makerPosthook
during trade execution immediately after the offer has been taken.
This allows makers, for instance, to post another offer to redisplay their liquidity instantly, in a manner similar to Automated Market Makers (AMMs).
Call sequence overview
The diagram below summarizes the call sequence induced by a taker order. Notice that first the makerExecute
functions is executed for all offers, and only subsequently are the makerPosthook
functions of the offers executed.
Where can I read more?
- Refer to the section on Creating and Updating Offers.
- Read more about Offer Execution on Mangrove.
- Read about the freely available Strat Library - a repository of Solidity code to help write your own custom maker contract.
- Read about the TypeScript SDK for developing off-chain apps to interact with Mangrove ecosystem.
Governance
The Mangrove Governance may set a number of parameters, which governs how Mangrove operates globally or for specific pairs. Refer to the section on Governance Parameters for details.