-
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(ProtoRev): Supporting Two Pool Routes #5953
Conversation
@@ -902,6 +903,91 @@ func (s *KeeperTestSuite) setUpPools() { | |||
// Pool 50 | |||
s.PrepareCosmWasmPool() | |||
|
|||
// Create a duplicate pool for testing |
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 we add in the comment what test these pools are for
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 after supporting both directions
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
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.
just have a question to understand this logic more before approving
x/protorev/keeper/routes.go
Outdated
func (k Keeper) BuildTwoPoolRoute( | ||
ctx sdk.Context, | ||
baseDenom types.BaseDenom, | ||
swapIn, swapOut string, |
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.
nit: or SwapInDenom, SwapOutDenom
swapIn, swapOut string, | |
tokenInDenom, tokenOutDenom string, |
hasRoute: true, | ||
}, | ||
{ | ||
description: "two pool route where swap is on the highest liquidity pool", |
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.
i'm trying to understand this: if SwapDenom == tokenOutDenom & huge swap occours in highest liquidity pool, isn't base denom being cheaper so you would create a route to balance it?
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.
just to make sure i understand the scenario:
if BaseDenom
== tokenOutDenom
, base denom becomes more expensive as the token supply of baseDenom
in that pool decreases. i.e. if x == tokenInDenom and y == tokenOutDenom, then x + deltaX / y - deltaY > x / y. in this case, tokenOut is y which means it is more expensive and hence we can get more of X on the current pool than the other pool. We should then find the highest liquidity pool with the same assets and route through that. if the swap occurred on the highest liquidity pool, then we cannot make a route.
@NotJeremyLiu @davidterpay getting the same protorev e2e failure after two runs. Any way you can take a look into this? |
It looks like its failing a CL test swap. I'll see if I can replicate the same issue and resolve it locally. Will ping once I find the issue (likely tmw morning EST). |
devbot merge base |
We think the issue may be arising because of the two pool routing as the swap in the CL test does create some arbitrage that the module is confirmed to capture. This might be messing with the calculations done in the test case. There are a few approaches for this:
|
Lines 330 to 332 in 92e2979
Added this for the time being. |
Do you think we can instead remove the route from protorev in the protorev test itself? It doesn't seem scalable if we have another test that relies on calculating the output of the pools to check if protorev is disabled. Also, since everything is concurrent, there could be a scenario in which
|
@czarcas7ic set the max pool points such that it will always pass on the ProtoRev test and will never execute a backrun in the CL test. Should always pass now even if the tests execute in parallel. |
* testing * changelog * trading both ways * updating test * nit * test fix * protorev test update * Update tests/e2e/configurer/chain/commands.go --------- Co-authored-by: devbot-wizard <141283918+devbot-wizard@users.noreply.github.com> Co-authored-by: Adam Tucker <adam@osmosis.team>
* testing * changelog * trading both ways * updating test * nit * test fix * protorev test update * Update tests/e2e/configurer/chain/commands.go --------- Co-authored-by: devbot-wizard <141283918+devbot-wizard@users.noreply.github.com> Co-authored-by: Adam Tucker <adam@osmosis.team>
What is the purpose of the change
This PR updates the route building logic of
ProtoRev
to be able to construct two pool arbitrage routes. This is particularly useful when there are multiple pools of that consist of the same assets and are imbalanced. As before, routes will only be constructed using the base denoms.Testing and Verifying
Documentation and Release Note
This PR is a part of the open issue for
ProtoRev
updates for V17 (#5858)