Skip to content

Commit

Permalink
Clarify error message when you try to completely exit a pool (#5165)
Browse files Browse the repository at this point in the history
* Clarify error message when you try to completely exit a pool

Closes #3427

* Add changelog

(cherry picked from commit c087264)

# Conflicts:
#	CHANGELOG.md
#	x/gamm/pool-models/internal/cfmm_common/lp.go
  • Loading branch information
ValarDragon authored and mergify[bot] committed May 12, 2023
1 parent c38bd33 commit aa71ecd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

* [#5129](https://github.com/osmosis-labs/osmosis/pull/5129) Relax twap record validation in init genesis to allow one of the spot prices to be non-zero when twap error is observed.
<<<<<<< HEAD
=======
* [#5165](https://github.com/osmosis-labs/osmosis/pull/5165) Improve error message when fully exiting from a pool.

### API breaks

* [#4336](https://github.com/osmosis-labs/osmosis/pull/4336) Move epochs module into its own go.mod
* [#4658](https://github.com/osmosis-labs/osmosis/pull/4658) Deprecate x/gamm Pool query. The new one is located in x/poolmanager.
* [#4682](https://github.com/osmosis-labs/osmosis/pull/4682) Deprecate x/gamm SpotPrice v2 query. The new one is located in x/poolmanager.
* [#4801](https://github.com/osmosis-labs/osmosis/pull/4801) remove GetTotalShares, GetTotalLiquidity and GetExitFee from PoolI. Define all on CFMMPoolI, define GetTotalLiquidity on PoolModuleI only.
* [#4868](https://github.com/osmosis-labs/osmosis/pull/4868) Remove wasmEnabledProposals []wasm.ProposalType from NewOsmosisApp
* [#4983](https://github.com/osmosis-labs/osmosis/pull/4983) Consume a gas when creating a new token using tokenfactory as a spam deterrence mechanism.
* [#4951](https://github.com/osmosis-labs/osmosis/pull/4951) Implement pool liquidity query in pool manager, deprecate the one in gamm

>>>>>>> c0872643 (Clarify error message when you try to completely exit a pool (#5165))
## v15.1.0

Expand Down
6 changes: 5 additions & 1 deletion x/gamm/pool-models/internal/cfmm_common/lp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ import (
"github.com/osmosis-labs/osmosis/v15/x/gamm/types"
)

const errMsgFormatSharesLargerThanMax = "%s resulted shares is larger than the max amount of %s"
const errMsgFormatSharesLargerThanMax = "cannot exit all shares in a pool. Attempted to exit %s shares, max allowed is %s"

// CalcExitPool returns how many tokens should come out, when exiting k LP shares against a "standard" CFMM
func CalcExitPool(ctx sdk.Context, pool types.CFMMPoolI, exitingShares sdk.Int, exitFee sdk.Dec) (sdk.Coins, error) {
totalShares := pool.GetTotalShares()
if exitingShares.GTE(totalShares) {
<<<<<<< HEAD
return sdk.Coins{}, sdkerrors.Wrapf(types.ErrLimitMaxAmount, errMsgFormatSharesLargerThanMax, exitingShares, totalShares)
=======
return sdk.Coins{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, errMsgFormatSharesLargerThanMax, exitingShares, totalShares.Sub(sdk.OneInt()))
>>>>>>> c0872643 (Clarify error message when you try to completely exit a pool (#5165))
}

// refundedShares = exitingShares * (1 - exit fee)
Expand Down

0 comments on commit aa71ecd

Please sign in to comment.