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 — fix(async): port price-floor and odd-tick TVL fixes to async clients by TimeToBuildBob · Pull Request #493 · uniswap-python/uniswap-python

Conversation

@TimeToBuildBob

@TimeToBuildBob TimeToBuildBob commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #482.

#482 fixed two arithmetic bugs in the sync clients only. The async clients added in #491 contain the same three expressions:

  • AsyncUniswap.get_raw_price (v3): sqrtPriceX96 * sqrtPriceX96 * 10**den1 >> 192 floors before decimal scaling. 9.87e-6 becomes 9e-6, 4.9e-7 becomes 0, and the reciprocal raises ZeroDivisionError.
  • AsyncUniswap4.get_token_token_spot_price: the same floor.
  • AsyncUniswap.get_tvl_in_pool: tick // 2 gives wrong sqrt-price bounds for odd ticks (fee=100, tick_spacing=1).

This PR applies the identical fix from #482 to each one. asyncuniswap4.py uses CRLF line endings, which are preserved, so its diff is two lines.

Testing

tests/units/test_async_numerical_regressions.py mirrors the #482 regressions for the async methods: low prices, reversed decimals, reciprocals for v3/v4, and positive/negative odd-tick TVL plus an even-tick control. All tests are offline with mocked contract state. On unmodified master, 21 of 28 cases fail; with this patch all 28 pass, and tests/units/ passes in full (96).

Credit for the original reports is the same as #482: YANGXIAO-LI (#269), and Xamit Kadirbekov and Daniyal Kadirbekov (GERO).

Sorry, something went wrong.

Uh oh!

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

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@TimeToBuildBob
fix(async): port price-floor and odd-tick TVL fixes to async clients
dc727af
uniswap-python#482 fixed premature integer flooring in get_raw_price (v3) and
get_token_token_spot_price (v4), and the tick // 2 boundary in
get_tvl_in_pool, but only in the sync clients. AsyncUniswap and
AsyncUniswap4 (added in uniswap-python#491) duplicate the same three expressions.

Port the identical fix and mirror the offline regression tests for the
async methods. Before the fix: 21 of 28 new cases fail; after: all pass.

Git-Session-Id: 1f5c341c-f980-49ad-8729-4af3af4f176d
@codecov

codecov Bot commented Oct 26, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.75%. Comparing base (bd4bd39) to head (17cb97d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #493      +/-   ##
==========================================
+ Coverage   70.68%   70.75%   +0.06%     
==========================================
  Files          14       14              
  Lines        4302     4302              
==========================================
+ Hits         3041     3044       +3     
+ Misses       1261     1258       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

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

@TimeToBuildBob
test(async): type the mocked client's w3 as AsyncWeb3
17cb97d
Git-Session-Id: 1f5c341c-f980-49ad-8729-4af3af4f176d
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Brings the async clients in line with the sync arithmetic fixes.

  • Async price readers keep tiny token prices instead of rounding them away.
  • Async v3 pool totals use half-step bounds for odd ticks.

No actionable issues found. Tests were inspected but not run.

Reviews (1) · Last reviewed commit: "fix(async): port price-floor and odd-tic..." · Reviewed by Greptile

All reactions

Sorry, something went wrong.

Uh oh!

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

@TimeToBuildBob

TimeToBuildBob commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

All five CI checks are green, and there are no outstanding review findings or human questions. I have pull-only access here, so merging requires a maintainer. No further code changes made.

All reactions

Sorry, something went wrong.

Uh oh!

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

@liquid-8
liquid-8 merged commit d706627 into uniswap-python:master Nov 8, 2026
5 checks passed

Uh oh!

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

@liquid-8

liquid-8 commented Nov 8, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

@TimeToBuildBob v3 tests don't pass, neither sync nor async, after the merge. Any suggestions? Note that the sync class hasn't been affected.

All reactions

Sorry, something went wrong.

Uh oh!

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

@TimeToBuildBob

TimeToBuildBob commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Looking at the failing CI run, the two failing tests are test_v3_deploy_pool_with_liquidity and test_close_position. Both fail with:

ContractLogicError: execution reverted: STF

"STF" is the Safe Transfer From revert string from Uniswap's NonfungiblePositionManager. It fires when the ERC-20 transferFrom from the test wallet is rejected — most commonly because the wallet's token balance is exhausted or the PositionManager's allowance has run out from a previous test run.

This is not caused by #493. The sync test_v3_deploy_pool_with_liquidity and test_close_position fail with the same error, and my PR only changed arithmetic in the async get_raw_price, get_token_token_spot_price, and get_tvl_in_pool methods — none of which are involved in pool deployment or position closing.

Suggested checks:

  1. Replenish the test wallet's DAI and USDC on mainnet (or whichever token the test uses).
  2. Re-approve the PositionManager contract (0xC36442b4a4522E871399CD717aBDD847Ab11FE88) for a fresh allowance.
  3. If the wallet balance is fine, check whether the pool already exists at the same tick range from a prior run — a reused tick range can cause the mint to revert.

The failing test is in tests/test_asyncuniswap.py:438 (IndexError after the STF revert) and the equivalent sync path, both pre-dating this PR's changes.

liquid-8 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.

@liquid-8 liquid-8 mentioned this pull request Nov 8, 2026
Revert "fix(async): port price-floor and odd-tick TVL fixes to async clients" #495
Closed
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.

2 participants

@TimeToBuildBob @liquid-8
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.