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

fix: split in-given-out amounts #4028

Open
wants to merge 1 commit into
base: stage
Choose a base branch
from
Open

Conversation

crnbarr93
Copy link
Contributor

@crnbarr93 crnbarr93 commented Jan 7, 2025

What is the purpose of the change:

These changes fix an issue with split routes for in-given-out message generation.

Linear Task

FE-1287

Brief Changelog

  • Initial amount for splits uses out_amount instead of in_amount

Testing and Verifying

Tested a split route for UM to JUNO

Custom
type: osmosis/poolmanager/split-amount-out
value:
  routes:
    - pools:
        - pool_id: '2281'
          token_in_denom: ibc/0FA9232B262B89E77D1335D54FB1E1F506A92A7E4B51524B400DC69C68D28372
        - pool_id: '497'
          token_in_denom: uosmo
      token_out_amount: '135000000'
    - pools:
        - pool_id: '1964'
          token_in_denom: ibc/0FA9232B262B89E77D1335D54FB1E1F506A92A7E4B51524B400DC69C68D28372
        - pool_id: '1464'
          token_in_denom: ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4
        - pool_id: '1097'
          token_in_denom: uosmo
      token_out_amount: '15000000'
  sender:*
  token_in_max_amount: '33856457'
  token_out_denom: ibc/46B44899322F3CD854D2D46DEEF881958467CDD4B3B10086DA49296BBED94BED
image

@crnbarr93 crnbarr93 requested a review from a team January 7, 2025 19:05
Copy link

vercel bot commented Jan 7, 2025

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 Jan 7, 2025 7:06pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Jan 7, 2025 7:06pm
osmosis-frontend-dev ⬜️ Ignored (Inspect) Jan 7, 2025 7:06pm
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Jan 7, 2025 7:06pm
osmosis-testnet ⬜️ Ignored (Inspect) Jan 7, 2025 7:06pm

Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/server/src/queries/sidecar/router.ts

Oops! 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/server/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

The pull request modifies the routeByTokenOut method in the OsmosisSidecarRemoteRouter class within the server's sidecar router. The key change involves switching the amount reference from input (in_amount) to output (out_amount) when mapping routes. This adjustment impacts how token routing is processed, specifically altering how token input denominations are mapped and handled during the routing calculation.

Changes

File Change Summary
packages/server/src/queries/sidecar/router.ts Updated routeByTokenOut method to use out_amount instead of in_amount when mapping routes. Reversed and modified tokenInDenoms mapping to align with new data structure.

Suggested reviewers

  • DavideSegullo

Possibly related PRs

Note: No sequence diagram was generated as the changes are primarily focused on internal routing logic modifications without a significant change in overall interaction flow.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7b03c95 and c7a268a.

📒 Files selected for processing (1)
  • packages/server/src/queries/sidecar/router.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: preview-portfolio-trx-tests
  • GitHub Check: preview-pools-and-select-pair-tests
  • GitHub Check: preview-claim-tests
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Summary
🔇 Additional comments (3)
packages/server/src/queries/sidecar/router.ts (3)

141-142: LGTM! Using out_amount for split routes is correct.

The change from in_amount to out_amount aligns with the PR objective to fix split route messages in in-given-out transactions.


Line range hint 143-150: LGTM! Reversing pools and token denominations maintains correct routing order.

The reversal of pools and token denominations is correct for token-out routing, as it ensures the route is properly ordered from input to output token when working backwards from the desired output amount.


Line range hint 141-150: Verify alignment with sidecar API documentation.

While the changes look correct, let's verify they align with the sidecar API documentation.

✅ Verification successful

Changes correctly align with sidecar API structure

The use of out_amount is consistent with both the sidecar API types and the underlying protocol structures. The mapping maintains the expected route format while preserving the reverse order of pools for proper processing.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check sidecar API documentation for route structure
# Looking for mentions of in_amount vs out_amount in routes

# Search for route structure documentation in markdown files
rg -A 5 "route.*structure|split.*route" --type md

# Search for amount fields in route-related code
ast-grep --pattern 'route.*amount|amount.*route'

Length of output: 102


Script:

#!/bin/bash
# Search for API-related files and route types
fd -e ts -e md . | grep -i "api\|route\|sidecar"

# Search for route-related type definitions and interfaces
ast-grep --pattern 'interface $_ {
  $$$
  amount
  $$$
}'

# Search for route-related test files
rg -l "test.*route" --type ts

# Look for actual usage of out_amount
rg "out_amount" --type ts -C 2

Length of output: 43774


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.

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