Background
For inspiration: a twitter thread about a $16m milkman order executed by ENS DAO
https://twitter.com/CoWSwap/status/1623680760522612738
If you’re not familiar with the milkman smart contract, here’s the repo
Milkman allows to defer the choice of the limit price from order initiation (pre DAO vote) to order execution time (solver settling the trade). It does so by using ERC1271 signatures and considers a proposed execution price valid if it’s within a predefined range from an external oracle (price checker)
Here’s a short tutorial with code example for creating an execution payload deploying a TWAP/DCA strategy using multiple milkman orders
General requirement
amountIn
: an amount of tokens to sellfromToken
: ERC20 you're swapping out oftoToken
: ERC20 you're swapping intoto
: the intended receiver of the bought tokenspriceChecker
: the address of a price checker, or address(0)
for none (should produce a warning if none);
Ideally it suggests choosing from a list of deployed price checkersslippageTolerance
: allowed slippage below the expectedOutAmount
. Or 0 if price checker not defined.
priceCheckerData
: encoded data to pass to the price checker; should be generated automatically for popular price checkers like UniV3validFrom
timestampapprove
to save manual execution overheadDefaults:
Bonus: