Repository navigation
fix(async): port price-floor and odd-tick TVL fixes to async clients - #493
Open
TimeToBuildBob wants to merge 2 commits into
Open
TimeToBuildBob wants to merge 2 commits into
TimeToBuildBob wants to merge 2 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Git-Session-Id: 1f5c341c-f980-49ad-8729-4af3af4f176d
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryBrings the async clients in line with the sync arithmetic fixes.
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 |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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 >> 192floors before decimal scaling.9.87e-6becomes9e-6,4.9e-7becomes0, and the reciprocal raisesZeroDivisionError.AsyncUniswap4.get_token_token_spot_price: the same floor.AsyncUniswap.get_tvl_in_pool:tick // 2gives wrong sqrt-price bounds for odd ticks (fee=100, tick_spacing=1).This PR applies the identical fix from #482 to each one.
asyncuniswap4.pyuses CRLF line endings, which are preserved, so its diff is two lines.Testing
tests/units/test_async_numerical_regressions.pymirrors 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, andtests/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).