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
  • SetReserveId
  • Parameters
  • RESERVE_ID
  • constructor
  • Parameters
  • _newOffer
  • Parameters
  • Return Values
  • _updateOffer
  • Parameters
  • Return Values
  • _retractOffer
  • Parameters
  • Return Values
  • provisionOf
  • Parameters
  • Return Values
  • put
  • Parameters
  • Return Values
  • get
  • Parameters
  • Return Values
  • posthookSuccess
  • Parameters
  • Return Values
  • checkList
  • Parameters
  1. Strat Lib
  2. Technical references
  3. API preferences
  4. Strats
  5. SRC
  6. Strategies
  7. Offer_maker
  8. Abstract

Direct

SetReserveId

event SetReserveId(address reserveId)

reserveId is set in the constructor by emitting this event, an indexer will be able to keep track of what reserve is used.

Parameters

Name
Type
Description

reserveId

address

identifier of this contract's reserve when using a router. This is indexed so that RPC calls can filter on it.

RESERVE_ID

address RESERVE_ID

identifier of this contract's reserve when using a router

two contracts using the same RESERVE_ID will share funds, therefore strat builder must make sure this contract is allowed to pull into the given reserve Id. a safe value for RESERVE_ID is address(this) in which case the funds will never be shared with another maker contract.

constructor

constructor(contract IMangrove mgv, contract AbstractRouter router_, address reserveId) internal

Direct's constructor.

reserveId==address(0) will set RESERVE_ID to address(this).

Parameters

Name
Type
Description

mgv

contract IMangrove

The Mangrove deployment that is allowed to call this for trade execution and posthook.

router_

contract AbstractRouter

the router that this contract will use to pull/push liquidity from offer maker's reserve. This can be NO_ROUTER.

reserveId

address

identifier of this contract's reserve when using a router.

_newOffer

function _newOffer(struct IOfferLogic.OfferArgs args) internal returns (uint256 offerId, bytes32 status)

Inserts a new offer in Mangrove Offer List.

Parameters

Name
Type
Description

args

struct IOfferLogic.OfferArgs

Function arguments stored in memory.

Return Values

Name
Type
Description

offerId

uint256

Identifier of the newly created offer. Returns 0 if offer creation was rejected by Mangrove and args.noRevert is set to true.

status

bytes32

NEW_OFFER_SUCCESS if the offer was successfully posted on Mangrove. Returns Mangrove's revert reason otherwise.

_updateOffer

function _updateOffer(struct IOfferLogic.OfferArgs args, uint256 offerId) internal returns (bytes32 status)

Updates the offer specified by offerId on Mangrove with the parameters in args.

Parameters

Name
Type
Description

args

struct IOfferLogic.OfferArgs

A memory struct containing the offer parameters to update.

offerId

uint256

An unsigned integer representing the identifier of the offer to be updated.

Return Values

Name
Type
Description

status

bytes32

status a bytes32 value representing either REPOST_SUCCESS if the update is successful, or an error message if an error occurs and OfferArgs.noRevert is true. If OfferArgs.noRevert is false, the function reverts with the error message as the reason.

_retractOffer

function _retractOffer(struct OLKey olKey, uint256 offerId, bool deprovision) internal returns (uint256 freeWei)

Retracts an offer from an Offer List of Mangrove.

An offer that is retracted without deprovision is retracted from the offer list, but still has its provisions locked by Mangrove. Calling this function, with the deprovision flag, on an offer that is already retracted must be used to retrieve the locked provisions.

Parameters

Name
Type
Description

olKey

struct OLKey

the offer list key.

offerId

uint256

the identifier of the offer in the offer list

deprovision

bool

if set to true if offer admin wishes to redeem the offer's provision.

Return Values

Name
Type
Description

freeWei

uint256

the amount of native tokens (in WEI) that have been retrieved by retracting the offer.

provisionOf

function provisionOf(struct OLKey olKey, uint256 offerId) external view returns (uint256 provision)

computes the amount of native tokens that can be redeemed when deprovisioning a given offer.

Parameters

Name
Type
Description

olKey

struct OLKey

the offer list key.

offerId

uint256

the identifier of the offer in the offer list

Return Values

Name
Type
Description

provision

uint256

the amount of native tokens that can be redeemed when deprovisioning the offer

put

function __put__(uint256, struct MgvLib.SingleOrder) internal virtual returns (uint256)

direct contract do not need to do anything specific with incoming funds during trade

one should override this function if one wishes to leverage taker's fund during trade execution

Parameters

Name
Type
Description

uint256

struct MgvLib.SingleOrder

Return Values

Name
Type
Description

[0]

uint256

get

function __get__(uint256 amount, struct MgvLib.SingleOrder order) internal virtual returns (uint256)

__get__ hook for Direct is to ask the router to pull liquidity from reserveId if strat is using a router otherwise the function simply returns what's missing in the local balance

if the last nested call to __get__ returns a non zero value, trade execution will revert

Parameters

Name
Type
Description

amount

uint256

of outbound tokens that still needs to be brought to the balance of this contract when entering this function

order

struct MgvLib.SingleOrder

is a recall of the taker order that is at the origin of the current trade.

Return Values

Name
Type
Description

[0]

uint256

posthookSuccess

function __posthookSuccess__(struct MgvLib.SingleOrder order, bytes32 makerData) internal virtual returns (bytes32)

Direct posthook flushes outbound and inbound token back to the router (if any)

Parameters

Name
Type
Description

order

struct MgvLib.SingleOrder

is a recall of the taker order that is at the origin of the current trade.

makerData

bytes32

is the returned value of the __lastLook__ hook, triggered during trade execution. The special value "lastLook/retract" should be treated as an instruction not to repost the offer on the list.

Return Values

Name
Type
Description

[0]

bytes32

checkList

function __checkList__(contract IERC20 token) internal view virtual

if strat has a router, verifies that the router is ready to pull/push on behalf of reserve id

Parameters

Name
Type
Description

token

contract IERC20

a token that is traded by this contract

PreviousAbstractNextMarket_making