Skip to content

feat: create pool and create/remove liquidity position for v3 #264

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

Closed
wants to merge 36 commits into from

Conversation

KeremP
Copy link
Contributor

@KeremP KeremP commented Jul 13, 2022

Added V3 features:

  • create/get v3 pool instance
  • create v3 liquidity position
  • remove v3 liquidity position

@ErikBjare
Copy link
Member

Very nice! Let me know when you want a review :)

Any idea why the CI chokes on the CLI tests?

@KeremP
Copy link
Contributor Author

KeremP commented Jul 13, 2022

Thanks! Will do.

Not sure as to why the CI isn't passing - was working earlier when I ran tests locally. I'll take a look tonight and see what's up.

@ErikBjare
Copy link
Member

Btw, do you think this would be easy to do at the same time? #254

@liquid-8
Copy link
Member

Btw, do you think this would be easy to do at the same time? #254

Long story short:
https://stackoverflow.com/questions/71814845/how-to-calculate-uniswap-v3-pools-total-value-locked-tvl-on-chain
Due to personal reasons, I can't implement that myself at the moment. However, it seems to be not too complicated to add.

@KeremP
Copy link
Contributor Author

KeremP commented Jul 13, 2022

Btw, do you think this would be easy to do at the same time? #254

Long story short: https://stackoverflow.com/questions/71814845/how-to-calculate-uniswap-v3-pools-total-value-locked-tvl-on-chain Due to personal reasons, I can't implement that myself at the moment. However, it seems to be not too complicated to add.

Sure thing, seems pretty straightforward to implement

@KeremP
Copy link
Contributor Author

KeremP commented Jul 14, 2022

Very nice! Let me know when you want a review :)

Any idea why the CI chokes on the CLI tests?

Took a peek at the logs for the CI, seems like provider env variable may not have set

@ErikBjare
Copy link
Member

ErikBjare commented Jul 14, 2022

Ah yeah, I just now remember that secrets (like our PROVIDER credentials) aren't set on PRs.

Might get a second key, obfuscate it slightly, and use it for PRs.

@ErikBjare
Copy link
Member

Should have fixed it in #266, feel free to rebase so the tests get green :)

@codecov
Copy link

codecov bot commented Jul 15, 2022

Codecov Report

Merging #264 (0175265) into master (208843c) will increase coverage by 2.16%.
The diff coverage is 92.67%.

@@            Coverage Diff             @@
##           master     #264      +/-   ##
==========================================
+ Coverage   82.42%   84.59%   +2.16%     
==========================================
  Files          10       10              
  Lines         808     1032     +224     
==========================================
+ Hits          666      873     +207     
- Misses        142      159      +17     
Impacted Files Coverage Δ
uniswap/util.py 86.95% <80.64%> (-5.36%) ⬇️
uniswap/uniswap.py 82.63% <94.32%> (+3.53%) ⬆️
uniswap/cli.py 92.95% <100.00%> (ø)
uniswap/constants.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@KeremP
Copy link
Contributor Author

KeremP commented Jul 15, 2022

Now that we have all green :) Going to write tests for the methods that address #254 and should be good for a review

@KeremP
Copy link
Contributor Author

KeremP commented Jul 15, 2022

Btw, do you think this would be easy to do at the same time? #254

Long story short: https://stackoverflow.com/questions/71814845/how-to-calculate-uniswap-v3-pools-total-value-locked-tvl-on-chain Due to personal reasons, I can't implement that myself at the moment. However, it seems to be not too complicated to add.

Sure thing, seems pretty straightforward to implement

After implementing a version of this - seems this takes quite a while to run as it iterates across the entire tick range of a pool and calls the .tick() function of the contract each iteration. So, I added a method to fetch the TVL data from the uniswap subgraph using the built-in request library.

Do you think I should remove the subgraph query function? suppose it's easy enough for users to make similar requests on their own (this is also failing some tests at the moment).

@KeremP
Copy link
Contributor Author

KeremP commented Aug 18, 2022

@ErikBjare this is now ready for review :)

wrt to #254 I've added a function get_tvl_in_pool() and have commented the logic (some weird hacks with the tickBitmap to get it working), but let me know if any questions.

Edit: I've removed my prior functions for querying subgraph, feel that's out of scope here and there are known issues w/ its calculation of TVL

@liquid-8
Copy link
Member

Amazing job, that's impressive. The only thing I just can't get why
def get_liquidity_positions(self) -> List[int]:
instead of
def get_liquidity_positions(address: AddressLike) -> List[int]:

IMO if we have a scenario when this function has the reason to be implemented for our address, then we also have a similar/same scenario for others.

@KeremP
Copy link
Contributor Author

KeremP commented Aug 26, 2022

Fair point, I agree. I'll make that change quick.

@liquid-8
Copy link
Member

@ErikBjare just take a look at this grandeur!

Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

Awesome work @KeremP! You da MVP! 🥇

Found no major issues, just a couple nits. I'll fix and merge :)

Sorry for the late review.

ErikBjare pushed a commit that referenced this pull request Aug 29, 2022
… position, TVL calculation (#264)

implementing V3 features. added methods to fetch on-chain pool data

feature: adding position miniting (WIP)

WIP testing V3 pool position minting

wip v3 features

feat: create v3 pool and mint/add liquidity position

fix: add 0x0 address assert in get_pool_instance

feat: close v3 liquidity position

minor cleanups

add get_tvl_in_pool to return total value locked in pool

implementing V3 features. added methods to fetch on-chain pool data

feature: adding position miniting (WIP)

WIP testing V3 pool position minting

wip v3 features

feat: create v3 pool and mint/add liquidity position

feat: close v3 liquidity position

minor cleanups

fixing minor errors afer rebase

cleanup asset amounts for tests

fix: ensure asset amounts are correct for v3 liquidity position tests

add tests for TVL calculations. include method for fetching TVL from V3 subgraph as on-chain method takes long to run

add arbitrum subgraph endpoint

fix typo

skip tvl tests for now

feat: get TVL on chain

minor cleanups

fix aribitrum multicall2 address. clean up TVL test

update get_liquidity_positions to take arbitrary address param
@ErikBjare
Copy link
Member

Merged a squashed version in 9edfbaa (which was messy), now trying to address some issues during rebase.

@ErikBjare
Copy link
Member

Alright, I can't manage to get this PR to get marked as "Merged" for some reason (keeps complaining about some conflict?).

Changes are merged though, fixing some lingering issues on master.

Thanks again for contributing @KeremP! ❤️

@ErikBjare ErikBjare closed this Aug 29, 2022
@KeremP
Copy link
Contributor Author

KeremP commented Aug 29, 2022

Sounds good! Thanks for the review :)

@ghost
Copy link

ghost commented Sep 28, 2023

What is the difference between mint_liquidity and mint_position here? I tried to create positions using both. mint_liquidity was successful but mint_position didn't seem to create a position though the function execution was successful.

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