Price Estimation

As stated in other sections, CoW Protocol works with signed messages instead of executing transactions on the go. This means, that on the UI, the user sees a price quote that is based on an estimation of what prices will that particular order be settled with. One particular feature of CoW Protocol is that within the price estimation, it shows "the minimum amount to be received" which is a price quote that can't be violated, meaning that the protocol will either give you that price or the order will expire and be canceled without any cost. Although, if through CoWs, the protocol can offer you a better quote than the minimum received, it will execute your order with a surplus. In other words, price estimation is a lower bound on the proceeds a user can get for their trade. While we are working on it, at the moment slippage is not yet included in the price estimate
In order for the front end to show the users the expected prices, the backend has implemented different routes for price estimation. This can be done through the /api/v1/feeAndQuote/sell / /api/v1/feeAndQuote/buy endpoints or /api/v1/markets endpoint.
These prices are calculated based on liquidity sources that have native support (Uniswapv2, Sushiswap, and hopefully soon Balancer and Uniswapv3) from the baseline solver. However, when finding the actual batch settlement, there are also smarter solvers like the MIP solver and other aggregators like 1Inch and Paraswap that are working on finding the best price settlement. This means that the settled price might be better than the estimated price.
As we add native support for more liquidity sources, improve the baseline solver, and start using other solvers for price estimation, such as the MIP solver, the protocol estimates should highly improve over time. Like the baseline solver, it uses a set of base tokens that are considered as intermediate hops between tokens to reach the buy token from the sell token. It takes gas cost into account so that for small orders fewer hops are preferred while for large orders more hops might be considered if they improve the price enough. The price estimation code is in shared/src/