Skip to content
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

Reduce excess CL position queries #3291

Merged
merged 3 commits into from
Jun 11, 2024
Merged

Reduce excess CL position queries #3291

merged 3 commits into from
Jun 11, 2024

Conversation

jonator
Copy link
Member

@jonator jonator commented Jun 4, 2024

What is the purpose of the change:

Linear Task

Linear Task URL

Brief Changelog

Testing and Verifying

Copy link

vercel bot commented Jun 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
osmosis-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2024 9:08pm
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Visit Preview Jun 4, 2024 9:08pm
osmosis-frontend-dev ⬜️ Ignored (Inspect) Visit Preview Jun 4, 2024 9:08pm
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Jun 4, 2024 9:08pm
osmosis-testnet ⬜️ Ignored (Inspect) Visit Preview Jun 4, 2024 9:08pm

Copy link
Contributor

coderabbitai bot commented Jun 4, 2024

Walkthrough

The recent updates focus on improving the handling of liquidity positions across various components and APIs. Key changes include the restructuring of how position data is queried and calculated, shifting data sources from local to edge, and refining component properties. These modifications aim to enhance performance and streamline data management in the application.

Changes

File Path Change Summary
packages/server/src/queries/complex/concentrated-liquidity/index.ts Restructured getPositionHistoricalPerformance function and replaced stakeCurrencyPromise with stakeCurrency.
packages/trpc/src/concentrated-liquidity.ts Added LiquidityPositionSchema and updated functions to accept new position identification types.
packages/web/components/cards/my-position/index.tsx Destructured position object from props and adjusted how positionId is accessed in queries.
packages/web/components/cards/my-position/expanded.tsx Updated data source for SuperfluidPositionInfo component from local to edge.
packages/web/components/complex/my-positions-section.tsx Switched getUserPositions function call from api.local to api.edge.
packages/web/components/complex/portfolio-page.tsx Updated useUserPositionsData function to use api.edge for getUserPositions function call.
packages/web/components/pool-detail/concentrated.tsx Changed getUserPositions function call from api.local to api.edge.
packages/web/server/api/edge-router.ts Added concentratedLiquidityRouter to the edgeRouter configuration.
packages/web/server/api/root-router.ts Removed concentratedLiquidityRouter from the localRouter creation.
packages/web/stores/index.tsx Updated references to concentratedLiquidity functions from local to edge within invalidateQueryData function.

Poem

In fields of code where data flows,
The edge now leads where local slows.
With queries swift and logic clean,
Our liquidity shines with a brighter sheen.
As rabbits leap through lines so tight,
Performance blooms in digital light. 🌸


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between edd9e07 and b5660ae.

Files selected for processing (1)
  • packages/web/components/cards/my-position/index.tsx (2 hunks)
Additional context used
Biome
packages/web/components/cards/my-position/index.tsx

[error] 72-84: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.


[error] 85-94: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

Additional comments not posted (1)
packages/web/components/cards/my-position/index.tsx (1)

26-26: Update the destructuring of props to match the new API changes.

This change aligns with the PR's objective to streamline data handling by directly using the position object.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (2)
packages/web/components/cards/my-position/index.tsx (1)

Line range hint 72-84: Add keyboard event handlers for accessibility.

+ onKeyUp={handleKeyUp}

Ensure that actions triggered by mouse events also have corresponding keyboard events to support accessibility.

Also applies to: 85-94

packages/server/src/queries/complex/concentrated-liquidity/index.ts (1)

Line range hint 60-69: Replace .map().flat() with .flatMap() for better performance.

- .map(...).flat();
+ .flatMap(...);

This change simplifies the code and may improve performance by reducing the complexity of operations on arrays.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (6)
packages/web/components/complex/my-positions-section.tsx (1)

Line range hint 62-62: Remove redundant Boolean call for simplicity.

- showLinkToPool={!Boolean(forPoolId)}
+ showLinkToPool={!forPoolId}
packages/web/components/cards/my-position/index.tsx (1)

Line range hint 72-84: Add keyboard event handlers for accessibility.

+ onKeyUp={handleKeyUp}

Ensure that actions triggered by mouse events are also accessible via keyboard.

Also applies to: 85-94

packages/web/components/complex/portfolio-page.tsx (1)

Line range hint 54-54: Use optional chaining for safer and cleaner code.

- wallet?.address ?? ""
+ wallet?.address

Apply this change wherever optional chaining can replace the current logic.

Also applies to: 83-83, 156-156, 198-198

packages/web/components/cards/my-position/expanded.tsx (3)

Line range hint 151-151: Add keyboard event handlers to complement mouse events for accessibility.

+ onKeyUp={handleKeyUp}
+ onKeyDown={handleKeyDown}
+ onKeyPress={handleKeyPress}

Ensure that actions triggered by mouse clicks are also accessible via keyboard events to support accessibility best practices.


Line range hint 342-342: Remove redundant Boolean calls.

- disabled={Boolean(account?.txTypeInProgress) || !Boolean(account)}
+ disabled={account?.txTypeInProgress || !account}

The Boolean function is redundant here as the values are automatically coerced to boolean in JavaScript. Simplifying this can improve code readability.

Also applies to: 354-354, 371-371


Line range hint 307-312: Explicitly set the button type to prevent unintended form submissions.

- <button onClick={...}>
+ <button type="button" onClick={...}>

Setting the button type to 'button' prevents it from submitting a form unintentionally, which is the default behavior when placed inside a form element.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range and nitpick comments (1)
packages/web/components/cards/my-position/index.tsx (1)

Line range hint 72-84: Add keyboard accessibility to clickable elements.

+ onKeyUp={(e) => { if (e.key === 'Enter') setCollapsed(false); }}
+ onKeyUp={(e) => { if (e.key === 'Enter') setCollapsed(true); }}

According to accessibility best practices, interactive elements triggered by mouse clicks should also be operable by keyboard events. This is crucial for users who rely on keyboard navigation.

Also applies to: 85-94

const { t } = useTranslation();
const [collapsed, setCollapsed] = useState(true);
const featureFlags = useFeatureFlags();

const { data: positionPerformance } =
api.local.concentratedLiquidity.getPositionHistoricalPerformance.useQuery(
{
positionId: id,
position: position.position,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the API calls are updated to the new edge API.

- api.local.concentratedLiquidity.getPositionHistoricalPerformance.useQuery
+ api.edge.concentratedLiquidity.getPositionHistoricalPerformance.useQuery
- api.local.concentratedLiquidity.getPositionDetails.useQuery
+ api.edge.concentratedLiquidity.getPositionDetails.useQuery

The PR summary indicates a shift from local to edge API for performance optimization. These lines should reflect that change.

Also applies to: 55-55

Committable suggestion was skipped due to low confidence.

@jonator jonator merged commit d2c561f into stage Jun 11, 2024
28 checks passed
@jonator jonator deleted the reduce-cl-query branch June 11, 2024 18:15
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.

4 participants