Views on offers

Mangrove getters for offers and offer lists.

Public getters

best(address outbound, address inbound)

Returns the offer identifier that occupies the best rank in the (outbound, inbound)offer list.

  • highest outbound volume

  • least gas required

  • oldest time of insertion on the list

bestOffer.sol
import "src/IMangrove.sol";

// context of the call
IMangrove mgv;
address outbound_tkn;
address inbound_tkn;

uint best = mgv.best(outbound_tkn, inbound_tkn); 

offers(address, address) / offerDetails(address, address, uint)

The data pertaining to a particular offer is contained in the OfferUnpacked and OfferDetailUnpacked structs, which are stored as packed custom types called, respectively, OfferPacked and OfferDetailUnpacked. For on-chain calls, Mangrove provides unpacking functions to extract a particular field out of a packed structure. For off-chain calls, Mangrove also provide direct getter for the unpacked structures.

isLive(address, address, uint)

An offer is live in a given Offer Lists if it can be matched during a market order. One can verify whether offerId identifies a live offer in a (outboundToken,inboundToken) Offer List of Mangrove using this view function.

Custom types

Offer data is split between OfferUnpacked and OfferDetailedUnPacked for storage read/write optimisation (as both structs can be efficiently packed on storage).

MgvLib.MgvStructs.OfferUnpacked

Type
Field
Comments

uint32

prev

Predecessor offer id (better price)

uint32

next

Successor offer id (worst price)

uint96

gives

What the offer gives (in wei units of base token of the offer's market)

uint96

wants

What the offer wants (in wei units of quote token of the offer's market)

MgvLib.OfferDetailUnpacked

Type
Field
Comments

address

maker

address of the offer's Maker Contract

uint24

gasreq

Gas required by the offer (in gas units)

uint16

gasprice

The gas price covered by the offer bounty (in gwei per gas units)

uint24

offer_gasbase

Mangrove's gasbase at the time the offer was posted (in gas units)

Last updated