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

GSW-875 feat use compute route logic from uniswap for router to calculate ratio #176

Conversation

r3v4s
Copy link
Member

@r3v4s r3v4s commented Feb 22, 2024

New

  1. router use computeRoute logic from uniswap to calculate ratio

NO MERGE YET

wait for #173 #174 #175

@r3v4s r3v4s added the wait-other-pr other pr(s) should merge first label Feb 22, 2024
@r3v4s r3v4s self-assigned this Feb 22, 2024
Comment on lines 147 to +148
uniqueTokenList := []string{}
poolList := p.PoolGetPoolList()
poolList := pl.PoolGetPoolList()
Copy link
Member

Choose a reason for hiding this comment

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

We don't know the final size of the uniqueTokenList, but using the size of the poolList seems to allow us to set the initial capacity and this will reduce the re-allocations.

+ poolList := pl.PoolGetPoolList()
+ uniqueTokenList := make([]string, 0, len(poolList)*2)
- uniqueTokenList := []string{}
- poolList := pl.PoolGetPoolList()

Copy link
Member Author

Choose a reason for hiding this comment

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

looks great, but why does initial length requires * 2?

Copy link
Member

@notJoon notJoon Feb 26, 2024

Choose a reason for hiding this comment

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

looks great, but why does initial length requires * 2?

I simply set it to double because I assumed that since each pool has two tokens (token0, token1), each pool would add up to two unique tokens to the list. However, since this value was not set after exact measurement (or, calibrated), we will need to reevaluate this part later.

@r3v4s r3v4s force-pushed the GSW-875-feat-use-compute-route-logic-from-uniswap-for-router-to-calculate-ratio branch from 84563ca to 182c0ce Compare February 26, 2024 06:47
@r3v4s r3v4s marked this pull request as ready for review February 26, 2024 06:47
@r3v4s r3v4s requested a review from notJoon February 26, 2024 06:47
@notJoon notJoon merged commit d463822 into main Feb 26, 2024
@notJoon notJoon deleted the GSW-875-feat-use-compute-route-logic-from-uniswap-for-router-to-calculate-ratio branch February 26, 2024 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wait-other-pr other pr(s) should merge first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants