Skip to content

Commit

Permalink
Minor typo fixes / switching to direct sdk methods (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored Apr 5, 2021
1 parent 295d3ed commit 7a6c81f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion x/gamm/keeper/pool_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (k Keeper) CreatePool(
records []types.Record,
) (uint64, error) {
if len(records) < 2 {
return 0, types.ErrTooLittleRecords
return 0, types.ErrTooFewRecords
}
// TODO: Add the limit of binding token to the pool params?
if len(records) > 8 {
Expand Down
10 changes: 5 additions & 5 deletions x/gamm/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ func NewPoolAccount(poolId uint64, poolParams PoolParams) PoolAccountI {
}

func (params PoolParams) Validate() error {
if params.ExitFee.LT(sdk.NewDec(0)) {
if params.ExitFee.IsNegative() {
return ErrNegativeExitFee
}

if params.ExitFee.GTE(sdk.NewDec(1)) {
if params.ExitFee.GTE(sdk.OneDec()) {
return ErrTooMuchExitFee
}

if params.SwapFee.LT(sdk.NewDec(0)) {
if params.SwapFee.IsNegative() {
return ErrNegativeSwapFee
}

if params.SwapFee.GTE(sdk.NewDec(1)) {
if params.SwapFee.GTE(sdk.OneDec()) {
return ErrTooMuchSwapFee
}

Expand Down Expand Up @@ -174,7 +174,7 @@ func (pa PoolAccount) GetRecord(denom string) (Record, error) {
recordA := pa.Records[i]

compare := strings.Compare(recordA.Token.Denom, denom)
return compare == 1 || compare == 0
return compare >= 0
})

if i < 0 || i >= len(pa.Records) {
Expand Down
2 changes: 1 addition & 1 deletion x/gamm/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var (
ErrPoolNotFound = sdkerrors.Register(ModuleName, 1, "pool not found")
ErrPoolAlreadyExist = sdkerrors.Register(ModuleName, 2, "pool already exist")
ErrPoolLocked = sdkerrors.Register(ModuleName, 3, "pool is locked")
ErrTooLittleRecords = sdkerrors.Register(ModuleName, 4, "pool should have at least 2 records")
ErrTooFewRecords = sdkerrors.Register(ModuleName, 4, "pool should have at least 2 records, as they must be swapping between at least two assets")
ErrTooManyRecords = sdkerrors.Register(ModuleName, 5, "pool has too many records")
ErrLimitMaxAmount = sdkerrors.Register(ModuleName, 6, "calculated amount is larger than max amount")
ErrLimitMinAmount = sdkerrors.Register(ModuleName, 7, "calculated amount is lesser than min amount")
Expand Down
11 changes: 4 additions & 7 deletions x/gamm/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ func (msg MsgCreatePool) ValidateBasic() error {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
}

if len(msg.Records) == 0 {
return ErrEmptyRecords
}

if len(msg.Records) == 1 {
return ErrTooLittleRecords
// The pool must be swapping between at least two assets
if len(msg.Records) < 2 {
return ErrTooFewRecords
}

// TODO: Add the limit of binding token to the pool params?
Expand All @@ -52,7 +49,7 @@ func (msg MsgCreatePool) ValidateBasic() error {
}

if msg.PoolParams.Lock {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "can't create the locked pool")
return sdkerrors.Wrap(sdkerrors.ErrLogic, "can't create a locked pool")
}

err = msg.PoolParams.Validate()
Expand Down

0 comments on commit 7a6c81f

Please sign in to comment.