Comment on page
Common questions about Swaps, asked and answered.
Upon proposal creation, you will receive a quote from CoW based on current market conditions. However, market conditions may change by the time of proposal execution, and a new quote from CoW will be used to create your order.
The default price checker on Tally uses Uniswap v3 as a price oracle and sets a max slippage. Custom price checkers can implement any logic they want.
If the price checker rejects fills with unfavorable prices, the assets to sell remain in the Milkman order contract. To return those funds to the DAO's treasury, the Milkman order needs to be canceled with another onchain proposal. See How do I cancel an order?.
Tally's default price checker uses the Uniswap V3 oracle to get market prices.
If you select this price checker, Tally suggests a max slippage and picks the Uniswap pair(s) to use for the price oracle.
If there is not a direct path (e.g. COMP<>USDT), Tally will try to make a “bridge” with two pairs, e.g. COMP->WETH->USDT instead of COMP->USDT. If that doesn’t work, you’ll have to make a custom price checker route.
Note that steps 3-7 happen after the Governor proposal.
- 1.You want to sell 5 COMP to buy USDT
- 2.You create an order with Milkman. You set the price checker to use the Uniswap v3 oracle oracle and to accept 10% slippage.
- 3.That milkman order goes onchain. Solvers compete to offer the best price for your order.
- 4.The best offer from CoW solvers is 100 USDT for 5 COMP.
- 5.The price checker uses the Uniswap v3 oracle. The Uni v3 price is 21 USDT for 1 COMP.
- 6.The price checker confirms that the best offer is greater than the market price with slippage. Here’s the logic:The offer of
100 USDT / 5 COMP = 20 USDT per COMPis greater than the price checker’s limit of
21 USDT per COMP * 0.9 slippage = 18.9 COMP
- 7.The price checker allows the order to execute on CoW protocol
If no solver comes up with a price greater than 90% of the oracle’s market price, then the order will sit unfilled until someone does. This order can also be canceled by whoever has the cancel role. In the context of a Governor proposal, that’s the DAO, as it is the entity that request the swap.
You will need to find the contract address of a price checker and encode the data it can use to determine if the order gets a good price, usually slippage and a swap path. You may need to find a custom price checker that Custom price checkers can do anything, though.
A Swap Recipe usually includes two executable calls.
approveMilkman to spend sell token
depositETH to WETH contract
approveMilkman to spend WETH
When casting a vote for a swap, you should check the receipt for accuracy.
The quoted price provides a rough estimate of current market conditions before a swap is filled. The path and slippage show how the price checker will calculate the market price and how much slippage to accept.
After a swap is executed successfully, the Swap Receipt will link to the CoW order and to the order contract.
To cancel an order, the Governor must call
cancelon Milkman via an onchain proposal. Only the governor has authority to cancel an order. Canceling the order returns the assets that were for sale to the treasury.
This means that the order isn’t placed yet. The governor proposal has not yet been executed. Once the proposal has been executed, it will create an order on CoW via Milkman.
Solvers pay gas to take an order. If the gas costs are large compared to the size of the trade, you’ll need high slippage to ensure that the solvers can make a profit after gas costs.