-
Notifications
You must be signed in to change notification settings - Fork 13
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 | Implement InGivenOut APIs for CL pool #604
Changes from 1 commit
1a9279f
acf6e4e
69d18a4
d254c1b
fa7aef9
f2088a2
39d0d3a
fb3dbab
0213a9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -257,7 +257,7 @@ | |||||||||||||||||||||||||||||||
currentSqrtPrice = concentratedPool.GetCurrentSqrtPrice() | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
amountRemainingOut = tokenOut.Amount.ToLegacyDec() | ||||||||||||||||||||||||||||||||
amountInTotal = osmomath.ZeroDec() | ||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if currentSqrtPrice.IsZero() { | ||||||||||||||||||||||||||||||||
|
@@ -328,17 +328,18 @@ | |||||||||||||||||||||||||||||||
return fmt.Sprintf("pool (%d), pool type (%d), pool denoms (%v), token out (%s)", concentratedPool.Id, poolmanagertypes.Concentrated, concentratedPool.GetPoolDenoms(sdk.Context{}), r.TokenOutDenom) | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
// ChargeTakerFee implements domain.RoutablePool. | ||||||||||||||||||||||||||||||||
// ChargeTakerFeeExactIn implements domain.RoutablePool. | ||||||||||||||||||||||||||||||||
// Charges the taker fee for the given token in and returns the token in after the fee has been charged. | ||||||||||||||||||||||||||||||||
func (r *routableConcentratedPoolImpl) ChargeTakerFeeExactIn(tokenIn sdk.Coin) (tokenInAfterFee sdk.Coin) { | ||||||||||||||||||||||||||||||||
tokenInAfterTakerFee, _ := poolmanager.CalcTakerFeeExactIn(tokenIn, r.GetTakerFee()) | ||||||||||||||||||||||||||||||||
return tokenInAfterTakerFee | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
// ChargeTakerFee implements domain.RoutablePool. | ||||||||||||||||||||||||||||||||
// ChargeTakerFeeExactOut implements domain.RoutablePool. | ||||||||||||||||||||||||||||||||
// Charges the taker fee for the given token out and returns the token out after the fee has been charged. | ||||||||||||||||||||||||||||||||
func (r *routableConcentratedPoolImpl) ChargeTakerFeeExactOut(tokenOut sdk.Coin) (tokenOutAfterFee sdk.Coin) { | ||||||||||||||||||||||||||||||||
return sdk.Coin{} | ||||||||||||||||||||||||||||||||
tokenOutAfterTakerFee, _ := poolmanager.CalcTakerFeeExactOut(tokenOut, r.GetTakerFee()) | ||||||||||||||||||||||||||||||||
return tokenOutAfterTakerFee | ||||||||||||||||||||||||||||||||
Comment on lines
+340
to
+344
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle potential errors returned by Similarly, in Apply this diff to handle the error: func (r *routableConcentratedPoolImpl) ChargeTakerFeeExactOut(tokenOut sdk.Coin) (tokenOutAfterFee sdk.Coin, err error) {
- tokenOutAfterTakerFee, _ := poolmanager.CalcTakerFeeExactOut(tokenOut, r.GetTakerFee())
+ tokenOutAfterTakerFee, err := poolmanager.CalcTakerFeeExactOut(tokenOut, r.GetTakerFee())
+ if err != nil {
+ return sdk.Coin{}, err
+ }
return tokenOutAfterTakerFee, nil
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
// SetTokenInDenom implements domain.RoutablePool. | ||||||||||||||||||||||||||||||||
|
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.
Handle potential errors returned by
CalcTakerFeeExactIn
.In
ChargeTakerFeeExactIn
, the error returned byCalcTakerFeeExactIn
is being ignored. Ignoring errors can lead to unintended consequences or silent failures. Consider handling the error to ensure robust error management.Apply this diff to handle the error:
📝 Committable suggestion