From a0541313d45d7240c1581f1be6b318b96cb566e6 Mon Sep 17 00:00:00 2001 From: Troels Damgaard Date: Mon, 5 Feb 2024 14:31:58 +0100 Subject: [PATCH] feat(strats): Update renege and repost guides to new protocol --- docs/developers/strat-lib/guides/howToRenege.md | 4 ++-- .../developers/strat-lib/guides/howToResidual.md | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/docs/developers/strat-lib/guides/howToRenege.md b/docs/developers/strat-lib/guides/howToRenege.md index ef959792..d0dce6b2 100644 --- a/docs/developers/strat-lib/guides/howToRenege.md +++ b/docs/developers/strat-lib/guides/howToRenege.md @@ -12,8 +12,8 @@ A maker can %%renege|renege%% on a trade if the market conditions are no longer You can follow the [smart offer tutorial](../getting-started/smart-offer.md), and extend it with the following function: -```solidity reference title="OfferMakerTutorial.sol" -https://github.com/mangrovedao/mangrove-strats/blob/a265abeb96a053e386d346c7c9e431878382749c/src/toy_strategies/offer_maker/tutorial/OfferMakerTutorialResidual.sol#L77-L80 +```solidity reference title="OfferMakerTutorialResidual.sol" +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|provision%% is lost as a %%bounty|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](../../protocol/background/taker-compensation.md#encouraging-early-renege). diff --git a/docs/developers/strat-lib/guides/howToResidual.md b/docs/developers/strat-lib/guides/howToResidual.md index e6309fa1..379eaeb8 100644 --- a/docs/developers/strat-lib/guides/howToResidual.md +++ b/docs/developers/strat-lib/guides/howToResidual.md @@ -11,10 +11,10 @@ In case an offer is %%partially taken|maker-partial-fill%%, the maker may want t ## Repost in posthook -In the tutorials the [posthook](../getting-started/smart-offer.md#emit-in-posthook) emitted an event. However, since reposting is such a common action, it is already implemented for the simple cases - if you invoke `super` like below, then the base implementation of [`__posthookSuccess__`](../technical-references/code/strats/src/strategies/MangroveOffer.md#posthooksuccess) will repost the residual. +In the tutorial, the [posthook](../getting-started/smart-offer.md#emit-in-posthook) emitted an event. However, since reposting is such a common action, it is already implemented for the simple cases - if you invoke `super` like below, then the base implementation of [`__posthookSuccess__`](../technical-references/code/strats/src/strategies/MangroveOffer.md#posthooksuccess) will repost the residual. ```solidity reference title="OfferMakerTutorial.sol" -https://github.com/mangrovedao/mangrove-strats/blob/a265abeb96a053e386d346c7c9e431878382749c/src/toy_strategies/offer_maker/tutorial/OfferMakerTutorialResidual.sol#L92-L101 +https://github.com/mangrovedao/mangrove-strats/blob/508bc8ace7f1d2ab54397611875306dc1ec31754/src/toy_strategies/offer_maker/tutorial/OfferMakerTutorialResidual.sol#L90-L100 ``` When writing posthooks to repost residuals there are both caveats and points to be aware: @@ -26,16 +26,8 @@ When writing posthooks to repost residuals there are both caveats and points to * Note that the parameters to `__posthookSuccess__` already point out the old offer. This can save storage since we do not have to store %%IDs|offer-id%% of posted offers. * Beware of gas usage changes on different code paths. As an example, the [gas requirements](./howtoGasreq.md) for the tutorial increases to 80,000 to be able to repost. -If you need to write a custom hook, for instance, for reposting multiple offers, then it can be a good idea to look at the base implementation below. A good exercise is to change the code above to emit the value returned from `super` and trigger the `reposted` and `dust` (see %%density|density%%) scenarios. - - +If you need to write a custom hook, for instance, for reposting multiple offers, then it can be a good idea to look at the base implementation of `__posthookSuccess__` (from `MangroveOffer`) below. A good exercise is to change the code above to emit the value returned from `super` and trigger the `reposted` and `dust` (see %%density|density%%) scenarios. ```solidity reference title="MangroveOffer.sol" -https://github.com/mangrovedao/mangrove-strats/blob/a265abeb96a053e386d346c7c9e431878382749c/src/strategies/MangroveOffer.sol#L251-L280 +https://github.com/mangrovedao/mangrove-strats/blob/508bc8ace7f1d2ab54397611875306dc1ec31754/src/strategies/MangroveOffer.sol#L205-L234 ```