Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Autopilot may create auctions without WETH price #2149

Closed
fleupold opened this issue Dec 8, 2023 · 0 comments · Fixed by #2159
Closed

bug: Autopilot may create auctions without WETH price #2149

fleupold opened this issue Dec 8, 2023 · 0 comments · Fixed by #2159
Assignees
Labels
bug Something isn't working E:3.1 Driver Colocation See https://github.com/cowprotocol/pm/issues/14 for details

Comments

@fleupold
Copy link
Contributor

fleupold commented Dec 8, 2023

Problem

The driver expects token prices for all buy and sell tokens in the auction. Yet, it wraps ETH into WETH if necessary:

let weth = eth.contracts().weth_address();
if !orders.iter().all(|order| {
tokens.0.contains_key(&order.buy.token.wrap(weth))
&& tokens.0.contains_key(&order.sell.token)
}) {
return Err(Error::InvalidTokens);
}

Yet, when creating the auction we don't ensure we have token prices for both the wrapped native version as well as the 0xe....e placeholder. We only insert the token address specified on the order.

let traded_tokens = orders
.iter()
.flat_map(|order| [order.data.sell_token, order.data.buy_token])
.collect::<HashSet<_>>()
.into_iter()
.collect::<Vec<_>>();

Impact

If an auction contains only a native token order (and no order trading the wrapped native token equivalent), all drivers will reject the auction.

To reproduce

If you can reproduce the behaviour, steps to reproduce:

  1. Start with an empty orderbook
  2. Only place a single order buying native ETH in the system
  3. See it not getting matched

Expected behaviour

Auctions like this should work normal

Additional context

Logs: https://production-6de61f.kb.eu-central-1.aws.cloud.es.io/app/r/s/bS0Vj

@fleupold fleupold added bug Something isn't working E:3.1 Driver Colocation See https://github.com/cowprotocol/pm/issues/14 for details labels Dec 8, 2023
@fleupold fleupold changed the title bug: Autopilot may create auctions with WETH price bug: Autopilot may create auctions without WETH price Dec 8, 2023
@squadgazzz squadgazzz self-assigned this Dec 13, 2023
squadgazzz added a commit that referenced this issue Dec 13, 2023
# Description
#2149

# Changes
Adds WETH price to the Auction cache if it doesn't exist.
Also adds WETH address to the Orders cache which should be refactored in
the future.

## How to test
Added e2e test

## Related Issues

Fixes #2149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working E:3.1 Driver Colocation See https://github.com/cowprotocol/pm/issues/14 for details
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants