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

Add univ3 router api #143

Merged
merged 2 commits into from
Apr 14, 2022
Merged

Add univ3 router api #143

merged 2 commits into from
Apr 14, 2022

Conversation

vkgnosis
Copy link
Contributor

Api for https://github.com/cowprotocol/univ3-api which will be used as a solver.

Test Plan

CI

@vkgnosis vkgnosis requested a review from a team as a code owner April 11, 2022 15:20
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.

Cool to have this uniswap integration!

pub fn new(client: Client, base: Url) -> Self {
Self {
client,
estimate: base.join("estimate").unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The current implementation of the uniswap router server interprets all requests as estimation requests. Should "/estimate" maybe be dropped here to avoid confusion?
Or should the "/estimate" endpoint be added to the uniswap router server?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I documented that the endpoint is /estimate in the router's readme. Technically it replies this way to all requests but I want to have the option to add other routes in the future.

#[tokio::test]
#[ignore]
async fn real() {
let api = Api::new(Default::default(), "http://localhost:8080".parse().unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess for local setups it would be nice if the default port of the uni router would not conflict with the default port of the order book.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to change the default port of other standalone projects to match this one. When you're running the test here you're probably not running the orderbook right now anyway.

#[serde(with = "serde_with::rust::display_fromstr")]
pub gas: u64,
#[serde(deserialize_with = "deserialize_prefixed_hex")]
pub call_data: Vec<u8>,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: IMO using Bytes seems more appropriate than Vec<u8> but we are using both throughout the code base so I don't have a strong opinion here.
Would be nice to make it consistent in the code base eventually, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I disagree with the use of Bytes but haven't consistently mentioned it in reviews. Bytes is is a "random" type from the web3 crate. No where do they document what it is used for and how it is serialized. So we shouldn't be relying on that. To me Vec is already bytes and how it is serialized is what you specify with the serde tag just like we do with the u64 above.

use reqwest::{Client, Url};
use serde::{Deserialize, Serialize};

#[derive(Debug, Copy, Clone, Serialize)]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: #[serde(rename_all = "camelCase")]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this one I felt giving the enum values explicitly was a bit easier to understand.

@vkgnosis vkgnosis enabled auto-merge (rebase) April 14, 2022 10:29
@vkgnosis vkgnosis disabled auto-merge April 14, 2022 10:35
@vkgnosis vkgnosis merged commit ad8b329 into main Apr 14, 2022
@vkgnosis vkgnosis deleted the univ3-router branch April 14, 2022 10:36
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.

3 participants