# Using last look to renege trades

### Example <a href="#example" id="example"></a>

A maker can [renege](https://docs.mangrove.exchange/dev/quick-links/glossary#renege) on a trade if the market conditions are no longer favorable. This can be done in [multiple ways](https://docs.mangrove.exchange/dev/protocol/technical-references/makers/maker-contract), but the strat lib has made it easy by adding a [`__lastLook__`](https://docs.mangrove.exchange/dev/technical-references/api-preferences/strats/src/strategies/mangroveoffer#lastlook) function which can be overridden.

You can follow the [smart offer tutorial](https://docs.mangrove.exchange/dev/strat-lib/getting-started/post-a-smart-offer), and extend it with the following function:

OfferMakerTutorialResidual.sol

```
function __lastLook__(MgvLib.SingleOrder calldata order) internal override returns (bytes32 data) {
  data = super.__lastLook__(order);
  require(order.takerWants == order.offer.gives(), "tutorial/mustBeFullyTaken");
}
```

[See entire file on GitHub](https://github.com/mangrovedao/mangrove-strats/blob/508bc8ace7f1d2ab54397611875306dc1ec31754/src/toy_strategies/offer_maker/tutorial/OfferMakerTutorialResidual.sol#L75-L78)

This override of the `__lastLook__` will renege if the offer is not fully taken. Note that since the [provision](https://docs.mangrove.exchange/dev/quick-links/glossary#provision) is lost as a [bounty](https://docs.mangrove.exchange/dev/quick-links/glossary#bounty) to the taker, care must be taken to select the right circumstances to renege. This uses the mechanisms for compensating the taker on failure, and therefore the maker should [renege early](https://docs.mangrove.exchange/dev/protocol/background/reneging-on-offers).

### Exercises[​](https://old.docs.mangrove.exchange/developers/strat-lib/guides/howToRenege#exercises) <a href="#exercises" id="exercises"></a>

1. Try posting an offer with a [maker contract](https://docs.mangrove.exchange/dev/protocol/technical-references/makers/maker-contract) with the above implementation of `__lastlook__` above.
2. Then, try out targeting this offer with a [market order](https://docs.mangrove.exchange/dev/protocol/technical-references/takers#market-orders) that takes only *part* of the tokens that the offer [gives](https://docs.mangrove.exchange/dev/quick-links/glossary#gives). The result should be a `makerExecute` fail with the reason that the offer must be fully taken.

**Note :**

For your offer to be targeted by a market order, it needs to sit at the top of the order book. Make sure to choose a very favorable price (i.e. tick) when posting your offer. For an example of how to calculate a tick from a ratio, check the Solidity snippets of [Posting a new offer](https://docs.mangrove.exchange/dev/strat-lib/guides/reposting-an-offer-in-the-posthook).

In a [Foundry](https://book.getfoundry.sh/getting-started/installation) trace, it would look like this:

```
    │   │   └─ ← 0x0000000000000000000000000000000000000000000000000000000000000001
    │   ├─ [623] OfferMakerTutorial::makerExecute((0x63E537A69b3f5B03F4f46c5765c82861BD874b6e, 0xC87385b5E62099f92d490750Fcd6C901a524BBcA, 565, 13965252376515437924197781608061731723491045742767017537776374226616320, 100000000000000000, 170000000000000000000, 114972889140951241694864433974031885472888135242322246917362470694355803832320, 95685385232850624329487581946028423310341827134083876137913628388789126692864, 452312848583266388373324160192082719549164520795168960635552751154278432768)) 
    │   │   └─ ← "tutorial/mustBeFullyTaken"
    │   └─ ← "Custom Error 6d67762f:(0x0000000000000000000000000000000000000000, 15120238736495)"
```
