Skip to content

Commit

Permalink
fix: allow the duplicate symbols on leverage token registry (#2197)
Browse files Browse the repository at this point in the history
* WIP: allow the duplicate symbols on leverage token registry

* fix the miss counter for duplicate symbol denoms

* +

* update the changelog and add comments about oracle votes on abci

* update the changelog
  • Loading branch information
gsk967 committed Aug 19, 2023
1 parent e4ef22a commit b2fe120
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
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.

### 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>
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

0 comments on commit b2fe120

Please sign in to comment.