Skip to content
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: allow the duplicate symbols on leverage token registry #2197

Merged
merged 6 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ Ref: https://keepachangelog.com/en/1.0.0/

- [2134](https://github.com/umee-network/umee/pull/2134) Bump CometBFT to 34.29.

### State Machine Breaking

- [2197](https://github.com/umee-network/umee/pull/2197) Allowing duplicate symbols on leverage token registry. Fix the oracle voting miss counter on duplicate symbol denoms.

### Bug Fixes

- [2148](https://github.com/umee-network/umee/pull/2148) Fix MsgBeginUnbonding counting existing unbondings against max unbond twice.
- [2148](https://github.com/umee-network/umee/pull/2148) Fix MsgLeverageLiquidate CLI not actually allowing wildcard denoms.
- [2197](https://github.com/umee-network/umee/pull/2197) Allowing duplicate symbols on leverage token registry. Fix the oracle voting miss counter on duplicate symbol denoms.
gsk967 marked this conversation as resolved.
Show resolved Hide resolved

### API Breaking

Expand Down
20 changes: 13 additions & 7 deletions x/leverage/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ func (s *IntegrationTestSuite) TestAddTokensToRegistry() {
// new token with existed symbol denom
ntB := fixtures.Token("untb", "ABCD", 6)
testCases := []struct {
name string
req *types.MsgGovUpdateRegistry
expectErr bool
errMsg string
name string
req *types.MsgGovUpdateRegistry
expectErr bool
errMsg string
noOfRecords int
}{
{
"invalid token data",
Expand All @@ -36,6 +37,7 @@ func (s *IntegrationTestSuite) TestAddTokensToRegistry() {
},
true,
"invalid denom",
0,
}, {
"no authority address",
&types.MsgGovUpdateRegistry{
Expand All @@ -48,6 +50,7 @@ func (s *IntegrationTestSuite) TestAddTokensToRegistry() {
},
true,
"empty address",
0,
}, {
"already registered token",
&types.MsgGovUpdateRegistry{
Expand All @@ -60,6 +63,7 @@ func (s *IntegrationTestSuite) TestAddTokensToRegistry() {
},
true,
fmt.Sprintf("token %s is already registered", registeredUmee.BaseDenom),
0,
}, {
"valid authority and valid token for registry",
&types.MsgGovUpdateRegistry{
Expand All @@ -72,6 +76,7 @@ func (s *IntegrationTestSuite) TestAddTokensToRegistry() {
},
false,
"",
7,
}, {
"regisering new token with existed symbol denom",
&types.MsgGovUpdateRegistry{
Expand All @@ -82,8 +87,9 @@ func (s *IntegrationTestSuite) TestAddTokensToRegistry() {
ntB,
},
},
true,
fmt.Sprintf("symbol denom %s is already registered", ntB.SymbolDenom),
false,
"",
8,
},
}

Expand All @@ -99,7 +105,7 @@ func (s *IntegrationTestSuite) TestAddTokensToRegistry() {
s.Require().NoError(err)
// no tokens should have been deleted
tokens := s.app.LeverageKeeper.GetAllRegisteredTokens(s.ctx)
s.Require().Len(tokens, 7)
s.Require().Len(tokens, tc.noOfRecords)

token, err := s.app.LeverageKeeper.GetTokenSettings(s.ctx, ntA.BaseDenom)
s.Require().NoError(err)
Expand Down
4 changes: 1 addition & 3 deletions x/leverage/keeper/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ func (k Keeper) UpdateTokenRegistry(
regSymbols[strings.ToUpper(regDenoms[i].SymbolDenom)] = true
}
for _, token := range toAdd {
// Note: we are allowing duplicate symbols (Kava USDT, axelar USDT both have same USDT symbol )
if _, ok := regDenoms[token.BaseDenom]; ok {
return types.ErrDuplicateToken.Wrapf("token %s is already registered", token.BaseDenom)
}
if _, ok := regSymbols[strings.ToUpper(token.SymbolDenom)]; ok {
return types.ErrDuplicateToken.Wrapf("symbol denom %s is already registered", token.SymbolDenom)
}
if err := k.SetTokenSettings(ctx, token); err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions x/oracle/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ func CalcPrices(ctx sdk.Context, params types.Params, k keeper.Keeper) error {
}

// voteTargets defines the symbol (ticker) denoms that we require votes on
voteTargets := make([]string, 0)
voteTargets := make(map[string]bool, 0)
voteTargetDenoms := make([]string, 0)
for _, v := range params.AcceptList {
voteTargets = append(voteTargets, v.SymbolDenom)
voteTargets[v.SymbolDenom] = true // unique symbol denoms <Note: we are allowing duplicate symbol denoms>
gsk967 marked this conversation as resolved.
Show resolved Hide resolved
voteTargetDenoms = append(voteTargetDenoms, v.BaseDenom)
}

k.ClearExchangeRates(ctx)

// NOTE: it filters out inactive or jailed validators
// ballotDenomSlice is oracle votes of the symbol denoms, those are stored by AggregateExchangeRateVote
ballotDenomSlice := k.OrganizeBallotByDenom(ctx, validatorClaimMap)
threshold := k.VoteThreshold(ctx).MulInt64(types.MaxVoteThresholdMultiplier).TruncateInt64()

Expand Down
Loading