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
  1. Vaults
  2. Custom interactions
  3. Managing a vault

Setting the position

PreviousManaging a vaultNextRebalancing

Last updated 1 month ago

A position on mangrove is described by the minimum tick (tickIndex0, on the BASE/QUOTE list), the difference between two ticks (tickOffset), and the number of offers.

A fourth parameter is computed automatically thanks to the oracle. It is the offer at which we stop posting bids, and post asks instead (firstAskIndex).

Other parameters are characteristics of mangrove can be kept to their default value:

  • the gasprice (default: 0, defaults to mangrove gasprice)

  • the gasreq (default depends on the used Kandel Seeder)

  • the step size (defaults to 1)

Finally, we also have to choose a state for the funds to be in:

  • Active: funds are deposited on the kandel and offer are posted (if possible)

  • Passive: funds are deposited on the kandel with no offers

  • Vault: funds are not in the kandel

When funds are in the kandel contract, they are actually deposited in their sourcing strategy, thus can earn passive income from AAVE for example.

A known UX quirk is that AAVE vaults should always be set to passive on initial mint, otherwise minting will revert.

A position can be set via this function:

Or right after rebalancing in this function:

https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/MangroveVault.sol#L55-L60
struct KandelPosition {
  Tick tickIndex0;
  uint256 tickOffset;
  Params params;
  FundsState fundsState;
}
https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/MangroveVault.sol#L782
  function setPosition(KandelPosition memory position) external onlyOwnerOrManager {
https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/MangroveVault.sol#L765-L772
  function swapAndSetPosition(
    address target,
    bytes calldata data,
    uint256 amountOut,
    uint256 amountInMin,
    bool sell,
    KandelPosition memory position
  ) external onlyOwnerOrManager nonReentrant returns (int256 netBaseChange, int256 netQuoteChange) {