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
  • Maker approvals​
  • Taker approvals​
  1. Strat Lib
  2. Guides

Approvals

PreviousSafe offer logic guidelinesNextTechnical references

Last updated 28 days ago

During trade settlement, Mangrove needs certain approvals for transferring funds between the offer taker and the maker with Mangrove as an intermediary.

Call sequence overview

In the following, we shall refer to the diagram depicting an for a successful trade when a maker with a market order. For easy reference, the diagram is included below.

Refer to and the pages linked there for more details on trade execution on Mangrove.

Both activate and checklist functions can be customized by hooks to adapt them to a particular strat built on top of the strat library.

As an outset, the administrator of the maker contract and any other contracts involved in trade settlement initiated by Mangrove must ensure that the proper approvals for liquidity flow is in place before offers are executed.

In this case,

  • the router needs approval to transfer outbound from the offer owner and needs approval to transfer inbound from the maker contract.

  • Mangrove needs approval to transfer outbound from the Maker contract.

This is illustrated in the diagram below where we only focus on the transferFrom calls.

Maker approvals

As a maker you either post offers directly from an EOA, or post connected to .

As the Mangrove contract handles transfers during trade settlement, this means that either the maker EOA or the maker contract needs to approve Mangrove for an token transfer for at least the amount that the offer .

Referring to the this maker approval is required for the transferFrom from the to Mangrove.

Maker contracts inheriting from MangroveOffer

Maker contracts inheriting from provide two methods to assist with approvals:

performs the required approvals so as to allow the contract itself to interact with Mangrove on a set of assets.

verifies that this contract's current state is ready to be used to post offers on Mangrove.

Advanced maker approvals

As drawn, the depicts a situation where the funds for the smart offer are available directly on the maker contract holding the offer logic. However, for more advanced smart offers several smart contracts may come into play when liquidity is sourced.

For maker contracts that are built using the Strat Lib, the default behavior of the is to assume the funds are in the maker contract itself. When this is not the case, additional approvals need to be set up so that liquidity can be brought from there. There are two noteworthy cases we comment below.

When a Strat Lib router is used to manage the funds of the maker

As described under the Strat Lib provides building blocks for advanced cash management strategies. The abstraction is provided for managing transfers of and token reserves of .

The maker contract should approve its router for any token it wishes to push to an 's reserve.

Please refer to the section on for more details, and refer to the API Reference for - the base that Strat Lib routers are implemented on top of.

When a Forwarder-based contract manages offers belonging to several offer owners

The building block provides a base for maker contracts that manage offers belonging to several offer owners.

A basic Forwarder strategy is to assume that the funds of each offer comes from its owner's addres. In such cases, the offer owners need to approve the maker contract's for outbound token transfer.

Please refer to the section on the and to the API Reference for the base for further reading.

The schematic diagram below illustrates the case, where a maker contract manages offers with a . Such a maker contract may be implemented with the building block combined with a .

Taker approvals

While we are mainly focused on the maker-side in this section, it is worth noting that the offer taker (be that an EOA or a contract) needs to approve Mangrove for an token transfer for at least the amount of tokens that the taker gives.

Looking at the this taker approval is required for the transferFrom from the Taker to Mangrove.

​
on-the-fly
smart offers
maker contracts
outbound
gives
call sequence diagram
Offer Logic(s)
​
MangroveOffer
activate
checklist
​
call sequence diagram
offer logic
​
Liquidity routing
router
outbound
inbound
offer owners
offer owner
Routers
AbstractRouter
​
Forwarder
router
Forwarder building block
Forwarder
router
Forwarder
router
​
inbound
call sequence diagram
​
overview of the call sequence
offer is taken
Protocol -> Technical Reference -> Overview