Creating & Updating offers
How to write Mangrovian offers
Posting a new offer
New offers should mostly be posted by contracts able to source liquidity when asked by Mangrove.
function newOffer(
address outboundTkn,
address inboundTkn,
uint wants, // amount of inbound Tokens
uint gives, // amount of outbound Tokens
uint gasreq,
uint gasprice,
uint pivotId
) external payable returns (uint offerId);// logging new offer's data
event OfferWrite(
address outboundTkn,
address inboundTkn,
address maker, // account that created the offer, will be called upon execution
uint wants,
uint gives,
uint gasprice, // gasprice that was used to compute the offer bounty
uint gasreq,
uint offerId, // id of the new offer
uint prev // offer id of the closest best offer at the time of insertion
);
// `maker` balance on Mangrove (who is `msg.sender`) is debited of `amount` WEIs to provision the offer
event DebitWei(address maker, uint amount);
// `maker` balance on Mangrove is credited of `amount` WEIs if `msg.value > 0`.
event CreditWei(address maker, uint amount); Inputs
outbound_tknaddress of the outbound token (that the offer will provide).inbound_tknaddress of the inbound token (that the offer will receive).wantsamount of inbound tokens requested by the offer. Must fit in auint96.givesamount of outbound **** tokens promised by the offer. Must fit in auint96and be strictly positive. Must provide enough volume w.r.t togasreqand offer list's density parameter.gasreqamount of gas that will be given to the offer's account. Must fit in auint24and be lower than gasmax. Should be sufficient to cover all calls to the offer logic posting the offer (makerExecuteandmakerPosthook). Must be compatible with the offered volumegivesand the offer list's density parameter.gaspricegas price override used to compute the order provision (see offer bounties). Any value lower than Mangrove's current gasprice will be ignored (thus 0 means "use Mangrove's current gasprice"). Must fit in auint16.pivotIdwhere to start the insertion process in the offer list. IfpivotIdis not in the offer list at the time the transaction is processed, the new offer will be inserted starting from the offer list's best offer. Should be the id of the existing live offer with the price closest to the price of the offer being posted.
Outputs
offerIdthe id of the newly created offer. Note that offer ids are scoped to offer lists, so many offers can share the same id.
Updating an existing offer
Offers are updated through the aptly-named updateOffer function described below (source code is here).
Inputs
offerIdis the offer id of the offer to be updated.For the other parameters, see above.
Outputs
None.
Retracting an offer
An offer can be withdrawn from the order book via the retractOffer function described below.
Inputs
offerIdis the offer id of the offer to be updated.deprovisionif true, will free the offer's ETH provision so that you can withdraw them. Otherwise, will leave the provision in the offer.For the other parameters, see above.
Outputs
None.
Last updated