GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add function to get amount of asset locked per tick in pool by TheBlueMastiff · Pull Request #283 · uniswap-python/uniswap-python

Conversation

@TheBlueMastiff

@TheBlueMastiff TheBlueMastiff commented Oct 11, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

This function is more or less the same as the get_tvl_in_pool() function but slightly modified to return the amount of each asset locked in a pool per tick.

I created a test to ensure that the amounts returned sum to the same result as get_tvl_in_pool(). I'm having trouble running the tests locally, so I thought I'd open a PR so the tests could run on Github.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
TheBlueMastiff added 2 commits October 11, 2022 15:14
@TheBlueMastiff
Add function to get amount of asset locked per tick in pool
fce193f
@TheBlueMastiff
change assert statements
217ced5
@ErikBjare

ErikBjare commented Oct 12, 2022

Copy link
Copy Markdown
Member

Wow, well done!

I've allowed the test to run now. If you want to run them yourself without having to wait for me to approve the run, you can push to the master branch of your own fork, which should trigger a run (althought might be missing credentials).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Oct 12, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Base: 84.17% // Head: 57.67% // Decreases project coverage by -26.50% ⚠️

Coverage data is based on head (acfa607) compared to base (dc053cd).
Patch coverage: 2.38% of modified lines in pull request are covered.

❗ Current head acfa607 differs from pull request most recent head 4a4cf25. Consider uploading reports for the commit 4a4cf25 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #283       +/-   ##
===========================================
- Coverage   84.17%   57.67%   -26.51%     
===========================================
  Files          10       10               
  Lines        1030     1082       +52     
===========================================
- Hits          867      624      -243     
- Misses        163      458      +295     
Impacted Files Coverage Δ
uniswap/constants.py 100.00% <ø> (ø)
uniswap/uniswap.py 50.58% <2.38%> (-31.88%) ⬇️
uniswap/util.py 64.86% <0.00%> (-22.10%) ⬇️

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

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ErikBjare

ErikBjare commented Oct 12, 2022

Copy link
Copy Markdown
Member

Looks like we have a failure:

/home/runner/work/uniswap-python/uniswap-python/tests/test_uniswap.py:385: TypeError: 'function' object is not subscriptable

Was also picked up by the typechecking:

poetry run mypy --pretty
uniswap/uniswap.py:1454: error: Need type annotation for
"liquidity_per_tick_dict"
            liquidity_per_tick_dict = {
                                      ^
tests/test_uniswap.py:385: error: Value of type "Callable[[Uniswap], Any]" is
not indexable
            pool = client.get_pool_instance(tokens[token0], tokens[token1]...
                                            ^
Found 2 errors in 2 files (checked 12 source files)
make: *** [Makefile:7: typecheck] Error 1
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KeremP

KeremP commented Oct 13, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

looks like the error is here:

@pytest.mark.parametrize("token0, token1", [("DAI", "USDC")])
 def test_asset_locked_per_tick_sums_to_tvl(self, client: Uniswap, token0, token1):
          .....

whereas in order to use the tokens dict that is scoped with the pytest decorators you must pass it in as input:

@pytest.mark.parametrize("token0, token1", [("DAI", "USDC")])
 def test_asset_locked_per_tick_sums_to_tvl(self, client: Uniswap, tokens, token0, token1):
          .....
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TheBlueMastiff
add tokens param to function
acfa607
@TheBlueMastiff

TheBlueMastiff commented Oct 13, 2022

Copy link
Copy Markdown
Author

Whoops. Sorry about that. Updated now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TheBlueMastiff
fix typecheck and round to nearest million
4a4cf25
@TheBlueMastiff

TheBlueMastiff commented Oct 13, 2022

Copy link
Copy Markdown
Author

this is how I had the test passing originally for what I was working on, where approximately correct was fine. Finding the discrepancy for exact values requires more digging and debugging.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KeremP

KeremP commented Oct 13, 2022

Copy link
Copy Markdown
Contributor

I think approximately correct is fine for now, working with the tickbitmap, etc. can get a little complex.

Apparently the subgraph bug has been fixed somewhat recently:
Uniswap/v3-subgraph#74 (comment)

I'll definitely take a look this weekend and see if there are any improvements to glean and update the tvl in pool code respectively.

Good work though! 👍

TheBlueMastiff reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shakibaei65

This comment has been minimized.

Sign in to view
@ErikBjare
ErikBjare force-pushed the master branch from f15ccc6 to 2b04dd3 Compare October 24, 2022 08:40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@TheBlueMastiff @ErikBjare @KeremP @shakibaei65
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.