MgvCleaner contract to clean failing offers
Mangrove provides a cleaner contract called
MgvCleaner to ease cleaning. This contract provides a
collect method that calls Mangrove.snipes (forwarding the parameters unchanged) but will revert if any offer in the
targets array succeed. Thus, cleaning via the cleaner contract guards you from offers unexpectedly succeeding when you try to snipe them to collect a bounty.
The prerequisites and steps needed to use the
MgvCleaner.collect function are:
msg.sendermust have approved Mangrove for spending
inbound_tknon the offer list you want to clean.
MgvCleaner.collect(..)specifying the offer list and an array of offers to clean. Refer to the documentation for sniping for details on the parameters.
- The collected bounties (in native token) will be transferred to
If at least one offer succeeds, the call will revert. The revert reason depends on whether
MgvCleaner has sufficient allowance to trade all succeeding offers on behalf of
msg.sender on that offer list:
Assume you have a cleaning bot that has 900 DAI and has approved Mangrove for spending its DAI.
Your bot detects that offer #708 on the WETH/DAI offer list will fail. The offer
wants 800 DAI and
gives 0.6584 WETH,
To clean the offer, your cleaning bot triggers the following steps:
- The bot calls
- Mangrove will use the bot's DAI to execute offer #708 and revert the offer execution after noticing that the offer fails.
- Because the offer failed, Mangrove transfers a bounty to
MgvCleanertransfers the bounty to the bot account.
- Borrowing funds for cleaning: Using borrowed funds for cleaning via Mangrove's delegation mechanism
- Background on why cleaning is needed in Mangrove: The role of cleaning bots in Mangrove