Open acanidio-econ opened 6 months ago
Related to https://github.com/cowprotocol/research/issues/3#issuecomment-1784559087 as a nullifier would allow to specify multiple orders with the same nullifier of which only one could be chosen.
If we implement #13 those types of markets could be added at will later on (but may still be good to include in the default market).
Problem
Currently, there is no way to express mutually exclusive orders; that is, that solvers should execute only one among several orders placed by the same user. But these mutually exclusive orders could be valuable in several situations:
people could specify orders like "sell this token for any stablecoin" or "sell this token for any major token (ETH/BTC/stable/...)" which could be valuable when there is high volatility. Also, in the future, solvers will need to manage their inventory (something we currently do for them). Because they accumulate random tokens in their buffers, they may want to use such orders to trade these random tokens back to something less risky.
we could create multi-tokens CoWAMM that work like personal ETFs. The problem here is that solvers can attack a CoWAMM by placing multiple orders for the same pool within the same batch, potentially emptying the pool. This is currently prevented via the following steps:
However, checking whether an order is "canonical" requires checking a price oracle, and costs gas. This cost is limited if the AMM has only two tokens but becomes very expensive if the AMM has multiple tokens. As a consequence, it is not possible right nor to have CoWAMM with more than 2 tokens.
Acceptance criteria
Details
With respect to "sell for any stablecoin" and "sell for any major token" order-type, when an user places such orders, there are multiple orders places on the users' behalf, all grouped under a specific label, and only one of them is executable.
With respect to multi-tokens CoWAMM: Assuming we won't support basket orders (at least, not in the near future), then the AMM will need to trade a single token pair at the time. In practice, the AMM is divided into several "buckets" (say 20). At deployment, a user can specify a token for each bucket. The same token can be specified for multiple buckets. Then, the watchtower creates an order for the AMM by figuring out which "bucket" has the largest difference in value and creating a rebalancing trade for those buckets. The AMM is fully rebalanced throughout a few auctions. The main difficulty is that to check that the "canonical order" created by the watchtower is valid, the smart contract needs to pull several price oracles, which cost gas. But if we have a way to prevent solvers from placing multiple orders per AMM, then this step is not required.
Possible Solutions
Research track
smart contract, solvers, CoWAMM