Skip to content

Commit

Permalink
chore: set oracle default params and values for the testnet launch
Browse files Browse the repository at this point in the history
- slashing fraction is 0
- voting period is ~1 min
- only ATOM with a correct IBC denom
- fix unit tests
  • Loading branch information
Max authored and xlab committed Apr 19, 2023
1 parent 40474ca commit 9b2c13e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 38 deletions.
6 changes: 1 addition & 5 deletions x/oracle/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ func (s *KeeperTestSuite) TestQueryAllExchangeRate() {
s.app.OracleKeeper.SetExchangeRate(s.ctx, types.PersistenceSymbol, sdk.OneDec())
// Set exchange rate for ATOM.
s.app.OracleKeeper.SetExchangeRate(s.ctx, types.AtomSymbol, sdk.OneDec())
// Set exchange rate for OSMO.
s.app.OracleKeeper.SetExchangeRate(s.ctx, types.OsmosisSymbol, sdk.OneDec())
// Set exchange rate for USDC.
s.app.OracleKeeper.SetExchangeRate(s.ctx, types.USDCSymbol, sdk.OneDec())

resp, err = s.queryClient.AllExchangeRates(s.ctx.Context(), &types.QueryAllExchangeRatesRequest{})
s.Require().NoError(err)
s.Require().Len(resp.ExchangeRates, 4)
s.Require().Len(resp.ExchangeRates, 2)
}
13 changes: 1 addition & 12 deletions x/oracle/types/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,10 @@ const (
BlocksPerYear = BlocksPerDay * 365
MicroUnit = int64(1e6)

// TODO: discuss the denom values, took the denoms from: https://docs.osmosis.zone/osmosis-core/asset-info/
// AtomDenom supported by oracle
AtomDenom string = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
AtomDenom string = "ibc/4A17832B26BF318D052563EFFE677C1DE11DF8CE104F00204860F3E3439818B2"
AtomSymbol string = "ATOM"
AtomExponent = uint32(6)

// OsmosisDenom supported by oracle
OsmosisDenom string = "uosmo"
OsmosisSymbol string = "OSMO"
OsmosisExponent = uint32(6)

// USDCDenom supported by oracle
USDCDenom string = "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858"
USDCSymbol string = "USDC"
UsdcExponent = uint32(6)
)

type (
Expand Down
4 changes: 2 additions & 2 deletions x/oracle/types/denom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestDenomString(t *testing.T) {
},
{
denom: types.DenomAtom,
expectedStr: "base_denom: ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2\nsymbol_denom: ATOM\nexponent: 6\n",
expectedStr: "base_denom: ibc/4A17832B26BF318D052563EFFE677C1DE11DF8CE104F00204860F3E3439818B2\nsymbol_denom: ATOM\nexponent: 6\n",
},
}

Expand Down Expand Up @@ -71,7 +71,7 @@ func TestDenomListString(t *testing.T) {
},
{
denomList: types.DenomList{types.DenomPersistence, types.DenomAtom},
expectedStr: "base_denom: uxprt\nsymbol_denom: XPRT\nexponent: 6\n\nbase_denom: ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2\nsymbol_denom: ATOM\nexponent: 6",
expectedStr: "base_denom: uxprt\nsymbol_denom: XPRT\nexponent: 6\n\nbase_denom: ibc/4A17832B26BF318D052563EFFE677C1DE11DF8CE104F00204860F3E3439818B2\nsymbol_denom: ATOM\nexponent: 6",
},
}

Expand Down
14 changes: 2 additions & 12 deletions x/oracle/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (

// Default parameter values
const (
DefaultVotePeriod = BlocksPerMinute / 2 // 30 seconds
DefaultVotePeriod = BlocksPerMinute * 1 // 1 minute
DefaultSlashWindow = BlocksPerWeek // window for a week
DefaultRewardDistributionWindow = BlocksPerYear // window for a year

Expand All @@ -42,18 +42,8 @@ var (
SymbolDenom: AtomSymbol,
Exponent: AtomExponent,
},
{
BaseDenom: OsmosisDenom,
SymbolDenom: OsmosisSymbol,
Exponent: OsmosisExponent,
},
{
BaseDenom: USDCDenom,
SymbolDenom: USDCSymbol,
Exponent: UsdcExponent,
},
}
DefaultSlashFraction = sdk.NewDecWithPrec(1, 4) // 0.01%
DefaultSlashFraction = sdk.NewDec(0) // 0%
DefaultMinValidPerWindow = sdk.NewDecWithPrec(5, 2) // 5%

oneDec = sdk.OneDec()
Expand Down
6 changes: 0 additions & 6 deletions x/oracle/types/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ var (
SymbolDenom: AtomSymbol,
Exponent: 6,
}

DenomOsmosis = Denom{
BaseDenom: OsmosisDenom,
SymbolDenom: AtomSymbol,
Exponent: 6,
}
)

// MockStakingKeeper implements the StakingKeeper interface.
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/types/vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestExchangeRateTuplesString(t *testing.T) {
exchangeRateTuple,
NewExchangeRateTuple(AtomDenom, sdk.SmallestDec()),
}
require.Equal(t, "- denom: uxprt\n exchange_rate: \"1.000000000000000000\"\n- denom: ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2\n exchange_rate: \"0.000000000000000001\"\n", exchangeRateTuples.String())
require.Equal(t, "- denom: uxprt\n exchange_rate: \"1.000000000000000000\"\n- denom: ibc/4A17832B26BF318D052563EFFE677C1DE11DF8CE104F00204860F3E3439818B2\n exchange_rate: \"0.000000000000000001\"\n", exchangeRateTuples.String())
}

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

0 comments on commit 9b2c13e

Please sign in to comment.