Cleaning offers
Getting paid to clean Mangrove offer lists.
Cleaning an offer
Offers on Mangrove may fail. This may be done on purpose, or be the result of unexpected conditions. Either way, callers are remunerated for their action by receiving a portion of the bounty attached to the failing offer.
Cleaning bots
Mangrove has been designed such that keeping offer lists clean of failing offers is incentive-compatible. Anyone can run a bot which repeatedly does the following:
Receive events from Mangrove to maintain an up-to-date view of the books.
Locally runs offers at regular intervals.
Detects failing offers and sends a transaction to make the offer fail on-chain, with a gas price set such that the offer's bounty compensates for the spent gas.
Mangrove provides a cleaner contract to help you. This contract provides the same interface as snipes but will revert if any offer in the targets array successfully executes.
Example scenario
Your bot has 900 DAI tokens, has given Mangrove an allowance to spend its DAI, and has given the cleaner contract an allowance to use its DAI on Mangrove.
You detect that offer #708, which
wants800DAI andgives800 USDC on the USDT-DAI offer list, fails on your local fork of mainnet, so you call the cleaner contract withtargetsset to[[708,type(uint96).max,0,type(uint).max]], andfillWantsset tofalse.Mangrove will use your DAI to execute offer #708 and revert after noticing that the offer fails. It will then transfer the offer bounty to you.
If the offer does not fail, the cleaner contract will revert.
Delegation
Cleaning can also use Mangrove's delegation mechanism, which means you only need Mangrove to have an allowance on any address that that has enough inbound tokens of the offer list you are targeting. The cleaner contract will use those funds to execute the cleaning.
Example scenario
The address
funder.ethhas 900 DAI tokens and given Mangrove an allowance to spend its DAI. Offer #708 is still failing.You call the cleaner contract with the same
targetsas above, andtakerset tofunder.eth.Mangrove will use
funder.eth's DAI to execute offer #708 and revert after noticing that the offer fails. It will then transfer the offer bounty to you.If the offer succeeds, Mangrove will notice that you had no allowance to use
funder.eth's DAI on Mangrove and revert (if you did have a high enough allowance, and the sniping succeeds, the cleaner contract will revert anyway).
Last updated
Was this helpful?