Skip to main content

Data structures and views

Ground truth for configuration can be found in the code documentation. All configuration options are under the control of governance.

GlobalUnpacked​

TypeFieldDescription
addressmonitorIf enabled, acts as a gas price oracle for Mangrove and/or receives notifications when an offer is executed.
booluseOracleIf true, monitor will be used as a gas price oracle. Otherwise, the internal gas price global parameter will be used.
boolnotifyIf true, monitor will be called every time an offer has been executed.
uintgaspriceInternal gas price estimate, in Mwei/gas. Used to calculate the provision required for writing offers.
uintgasmaxMaximum gas an offer can require.
booldeadIf true, this Mangrove instance is dead and the only possible interactions are retracting offers and getting provisions back. Once true, it cannot be set back to false.
uintmaxRecursionDepthThe maximum number of times a market order can recursively execute offers. This is a protection against stack overflows.
uintmaxGasreqForFailingOffersThe maximum gasreq failing offers can consume in total. This is used in a protection against failing offers collectively consuming the block gas limit in a market order.

LocalUnpacked​

For every offer list, there is a set of local parameters. Note that the parameters for an (A,B,t) offer list might be different from the (B, A, t) offer list parameters.

Note that root and level{1,2,3} are part of the internal tick tree datastructure.

TypeFieldDescription
boolactiveIf inactive, offers on this pair can only be retracted.
uintfeeFee in basis points, at most 255 (~2.5%).
DensitydensityMinimum amount of token an offer must promise per gas required.
uintkilo_offer_gasbaseRepresents the gas overhead used by processing the offer inside Mangrove + the overhead of initiating an entire order, in 1k gas increments.
boollockRe-entrancy and read-lock that is applied during order execution and cleaning.
uintlastCounter for offer IDs, incremented every time a new offer is created.
Fieldlevel3Cache of level 3 for the best, non-empty tick of the tick tree.
Fieldlevel2Cache of level 2 for the best, non-empty tick of the tick tree.
Fieldlevel1Cache of level 1 for the best, non-empty tick of the tick tree.
FieldrootRoot of the tick tree.

Views​

info

The data structures containing Mangrove's global and local configuration parameters are accessible via the public view function configInfo(address outbound, address inbound) function on the MgvReader periphery contract.

info

For read/write efficiency, Mangrove provides access to configuration parameters in a packed manner via the getter config(OLKey memory olKey).

import "src/IMangrove.sol";

// context of the call

// IMangrove mgv = IMangrove(payable(<address of Mangrove>));
// Mangrove contract
IMangrove mgv = IMangrove(payable(mangrove));

// MgvReader reader = MgvReader(<address of MgvReader>);
MgvReader reader = MgvReader(readerAddress);

// OLKey olkey = OLKey(<address of outbound token>, <address of inbound token>, <tick spacing>);
// struct containing outbound_tkn, inbound_tkn and tickSpacing
OLKey memory olkey = OLKey(address(base), address(quote), 1);

// getting packed config data (gas efficient)
(GlobalPacked global32, LocalPacked local32) = mgv.config(olKey);

// for all fields f of `GlobalUnpacked global`
// one may unpack a specific element of `GlobalPacked global32` using the following scheme:
global.f == global32.f()

// for all fields f of `LocalUnpacked local`
// a similar scheme applies to `LocalPacked local32`:
local.f == local32.f()

// getting Mangrove's global configuration parameters and those that pertain to the olKey offer list
// in an ABI compatible format (gas costly, use for off-chain static calls)
(GlobalUnpacked global, LocalUnpacked local) = reader.configInfo(olKey);