Swaps: FAQs
Common questions about Swaps, asked and answered.
Last updated
Was this helpful?
Common questions about Swaps, asked and answered.
Last updated
Was this helpful?
The quotes come from, which estimates current prices from onchain sources. As the order executes in the future, prices may vary.
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.
ensures that your order only executes if the market price is close, using a price oracle and a slippage parameter.
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.
enables smart contracts, like Governor, to place CoW Swap market orders onchain. Milkman's price checker ensures that orders only fill at prices close to the market price.
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 .
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.
You want to sell 5 COMP to buy USDT
You create an order with Milkman. You set the price checker to use the Uniswap v3 oracle oracle and to accept 10% slippage.
That milkman order goes onchain. Solvers compete to offer the best price for your order.
The best offer from CoW solvers is 100 USDT for 5 COMP.
The price checker uses the Uniswap v3 oracle. The Uni v3 price is 21 USDT for 1 COMP.
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 COMP
is greater than the price checker’s limit of
21 USDT per COMP * 0.9 slippage = 18.9 COMP
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.
approve
Milkman to spend sell token
requestSwapExactTokensForTokens
on Milkman
deposit
ETH to WETH contract
approve
Milkman to spend WETH
requestSwapExactTokensForTokens
on Milkman
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 cancel
on 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.
If the trade sells ETH, the funds must first be deposited for , since swap pairs must be ERC20s.