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

Cow-ify repository #132

Merged
merged 5 commits into from
Apr 7, 2022
Merged

Cow-ify repository #132

merged 5 commits into from
Apr 7, 2022

Conversation

nlordell
Copy link
Contributor

@nlordell nlordell commented Apr 5, 2022

This PR just "Cow-ifies" the repository. It tries to:

  • Replace references to GPv2 into Cow Protocol
  • Replace URLs to the new cow.fi ones
  • Replace issue links to the ones created in this repo.
  • Update dependencies to use the github.com/cowprotocol org forks
  • Contract vendoring with new repo pacakges (Note, the @cowprotocol/[email protected] package is not deployed on NPM pending Cow-ify token repository token#1 - feel free to review that PR as well 😄).

Test Plan

CI - no code or logic changes, just metadata things.

Run the vendoring script to make sure that the contract sources are correct.
% cargo run -p contracts --features bin --bin vendor
[2022-04-07T09:52:59Z INFO  vendor] vendoring contract artifacts to '/Users/nlordell/Developer/cowprotocol/services/crates/contracts/artifacts'
[2022-04-07T09:52:59Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-v2-monorepo/a3b570a2aa655d4c4941a67e3db6a06fbd72ef09/pkg/deployments/deployed/mainnet/Authorizer.json", query: None, fragment: None })
[2022-04-07T09:52:59Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-v2-monorepo/a3b570a2aa655d4c4941a67e3db6a06fbd72ef09/pkg/deployments/deployed/mainnet/Vault.json", query: None, fragment: None })
[2022-04-07T09:52:59Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-v2-monorepo/a3b570a2aa655d4c4941a67e3db6a06fbd72ef09/pkg/deployments/deployed/mainnet/WeightedPoolFactory.json", query: None, fragment: None })
[2022-04-07T09:52:59Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-v2-monorepo/a3b570a2aa655d4c4941a67e3db6a06fbd72ef09/pkg/deployments/deployed/mainnet/WeightedPool2TokensFactory.json", query: None, fragment: None })
[2022-04-07T09:53:00Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-v2-monorepo/ad1442113b26ec22081c2047e2ec95355a7f12ba/pkg/deployments/tasks/20210624-stable-pool/abi/StablePoolFactory.json", query: None, fragment: None })
[2022-04-07T09:53:00Z INFO  vendor] retrieving Npm("@openzeppelin/[email protected]/build/contracts/ERC20Mintable.json")
[2022-04-07T09:53:02Z INFO  vendor] retrieving Npm("@cowprotocol/[email protected]/deployments/mainnet/GPv2AllowListAuthentication_Implementation.json")
[2022-04-07T09:53:05Z INFO  vendor] retrieving Npm("@cowprotocol/[email protected]/deployments/mainnet/GPv2Settlement.json")
[2022-04-07T09:53:05Z INFO  vendor] retrieving Npm("@uniswap/[email protected]/build/UniswapV2Factory.json")
[2022-04-07T09:53:07Z INFO  vendor] retrieving Npm("@uniswap/[email protected]/build/UniswapV2Router02.json")
[2022-04-07T09:53:08Z INFO  vendor] retrieving Npm("[email protected]/build/contracts/WETH9.json")
[2022-04-07T09:53:10Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-v2-monorepo/7a643349a5ef4511234b19a33e3f18d30770cb66/pkg/deployments/tasks/20210721-liquidity-bootstrapping-pool/abi/LiquidityBootstrappingPool.json", query: None, fragment: None })
[2022-04-07T09:53:10Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-v2-monorepo/7a643349a5ef4511234b19a33e3f18d30770cb66/pkg/deployments/tasks/20210721-liquidity-bootstrapping-pool/abi/LiquidityBootstrappingPoolFactory.json", query: None, fragment: None })
[2022-04-07T09:53:10Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-v2-monorepo/a3b570a2aa655d4c4941a67e3db6a06fbd72ef09/pkg/deployments/extra-abis/WeightedPool.json", query: None, fragment: None })
[2022-04-07T09:53:11Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/balancer-labs/balancer-subgraph-v2/2b97edd5e65aed06718ce64a69111ccdabccf048/abis/StablePool.json", query: None, fragment: None })
[2022-04-07T09:53:11Z INFO  vendor] retrieving Npm("@openzeppelin/[email protected]/build/contracts/ERC20.json")
[2022-04-07T09:53:15Z INFO  vendor] retrieving Npm("@uniswap/[email protected]/build/IUniswapV2Factory.json")
[2022-04-07T09:53:21Z INFO  vendor] retrieving Npm("@uniswap/[email protected]/build/IUniswapV2Pair.json")
[2022-04-07T09:53:24Z INFO  vendor] retrieving Npm("@uniswap/[email protected]/build/IUniswapV2Router02.json")
[2022-04-07T09:53:25Z INFO  vendor] skipping BalancerV2BasePool: Balancer does not publish ABIs for base contracts
[2022-04-07T09:53:25Z INFO  vendor] skipping BalancerV2BasePoolFactory: Balancer does not publish ABIs for base contracts
[2022-04-07T09:53:25Z INFO  vendor] retrieving Npm("@uniswap/[email protected]/artifacts/contracts/interfaces/IUniswapV3Factory.sol/IUniswapV3Factory.json")
[2022-04-07T09:53:26Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/0xProject/protocol/c1177416f50c2465ee030dacc14ff996eebd4e74/packages/contract-artifacts/artifacts/IZeroEx.json", query: None, fragment: None })
[2022-04-07T09:53:26Z INFO  vendor] retrieving Http(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("raw.githubusercontent.com")), port: None, path: "/levelkdev/dxswap-core/3511bab996096f9c9c9bc3af0d94222650fd1e40/build/IDXswapPair.json", query: None, fragment: None })
[2022-04-07T09:53:27Z INFO  vendor] retrieving Npm("@cowprotocol/[email protected]/build/artifacts/src/contracts/CowProtocolToken.sol/CowProtocolToken.json")
[2022-04-07T09:53:30Z INFO  vendor] retrieving Npm("@cowprotocol/[email protected]/build/artifacts/src/contracts/CowProtocolVirtualToken.sol/CowProtocolVirtualToken.json")

@nlordell nlordell requested a review from a team as a code owner April 5, 2022 13:03
@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2022

Codecov Report

Merging #132 (7e6f389) into main (e73b207) will decrease coverage by 0.00%.
The diff coverage is 11.11%.

@@            Coverage Diff             @@
##             main     #132      +/-   ##
==========================================
- Coverage   65.11%   65.11%   -0.01%     
==========================================
  Files         182      182              
  Lines       38049    38049              
==========================================
- Hits        24775    24774       -1     
- Misses      13274    13275       +1     

Copy link
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replacements seem reasonable and the links I tested are working (except the one Valentin already highlighted).
I'm already approving assuming you fix the broken link.

Nicholas Rodrigues Lordello and others added 2 commits April 6, 2022 18:38
@nlordell
Copy link
Contributor Author

nlordell commented Apr 7, 2022

Just holding off merging waiting for cowprotocol/token#1.

@nlordell
Copy link
Contributor Author

nlordell commented Apr 7, 2022

Token repo was publised to NPM and I ran the vendor script to make sure it works (see updated test plan).

@nlordell nlordell merged commit 46dd0cc into main Apr 7, 2022
@nlordell nlordell deleted the cowification branch April 7, 2022 09:59
nlordell pushed a commit that referenced this pull request Apr 7, 2022
#132 introduced regressions that caused the order alerter to constantly fail to retrieve orders. This is because the public API URL contains `/$network` path prefix that wasn't supported by the alerter.

This PR adds support for this. Basically, it just `join`s instead of replacing the path entirely with `set_path`.

### Test Plan

Run the alerter and see it make successful API requests:
```
% cargo run -p alerter -- --min-order-age 1 --time-without-trade 1
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/alerter --min-order-age 1 --time-without-trade 1`
2022-04-07T11:24:09.456Z  INFO alerter: running alerter with Arguments {
    time_without_trade: 1s,
    min_order_age: 1s,
    min_alert_interval: 1799.99997952s,
    errors_in_a_row_before_alert: 5,
    orderbook_api: "https://api.cow.fi/mainnet/",
}
2022-04-07T11:24:09.701Z DEBUG alerter: found 16 open orders
2022-04-07T11:24:09.701Z DEBUG alerter: found no fulfilled orders
2022-04-07T11:24:39.747Z DEBUG alerter: found 14 open orders
2022-04-07T11:24:39.802Z DEBUG alerter: found no fulfilled orders
2022-04-07T11:24:41.905Z DEBUG alerter: 0x url="https://api.0x.org/swap/v1/price?sellToken=0x6b175474e89094c44da98b954eedeac495271d0f&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellAmount=811063811362965485568" response=Response { sell_amount: 811063811362965485568, buy_amount: 810420605 }
2022-04-07T11:24:43.441Z DEBUG alerter: 0x url="https://api.0x.org/swap/v1/price?sellToken=0x6b175474e89094c44da98b954eedeac495271d0f&buyToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmount=475833914861854859264" response=Response { sell_amount: 475833914861854859264, buy_amount: 474553897 }
2022-04-07T11:24:43.952Z DEBUG alerter: 0x url="https://api.0x.org/swap/v1/price?sellToken=0xab846fb6c81370327e784ae7cbb6d6a6af6ff4bf&buyToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&sellAmount=45974334753652705821" response=Response { sell_amount: 45974334753652705821, buy_amount: 19342714737093254 }
2022-04-07T11:25:13.994Z DEBUG alerter: found 13 open orders
2022-04-07T11:25:14.084Z DEBUG alerter: found no fulfilled orders
2022-04-07T11:25:15.393Z DEBUG alerter: 0x url="https://api.0x.org/swap/v1/price?sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7&sellAmount=220029560" response=Response { sell_amount: 220029560, buy_amount: 218997589 }
...
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants