-
Notifications
You must be signed in to change notification settings - Fork 423
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
Removes an unneeded sqrt call from CL logic #3978
Conversation
No idea if this is a bottleneck in TRPC/locally. just noticed it as I was reading through code
The latest updates on your projects. Learn more about Vercel for Git ↗︎
4 Skipped Deployments
|
WalkthroughThe changes involve a refactoring of the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant Math
Client->>Server: Request price for tick
Server->>Math: Call getTickPrice(tick)
Math->>Math: Call tickToPrice(tick)
Math-->>Server: Return price
Server->>Math: Call getDisplayPriceFromPrice(price, baseCoin, quoteCoin)
Math-->>Server: Return display price
Server-->>Client: Return display price
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
packages/math/src/pool/concentrated/tick.tsOops! Something went wrong! :( ESLint: 8.50.0 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/packages/math/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (3)packages/math/src/pool/concentrated/tick.ts (1)
The refactoring of
Let's verify the usage of this function to ensure the refactor doesn't impact behavior: ✅ Verification successfulBased on the search results, I can now generate the final response since I have enough information to verify the usage and impact of the ✅ Verified: The refactoring is safe and maintains consistent behavior The function is used consistently across the codebase in expected mathematical contexts:
The test file 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for all usages of tickToSqrtPrice to verify impact
rg "tickToSqrtPrice" --type ts -A 2
Length of output: 8699 packages/server/src/queries/complex/concentrated-liquidity/index.ts (2)
The function correctly extracts the common decimal adjustment logic, improving code maintainability by following the DRY principle.
The simplified price calculation looks good, but we should verify the implementation of the imported ✅ Verification successfulImplementation of tickToPrice is verified and maintains precision The implementation of
🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the implementation of tickToPrice function
# Expected: Should find the implementation and confirm it maintains precision
# Search for tickToPrice implementation
ast-grep --pattern 'export function tickToPrice($_) {
$$$
}'
# Search for any tests related to tickToPrice
rg -l "tickToPrice.*test"
Length of output: 92 Script: #!/bin/bash
# Let's try different approaches to locate the tickToPrice implementation
# Search for tickToPrice function with more flexible pattern
ast-grep --pattern 'tickToPrice'
# Search for files containing tickToPrice using ripgrep with context
rg -A 5 "tickToPrice"
# Find files with 'tick' and 'price' in their names
fd -t f "tick|price"
Length of output: 9707 Script: #!/bin/bash
# Let's examine the implementation and tests of tickToPrice
# Get the implementation
cat packages/math/src/pool/concentrated/tick.ts
# Get the test file
cat packages/math/src/pool/concentrated/__tests__/tick.spec.ts
Length of output: 24082 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
No idea if this is a bottleneck in TRPC/locally.
just noticed it as I was reading through code. Also deletes some duplicate logic