-
Notifications
You must be signed in to change notification settings - Fork 593
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: Remove balance check from EstimateSwap #2764
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.
Reviewed all of the wasmbinding and proto changes, looks great to me! Reviewing keeper logic now
(Had a call to rename the internal |
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
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.
Left some comments, main thing is changing the multi-hop logic to match the new design here #3352
Also, unclear what is going on with the proto gen CI check
if swap == nil { | ||
return nil, wasmvmtypes.InvalidRequest{Err: "gamm perform swap null swap"} | ||
} | ||
if swap.Amount.ExactIn != nil { |
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.
Shouldn't we double check swap.Amount.ExactIn != nil && swap.Amount.ExactOut == nil
here?
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.
Why do you think that's the case? AFAIU, i think swap.Amount.ExactIn != nil && swap.Amount.ExactOut == nil
can be a possible scenario, for example, when a pool is 1:1 ratio(10 uosmo, 10 uatom), you could be expecting 1 in 1out or similar
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.
Right, not only CAN it be a possible scenario, it should be the only scenario for the one sided argument. What I am trying to prevent here is if someone provides a SwapMsg with both a swap.Amount.ExactIn and swap.Amount.ExactOut, with this current code instead of erroring they would go through the first for loop. EstimatePerformSwap should only return a valid response if one side is given, not both sides
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.
AFAIU, we should never call an estimate method with both the in and the out. We either give it the in to calculate the out or we give it the out to calculate the in
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 still feel this is the case
Wait, but wouldn't it be as simple as adding a "useCacheCtx" boolean here osmosis/x/gamm/keeper/multihop.go Lines 13 to 19 in bef8a4b
|
@czarcas7ic I actaully think that's a great idea. Removed the whole file of estimate swap in my last commit and changed the existing swap methods to have a boolean filed for the estimate swaps. I think this requires detailed, in-depth review as it touches the core swap logic |
@mattverse will review in depth tomorrow! |
Is this v13 blocking? |
NVM, I see that we went with the code duplication approach for safety here: #3424 |
@mattverse should we close this PR, and re-PR with elements you want added in still? |
Closing per last comment |
Closes: #2337
What is the purpose of the change
EstimateSwap currently checks the balance of the query sender, not because it actually moves the assets on an actual swap, but beacuse it uses the same API with the actual multi swaps that happen.
This PR separates out the API needed for the estimation so that it does not check balance of the query sender.
(Special thanks to @vuong177 the original author of this PR!)
Brief Changelog
EstimateSwap
Testing and Verifying
This change added tests.
Documentation and Release Note
Unreleased
section inCHANGELOG.mxd
? yesx/<module>/spec/
) / Osmosis docs repo / not documented)