Skip to content

Commit

Permalink
chore: remove atom token settings from leverage registry and oracle d…
Browse files Browse the repository at this point in the history
…efault params accept list (#1918)

* fix: remove atom settings from leverage default genesis

* fix: fix the tests

* chore: remove atom from orclae default accept list
  • Loading branch information
gsk967 authored Mar 15, 2023
1 parent 04399b6 commit 079f7d6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 55 deletions.
17 changes: 6 additions & 11 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,8 @@ func (s *IntegrationTestSuite) initGenesis() {

leverageGenState.Registry = append(leverageGenState.Registry,
fixtures.Token(appparams.BondDenom, appparams.DisplayDenom, 6),
fixtures.Token(ATOM_BASE_DENOM, ATOM_SYMBOL, uint32(ATOM_EXPONENT)),
)
for index, t := range leverageGenState.Registry {
if t.BaseDenom == oracletypes.AtomDenom {
// replace atom test ibc hash for testing
leverageGenState.Registry[index].BaseDenom = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
}
}

bz, err = cdc.MarshalJSON(&leverageGenState)
s.Require().NoError(err)
Expand All @@ -287,11 +282,11 @@ func (s *IntegrationTestSuite) initGenesis() {
oracleGenState.Params.MedianStampPeriod = 20
oracleGenState.Params.MaximumMedianStamps = 2

for index, t := range oracleGenState.Params.AcceptList {
if t.BaseDenom == oracletypes.AtomDenom {
oracleGenState.Params.AcceptList[index].BaseDenom = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
}
}
oracleGenState.Params.AcceptList = append(oracleGenState.Params.AcceptList, oracletypes.Denom{
BaseDenom: ATOM_BASE_DENOM,
SymbolDenom: ATOM_SYMBOL,
Exponent: uint32(ATOM_EXPONENT),
})

bz, err = cdc.MarshalJSON(&oracleGenState)
s.Require().NoError(err)
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import (
"github.com/cosmos/go-bip39"
)

var (
ATOM_SYMBOL = "ATOM"
ATOM_BASE_DENOM = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
ATOM_EXPONENT = 6
)

func createMnemonic() (string, error) {
entropySeed, err := bip39.NewEntropy(256)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/leverage/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *SimTestSuite) TestSimulateMsgSupply() {
var msg types.MsgSupply
s.unmarshal(&operationMsg, &msg)
s.Require().Equal("umee1ghekyjucln7y67ntx7cf27m9dpuxxemn8w6h33", msg.Supplier)
s.Require().Equal("23872177uumee", msg.Asset.String())
s.Require().Equal("4896096uumee", msg.Asset.String())
s.Require().Len(futureOperations, 0)
}

Expand Down
30 changes: 0 additions & 30 deletions x/leverage/types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,38 +190,8 @@ func defaultUmeeToken() Token {
}
}

func defaultAtomToken() Token {
return Token{
// Denom matches mainnet (channel-1) ATOM
BaseDenom: "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9",
SymbolDenom: "ATOM",
Exponent: 6,
EnableMsgSupply: true,
EnableMsgBorrow: true,
Blacklist: false,
// Reserves
ReserveFactor: sdk.MustNewDecFromStr("0.10"),
// Interest rate model
BaseBorrowRate: sdk.MustNewDecFromStr("0.03"),
KinkBorrowRate: sdk.MustNewDecFromStr("0.11"),
MaxBorrowRate: sdk.MustNewDecFromStr("0.80"),
KinkUtilization: sdk.MustNewDecFromStr("0.70"),
// Collateral
CollateralWeight: sdk.MustNewDecFromStr("0.70"),
LiquidationThreshold: sdk.MustNewDecFromStr("0.80"),
// Liquidation
LiquidationIncentive: sdk.MustNewDecFromStr("0.05"),
// Market limits
MaxCollateralShare: sdk.MustNewDecFromStr("1.00"),
MaxSupplyUtilization: sdk.MustNewDecFromStr("0.95"),
MinCollateralLiquidity: sdk.MustNewDecFromStr("0.18"),
MaxSupply: sdk.NewInt(0),
}
}

func DefaultRegistry() []Token {
return []Token{
defaultUmeeToken(),
defaultAtomToken(),
}
}
8 changes: 4 additions & 4 deletions x/oracle/keeper/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (

func (s *IntegrationTestSuite) TestHooks_AfterTokenRegistered() {
h := s.app.OracleKeeper.Hooks()
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 2)
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 1)

// require that an existing token does not change the accept list
h.AfterTokenRegistered(s.ctx, leveragetypes.Token{
BaseDenom: appparams.BondDenom,
SymbolDenom: appparams.DisplayDenom,
Exponent: 6,
})
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 2)
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 1)

// require a new registered token updates the accept list
h.AfterTokenRegistered(s.ctx, leveragetypes.Token{
BaseDenom: "ibc/CDC4587874B85BEA4FCEC3CEA5A1195139799A1FEE711A07D972537E18FDA39D",
SymbolDenom: "atom",
Exponent: 6,
})
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 3)
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 2)

// require a blacklisted token does not update the accept list
h.AfterTokenRegistered(s.ctx, leveragetypes.Token{
Expand All @@ -32,5 +32,5 @@ func (s *IntegrationTestSuite) TestHooks_AfterTokenRegistered() {
Exponent: 6,
Blacklist: true,
})
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 3)
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 2)
}
3 changes: 0 additions & 3 deletions x/oracle/types/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const (
UmeeDenom string = appparams.BondDenom
UmeeSymbol string = "umee"
UmeeExponent = uint32(6)
AtomDenom string = "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9"
AtomSymbol string = "atom"
AtomExponent = uint32(6)
USDDenom string = "USD"
BlocksPerMinute = uint64(10)
BlocksPerHour = BlocksPerMinute * 60
Expand Down
5 changes: 0 additions & 5 deletions x/oracle/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ func DefaultParams() Params {
SymbolDenom: UmeeSymbol,
Exponent: UmeeExponent,
},
{
BaseDenom: AtomDenom,
SymbolDenom: AtomSymbol,
Exponent: AtomExponent,
},
}

return Params{
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestParamsEqual(t *testing.T) {
assert.ErrorContains(t, err, "oracle parameter AcceptList Denom must have SymbolDenom")

p13 := DefaultParams()
assert.Equal(t, len(p13.AcceptList), 2)
assert.Equal(t, len(p13.AcceptList), 1)
}

func TestValidateVotingThreshold(t *testing.T) {
Expand Down

0 comments on commit 079f7d6

Please sign in to comment.