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:
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.
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 are where Mangrove really distinguishes itself from other DEX's, so we shall discuss them in a bit more detail in this overview.
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
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.
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.