Skip to main content

DirectWithBidsAndAsksDistribution

DirectWithBidsAndAsksDistribution​

PopulateStart​

event PopulateStart()

logs the start of a call to populate By emitting this, an indexer will be able to know that the following events are in the context of populate.

PopulateEnd​

event PopulateEnd()

logs the end of a call to populate By emitting this, an indexer will know that the previous PopulateStart event is over.

RetractStart​

event RetractStart()

logs the start of a call to retractOffers By emitting this, an indexer will be able to know that the following events are in the context of retract.

RetractEnd​

event RetractEnd()

logs the end of a call to retractOffers By emitting this, an indexer will know that the previous RetractStart event is over.

constructor​

constructor(contract IMangrove mgv, address reserveId) internal

Constructor

Parameters​

NameTypeDescription
mgvcontract IMangroveThe Mangrove deployment.
reserveIdaddressidentifier of this contract's reserve when using a router.

DistributionOffer​

Parameters​

NameTypeDescription
struct DistributionOffer {
uint256 index;
Tick tick;
uint256 gives;
}

Distribution​

Parameters​

NameTypeDescription
struct Distribution {
struct DirectWithBidsAndAsksDistribution.DistributionOffer[] asks;
struct DirectWithBidsAndAsksDistribution.DistributionOffer[] bids;
}

populateChunkInternal​

function populateChunkInternal(struct DirectWithBidsAndAsksDistribution.Distribution distribution, uint256 gasreq, uint256 gasprice) internal

Publishes bids/asks for the distribution in the indices. Care must be taken to publish offers in meaningful chunks. For instance, for Kandel an offer and its dual should be published in the same chunk (one being optionally initially dead).

Gives of 0 means create/update and then retract offer (but update price, gasreq, gasprice of the offer)

Parameters​

NameTypeDescription
distributionstruct DirectWithBidsAndAsksDistribution.Distributionthe distribution of bids and asks to populate
gasrequint256the amount of gas units that are required to execute the trade.
gaspriceuint256the gasprice used to compute offer's provision.

populateOfferListChunkInternal​

function populateOfferListChunkInternal(struct DirectWithBidsAndAsksDistribution.DistributionOffer[] offers, enum OfferType ba, struct IOfferLogic.OfferArgs args) internal

populates one of the offer lists with the given offers

Parameters​

NameTypeDescription
offersstruct DirectWithBidsAndAsksDistribution.DistributionOffer[]the offers to populate
baenum OfferTypewhether to populate bids or asks
argsstruct IOfferLogic.OfferArgsa reused offer creation args structure with defaults passed from caller.

populateIndex​

function populateIndex(enum OfferType ba, uint256 offerId, uint256 index, struct IOfferLogic.OfferArgs args, uint256 minGives) internal

publishes (by either creating or updating) a bid/ask at a given price index.

Parameters​

NameTypeDescription
baenum OfferTypewhether the offer is a bid or an ask.
offerIduint256the Mangrove offer id (0 for a new offer).
indexuint256the price index.
argsstruct IOfferLogic.OfferArgsthe argument of the offer. args.gives=0 means offer will be created/updated and then retracted.
minGivesuint256the minimum gives to satisfy density requirement - used for creating/updating offers when args.gives=0.

retractOffers​

function retractOffers(uint256 from, uint256 to) public

retracts and deprovisions offers of the distribution interval [from, to[.

use in conjunction of withdrawFromMangrove if the user wishes to redeem the available WEIs.

Parameters​

NameTypeDescription
fromuint256the start index.
touint256the end index.

retractOffersOnOfferList​

function retractOffersOnOfferList(uint256 from, uint256 to, enum OfferType ba) internal

retracts and deprovisions offers of the distribution interval [from, to[ for the given offer type.

Parameters​

NameTypeDescription
fromuint256the start index.
touint256the end index.
baenum OfferTypethe offer type.

getOffer​

function getOffer(enum OfferType ba, uint256 index) public view returns (Offer offer)

gets the Mangrove offer at the given index for the offer type.

Parameters​

NameTypeDescription
baenum OfferTypethe offer type.
indexuint256the index.

Return Values​

NameTypeDescription
offerOfferthe Mangrove offer.

offeredVolume​

function offeredVolume(enum OfferType ba) public view returns (uint256 volume)

gets the total gives of all offers of the offer type.

function is very gas costly, for external calls only.

Parameters​

NameTypeDescription
baenum OfferTypeoffer type.

Return Values​

NameTypeDescription
volumeuint256the total gives of all offers of the offer type.