Mangrove
Developper
Developper
  • Welcome
  • Protocol
    • Introduction
    • Technical References
      • Overview
      • Ticks, ratios, and prices
      • Offer-list
        • Views on offers
      • Market-order
        • Delegation
      • Creating & Updating offers
        • Maker contract
        • Offer provisions
        • Gas requirement
        • Public data structures
        • Executing offers
      • Cleaning offers
      • Governance-parameters
        • Global variables
        • Local variables
        • Data structures and views
      • Periphery Contracts
        • MgvReader
        • MgvOracle
      • Literate Source Code
    • Background
      • Taking available liquidity
      • Making liquidity available
      • Reneging on offers
  • Strat Lib
    • What is the Strat Library?
    • Getting-started
      • Set Up Your Local Environment
      • Post a Smart Offer
    • Guides
      • Unlocking liquidity
      • Reposting an offer in the posthook
      • Using last look to renege trades
      • Determining gas requirements
      • Creating a Direct contract
      • Deploying your contract
      • Testing a maker contract
      • Safe offer logic guidelines
      • Approvals
    • Technical references
      • Principal hooks
      • Liquidity routing
      • API preferences
        • Core
          • SRC
            • IMangrove
        • Strats
          • SRC
            • Strategies
              • MangroveOffer
              • MangroveOrder
              • Integrations
                • AaveV3Borrower
                • AaveV3BorrowerImplementation
                • AaveV3BorrowerStorage
                • AaveV3Lender
                • CompoundModule
              • Interfaces
                • IForwarder
                • ILiquidityProvider
                • IOfferLogic
                • IOrderLogic
              • Offer_forwarder
                • Abstract
                  • Forwarder
              • Offer_maker
                • Abstract
                  • Direct
                • Market_making
                  • Kandel
                    • AaveKandel
                    • AaveKandelSeeder
                    • KandelSeeder
                    • Abstract
                      • AbstractKandelSeeder
                      • CoreKandel
                      • DirectWithBidsAndAsksDistribution
                      • GeometricKandel
                      • HasIndexedBidsAndAsks
                      • KandelLib
                      • TradesBaseQuotePair
              • Routeurs
                • SimpleRouter
                • Abstract
                  • AbstractRouter
                • Integrations
                  • AavePooledRouter
                  • HasAaveBalanceMemoizer
              • Utils
                • AccessControlled
              • Vendor
                • AAVE
                  • V3
                    • Contracts
                      • Dependencies
                        • Oppenzeppelin
                          • Contracts
                            • IERC20
                      • Interfaces
                        • IAToken
                        • IAaveIncentivesController
                        • IAaveOracle
                        • ICreditDelegationToken
                        • IInitializableAToken
                        • IPool
                        • IPoolAddressesProvider
                        • IPriceOracleGetter
                        • IScaledBalanceToken
                      • Protocol
                        • Libraries
                          • Configurations
                            • ReserveConfiguration
                          • Helpers
                            • Errors
                          • Types
                            • DataTypes
                    • Periphery
                      • Contracts
                        • MISC
                          • Interfaces
                            • IEACAggregatorProxy
                        • Rewards
                          • Interfaces
                            • IRewardsController
                            • IRewardsDistributor
                            • ITransferStrategyBase
                          • Libraries
                            • RewardsDataTypes
                • Compound
                  • CarefulMath
                  • Exponential
                  • ExponentialNoError
                  • ICompound
    • Background
      • Building Blocks
        • MangroveOffer
        • Direct
        • Forwarder
  • Vaults
    • Understanding vaults
      • Oracles
    • Managing a vault (CLI)
      • Deploying an oracle
      • Creating a vault
      • Monitoring the vault
      • Setting the vault position
      • Setting the fee data
      • Rebalancing
      • Adding or removing liquidity
    • Custom interactions
      • Oracles
      • Vault Factory
      • Managing a vault
        • Setting the position
        • Rebalancing
        • Setting a manager
        • Setting fee
  • Keeper Bots
    • Keeper Bots
    • Guides
      • Using borrowed funds for cleaning
    • Backgroud
      • The role of cleaning bots in Mangrove
      • The role of gas price updater bots in Mangrove
  • Adresses
    • Deployment Addresses
  • Quick Links
    • Glossary
    • Website
    • Whitepaper
Powered by GitBook
On this page
  • Takers
  • Makers
  • Smart offers
  • When a smart offer is taken
  • After a smart offer is taken
  • Call sequence overview
  • Where can I read more?
  • Literate source code
  • Governance
  1. Protocol
  2. Technical References

Overview

PreviousTechnical ReferencesNextTicks, ratios, and prices

Last updated 28 days ago

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:

  • add liquidity promises to Mangrove.

  • use Mangrove to find liquidity by executing market orders and thereby executing offers published on Mangrove.

  • Cleaners identify offers that will fail to deliver the promised liquidity and clean them, i.e. remove them from the book in exchange for a bounty.

  • 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 are taken using market orders.

Takers typically operate via a web front-end or with the help of the TypeScript SDK for developing off-chain apps to interact with the Mangrove ecosystem.

Makers

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 EOA, when the offer is matched during a trade.

Smart offers

Smart offers are where Mangrove really distinguishes itself from other DEXes, so we shall discuss them in a bit more detail in this overview.

When a smart offer is taken

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 to, for instance, 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 market 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?

  • The concepts of ticks and ratio are crucial in Mangrove - you'll want to get familiar with them first.

  • 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.

Literate source code

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.

Makers own offers, which live in in the Mangrove order book.

posted via a smart contract - called a . When a smart offer is matched by a market order during trade execution, the maker contract will be called and given the opportunity to execute its .

The offer logic of the maker contract is called twice by the Mangrove protocol during trade execution: and .

Mangrove calls the offer logic of the maker contract a first time, via the callback function , when an offer is matched by a market 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).

The Mangrove core protocol is commented in the tradition of where natural language and code is intervowen. Thus, the protocol code itself actually constitutes a very readable and comprehensive technical documentation.

A nicely formatted, single webpage representation of the literate source code can be found .

offer lists
literate programming
here
maker contract
offer logic
Smart offers
when the smart offer is taken
after the smart offer was taken
makerExecute
Offer makers
Governance
Takers