Skip to content

fix(async): port price-floor and odd-tick TVL fixes to async clients - #493

Open
TimeToBuildBob wants to merge 2 commits into
uniswap-python:masterfrom
TimeToBuildBob:fix/async-price-floor-odd-tick
Open

TimeToBuildBob wants to merge 2 commits into
uniswap-python:masterfrom
TimeToBuildBob:fix/async-price-floor-odd-tick

Conversation

@TimeToBuildBob

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).

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 •

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.

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

greptile-apps Bot commented Oct 26, 2026 •

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

@TimeToBuildBob

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant