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

BE-676 | Add SwapOutGivenInCases for CL pool #8954

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

deividaspetraitis
Copy link
Contributor

@deividaspetraitis deividaspetraitis commented Jan 22, 2025

Closes: BE-676

What is the purpose of the change

This PR adds swap in given out test cases for CL pools and is part of osmosis-labs/sqs#604.

Testing and Verifying

This change is a trivial rework / code cleanup without any test coverage.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

@deividaspetraitis deividaspetraitis self-assigned this Jan 22, 2025
@github-actions github-actions bot added the C:app-wiring Changes to the app folder label Jan 22, 2025
@deividaspetraitis
Copy link
Contributor Author

Note for reviewer: pipeline seems to be failing due Error: This request has been automatically failed because it uses a deprecated version of actions/upload-artifact: v3. Learn more: https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/ error, should I solve this first or there is a fix already availble? I was trying to sync my branch but with no luck.

@PaddyMc PaddyMc closed this Jan 23, 2025
@PaddyMc PaddyMc reopened this Jan 23, 2025
Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

The pull request introduces a comprehensive set of test cases for concentrated liquidity swaps in the app/apptesting/concentrated_liquidity.go file. The new SwapInGivenOutCases map defines multiple test scenarios for swapping tokens with given output amounts. These test cases cover various swap conditions, including single and multiple position swaps between different tokens like ETH and USDC, with detailed specifications for price ranges, spread factors, and expected outputs.

Changes

File Change Summary
app/apptesting/concentrated_liquidity.go Added SwapInGivenOutCases map with multiple concentrated liquidity swap test scenarios, including single and multi-position swap tests for ETH and USDC

Sequence Diagram

sequenceDiagram
    participant Swap as Swap Mechanism
    participant Position1 as Liquidity Position 1
    participant Position2 as Liquidity Position 2
    participant TokenIn as Input Token
    participant TokenOut as Output Token

    TokenIn ->> Swap: Swap Request (Given Output Amount)
    Swap ->> Position1: Check Liquidity
    Swap ->> Position2: Check Liquidity
    Position1 -->> Swap: Liquidity Details
    Position2 -->> Swap: Liquidity Details
    Swap ->> TokenOut: Transfer Output Amount
    Swap ->> TokenIn: Receive Input Amount
Loading

The sequence diagram illustrates the high-level flow of the concentrated liquidity swap mechanism, showing how the swap is processed across multiple potential liquidity positions when a swap is initiated with a given output amount.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

🧹 Nitpick comments (1)
app/apptesting/concentrated_liquidity.go (1)

804-832: Consider adding high-level behavioral expectations.

While the test case includes detailed Python calculations, it would be helpful to add a brief comment explaining the expected behavior and why these specific values were chosen.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fcdeeb and 6bb88cc.

📒 Files selected for processing (1)
  • app/apptesting/concentrated_liquidity.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (4)
app/apptesting/concentrated_liquidity.go (4)

798-804: LGTM! Well-organized test cases with clear structure.

The test cases are logically organized and cover various scenarios, starting from simple single position cases to complex overlapping ranges.


1046-1052: Great use of ASCII art for visualizing price ranges!

The ASCII art diagrams effectively communicate the price range relationships between positions, making it easier to understand the test scenarios.


1378-1403: Well-documented edge case for slippage protection.

The test case clearly documents the behavior when slippage protection interrupts the trade early, which is an important edge case to test.


Line range hint 1405-1781: LGTM! Existing helper functions remain unchanged.

The helper functions provide comprehensive utilities for testing concentrated liquidity pools.

@PaddyMc PaddyMc added the V:state/compatible/no_backport State machine compatible PR, depends on prior breaks label Jan 24, 2025
@deividaspetraitis deividaspetraitis requested a review from a team as a code owner January 24, 2025 10:55
@github-actions github-actions bot added the T:CI label Jan 24, 2025
Copy link
Contributor

@alessandrolomanto alessandrolomanto left a comment

Choose a reason for hiding this comment

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

+1 for the github actions

@deividaspetraitis
Copy link
Contributor Author

Note that we are merging to main branch, but in SQS we're importing v28.x, I think should we backport?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder T:CI V:state/compatible/no_backport State machine compatible PR, depends on prior breaks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants