-
Notifications
You must be signed in to change notification settings - Fork 609
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
feat(x/poolmanager): split routes swap message #4886
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits, but overall looks good from a quick scan
Co-authored-by: Jon Ator <jonathanator0@gmail.com>
Co-authored-by: Jon Ator <jonathanator0@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job on this, clear and well tested
TokenInAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), | ||
} | ||
|
||
priceImpactThreshold = sdk.NewInt(97866545) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining where this number comes from? It made sense after I read through the tests, but would be nice to have the context prior to then
"valid solo route multi hop": { | ||
routes: []types.SwapAmountInSplitRoute{defaultSingleRouteTwoHops}, | ||
tokenInDenom: foo, | ||
tokenOutMinAmount: sdk.OneInt(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asking for my own learning, what is significant about one here? Can this not be 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can, just small value that we know well not trigger the price impact protection
Co-authored-by: Adam Tucker <adam@osmosis.team>
…sis into roman/split-routes-msg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com>
Closes: #4869
What is the purpose of the change
Implementing new swap message for split routes.
Each route can be thought of as a separate multi-hop swap.
Splitting swaps across multiple pools for the same token pair can be beneficial for several reasons,
primarily relating to reduced slippage, price impact, and potentially lower fees.
Here's a detailed explanation of these advantages:
Reduced slippage: When a large trade is executed in a single pool, it can be significantly affected if someone else executes a large swap against that pool.
Lower price impact: when executing a large trade in a single pool, the price impact can be substantial, leading to a less favorable exchange rate for the trader.
By splitting the swap across multiple pools, the price impact in each pool is minimized, resulting in a better overall exchange rate.
Improved liquidity utilization: Different pools may have varying levels of liquidity, fees, and price curves. By splitting swaps across multiple pools,
the router can utilize liquidity from various sources, allowing for more efficient execution of trades. This is particularly useful when the liquidity in
a single pool is not sufficient to handle a large trade or when the price curve of one pool becomes less favorable as the trade size increases.
Potentially lower fees: In some cases, splitting swaps across multiple pools may result in lower overall fees. This can happen when different pools
have different fee structures, or when the total fee paid across multiple pools is lower than the fee for executing the entire trade in a single pool with
higher slippage.
Note, that the actual split happens off-chain. The router is only responsible for executing the swaps in the order and quantities of token in provided
by the routes.
Brief Changelog
Testing and Verifying
This change is a trivial rework / code cleanup without any test coverage.
TODO
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? TBD