Skip to content

Commit 9245b5f

Browse files
authored
Normalize ticker to uppercase in x/listing and make existence-checking case-insensitive in x/prices (#3330)
1 parent 84d4664 commit 9245b5f

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

protocol/x/listing/keeper/listing.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"math"
66
"math/big"
7+
"strings"
78

89
"github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager"
910
"github.com/dydxprotocol/v4-chain/protocol/lib/slinky"
@@ -43,6 +44,7 @@ func (k Keeper) CreateMarket(
4344
ctx sdk.Context,
4445
ticker string,
4546
) (marketId uint32, err error) {
47+
ticker = strings.ToUpper(ticker)
4648
marketId = k.PricesKeeper.AcquireNextMarketID(ctx)
4749

4850
// Get market details from marketmap

protocol/x/prices/keeper/market.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package keeper
22

33
import (
44
"fmt"
5+
"strings"
56

67
gogotypes "github.com/cosmos/gogoproto/types"
78

@@ -41,7 +42,7 @@ func (k Keeper) CreateMarket(
4142
}
4243
// Stateful Validation
4344
for _, market := range k.GetAllMarketParams(ctx) {
44-
if market.Pair == marketParam.Pair {
45+
if strings.EqualFold(market.Pair, marketParam.Pair) {
4546
return types.MarketParam{}, errorsmod.Wrap(
4647
types.ErrMarketParamPairAlreadyExists,
4748
marketParam.Pair,

protocol/x/prices/keeper/market_param.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package keeper
22

33
import (
44
"sort"
5+
"strings"
56

67
errorsmod "cosmossdk.io/errors"
78
"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/metrics"
@@ -41,7 +42,7 @@ func (k Keeper) ModifyMarketParam(
4142

4243
// Validate update is permitted.
4344
for _, market := range k.GetAllMarketParams(ctx) {
44-
if market.Pair == updatedMarketParam.Pair && market.Id != updatedMarketParam.Id {
45+
if strings.EqualFold(market.Pair, updatedMarketParam.Pair) && market.Id != updatedMarketParam.Id {
4546
return types.MarketParam{}, errorsmod.Wrap(types.ErrMarketParamPairAlreadyExists, updatedMarketParam.Pair)
4647
}
4748
}

0 commit comments

Comments
 (0)