cowprotocol / research

CoW Protocol Research
GNU Lesser General Public License v3.0
0 stars 0 forks source link

research(contracts): hook enforcement and context determinism #12

Open mfw78 opened 7 months ago

mfw78 commented 7 months ago

Problem

Hooks as they are used at the moment are non-trivial to enforce. Pre-hooks must manipulate some condition that then allows the trade to take place (i.e just-in-time vault-relayer allowance setting), and post-hooks would require some economic game with the solver committing to bond beforehand and requiring the post-hook to retrieve the funds. These are non-trivial and cause drastic limitations on developer experience / adoption.

Acceptance criteria

Details

Hooks are a way that users are able to express their desired pre and post interactions associated with their order. These hooks are then executed by the HooksTrampoline, therefore all hooks, irrespective of the user whose order they're associated with, are executed with the same msg.sender.

Hooks are specified in appData, which is not parsable by smart contract and represents a keccak256 hash of a JSON stringified object, therefore there is no way for the settlement contract to enforce pre and post hooks.

Possible Solutions

Research track

fleupold commented 5 months ago

Should the hook also already have access to the clearing prices of the order that is about to be executed (could be useful to determine the correct amount to unstake for instance)?