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

feat: search entire UniswapV3 fee range for longtail swaps #5870

Merged
merged 7 commits into from
Dec 19, 2023

Conversation

0xApotheosis
Copy link
Member

@0xApotheosis 0xApotheosis commented Dec 15, 2023

Description

Adds UniswapV3 pool optimization to long-tail swaps, enabling more assets and better rates.

This PR adds the ability to search all fee ranges for a given asset pair's available pools, get a quote for each, and transact against the contract resulting in the best rate. In particular, we'll get better rates for assets with tight liquidity pools.

Also adds support for additional assets that did not have pools for the 3000 fee range of UniswapV3.

An example to see this working: compare the rate between this branch and prod for LINK to DOGE.

Pull Request Type

  • 🐛 Bug fix (Non-breaking Change: Fixes an issue)
  • 🛠️ Chore (Non-breaking Change: Doc updates, pkg upgrades, typos, etc..)
  • 💅 New Feature (Breaking/Non-breaking Change)

Issue (if applicable)

Closes #5878

Risk

High risk to long-tail swaps - we'll want to test these again, as messing up the contracts here (e.g. using a non-whitelisted contract) could lead to funds landing in a black hole.

Testing

Perform longtail swaps on a range of assets (the sell asset is important, not so much the buy asset - so just use the cheapest).

Engineering

Sanity check the contract selection logic - using the wrong aggregator contract will cause lost funds.

Operations

☝️

Screenshots (if applicable)

N/A

Comment on lines +64 to +67
TSAggregatorUniswapV3_100 = '0xbd68cbe6c247e2c3a0e36b8f0e24964914f26ee8',
TSAggregatorUniswapV3_500 = '0xe4ddca21881bac219af7f217703db0475d2a9f02',
TSAggregatorUniswapV3_3000 = '0x11733abf0cdb43298f7e949c930188451a9a9ef2',
TSAggregatorUniswapV3_10000 = '0xb33874810e5395eb49d8bd7e912631db115d5a03',
Copy link
Member Author

@0xApotheosis 0xApotheosis Dec 15, 2023

Choose a reason for hiding this comment

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

THORChain will blackhole funds if any of these are wrong - they must be whitelisted on https://gitlab.com/thorchain/thornode/-/blob/develop/x/thorchain/aggregators/dex_mainnet_current.go

@0xApotheosis 0xApotheosis force-pushed the add-v3-fee-ranges branch 2 times, most recently from 07146fb to bb312d0 Compare December 17, 2023 22:41
@0xApotheosis 0xApotheosis marked this pull request as ready for review December 18, 2023 23:42
@0xApotheosis 0xApotheosis requested a review from a team as a code owner December 18, 2023 23:42
Copy link
Member

@woodenfurniture woodenfurniture left a comment

Choose a reason for hiding this comment

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

lgtm, no blocking comments

@0xApotheosis 0xApotheosis merged commit 9fdb226 into develop Dec 19, 2023
1 check passed
@0xApotheosis 0xApotheosis deleted the add-v3-fee-ranges branch December 19, 2023 01:35
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.

Search entire UniswapV3 fee range for longtail swaps
3 participants