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 uniswap V2 WETH-USDC swap example #1353

Merged
merged 11 commits into from
Apr 29, 2024
Merged

Conversation

pawurb
Copy link
Contributor

@pawurb pawurb commented Apr 22, 2024

Related to #1084 . This example shows common use cases not covered by other examples.

Screenshot 2024-04-22 at 13 51 58

examples/uniswap_v2_usdc_swap.rs Outdated Show resolved Hide resolved
@pawurb pawurb force-pushed the swap_example branch 3 times, most recently from 8241d25 to 8cbffa7 Compare April 23, 2024 13:16
@pawurb
Copy link
Contributor Author

pawurb commented Apr 23, 2024

@onbjerg Should be fixed. I think ethers_providers has to stay because of EthersDB, or is there some alloy alternative?

@pawurb pawurb requested a review from onbjerg April 23, 2024 13:29
@onbjerg
Copy link
Collaborator

onbjerg commented Apr 25, 2024

@pawurb you can use AlloyDB! 😄

@onbjerg onbjerg added the feature New feature or lib ability label Apr 25, 2024
@pawurb pawurb requested a review from onbjerg April 25, 2024 09:46
Comment on lines 24 to 25
let mut alloydb = AlloyDB::new(client, None);
let mut cache_db = CacheDB::new(EmptyDB::default());
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can just do CacheDB::new(AlloyDB::new(client, None)), then calls to e.g. db.basic will automatically first get pulled from the alloy provider, and then stored in the cache db! that avoids you needing to do what you are doing on eg L45, L48 etc

@rakita
Copy link
Member

rakita commented Apr 29, 2024

pending comment #1353 (comment)

@pawurb
Copy link
Contributor Author

pawurb commented Apr 29, 2024

pending comment #1353 (comment)

@rakita I don't understand, I think I've already applied suggestions from this comment.

@rakita
Copy link
Member

rakita commented Apr 29, 2024

pending comment #1353 (comment)

@rakita I don't understand, I think I've already applied suggestions from this comment.

That is true, didn't see that is a outdated comment. lgtm, merging

@rakita rakita merged commit 3f5bb76 into bluealloy:main Apr 29, 2024
25 checks passed
@github-actions github-actions bot mentioned this pull request Apr 29, 2024
@pawurb pawurb deleted the swap_example branch April 29, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or lib ability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants