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
  • Example: WETH/DAI market​
  • Offer list #1: WETH-DAI ("asks")​
  • Offer list #2: DAI-WETH ("bids")​
  • Some terminology​
  • Offer ID​
  • Gas required​
  • Maker Contract​
  • Gas Price​
  • Offer list configuration​
  • Gas cost of posting, updating, and retracting offers​
  1. Protocol
  2. Technical References

Offer-list

PreviousTicks, ratios, and pricesNextViews on offers

Last updated 28 days ago

An "offer list" corresponds to either the "asks" or "bids" side of an order book. Mangrove has no explicit on-chain representation of an order book, only offer lists.

Hence, a full market will always feature two offer lists. For instance, a WETH/DAI market consists of:

  • a WETH-DAI offer list (where WETH is offered in exchange for DAI)

  • a DAI-WETH offer list (where DAI is offered in exchange for WETH)

market abstractions over offer lists

offers Market abstractions that allows liquidity providers and takers to interact with Mangrove using standard trading concepts such as order book, base, and quote.

An offer list is identified by a struct OLKey(outbound_tkn, inbound_tkn, tickSpacing). For example, for a WETH-DAI offer list, the struct values would be:

  • outbound_tkn: the address of the WETH token (i.e., sent by the offer)

  • inbound_tkn: the address of the DAI token (i.e., wanted by the offer)

  • tickSpacing: typically 1 meaning that all ticks are allowed (see the for details).

Offers are grouped by tick. The offers for a given tick are stored in a FIFO, doubly linked-list (an offer points to the previous and to the next one).

Note :

Let's take a WETH/DAI market and look at its two corresponding offer lists, WETH-DAI and DAI-WETH, with tickSpacing = 1:

For a WETH/DAI market, the WETH-DAI offer list corresponds to the "asks" of the order book:

  • WETH is the outbound token, i.e, offers give WETH

  • DAI is the inbound token, i.e, offers want DAI

Here's an example of such an offer list:

Tick
Ratio (DAI/WETH)
Offer ID
Gives (WETH)
Gas required
Maker Contract
Offer Gas Price

75171

1838.53

42

0.7

220,000

0x2468xyz...

160

75171

1838.53

96

1.3

280,000

0x1357klm...

140

75200

1843.87

7

0.6

210,000

0x3287opq...

190

  • Ratio: The amount of inbound token to be paid per outbound token. This is not stored on-chain, but is derived from the tick.

  • Offer ID: An ID for the offer which is assigned by Mangrove when the offer is first created. The ID is unique only on that offer list.

  • Gives: The amount of outbound token offered.

  • Gas required: The amount of gas needed to execute the offer and its posthook.

Beware Decimals :

We display human-readable amounts in the examples for readability, but on-chain Mangrove only works with raw token values and never uses the decimals a token.

For simplicity, the tokens used in these examples have the same number of decimals (18). When that's not the case, care must be taken to handle decimals, especially for ratios.

For a WETH/DAI market, the DAI-WETH offer list corresponds to the "bids" of the order book:

  • DAI is the outbound token, i.e, offers give DAI

  • WETH is the inbound token, i.e, offers want WETH

Here's an example of such an offer list:

Tick
Ratio (WETH/DAI)
Offer ID
Gives (DAI)
Gas required
Maker Contract
Offer Gas Price

-75103

0.0005476

77

925.26

250,000

0x5678def...

150

-75103

0.0005476

177

916.47

270,000

0x9101ghi...

170

-75041

0.0005510

42

871.76

300,000

0x1234abc...

200

The identifier of the offer in the offer list.

Important :

Two offers may have the same ID as long as they belong to different offer lists. For instance, in the example above, both offer lists contain offers with ID 42.

Example :

The offer with ID 77 in the DAI-WETH offer list above may consume up to 250K gas units.

The gas price of an offer must be at least Mangrove's gas price at the time when the offer is posted.

If you haven't done it yet, we strongly suggest that you first get familiar with the page.

Example: WETH/DAI market

Offer list #1: WETH-DAI ("asks")

The unit of is DAI/WETH and price = ratio.

Understanding the table

Tick: The discrete "price" of the offer which corresponds to a ratio and price. Offers at the same tick are stored in FIFO order.

Maker contract: The address of the make who posted the offer. Either an EOA or a (for smart offers).

Offer gas price: Gas price used to compute the order's (see also ). Must be at least Mangrove's gas price when the offer is posted.

See the page for a detailed discussion of decimals.

Offer list #2: DAI-WETH ("bids")

The unit of is WETH/DAI and price = ratio−1−1−1−1−1−1.

Some terminology

Offer ID

Gas required

The maximum amount of gas the managing the offer will be allowed to spend if called by Mangrove. This includes both makerExecute and makerPosthook.

Maker Contract

The address of the bound to the offer. The function of this contract's will be called when one of its offers is executed, and the corresponding will be called immediately after trade settlement.

An offer may also be posted from EOA with no logic attached - see .

Gas Price

Gas price that was used to compute the . If the offer fails to deliver the promised outbound tokens, it will be charged based on this gasprice.

Offer list configuration

Several parameters determine how new offers are inserted. Some are to Mangrove, some are See section for details.

Gas cost of posting, updating, and retracting offers

The gas cost for posting, updating, and retracting offers is bounded by a constant thanks to ticks being organized internally in a fixed tree structure. The details are described in the of the Mangrove protocol.

Ticks, ratios, and prices
​
​
ratios
​
tick
maker contract
provision
offer bounties
Ticks, ratios, and prices
​
ratios
​
​
​
maker contract
​
maker contract
makerExecute
offer logic
makerPosthook
On-the-fly offers
​
offer provision
​
configuration
global
offer list specific.
Governance
​
annotated code
Mangrove's SDK
previous page