diff --git a/app/_sim_test.go b/app/_sim_test.go index 6e8a1155..02ae732f 100644 --- a/app/_sim_test.go +++ b/app/_sim_test.go @@ -168,10 +168,12 @@ func TestAppImportExport(t *testing.T) { storeKeysPrefixes := []StoreKeysPrefixes{ {app.keys[baseapp.MainStoreKey], newApp.keys[baseapp.MainStoreKey], [][]byte{}}, {app.keys[auth.StoreKey], newApp.keys[auth.StoreKey], [][]byte{}}, - {app.keys[staking.StoreKey], newApp.keys[staking.StoreKey], + { + app.keys[staking.StoreKey], newApp.keys[staking.StoreKey], [][]byte{ staking.UnbondingQueueKey, staking.RedelegationQueueKey, staking.ValidatorQueueKey, - }}, // ordering may change but it doesn't matter + }, + }, // ordering may change but it doesn't matter {app.keys[slashing.StoreKey], newApp.keys[slashing.StoreKey], [][]byte{}}, {app.keys[mint.StoreKey], newApp.keys[mint.StoreKey], [][]byte{}}, {app.keys[distr.StoreKey], newApp.keys[distr.StoreKey], [][]byte{}}, @@ -320,7 +322,6 @@ func TestAppStateDeterminism(t *testing.T) { func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simulation.AppStateFn { return func(r *rand.Rand, accs []simulation.Account, config simulation.Config, ) (appState json.RawMessage, simAccs []simulation.Account, chainID string, genesisTimestamp time.Time) { - if simapp.FlagGenesisTimeValue == 0 { genesisTimestamp = time.Unix(r.Int63n(190288396800), 0) // 1st Jan year 8000 } else { diff --git a/app/ante/authorized_test.go b/app/ante/authorized_test.go index ca0b88ce..f962f2b1 100644 --- a/app/ante/authorized_test.go +++ b/app/ante/authorized_test.go @@ -12,9 +12,7 @@ import ( "github.com/kava-labs/kava/app/ante" ) -var ( - _ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle -) +var _ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle type MockAnteHandler struct { WasCalled bool diff --git a/app/ante/authz_test.go b/app/ante/authz_test.go index 78155440..d7768012 100644 --- a/app/ante/authz_test.go +++ b/app/ante/authz_test.go @@ -211,7 +211,6 @@ func TestAuthzLimiterDecorator(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - tx, err := helpers.GenTx( txConfig, tc.msgs, diff --git a/app/app.go b/app/app.go index 943c73a2..df01f6b5 100644 --- a/app/app.go +++ b/app/app.go @@ -323,7 +323,6 @@ func NewApp( options Options, baseAppOptions ...func(*baseapp.BaseApp), ) *App { - appCodec := encodingConfig.Marshaler legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -348,7 +347,7 @@ func NewApp( tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - var app = &App{ + app := &App{ BaseApp: bApp, legacyAmino: legacyAmino, appCodec: appCodec, diff --git a/app/export.go b/app/export.go index bf3cda5e..df4228e7 100644 --- a/app/export.go +++ b/app/export.go @@ -46,7 +46,7 @@ func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList [] func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) { applyWhiteList := false - //Check if there is a whitelist + // Check if there is a whitelist if len(jailWhiteList) > 0 { applyWhiteList = true } diff --git a/app/test_builder.go b/app/test_builder.go index 791e22db..b2c01f6c 100644 --- a/app/test_builder.go +++ b/app/test_builder.go @@ -84,7 +84,6 @@ func (builder *AuthBankGenesisBuilder) WithSimpleModuleAccount(moduleName string // WithSimplePeriodicVestingAccount adds a periodic vesting account to the genesis state. func (builder *AuthBankGenesisBuilder) WithSimplePeriodicVestingAccount(address sdk.AccAddress, balance sdk.Coins, periods vestingtypes.Periods, firstPeriodStartTimestamp int64) *AuthBankGenesisBuilder { - vestingAccount := newPeriodicVestingAccount(address, periods, firstPeriodStartTimestamp) return builder. diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index 0f49a216..b9f9d68b 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -1,3 +1,4 @@ +//go:build cli_test // +build cli_test package clitest @@ -1137,7 +1138,8 @@ func TestKvCLIMultisignSortSignatures(t *testing.T) { // Multisign, keys in different order success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{ - bazSignatureFile.Name(), fooSignatureFile.Name()}) + bazSignatureFile.Name(), fooSignatureFile.Name(), + }) require.True(t, success) // Write the output to disk @@ -1205,13 +1207,15 @@ func TestKvCLIMultisign(t *testing.T) { // Does not work in offline mode success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{ - fooSignatureFile.Name(), barSignatureFile.Name()}, "--offline") + fooSignatureFile.Name(), barSignatureFile.Name(), + }, "--offline") require.Contains(t, "couldn't verify signature", stdout) require.False(t, success) // Success multisign success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{ - fooSignatureFile.Name(), barSignatureFile.Name()}) + fooSignatureFile.Name(), barSignatureFile.Name(), + }) require.True(t, success) // Write the output to disk diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 72427a2e..2b94b562 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -367,8 +367,8 @@ func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, str // TxMultisign is kvcli tx multisign func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string, - flags ...string) (bool, string, string) { - + flags ...string, +) (bool, string, string) { cmd := fmt.Sprintf("%s tx multisign --keyring-backend=test %v %s %s %s", f.KvcliBinary, f.Flags(), fileName, name, strings.Join(signaturesFiles, " "), ) @@ -425,7 +425,6 @@ func (f *Fixtures) TxGovVote(proposalID int, option gov.VoteOption, from string, func (f *Fixtures) TxGovSubmitParamChangeProposal( from, proposalPath string, deposit sdk.Coin, flags ...string, ) (bool, string, string) { - cmd := fmt.Sprintf( "%s tx gov submit-proposal param-change %s --keyring-backend=test --from=%s %v", f.KvcliBinary, proposalPath, from, f.Flags(), @@ -439,7 +438,6 @@ func (f *Fixtures) TxGovSubmitParamChangeProposal( func (f *Fixtures) TxGovSubmitCommunityPoolSpendProposal( from, proposalPath string, deposit sdk.Coin, flags ...string, ) (bool, string, string) { - cmd := fmt.Sprintf( "%s tx gov submit-proposal community-pool-spend %s --keyring-backend=test --from=%s %v", f.KvcliBinary, proposalPath, from, f.Flags(), diff --git a/client/keys.go b/client/keys.go index 70d0ffa4..8de84035 100644 --- a/client/keys.go +++ b/client/keys.go @@ -16,9 +16,7 @@ import ( "github.com/tharsis/ethermint/crypto/hd" ) -var ( - ethFlag = "eth" -) +var ethFlag = "eth" // KeyCommands registers a sub-tree of commands to interact with // local private key storage. diff --git a/cmd/kava/cmd/app.go b/cmd/kava/cmd/app.go index 608c5719..c74936b6 100644 --- a/cmd/kava/cmd/app.go +++ b/cmd/kava/cmd/app.go @@ -43,7 +43,6 @@ func (ac appCreator) newApp( traceStore io.Writer, appOpts servertypes.AppOptions, ) servertypes.Application { - var cache sdk.MultiStorePersistentCache if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) { cache = store.NewCommitKVStoreCacheManager() @@ -114,7 +113,6 @@ func (ac appCreator) appExport( jailAllowedAddrs []string, appOpts servertypes.AppOptions, ) (servertypes.ExportedApp, error) { - homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { return servertypes.ExportedApp{}, errors.New("application home not set") diff --git a/migrate/utils/periodic_vesting_reset_test.go b/migrate/utils/periodic_vesting_reset_test.go index f1ca45a5..c918fefb 100644 --- a/migrate/utils/periodic_vesting_reset_test.go +++ b/migrate/utils/periodic_vesting_reset_test.go @@ -83,7 +83,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) { expectedEndtime := newVestingStartTime.Add(15 * 24 * time.Hour).Unix() // new period length changed, amount unchanged expectedPeriods := []vestingtypes.Period{ - vestingtypes.Period{ + { Length: 15 * 24 * 60 * 60, // 15 days Amount: balance, }, @@ -156,11 +156,11 @@ func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) { expectedEndtime := newVestingStartTime.Add(30 * 24 * time.Hour).Unix() // new period length changed, amount unchanged expectedPeriods := []vestingtypes.Period{ - vestingtypes.Period{ + { Length: 15 * 24 * 60 * 60, // 15 days Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))), }, - vestingtypes.Period{ + { Length: 15 * 24 * 60 * 60, // 15 days Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))), }, diff --git a/migrate/v0_17/cosmos_auth.go b/migrate/v0_17/cosmos_auth.go index e71591cb..4ca6ae8d 100644 --- a/migrate/v0_17/cosmos_auth.go +++ b/migrate/v0_17/cosmos_auth.go @@ -14,7 +14,7 @@ import ( // v40 cosmos auth module genesis state, returning a copy of the original state where all // periodic vesting accounts have been zeroed out. func MigrateAuthV040(authGenState v040auth.GenesisState, genesisTime time.Time, ctx client.Context) *v040auth.GenesisState { - var anyAccounts = make([]*codectypes.Any, len(authGenState.Accounts)) + anyAccounts := make([]*codectypes.Any, len(authGenState.Accounts)) for i, anyAcc := range authGenState.Accounts { // Only need to make modifications to vesting accounts if anyAcc.TypeUrl != "/cosmos.vesting.v1beta1.PeriodicVestingAccount" { diff --git a/migrate/v0_17/kava_committee.go b/migrate/v0_17/kava_committee.go index 0a8f571d..525cd093 100644 --- a/migrate/v0_17/kava_committee.go +++ b/migrate/v0_17/kava_committee.go @@ -8,7 +8,6 @@ import ( ) func migrateCommitteePermissions(genState committeetypes.GenesisState) committeetypes.GenesisState { - var newCommittees committeetypes.Committees for _, committee := range genState.GetCommittees() { switch committee.GetDescription() { diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 8338404b..49313450 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -33,7 +33,6 @@ func GetTxCmd() *cobra.Command { txCmd.AddCommand(cmds...) return txCmd - } // GetCmdPlaceBid cli command for placing bids on auctions diff --git a/x/auction/client/rest/query.go b/x/auction/client/rest/query.go index 97f337af..0a97df8c 100644 --- a/x/auction/client/rest/query.go +++ b/x/auction/client/rest/query.go @@ -3,7 +3,6 @@ package rest import ( "fmt" "net/http" - "strings" "github.com/cosmos/cosmos-sdk/client" diff --git a/x/auction/genesis_test.go b/x/auction/genesis_test.go index a349b3b4..d794d541 100644 --- a/x/auction/genesis_test.go +++ b/x/auction/genesis_test.go @@ -16,16 +16,18 @@ import ( "github.com/kava-labs/kava/x/auction/types" ) -var _, testAddrs = app.GeneratePrivKeyAddressPairs(2) -var testTime = time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC) -var testAuction = types.NewCollateralAuction( - "seller", - c("lotdenom", 10), - testTime, - c("biddenom", 1000), - types.WeightedAddresses{Addresses: testAddrs, Weights: []sdk.Int{sdk.OneInt(), sdk.OneInt()}}, - c("debt", 1000), -).WithID(3).(types.GenesisAuction) +var ( + _, testAddrs = app.GeneratePrivKeyAddressPairs(2) + testTime = time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC) + testAuction = types.NewCollateralAuction( + "seller", + c("lotdenom", 10), + testTime, + c("biddenom", 1000), + types.WeightedAddresses{Addresses: testAddrs, Weights: []sdk.Int{sdk.OneInt(), sdk.OneInt()}}, + c("debt", 1000), + ).WithID(3).(types.GenesisAuction) +) func TestInitGenesis(t *testing.T) { t.Run("valid", func(t *testing.T) { diff --git a/x/auction/keeper/auctions.go b/x/auction/keeper/auctions.go index ce692196..4f6bcfc9 100644 --- a/x/auction/keeper/auctions.go +++ b/x/auction/keeper/auctions.go @@ -46,7 +46,6 @@ func (k Keeper) StartSurplusAuction(ctx sdk.Context, seller string, lot sdk.Coin // StartDebtAuction starts a new debt (reverse) auction. func (k Keeper) StartDebtAuction(ctx sdk.Context, buyer string, bid sdk.Coin, initialLot sdk.Coin, debt sdk.Coin) (uint64, error) { - auction := types.NewDebtAuction( buyer, bid, @@ -132,7 +131,6 @@ func (k Keeper) StartCollateralAuction( // PlaceBid places a bid on any auction. func (k Keeper) PlaceBid(ctx sdk.Context, auctionID uint64, bidder sdk.AccAddress, newAmount sdk.Coin) error { - auction, found := k.GetAuction(ctx, auctionID) if !found { return sdkerrors.Wrapf(types.ErrAuctionNotFound, "%d", auctionID) diff --git a/x/auction/keeper/bidding_test.go b/x/auction/keeper/bidding_test.go index da047c33..bfd7c218 100644 --- a/x/auction/keeper/bidding_test.go +++ b/x/auction/keeper/bidding_test.go @@ -25,11 +25,10 @@ const ( ) func TestAuctionBidding(t *testing.T) { - config := sdk.GetConfig() app.SetBech32AddressPrefixes(config) - someTime := time.Date(0001, time.January, 1, 0, 0, 0, 0, time.UTC) + someTime := time.Date(0o001, time.January, 1, 0, 0, 0, 0, time.UTC) _, addrs := app.GeneratePrivKeyAddressPairs(5) buyer := addrs[0] diff --git a/x/auction/keeper/grpc_query_test.go b/x/auction/keeper/grpc_query_test.go index 66de5665..b7d65bf5 100644 --- a/x/auction/keeper/grpc_query_test.go +++ b/x/auction/keeper/grpc_query_test.go @@ -117,7 +117,6 @@ func TestGrpcAuctionsFilter(t *testing.T) { for _, tc := range tests { t.Run(tc.giveName, func(t *testing.T) { - res, err := qs.Auctions(sdk.WrapSDKContext(ctx), &tc.giveRequest) require.NoError(t, err) diff --git a/x/auction/keeper/invariants.go b/x/auction/keeper/invariants.go index 0a7fbeee..d83ecbc7 100644 --- a/x/auction/keeper/invariants.go +++ b/x/auction/keeper/invariants.go @@ -12,7 +12,6 @@ import ( // RegisterInvariants registers all staking invariants func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) { - ir.RegisterRoute(types.ModuleName, "module-account", ModuleAccountInvariants(k)) ir.RegisterRoute(types.ModuleName, "valid-auctions", @@ -24,7 +23,6 @@ func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) { // ModuleAccountInvariants checks that the module account's coins matches those stored in auctions func ModuleAccountInvariants(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { - totalAuctionCoins := sdk.NewCoins() k.IterateAuctions(ctx, func(auction types.Auction) bool { a, ok := auction.(types.GenesisAuction) diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 702f78ab..c47310ec 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -24,7 +24,8 @@ type Keeper struct { // NewKeeper returns a new auction keeper. func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramstore paramtypes.Subspace, - bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper) Keeper { + bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper, +) Keeper { if !paramstore.HasKeyTable() { paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) } @@ -81,7 +82,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) SetNextAuctionID(ctx sdk.Context, id uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.NextAuctionIDKey) store.Set(types.NextAuctionIDKey, types.Uint64ToBytes(id)) - } // GetNextAuctionID reads the next available global ID from store diff --git a/x/auction/keeper/keeper_test.go b/x/auction/keeper/keeper_test.go index ce95a169..c45bfaf5 100644 --- a/x/auction/keeper/keeper_test.go +++ b/x/auction/keeper/keeper_test.go @@ -124,7 +124,6 @@ func TestIterateAuctionsByTime(t *testing.T) { if v.endTime.Before(cutoffTime) || v.endTime.Equal(cutoffTime) { // endTime ≤ cutoffTime expectedIndex = append(expectedIndex, v.auctionID) } - } var readIndex []uint64 keeper.IterateAuctionsByTime(ctx, cutoffTime, func(id uint64) bool { diff --git a/x/auction/simulation/genesis.go b/x/auction/simulation/genesis.go index 3d4949f9..0f875cbb 100644 --- a/x/auction/simulation/genesis.go +++ b/x/auction/simulation/genesis.go @@ -36,6 +36,7 @@ func GenBidDuration(r *rand.Rand) time.Duration { } return d } + func GenMaxAuctionDuration(r *rand.Rand) time.Duration { d, err := RandomPositiveDuration(r, MaxBidDuration, AverageBlockTime*200) if err != nil { @@ -48,12 +49,13 @@ func GenIncrementCollateral(r *rand.Rand) sdk.Dec { return simulation.RandomDecAmount(r, sdk.MustNewDecFromStr("1")) } -var GenIncrementDebt = GenIncrementCollateral -var GenIncrementSurplus = GenIncrementCollateral +var ( + GenIncrementDebt = GenIncrementCollateral + GenIncrementSurplus = GenIncrementCollateral +) // RandomizedGenState generates a random GenesisState for auction func RandomizedGenState(simState *module.SimulationState) { - p := types.NewParams( GenMaxAuctionDuration(simState.Rand), GenBidDuration(simState.Rand), @@ -80,7 +82,7 @@ func RandomizedGenState(simState *module.SimulationState) { sdk.NewInt64Coin("debt", 100), // same as usdx ), } - var startingID = auctionGenesis.NextAuctionID + startingID := auctionGenesis.NextAuctionID var ok bool var totalAuctionCoins sdk.Coins for i, a := range auctions { diff --git a/x/auction/simulation/operations.go b/x/auction/simulation/operations.go index 1f2a9225..4cf7656d 100644 --- a/x/auction/simulation/operations.go +++ b/x/auction/simulation/operations.go @@ -122,7 +122,8 @@ func SimulateMsgPlaceBid(ak auth.AccountKeeper, keeper keeper.Keeper) simulation func generateBidAmount( r *rand.Rand, params types.Params, auc types.Auction, - bidder authexported.Account, blockTime time.Time) (sdk.Coin, error) { + bidder authexported.Account, blockTime time.Time, +) (sdk.Coin, error) { bidderBalance := bidder.SpendableCoins(blockTime) switch a := auc.(type) { diff --git a/x/auction/types/genesis_test.go b/x/auction/types/genesis_test.go index fd2e858f..1894ff52 100644 --- a/x/auction/types/genesis_test.go +++ b/x/auction/types/genesis_test.go @@ -20,7 +20,6 @@ func newTestModuleCodec() codec.Codec { } func TestGenesisState_Validate(t *testing.T) { - arbitraryTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC) validAuction := &CollateralAuction{ BaseAuction: BaseAuction{ @@ -82,7 +81,6 @@ func TestGenesisState_Validate(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - err := tc.genesis.Validate() if tc.expectPass { require.NoError(t, err) @@ -91,11 +89,9 @@ func TestGenesisState_Validate(t *testing.T) { } }) } - } func TestGenesisState_UnmarshalAnys(t *testing.T) { - cdc := newTestModuleCodec() arbitraryTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC) diff --git a/x/bep3/client/rest/query.go b/x/bep3/client/rest/query.go index 1e761e02..560db0d6 100644 --- a/x/bep3/client/rest/query.go +++ b/x/bep3/client/rest/query.go @@ -14,8 +14,10 @@ import ( "github.com/kava-labs/kava/x/bep3/types" ) -const restSwapID = "swap-id" -const restDenom = "denom" +const ( + restSwapID = "swap-id" + restDenom = "denom" +) func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { r.HandleFunc(fmt.Sprintf("/%s/swap/{%s}", types.ModuleName, restSwapID), queryAtomicSwapHandlerFn(cliCtx)).Methods("GET") @@ -23,7 +25,6 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { r.HandleFunc(fmt.Sprintf("/%s/supply/{%s}", types.ModuleName, restDenom), queryAssetSupplyHandlerFn(cliCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/supplies", types.ModuleName), queryAssetSuppliesHandlerFn(cliCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/parameters", types.ModuleName), queryParamsHandlerFn(cliCtx)).Methods("GET") - } func queryAtomicSwapHandlerFn(cliCtx client.Context) http.HandlerFunc { diff --git a/x/bep3/genesis_test.go b/x/bep3/genesis_test.go index afeecc1b..b84e3035 100644 --- a/x/bep3/genesis_test.go +++ b/x/bep3/genesis_test.go @@ -340,7 +340,6 @@ func (suite *GenesisTestSuite) TestGenesisState() { }, tc.name) } }) - } } diff --git a/x/bep3/keeper/asset_test.go b/x/bep3/keeper/asset_test.go index 929af69d..30d0d52d 100644 --- a/x/bep3/keeper/asset_test.go +++ b/x/bep3/keeper/asset_test.go @@ -98,7 +98,6 @@ func (suite *AssetTestSuite) TestIncrementCurrentAssetSupply() { for _, tc := range testCases { suite.SetupTest() suite.Run(tc.name, func() { - preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom) err := suite.keeper.IncrementCurrentAssetSupply(suite.ctx, tc.args.coin) postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom) @@ -138,7 +137,8 @@ func (suite *AssetTestSuite) TestIncrementTimeLimitedCurrentAssetSupply() { OutgoingSupply: c("inc", 5), CurrentSupply: c("inc", 10), TimeLimitedCurrentSupply: c("inc", 5), - TimeElapsed: time.Duration(0)}, + TimeElapsed: time.Duration(0), + }, }, errArgs{ expectPass: true, @@ -215,7 +215,6 @@ func (suite *AssetTestSuite) TestDecrementCurrentAssetSupply() { for _, tc := range testCases { suite.SetupTest() suite.Run(tc.name, func() { - preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom) err := suite.keeper.DecrementCurrentAssetSupply(suite.ctx, tc.args.coin) postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom) @@ -313,7 +312,8 @@ func (suite *AssetTestSuite) TestIncrementTimeLimitedIncomingAssetSupply() { OutgoingSupply: c("inc", 5), CurrentSupply: c("inc", 5), TimeLimitedCurrentSupply: c("inc", 0), - TimeElapsed: time.Duration(0)}, + TimeElapsed: time.Duration(0), + }, }, errArgs{ expectPass: true, @@ -390,7 +390,6 @@ func (suite *AssetTestSuite) TestDecrementIncomingAssetSupply() { for _, tc := range testCases { suite.SetupTest() suite.Run(tc.name, func() { - preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom) err := suite.keeper.DecrementIncomingAssetSupply(suite.ctx, tc.args.coin) postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom) @@ -449,7 +448,6 @@ func (suite *AssetTestSuite) TestIncrementOutgoingAssetSupply() { for _, tc := range testCases { suite.SetupTest() suite.Run(tc.name, func() { - preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom) err := suite.keeper.IncrementOutgoingAssetSupply(suite.ctx, tc.args.coin) postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom) diff --git a/x/bep3/keeper/keeper.go b/x/bep3/keeper/keeper.go index 6c95f7cc..2c31f9ee 100644 --- a/x/bep3/keeper/keeper.go +++ b/x/bep3/keeper/keeper.go @@ -25,7 +25,8 @@ type Keeper struct { // NewKeeper creates a bep3 keeper func NewKeeper(cdc codec.Codec, key sdk.StoreKey, sk types.BankKeeper, ak types.AccountKeeper, - paramstore paramtypes.Subspace, maccs map[string]bool) Keeper { + paramstore paramtypes.Subspace, maccs map[string]bool, +) Keeper { if !paramstore.HasKeyTable() { paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) } @@ -160,7 +161,8 @@ func (k Keeper) RemoveFromLongtermStorage(ctx sdk.Context, atomicSwap types.Atom // IterateAtomicSwapsLongtermStorage provides an iterator over AtomicSwaps ordered by deletion height. // For each AtomicSwap cb will be called. If cb returns true the iterator will close and stop. func (k Keeper) IterateAtomicSwapsLongtermStorage(ctx sdk.Context, inclusiveCutoffTime uint64, - cb func(swapID []byte) (stop bool)) { + cb func(swapID []byte) (stop bool), +) { store := prefix.NewStore(ctx.KVStore(k.key), types.AtomicSwapLongtermStoragePrefix) iterator := store.Iterator( nil, // start at the very start of the prefix store diff --git a/x/bep3/keeper/keeper_test.go b/x/bep3/keeper/keeper_test.go index c65b02d4..04922060 100644 --- a/x/bep3/keeper/keeper_test.go +++ b/x/bep3/keeper/keeper_test.go @@ -78,6 +78,7 @@ func (suite *KeeperTestSuite) TestRemoveAtomicSwap() { _, found = suite.keeper.GetAtomicSwap(suite.ctx, atomicSwap.GetSwapID()) suite.False(found) } + func (suite *KeeperTestSuite) TestIterateAtomicSwaps() { suite.ResetChain() @@ -324,7 +325,6 @@ func (suite *KeeperTestSuite) TestGetSetAssetSupply() { } func (suite *KeeperTestSuite) TestGetAllAssetSupplies() { - // Put asset supply in store assetSupply := types.NewAssetSupply(c("bnb", 0), c("bnb", 0), c("bnb", 50000), c("bnb", 0), time.Duration(0)) suite.keeper.SetAssetSupply(suite.ctx, assetSupply, "bnb") diff --git a/x/bep3/keeper/params_test.go b/x/bep3/keeper/params_test.go index 0a01f468..e09cf106 100644 --- a/x/bep3/keeper/params_test.go +++ b/x/bep3/keeper/params_test.go @@ -63,7 +63,6 @@ func (suite *ParamsTestSuite) TestGetSetDeputyAddress() { addr, err := suite.keeper.GetDeputyAddress(suite.ctx, "bnb") suite.Require().NoError(err) suite.Equal(suite.addrs[1], addr) - } func (suite *ParamsTestSuite) TestGetDeputyFixedFee() { diff --git a/x/bep3/keeper/swap.go b/x/bep3/keeper/swap.go index 3efc5929..7148a259 100644 --- a/x/bep3/keeper/swap.go +++ b/x/bep3/keeper/swap.go @@ -15,7 +15,8 @@ import ( // CreateAtomicSwap creates a new atomic swap. func (k Keeper) CreateAtomicSwap(ctx sdk.Context, randomNumberHash []byte, timestamp int64, heightSpan uint64, sender, recipient sdk.AccAddress, senderOtherChain, recipientOtherChain string, - amount sdk.Coins, crossChain bool) error { + amount sdk.Coins, crossChain bool, +) error { // Confirm that this is not a duplicate swap swapID := types.CalculateSwapID(randomNumberHash, sender, senderOtherChain) _, found := k.GetAtomicSwap(ctx, swapID) diff --git a/x/bep3/keeper/swap_test.go b/x/bep3/keeper/swap_test.go index ccb5414b..a5dcc7dd 100644 --- a/x/bep3/keeper/swap_test.go +++ b/x/bep3/keeper/swap_test.go @@ -197,7 +197,6 @@ func (suite *AtomicSwapTestSuite) TestCreateAtomicSwap() { true, }, { - "outgoing swap amount not greater than fixed fee", currentTmTime, args{ @@ -453,21 +452,20 @@ func (suite *AtomicSwapTestSuite) TestCreateAtomicSwap() { suite.NotNil(actualSwap) // Confirm swap contents - expectedSwap := - types.AtomicSwap{ - Amount: tc.args.coins, - RandomNumberHash: tc.args.randomNumberHash, - ExpireHeight: uint64(suite.ctx.BlockHeight()) + tc.args.heightSpan, - Timestamp: tc.args.timestamp, - Sender: tc.args.sender, - Recipient: tc.args.recipient, - SenderOtherChain: tc.args.senderOtherChain, - RecipientOtherChain: tc.args.recipientOtherChain, - ClosedBlock: 0, - Status: types.SWAP_STATUS_OPEN, - CrossChain: tc.args.crossChain, - Direction: tc.args.direction, - } + expectedSwap := types.AtomicSwap{ + Amount: tc.args.coins, + RandomNumberHash: tc.args.randomNumberHash, + ExpireHeight: uint64(suite.ctx.BlockHeight()) + tc.args.heightSpan, + Timestamp: tc.args.timestamp, + Sender: tc.args.sender, + Recipient: tc.args.recipient, + SenderOtherChain: tc.args.senderOtherChain, + RecipientOtherChain: tc.args.recipientOtherChain, + ClosedBlock: 0, + Status: types.SWAP_STATUS_OPEN, + CrossChain: tc.args.crossChain, + Direction: tc.args.direction, + } suite.Equal(expectedSwap, actualSwap) } else { suite.Error(err) diff --git a/x/bep3/simulation/genesis.go b/x/bep3/simulation/genesis.go index cf1a49a8..c895d8b0 100644 --- a/x/bep3/simulation/genesis.go +++ b/x/bep3/simulation/genesis.go @@ -78,7 +78,6 @@ func GenMaxBlockLock(r *rand.Rand, minBlockLock uint64) uint64 { // GenSupportedAssets gets randomized SupportedAssets func GenSupportedAssets(r *rand.Rand) types.AssetParams { - numAssets := (r.Intn(10) + 1) assets := make(types.AssetParams, numAssets+1) for i := 0; i < numAssets; i++ { @@ -113,7 +112,8 @@ func genSupportedAsset(r *rand.Rand, denom string) types.AssetParam { Limit: limit, TimeLimited: timeLimited, TimePeriod: time.Hour * 24, - TimeBasedLimit: timeBasedLimit}, + TimeBasedLimit: timeBasedLimit, + }, Active: true, DeputyAddress: GenRandBnbDeputy(r).Address, FixedFee: GenRandFixedFee(r), @@ -146,7 +146,6 @@ func RandomizedGenState(simState *module.SimulationState) { } func loadRandomBep3GenState(simState *module.SimulationState) types.GenesisState { - supportedAssets := GenSupportedAssets(simState.Rand) supplies := types.AssetSupplies{} for _, asset := range supportedAssets { diff --git a/x/bep3/simulation/operations.go b/x/bep3/simulation/operations.go index 254dacf7..bb8519e3 100644 --- a/x/bep3/simulation/operations.go +++ b/x/bep3/simulation/operations.go @@ -133,7 +133,6 @@ func SimulateMsgCreateAtomicSwap(ak types.AccountKeeper, k keeper.Keeper) simula } // The maximum amount for outgoing swaps is limited by the asset's current supply if recipient.Address.Equals(asset.DeputyAddress) { - if maximumAmount.GT(assetSupply.CurrentSupply.Amount.Sub(assetSupply.OutgoingSupply.Amount)) { maximumAmount = assetSupply.CurrentSupply.Amount.Sub(assetSupply.OutgoingSupply.Amount) } @@ -330,7 +329,8 @@ func operationRefundAtomicSwap(ak types.AccountKeeper, k keeper.Keeper, swapID [ // findValidAccountAssetSupplyPair finds an account for which the callback func returns true func findValidAccountAssetPair(accounts []simulation.Account, assets types.AssetParams, - cb func(simulation.Account, types.AssetParam) bool) (simulation.Account, types.AssetParam, bool) { + cb func(simulation.Account, types.AssetParam) bool, +) (simulation.Account, types.AssetParam, bool) { for _, asset := range assets { for _, acc := range accounts { if isValid := cb(acc, asset); isValid { diff --git a/x/bep3/types/genesis_test.go b/x/bep3/types/genesis_test.go index c561c56c..205cc508 100644 --- a/x/bep3/types/genesis_test.go +++ b/x/bep3/types/genesis_test.go @@ -113,7 +113,6 @@ func (suite *GenesisTestSuite) TestValidate() { } else { suite.Require().Error(err, tc.name) } - }) } } diff --git a/x/bep3/types/msg.go b/x/bep3/types/msg.go index 25263ed1..84447e21 100644 --- a/x/bep3/types/msg.go +++ b/x/bep3/types/msg.go @@ -38,7 +38,8 @@ var ( // NewMsgCreateAtomicSwap initializes a new MsgCreateAtomicSwap func NewMsgCreateAtomicSwap(from, to string, recipientOtherChain, senderOtherChain string, randomNumberHash tmbytes.HexBytes, timestamp int64, - amount sdk.Coins, heightSpan uint64) MsgCreateAtomicSwap { + amount sdk.Coins, heightSpan uint64, +) MsgCreateAtomicSwap { return MsgCreateAtomicSwap{ From: from, To: to, diff --git a/x/bep3/types/params_test.go b/x/bep3/types/params_test.go index 6c105521..1804c468 100644 --- a/x/bep3/types/params_test.go +++ b/x/bep3/types/params_test.go @@ -39,7 +39,6 @@ func (suite *ParamsTestSuite) SetupTest() { } func (suite *ParamsTestSuite) TestParamValidation() { - type args struct { assetParams types.AssetParams } @@ -83,10 +82,11 @@ func (suite *ParamsTestSuite) TestParamValidation() { { name: "valid multi asset", args: args{ - assetParams: types.AssetParams{types.NewAssetParam( - "bnb", 714, suite.supply[0], true, - suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000), - types.DefaultMinBlockLock, types.DefaultMaxBlockLock), + assetParams: types.AssetParams{ + types.NewAssetParam( + "bnb", 714, suite.supply[0], true, + suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000), + types.DefaultMinBlockLock, types.DefaultMaxBlockLock), types.NewAssetParam( "btcb", 0, suite.supply[1], true, suite.addr, sdk.NewInt(1000), sdk.NewInt(10000000), sdk.NewInt(100000000000), @@ -213,10 +213,11 @@ func (suite *ParamsTestSuite) TestParamValidation() { { name: "duplicate denom", args: args{ - assetParams: types.AssetParams{types.NewAssetParam( - "bnb", 714, suite.supply[0], true, - suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000), - types.DefaultMinBlockLock, types.DefaultMaxBlockLock), + assetParams: types.AssetParams{ + types.NewAssetParam( + "bnb", 714, suite.supply[0], true, + suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000), + types.DefaultMinBlockLock, types.DefaultMaxBlockLock), types.NewAssetParam( "bnb", 0, suite.supply[0], true, suite.addr, sdk.NewInt(1000), sdk.NewInt(10000000), sdk.NewInt(100000000000), diff --git a/x/bep3/types/querier.go b/x/bep3/types/querier.go index 7ec6a246..892a7a6f 100644 --- a/x/bep3/types/querier.go +++ b/x/bep3/types/querier.go @@ -70,7 +70,8 @@ type QueryAtomicSwaps struct { // NewQueryAtomicSwaps creates a new instance of QueryAtomicSwaps func NewQueryAtomicSwaps(page, limit int, involve sdk.AccAddress, expiration uint64, - status SwapStatus, direction SwapDirection) QueryAtomicSwaps { + status SwapStatus, direction SwapDirection, +) QueryAtomicSwaps { return QueryAtomicSwaps{ Page: page, Limit: limit, diff --git a/x/bep3/types/swap.go b/x/bep3/types/swap.go index 7f2dc9f3..78388233 100644 --- a/x/bep3/types/swap.go +++ b/x/bep3/types/swap.go @@ -15,7 +15,8 @@ import ( // NewAtomicSwap returns a new AtomicSwap func NewAtomicSwap(amount sdk.Coins, randomNumberHash tmbytes.HexBytes, expireHeight uint64, timestamp int64, sender, recipient sdk.AccAddress, senderOtherChain, recipientOtherChain string, closedBlock int64, - status SwapStatus, crossChain bool, direction SwapDirection) AtomicSwap { + status SwapStatus, crossChain bool, direction SwapDirection, +) AtomicSwap { return AtomicSwap{ Amount: amount, RandomNumberHash: randomNumberHash, diff --git a/x/cdp/abci_test.go b/x/cdp/abci_test.go index 91bfb3e1..aa9275ae 100644 --- a/x/cdp/abci_test.go +++ b/x/cdp/abci_test.go @@ -120,6 +120,7 @@ func (suite *ModuleTestSuite) setPrice(price sdk.Dec, market string) { suite.NoError(err) suite.Equal(price, pp.Price) } + func (suite *ModuleTestSuite) TestBeginBlock() { suite.createCdps() ak := suite.app.GetAccountKeeper() @@ -147,7 +148,6 @@ func (suite *ModuleTestSuite) TestBeginBlock() { acc = ak.GetModuleAccount(suite.ctx, auctiontypes.ModuleName) suite.Equal(int64(71955653865), bk.GetBalance(suite.ctx, acc.GetAddress(), "debt").Amount.Int64()) - } func (suite *ModuleTestSuite) TestSeizeSingleCdpWithFees() { diff --git a/x/cdp/genesis.go b/x/cdp/genesis.go index 600d306f..c3123b65 100644 --- a/x/cdp/genesis.go +++ b/x/cdp/genesis.go @@ -11,7 +11,6 @@ import ( // InitGenesis sets initial genesis state for cdp module func InitGenesis(ctx sdk.Context, k keeper.Keeper, pk types.PricefeedKeeper, ak types.AccountKeeper, gs types.GenesisState) { - if err := gs.Validate(); err != nil { panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err)) } @@ -85,7 +84,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, pk types.PricefeedKeeper, ak for _, d := range gs.Deposits { k.SetDeposit(ctx, d) } - } // ExportGenesis export genesis state for cdp module diff --git a/x/cdp/genesis_test.go b/x/cdp/genesis_test.go index 4c7be4bc..21a08f7e 100644 --- a/x/cdp/genesis_test.go +++ b/x/cdp/genesis_test.go @@ -168,7 +168,6 @@ func (suite *GenesisTestSuite) TestValidGenState() { } func (suite *GenesisTestSuite) Test_InitExportGenesis() { - cdps := types.CDPs{ { ID: 2, diff --git a/x/cdp/integration_test.go b/x/cdp/integration_test.go index 920143d8..a3e135e7 100644 --- a/x/cdp/integration_test.go +++ b/x/cdp/integration_test.go @@ -108,6 +108,7 @@ func NewPricefeedGenStateMulti(cdc codec.JSONCodec) app.GenesisState { } return app.GenesisState{pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pfGenesis)} } + func NewCDPGenStateMulti(cdc codec.JSONCodec) app.GenesisState { cdpGenesis := types.GenesisState{ Params: types.Params{ diff --git a/x/cdp/keeper/auctions.go b/x/cdp/keeper/auctions.go index 98645610..87187a04 100644 --- a/x/cdp/keeper/auctions.go +++ b/x/cdp/keeper/auctions.go @@ -27,8 +27,8 @@ func (k Keeper) AuctionCollateral(ctx sdk.Context, deposits types.Deposits, coll // CreateAuctionsFromDeposit creates auctions from the input deposit func (k Keeper) CreateAuctionsFromDeposit( ctx sdk.Context, collateral sdk.Coin, collateralType string, returnAddr sdk.AccAddress, debt, auctionSize sdk.Int, - principalDenom string) error { - + principalDenom string, +) error { // number of auctions of auctionSize numberOfAuctions := collateral.Amount.Quo(auctionSize) debtPerAuction := debt.Mul(auctionSize).Quo(collateral.Amount) @@ -73,7 +73,6 @@ func (k Keeper) CreateAuctionsFromDeposit( sdk.NewCoin(principalDenom, debtAmount.Add(penalty)), []sdk.AccAddress{returnAddr}, []sdk.Int{auctionSize}, sdk.NewCoin(debtDenom, debtAmount), ) - if err != nil { return err } diff --git a/x/cdp/keeper/cdp.go b/x/cdp/keeper/cdp.go index 831f3b09..8661b41d 100644 --- a/x/cdp/keeper/cdp.go +++ b/x/cdp/keeper/cdp.go @@ -173,7 +173,6 @@ func (k Keeper) BurnDebtCoins(ctx sdk.Context, moduleAccount string, denom strin // GetCdpID returns the id of the cdp corresponding to a specific owner and collateral denom func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType string) (uint64, bool) { - cdpIDs, found := k.GetCdpIdsByOwner(ctx, owner) if !found { return 0, false @@ -185,7 +184,6 @@ func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType s } } return 0, false - } // GetCdpIdsByOwner returns all the ids of cdps corresponding to a particular owner @@ -256,7 +254,6 @@ func (k Keeper) DeleteCDP(ctx sdk.Context, cdp types.CDP) error { } store.Delete(types.CdpKey(cdp.Type, cdp.ID)) return nil - } // GetAllCdps returns all cdps from the store diff --git a/x/cdp/keeper/deposit.go b/x/cdp/keeper/deposit.go index 3966d4cb..65ff2158 100644 --- a/x/cdp/keeper/deposit.go +++ b/x/cdp/keeper/deposit.go @@ -124,7 +124,6 @@ func (k Keeper) GetDeposit(ctx sdk.Context, cdpID uint64, depositor sdk.AccAddre } k.cdc.MustUnmarshal(bz, &deposit) return deposit, true - } // SetDeposit sets the deposit in the store @@ -133,7 +132,6 @@ func (k Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit) { bz := k.cdc.MustMarshal(&deposit) store.Set(types.DepositKey(deposit.CdpID, deposit.Depositor), bz) - } // DeleteDeposit deletes a deposit from the store diff --git a/x/cdp/keeper/deposit_test.go b/x/cdp/keeper/deposit_test.go index 34456aed..faad7677 100644 --- a/x/cdp/keeper/deposit_test.go +++ b/x/cdp/keeper/deposit_test.go @@ -35,7 +35,8 @@ func (suite *DepositTestSuite) SetupTest() { cdc, []sdk.Coins{ cs(c("xrp", 500000000), c("btc", 500000000)), - cs(c("xrp", 200000000))}, + cs(c("xrp", 200000000)), + }, addrs[0:2], ) tApp.InitializeFromGenesisStates( diff --git a/x/cdp/keeper/draw_test.go b/x/cdp/keeper/draw_test.go index d56174f1..960bc8cb 100644 --- a/x/cdp/keeper/draw_test.go +++ b/x/cdp/keeper/draw_test.go @@ -53,7 +53,6 @@ func (suite *DrawTestSuite) SetupTest() { } func (suite *DrawTestSuite) TestAddRepayPrincipal() { - err := suite.keeper.AddPrincipal(suite.ctx, suite.addrs[0], "xrp-a", c("usdx", 10000000)) suite.NoError(err) @@ -125,7 +124,6 @@ func (suite *DrawTestSuite) TestAddRepayPrincipal() { bk = suite.app.GetBankKeeper() acc = ak.GetModuleAccount(suite.ctx, types.ModuleName) suite.Equal(sdk.Coins{}, bk.GetAllBalances(suite.ctx, acc.GetAddress())) - } func (suite *DrawTestSuite) TestRepayPrincipalOverpay() { diff --git a/x/cdp/keeper/grpc_query.go b/x/cdp/keeper/grpc_query.go index 94c5419d..4e699af0 100644 --- a/x/cdp/keeper/grpc_query.go +++ b/x/cdp/keeper/grpc_query.go @@ -97,8 +97,7 @@ func (s QueryServer) TotalCollateral(c context.Context, req *types.QueryTotalCol // collect collateral types for each denom for _, collateralParam := range params.CollateralParams { - denomCollateralTypes[collateralParam.Denom] = - append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type) + denomCollateralTypes[collateralParam.Denom] = append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type) } // sort collateral types alphabetically diff --git a/x/cdp/keeper/grpc_query_test.go b/x/cdp/keeper/grpc_query_test.go index e5f43a4b..a045388b 100644 --- a/x/cdp/keeper/grpc_query_test.go +++ b/x/cdp/keeper/grpc_query_test.go @@ -217,6 +217,7 @@ func (suite *grpcQueryTestSuite) TestGrpcQueryCdp() { }) } } + func (suite *grpcQueryTestSuite) TestGrpcQueryDeposits() { suite.addCdp() diff --git a/x/cdp/keeper/interest.go b/x/cdp/keeper/interest.go index 7b523b2c..994705b0 100644 --- a/x/cdp/keeper/interest.go +++ b/x/cdp/keeper/interest.go @@ -9,9 +9,7 @@ import ( "github.com/kava-labs/kava/x/cdp/types" ) -var ( - scalingFactor = 1e18 -) +var scalingFactor = 1e18 // AccumulateInterest calculates the new interest that has accrued for the input collateral type based on the total amount of principal // that has been created with that collateral type and the amount of time that has passed since interest was last accumulated diff --git a/x/cdp/keeper/interest_test.go b/x/cdp/keeper/interest_test.go index d28d1cda..a6109450 100644 --- a/x/cdp/keeper/interest_test.go +++ b/x/cdp/keeper/interest_test.go @@ -146,7 +146,6 @@ func (suite *InterestTestSuite) TestCalculateInterestFactor() { } func (suite *InterestTestSuite) TestAccumulateInterest() { - type args struct { ctype string initialTime time.Time @@ -385,7 +384,6 @@ func (suite *InterestTestSuite) TestSynchronizeInterest() { suite.Require().Equal(tc.args.expectedFees, cdp.AccumulatedFees) suite.Require().Equal(tc.args.expectedFeesUpdatedTime, cdp.FeesUpdated) - }) } } @@ -532,7 +530,6 @@ func (suite *InterestTestSuite) TestMultipleCDPInterest() { } suite.Require().Equal(tc.args.expectedSumOfCDPPrincipal, sumOfCDPPrincipal) - }) } } @@ -640,7 +637,6 @@ func (suite *InterestTestSuite) TestCalculateCDPInterest() { newInterest := suite.keeper.CalculateNewInterest(suite.ctx, cdp) suite.Require().Equal(tc.args.expectedFees, newInterest) - }) } } @@ -665,7 +661,6 @@ func (suite *InterestTestSuite) TestSyncInterestForRiskyCDPs() { oneYearInSeconds := 31536000 testCases := []test{ - { "1 year", args{ diff --git a/x/cdp/keeper/keeper.go b/x/cdp/keeper/keeper.go index dcc7947e..ee6f207e 100644 --- a/x/cdp/keeper/keeper.go +++ b/x/cdp/keeper/keeper.go @@ -27,7 +27,8 @@ type Keeper struct { // NewKeeper creates a new keeper func NewKeeper(cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace, pfk types.PricefeedKeeper, - ak types.AuctionKeeper, bk types.BankKeeper, ack types.AccountKeeper, maccs map[string][]string) Keeper { + ak types.AuctionKeeper, bk types.BankKeeper, ack types.AccountKeeper, maccs map[string][]string, +) Keeper { if !paramstore.HasKeyTable() { paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) } diff --git a/x/cdp/keeper/keeper_bench_test.go b/x/cdp/keeper/keeper_bench_test.go index e9b63d28..38427306 100644 --- a/x/cdp/keeper/keeper_bench_test.go +++ b/x/cdp/keeper/keeper_bench_test.go @@ -117,7 +117,6 @@ func BenchmarkCdpIteration(b *testing.B) { } }) } - } var errResult error diff --git a/x/cdp/keeper/querier.go b/x/cdp/keeper/querier.go index 643e23cf..ba15b557 100644 --- a/x/cdp/keeper/querier.go +++ b/x/cdp/keeper/querier.go @@ -68,7 +68,6 @@ func queryGetCdp(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQu return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } return bz, nil - } // query deposits on a particular cdp @@ -96,7 +95,6 @@ func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, leg return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } return bz, nil - } // query cdps with matching denom and ratio LESS THAN the input ratio @@ -264,8 +262,7 @@ func queryGetTotalCollateral(ctx sdk.Context, req abci.RequestQuery, keeper Keep // collect collateral types for each denom for _, collateralParam := range params.CollateralParams { - denomCollateralTypes[collateralParam.Denom] = - append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type) + denomCollateralTypes[collateralParam.Denom] = append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type) } // sort collateral types alphabetically diff --git a/x/cdp/keeper/querier_test.go b/x/cdp/keeper/querier_test.go index 03772abe..41fa16b1 100644 --- a/x/cdp/keeper/querier_test.go +++ b/x/cdp/keeper/querier_test.go @@ -152,7 +152,6 @@ func (suite *QuerierTestSuite) TestQueryCdp() { } _, err = suite.querier(ctx, []string{types.QueryGetCdp}, query) suite.Error(err) - } func (suite *QuerierTestSuite) TestQueryCdpsByCollateralType() { @@ -282,7 +281,6 @@ func (suite *QuerierTestSuite) TestQueryDeposits() { var d types.Deposits suite.Nil(suite.legacyAmino.UnmarshalJSON(bz, &d)) suite.Equal(deposits, d) - } func (suite *QuerierTestSuite) TestQueryAccounts() { diff --git a/x/cdp/types/errors.go b/x/cdp/types/errors.go index f248a223..1219d819 100644 --- a/x/cdp/types/errors.go +++ b/x/cdp/types/errors.go @@ -27,11 +27,11 @@ var ( ErrInvalidDeposit = sdkerrors.Register(ModuleName, 10, "invalid deposit") // ErrInvalidPayment error for invalid payment ErrInvalidPayment = sdkerrors.Register(ModuleName, 11, "invalid payment") - //ErrDepositNotAvailable error for withdrawing deposits in liquidation + // ErrDepositNotAvailable error for withdrawing deposits in liquidation ErrDepositNotAvailable = sdkerrors.Register(ModuleName, 12, "deposit in liquidation") // ErrInvalidWithdrawAmount error for invalid withdrawal amount ErrInvalidWithdrawAmount = sdkerrors.Register(ModuleName, 13, "withdrawal amount exceeds deposit") - //ErrCdpNotAvailable error for depositing to a CDP in liquidation + // ErrCdpNotAvailable error for depositing to a CDP in liquidation ErrCdpNotAvailable = sdkerrors.Register(ModuleName, 14, "cannot modify cdp in liquidation") // ErrBelowDebtFloor error for creating a cdp with debt below the minimum ErrBelowDebtFloor = sdkerrors.Register(ModuleName, 15, "proposed cdp debt is below minimum") diff --git a/x/cdp/types/genesis.go b/x/cdp/types/genesis.go index da13860f..07e0dd0d 100644 --- a/x/cdp/types/genesis.go +++ b/x/cdp/types/genesis.go @@ -11,7 +11,8 @@ import ( // NewGenesisState returns a new genesis state func NewGenesisState(params Params, cdps CDPs, deposits Deposits, startingCdpID uint64, debtDenom, govDenom string, prevAccumTimes GenesisAccumulationTimes, - totalPrincipals GenesisTotalPrincipals) GenesisState { + totalPrincipals GenesisTotalPrincipals, +) GenesisState { return GenesisState{ Params: params, CDPs: cdps, @@ -41,7 +42,6 @@ func DefaultGenesisState() GenesisState { // Validate performs basic validation of genesis data returning an // error for any failed validation criteria. func (gs GenesisState) Validate() error { - if err := gs.Params.Validate(); err != nil { return err } diff --git a/x/cdp/types/keys.go b/x/cdp/types/keys.go index a8fe3e83..4949ce2a 100644 --- a/x/cdp/types/keys.go +++ b/x/cdp/types/keys.go @@ -137,7 +137,6 @@ func CollateralRatioKey(collateralType string, cdpID uint64, ratio sdk.Dec) []by // SplitCollateralRatioKey split the collateral ratio key and return the denom, cdp id, and collateral:debt ratio func SplitCollateralRatioKey(key []byte) (string, uint64, sdk.Dec) { - cdpID := GetCdpIDFromBytes(key[len(key)-8:]) split := bytes.Split(key[:len(key)-8], sep) collateralType := string(split[0]) diff --git a/x/cdp/types/params.go b/x/cdp/types/params.go index 7e841580..c00f58b8 100644 --- a/x/cdp/types/params.go +++ b/x/cdp/types/params.go @@ -68,7 +68,8 @@ func DefaultParams() Params { // NewCollateralParam returns a new CollateralParam func NewCollateralParam( denom, ctype string, liqRatio sdk.Dec, debtLimit sdk.Coin, stabilityFee sdk.Dec, auctionSize sdk.Int, - liqPenalty sdk.Dec, spotMarketID, liquidationMarketID string, keeperReward sdk.Dec, checkIndexCount sdk.Int, conversionFactor sdk.Int) CollateralParam { + liqPenalty sdk.Dec, spotMarketID, liquidationMarketID string, keeperReward sdk.Dec, checkIndexCount sdk.Int, conversionFactor sdk.Int, +) CollateralParam { return CollateralParam{ Denom: denom, Type: ctype, diff --git a/x/committee/client/rest/tx.go b/x/committee/client/rest/tx.go index a7ac546d..73aae0e7 100644 --- a/x/committee/client/rest/tx.go +++ b/x/committee/client/rest/tx.go @@ -31,7 +31,6 @@ type PostProposalReq struct { func postProposalHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - // Parse and validate url params vars := mux.Vars(r) if len(vars[RestCommitteeID]) == 0 { @@ -78,7 +77,6 @@ type PostVoteReq struct { func postVoteHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - // Parse and validate url params vars := mux.Vars(r) if len(vars[RestProposalID]) == 0 { @@ -148,7 +146,6 @@ func ProposalRESTHandler(cliCtx client.Context) govrest.ProposalRESTHandler { func postGovProposalHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - // Parse and validate http request body var req PostGovProposalReq if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { diff --git a/x/committee/genesis_test.go b/x/committee/genesis_test.go index 17565981..4aab900b 100644 --- a/x/committee/genesis_test.go +++ b/x/committee/genesis_test.go @@ -33,7 +33,6 @@ func (suite *GenesisTestSuite) SetupTest() { } func (suite *GenesisTestSuite) TestInitGenesis() { - memberCom := types.MustNewMemberCommittee( 1, "This member committee is for testing.", diff --git a/x/committee/keeper/_param_permission_test.go b/x/committee/keeper/_param_permission_test.go index f9170478..4163c510 100644 --- a/x/committee/keeper/_param_permission_test.go +++ b/x/committee/keeper/_param_permission_test.go @@ -260,8 +260,8 @@ func (suite *PermissionTestSuite) TestSubParamChangePermission_Allows() { ) }) } - } + func TestPermissionTestSuite(t *testing.T) { suite.Run(t, new(PermissionTestSuite)) } diff --git a/x/committee/keeper/integration_test.go b/x/committee/keeper/integration_test.go index dc463bdf..e118af40 100644 --- a/x/committee/keeper/integration_test.go +++ b/x/committee/keeper/integration_test.go @@ -16,7 +16,6 @@ import ( // getProposalVoteMap collects up votes into a map indexed by proposalID func getProposalVoteMap(k keeper.Keeper, ctx sdk.Context) map[uint64]([]types.Vote) { - proposalVoteMap := map[uint64]([]types.Vote){} k.IterateProposals(ctx, func(p types.Proposal) bool { diff --git a/x/committee/keeper/keeper.go b/x/committee/keeper/keeper.go index a4d2c668..3fdc8c88 100644 --- a/x/committee/keeper/keeper.go +++ b/x/committee/keeper/keeper.go @@ -25,7 +25,8 @@ type Keeper struct { } func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, router govtypes.Router, - paramKeeper types.ParamKeeper, ak types.AccountKeeper, sk types.BankKeeper) Keeper { + paramKeeper types.ParamKeeper, ak types.AccountKeeper, sk types.BankKeeper, +) Keeper { // Logic in the keeper methods assume the set of gov handlers is fixed. // So the gov router must be sealed so no handlers can be added or removed after the keeper is created. router.Seal() diff --git a/x/committee/keeper/msg_server_test.go b/x/committee/keeper/msg_server_test.go index edb99440..d8eb5246 100644 --- a/x/committee/keeper/msg_server_test.go +++ b/x/committee/keeper/msg_server_test.go @@ -66,7 +66,7 @@ func (suite *MsgServerTestSuite) SetupTest() { suite.app.InitializeFromGenesisStates( app.GenesisState{types.ModuleName: cdc.MustMarshalJSON(testGenesis)}, // TODO: not used? - //NewDistributionGenesisWithPool(suite.communityPoolAmt), + // NewDistributionGenesisWithPool(suite.communityPoolAmt), ) suite.ctx = suite.app.NewContext(true, tmproto.Header{Height: 1, Time: firstBlockTime}) } @@ -118,7 +118,6 @@ func (suite *MsgServerTestSuite) TestSubmitProposalMsg_Invalid() { suite.keeper.GetProposalsByCommittee(suite.ctx, committeeID), "proposal found when none should exist", ) - } func (suite *MsgServerTestSuite) TestSubmitProposalMsg_ValidUpgrade() { diff --git a/x/committee/keeper/proposal.go b/x/committee/keeper/proposal.go index 892dbabc..95d8b232 100644 --- a/x/committee/keeper/proposal.go +++ b/x/committee/keeper/proposal.go @@ -57,7 +57,6 @@ func (k Keeper) AddVote(ctx sdk.Context, proposalID uint64, voter sdk.AccAddress } if pr.HasExpiredBy(ctx.BlockTime()) { return sdkerrors.Wrapf(types.ErrProposalExpired, "%s ≥ %s", ctx.BlockTime(), pr.Deadline) - } com, found := k.GetCommittee(ctx, pr.CommitteeID) if !found { @@ -189,7 +188,8 @@ func (k Keeper) GetTokenCommitteeProposalResult(ctx sdk.Context, proposalID uint // total current votes, total possible votes (equal to token supply), vote threshold (yes vote ratio // required for proposal to pass), and quorum (votes tallied at this percentage). func (k Keeper) TallyTokenCommitteeVotes(ctx sdk.Context, proposalID uint64, - tallyDenom string) (yesVotes, noVotes, totalVotes, possibleVotes sdk.Dec) { + tallyDenom string, +) (yesVotes, noVotes, totalVotes, possibleVotes sdk.Dec) { votes := k.GetVotesByProposal(ctx, proposalID) yesVotes = sdk.ZeroDec() diff --git a/x/committee/keeper/querier.go b/x/committee/keeper/querier.go index 7f46f970..14d889d8 100644 --- a/x/committee/keeper/querier.go +++ b/x/committee/keeper/querier.go @@ -43,7 +43,6 @@ func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { // ------------------------------------------ func queryCommittees(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - committees := keeper.GetCommittees(ctx) bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, committees) @@ -128,7 +127,6 @@ func queryNextProposalID(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac func queryVotes(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryProposalParams err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } diff --git a/x/committee/keeper/querier_test.go b/x/committee/keeper/querier_test.go index 5630daf1..cb0d5ee2 100644 --- a/x/committee/keeper/querier_test.go +++ b/x/committee/keeper/querier_test.go @@ -192,7 +192,6 @@ func (suite *QuerierTestSuite) TestQueryVote() { } func (suite *QuerierTestSuite) TestQueryTally() { - ctx := suite.ctx.WithIsCheckTx(false) // Expected result @@ -236,6 +235,7 @@ func (p *TestParams) ParamSetPairs() paramstypes.ParamSetPairs { paramstypes.NewParamSetPair([]byte(paramKey), &p.TestKey, func(interface{}) error { return nil }), } } + func (suite *QuerierTestSuite) TestQueryRawParams() { ctx := suite.ctx.WithIsCheckTx(false) diff --git a/x/committee/legacy/v0_15/committee.go b/x/committee/legacy/v0_15/committee.go index c73f2484..0dc397b7 100644 --- a/x/committee/legacy/v0_15/committee.go +++ b/x/committee/legacy/v0_15/committee.go @@ -239,7 +239,8 @@ type MemberCommittee struct { // NewMemberCommittee instantiates a new instance of MemberCommittee func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission, - threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) MemberCommittee { + threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, +) MemberCommittee { return MemberCommittee{ BaseCommittee: BaseCommittee{ ID: id, @@ -276,7 +277,8 @@ type TokenCommittee struct { // NewTokenCommittee instantiates a new instance of TokenCommittee func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission, - threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) TokenCommittee { + threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string, +) TokenCommittee { return TokenCommittee{ BaseCommittee: BaseCommittee{ ID: id, diff --git a/x/committee/legacy/v0_15/permissions.go b/x/committee/legacy/v0_15/permissions.go index 0f049bbf..fb978b1a 100644 --- a/x/committee/legacy/v0_15/permissions.go +++ b/x/committee/legacy/v0_15/permissions.go @@ -112,7 +112,8 @@ type AllowedCollateralParam struct { func NewAllowedCollateralParam( ctype string, denom, liqRatio, debtLimit, stabilityFee, auctionSize, liquidationPenalty, - prefix, spotMarket, liquidationMarket, conversionFactor, keeperReward, ltvIndexCount bool) AllowedCollateralParam { + prefix, spotMarket, liquidationMarket, conversionFactor, keeperReward, ltvIndexCount bool, +) AllowedCollateralParam { return AllowedCollateralParam{ Type: ctype, Denom: denom, diff --git a/x/committee/legacy/v0_16/migrate_test.go b/x/committee/legacy/v0_16/migrate_test.go index fb7f4b2b..23379fdc 100644 --- a/x/committee/legacy/v0_16/migrate_test.go +++ b/x/committee/legacy/v0_16/migrate_test.go @@ -105,7 +105,7 @@ func (s *migrateTestSuite) TestMigrate_PricefeedPermissions() { genstate := Migrate(s.v15genstate, s.v15pricefeedgenstate) - var uniqueMarkets = make(map[string]bool) + uniqueMarkets := make(map[string]bool) for _, permission := range genstate.GetCommittees()[0].GetPermissions() { paramChangePermission, ok := permission.(v016committee.ParamsChangePermission) diff --git a/x/committee/simulation/operations.go b/x/committee/simulation/operations.go index 74dd320d..6c092700 100644 --- a/x/committee/simulation/operations.go +++ b/x/committee/simulation/operations.go @@ -16,9 +16,7 @@ import ( "github.com/kava-labs/kava/x/committee/types" ) -var ( - proposalPassPercentage = 0.9 -) +var proposalPassPercentage = 0.9 type AccountKeeper interface { GetAccount(sdk.Context, sdk.AccAddress) authexported.Account @@ -27,8 +25,8 @@ type AccountKeeper interface { // WeightedOperations creates an operation (with weight) for each type of proposal generator. // Custom proposal generators can be added for more control over types of proposal submitted, eg to increase likelyhood of particular cdp param changes. func WeightedOperations(appParams simulation.AppParams, cdc *codec.Codec, ak AccountKeeper, - k keeper.Keeper, wContents []simulation.WeightedProposalContent) simulation.WeightedOperations { - + k keeper.Keeper, wContents []simulation.WeightedProposalContent, +) simulation.WeightedOperations { var wops simulation.WeightedOperations for _, wContent := range wContents { @@ -59,7 +57,6 @@ func WeightedOperations(appParams simulation.AppParams, cdc *codec.Codec, ak Acc // For each submit proposal msg, future ops for the vote messages are generated. Sometimes it doesn't run enough votes to allow the proposal to timeout - the likelihood of this happening is controlled by a parameter. func SimulateMsgSubmitProposal(cdc *codec.Codec, ak AccountKeeper, k keeper.Keeper, contentSim simulation.ContentSimulatorFn) simulation.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string) (simulation.OperationMsg, []simulation.FutureOperation, error) { - // 1) Send a submit proposal msg committees := k.GetCommittees(ctx) @@ -176,8 +173,8 @@ func SimulateMsgSubmitProposal(cdc *codec.Codec, ak AccountKeeper, k keeper.Keep func SimulateMsgVote(k keeper.Keeper, ak AccountKeeper, voter sdk.AccAddress, proposalID uint64, voteType types.VoteType) simulation.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string) ( - opMsg simulation.OperationMsg, fOps []simulation.FutureOperation, err error) { - + opMsg simulation.OperationMsg, fOps []simulation.FutureOperation, err error, + ) { msg := types.NewMsgVote(voter, proposalID, voteType) account := ak.GetAccount(ctx, voter) diff --git a/x/committee/types/committee.go b/x/committee/types/committee.go index 9f4542f1..96df78d1 100644 --- a/x/committee/types/committee.go +++ b/x/committee/types/committee.go @@ -242,7 +242,8 @@ func (c BaseCommittee) Validate() error { // NewMemberCommittee instantiates a new instance of MemberCommittee func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission, - threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) (*MemberCommittee, error) { + threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, +) (*MemberCommittee, error) { permissionsAny, err := PackPermissions(permissions) if err != nil { return nil, err @@ -262,7 +263,8 @@ func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, // MustNewMemberCommittee instantiates a new instance of MemberCommittee and panics on error func MustNewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission, - threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) *MemberCommittee { + threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, +) *MemberCommittee { committee, err := NewMemberCommittee(id, description, members, permissions, threshold, duration, tallyOption) if err != nil { panic(err) @@ -275,7 +277,8 @@ func (c MemberCommittee) GetType() string { return MemberCommitteeType } // NewTokenCommittee instantiates a new instance of TokenCommittee func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission, - threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) (*TokenCommittee, error) { + threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string, +) (*TokenCommittee, error) { permissionsAny, err := PackPermissions(permissions) if err != nil { return nil, err @@ -297,7 +300,8 @@ func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, // MustNewTokenCommittee instantiates a new instance of TokenCommittee and panics on error func MustNewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission, - threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) *TokenCommittee { + threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string, +) *TokenCommittee { committee, err := NewTokenCommittee(id, description, members, permissions, threshold, duration, tallyOption, quorum, tallyDenom) if err != nil { panic(err) diff --git a/x/committee/types/genesis_test.go b/x/committee/types/genesis_test.go index ecebe6a2..99f6e002 100644 --- a/x/committee/types/genesis_test.go +++ b/x/committee/types/genesis_test.go @@ -57,8 +57,9 @@ func TestGenesisState_Validate(t *testing.T) { "hard", ), }, - types.Proposals{types.MustNewProposal( - govtypes.NewTextProposal("A Title", "A description of this proposal."), 1, 1, testTime.Add(7*24*time.Hour)), + types.Proposals{ + types.MustNewProposal( + govtypes.NewTextProposal("A Title", "A description of this proposal."), 1, 1, testTime.Add(7*24*time.Hour)), }, []types.Vote{ {ProposalID: 1, Voter: addresses[0], VoteType: types.VOTE_TYPE_YES}, diff --git a/x/committee/types/msg_test.go b/x/committee/types/msg_test.go index 228c42fb..803d9fd5 100644 --- a/x/committee/types/msg_test.go +++ b/x/committee/types/msg_test.go @@ -45,7 +45,6 @@ func TestMsgSubmitProposal_ValidateBasic(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := tc.msg.ValidateBasic() if tc.expectPass { @@ -98,7 +97,6 @@ func TestMsgVote_ValidateBasic(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := tc.msg.ValidateBasic() if tc.expectPass { diff --git a/x/committee/types/param_permissions_test.go b/x/committee/types/param_permissions_test.go index 0fc6dc2c..0835b88c 100644 --- a/x/committee/types/param_permissions_test.go +++ b/x/committee/types/param_permissions_test.go @@ -794,16 +794,18 @@ func (s *ParamsChangeTestSuite) TestParamsChangePermission_NoSubparamRequirement { name: "fail if one change is not allowed", expected: false, - changes: []paramsproposal.ParamChange{{ - Subspace: cdptypes.ModuleName, - Key: string(cdptypes.KeySurplusThreshold), - Value: sdk.NewInt(120).String(), - }, + changes: []paramsproposal.ParamChange{ + { + Subspace: cdptypes.ModuleName, + Key: string(cdptypes.KeySurplusThreshold), + Value: sdk.NewInt(120).String(), + }, { Subspace: cdptypes.ModuleName, Key: string(cdptypes.KeySurplusLot), Value: sdk.NewInt(120).String(), - }}, + }, + }, }, } @@ -834,7 +836,6 @@ func TestParamsChangeTestSuite(t *testing.T) { } func TestAllowedParamsChanges_Get(t *testing.T) { - exampleAPCs := types.AllowedParamsChanges{ { Subspace: "subspaceA", @@ -907,7 +908,6 @@ func TestAllowedParamsChanges_Get(t *testing.T) { } func TestAllowedParamsChanges_Set(t *testing.T) { - exampleAPCs := types.AllowedParamsChanges{ { Subspace: "subspaceA", @@ -1029,7 +1029,6 @@ func TestAllowedParamsChanges_Set(t *testing.T) { } func TestAllowedParamsChanges_Delete(t *testing.T) { - exampleAPCs := types.AllowedParamsChanges{ { Subspace: "subspaceA", diff --git a/x/evmutil/keeper/bank_keeper_test.go b/x/evmutil/keeper/bank_keeper_test.go index 38e45624..16b87464 100644 --- a/x/evmutil/keeper/bank_keeper_test.go +++ b/x/evmutil/keeper/bank_keeper_test.go @@ -150,7 +150,7 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromModuleToAccount() { sdk.NewCoins(sdk.NewInt64Coin("akava", 98_000_000_000_000)), sdk.Coins{}, sdk.NewCoins( - sdk.NewInt64Coin("akava", 00), + sdk.NewInt64Coin("akava", 0o0), sdk.NewInt64Coin("ukava", 98), ), false, diff --git a/x/evmutil/keeper/invariants.go b/x/evmutil/keeper/invariants.go index a2e5fdb2..1a7d0109 100644 --- a/x/evmutil/keeper/invariants.go +++ b/x/evmutil/keeper/invariants.go @@ -33,7 +33,6 @@ func FullyBackedInvariant(bankK types.BankKeeper, k Keeper) sdk.Invariant { message := sdk.FormatInvariant(types.ModuleName, "fully backed broken", "sum of minor balances greater than module account") return func(ctx sdk.Context) (string, bool) { - totalMinorBalances := sdk.ZeroInt() k.IterateAllAccounts(ctx, func(acc types.Account) bool { totalMinorBalances = totalMinorBalances.Add(acc.Balance) @@ -55,7 +54,6 @@ func SmallBalancesInvariant(_ types.BankKeeper, k Keeper) sdk.Invariant { message := sdk.FormatInvariant(types.ModuleName, "small balances broken", "minor balances not all less than overflow") return func(ctx sdk.Context) (string, bool) { - k.IterateAllAccounts(ctx, func(account types.Account) bool { if account.Balance.GTE(ConversionMultiplier) { broken = true diff --git a/x/evmutil/keeper/invariants_test.go b/x/evmutil/keeper/invariants_test.go index 072a065d..e963c46f 100644 --- a/x/evmutil/keeper/invariants_test.go +++ b/x/evmutil/keeper/invariants_test.go @@ -78,7 +78,6 @@ func (suite *invariantTestSuite) runInvariant(route string, invariant func(bankK } func (suite *invariantTestSuite) TestFullyBackedInvariant() { - // default state is valid _, broken := suite.runInvariant("fully-backed", keeper.FullyBackedInvariant) suite.Equal(false, broken) diff --git a/x/evmutil/types/keys.go b/x/evmutil/types/keys.go index e64fea05..a3805430 100644 --- a/x/evmutil/types/keys.go +++ b/x/evmutil/types/keys.go @@ -12,9 +12,7 @@ const ( StoreKey = "utilevm" // cannot be emvutil due to collision with x/evm ) -var ( - AccountStoreKeyPrefix = []byte{0x00} // prefix for keys that store accounts -) +var AccountStoreKeyPrefix = []byte{0x00} // prefix for keys that store accounts // AccountStoreKey turns an address to a key used to get the account from the store func AccountStoreKey(addr sdk.AccAddress) []byte { diff --git a/x/hard/genesis_test.go b/x/hard/genesis_test.go index 5c57450a..da91b4ae 100644 --- a/x/hard/genesis_test.go +++ b/x/hard/genesis_test.go @@ -39,7 +39,6 @@ func (suite *GenesisTestSuite) SetupTest() { } func (suite *GenesisTestSuite) Test_InitExportGenesis() { - loanToValue, _ := sdk.NewDecFromStr("0.6") params := types.NewParams( types.MoneyMarkets{ diff --git a/x/hard/keeper/borrow_test.go b/x/hard/keeper/borrow_test.go index 97deeec5..a0db8c78 100644 --- a/x/hard/keeper/borrow_test.go +++ b/x/hard/keeper/borrow_test.go @@ -427,7 +427,6 @@ func (suite *KeeperTestSuite) TestBorrow() { } func (suite *KeeperTestSuite) TestValidateBorrow() { - blockDuration := time.Second * 3600 * 24 // long blocks to accumulate larger interest _, addrs := app.GeneratePrivKeyAddressPairs(5) diff --git a/x/hard/keeper/grpc_query_test.go b/x/hard/keeper/grpc_query_test.go index 39789a4d..a330c3be 100644 --- a/x/hard/keeper/grpc_query_test.go +++ b/x/hard/keeper/grpc_query_test.go @@ -55,7 +55,6 @@ func (suite *grpcQueryTestSuite) SetupTest() { addrs, ), ) - } func (suite *grpcQueryTestSuite) TestGrpcQueryParams() { diff --git a/x/hard/keeper/interest.go b/x/hard/keeper/interest.go index 499c3c6b..6f5a3449 100644 --- a/x/hard/keeper/interest.go +++ b/x/hard/keeper/interest.go @@ -60,7 +60,6 @@ func (k Keeper) ApplyInterestRateUpdates(ctx sdk.Context) { // AccrueInterest applies accrued interest to total borrows and reserves by calculating // interest from the last checkpoint time and writing the updated values to the store. func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error { - previousAccrualTime, found := k.GetPreviousAccrualTime(ctx, denom) if !found { k.SetPreviousAccrualTime(ctx, denom, ctx.BlockTime()) diff --git a/x/hard/keeper/keeper.go b/x/hard/keeper/keeper.go index c98451e9..6b621c7f 100644 --- a/x/hard/keeper/keeper.go +++ b/x/hard/keeper/keeper.go @@ -26,7 +26,8 @@ type Keeper struct { // NewKeeper creates a new keeper func NewKeeper(cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace, ak types.AccountKeeper, bk types.BankKeeper, - pfk types.PricefeedKeeper, auk types.AuctionKeeper) Keeper { + pfk types.PricefeedKeeper, auk types.AuctionKeeper, +) Keeper { if !paramstore.HasKeyTable() { paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) } diff --git a/x/hard/keeper/keeper_test.go b/x/hard/keeper/keeper_test.go index 90a61949..8558c142 100644 --- a/x/hard/keeper/keeper_test.go +++ b/x/hard/keeper/keeper_test.go @@ -62,7 +62,6 @@ func (suite *KeeperTestSuite) TestGetSetDeleteDeposit() { _, f = suite.keeper.GetDeposit(suite.ctx, sdk.AccAddress("test")) suite.Require().False(f) - } func (suite *KeeperTestSuite) TestIterateDeposits() { diff --git a/x/hard/keeper/liquidation.go b/x/hard/keeper/liquidation.go index 315b0bd0..58b9c930 100644 --- a/x/hard/keeper/liquidation.go +++ b/x/hard/keeper/liquidation.go @@ -73,7 +73,8 @@ func (k Keeper) AttemptKeeperLiquidation(ctx sdk.Context, keeper sdk.AccAddress, // SeizeDeposits seizes a list of deposits and sends them to auction func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit types.Deposit, - borrow types.Borrow, dDenoms, bDenoms []string) error { + borrow types.Borrow, dDenoms, bDenoms []string, +) error { liqMap, err := k.LoadLiquidationData(ctx, deposit, borrow) if err != nil { return err @@ -146,7 +147,8 @@ func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit ty // StartAuctions attempts to start auctions for seized assets func (k Keeper) StartAuctions(ctx sdk.Context, borrower sdk.AccAddress, borrows, deposits sdk.Coins, - depositCoinValues, borrowCoinValues types.ValuationMap, ltv sdk.Dec, liqMap map[string]LiqData) (sdk.Coins, error) { + depositCoinValues, borrowCoinValues types.ValuationMap, ltv sdk.Dec, liqMap map[string]LiqData, +) (sdk.Coins, error) { // Sort keys to ensure deterministic behavior bKeys := borrowCoinValues.GetSortedKeys() dKeys := depositCoinValues.GetSortedKeys() @@ -387,7 +389,6 @@ func (k Keeper) LoadLiquidationData(ctx sdk.Context, deposit types.Deposit, borr mm, found := k.GetMoneyMarket(ctx, denom) if !found { return liqMap, sdkerrors.Wrapf(types.ErrMarketNotFound, "no market found for denom %s", denom) - } priceData, err := k.pricefeedKeeper.GetCurrentPrice(ctx, mm.SpotMarketID) diff --git a/x/hard/keeper/querier.go b/x/hard/keeper/querier.go index 751f5449..3c33b08b 100644 --- a/x/hard/keeper/querier.go +++ b/x/hard/keeper/querier.go @@ -82,7 +82,6 @@ func queryGetModAccounts(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac } bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, response) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } @@ -91,7 +90,6 @@ func queryGetModAccounts(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac } func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDepositsParams err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) if err != nil { @@ -163,7 +161,6 @@ func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQu } func queryGetUnsyncedDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryUnsyncedDepositsParams err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) if err != nil { @@ -219,7 +216,6 @@ func queryGetUnsyncedDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, } func queryGetBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryBorrowsParams err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) if err != nil { @@ -291,7 +287,6 @@ func queryGetBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQue } func queryGetUnsyncedBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryUnsyncedBorrowsParams err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) if err != nil { diff --git a/x/hard/keeper/withdraw_test.go b/x/hard/keeper/withdraw_test.go index d5df71ee..6613d26b 100644 --- a/x/hard/keeper/withdraw_test.go +++ b/x/hard/keeper/withdraw_test.go @@ -207,7 +207,6 @@ func (suite *KeeperTestSuite) TestWithdraw() { suite.Require().True(strings.Contains(err.Error(), tc.errArgs.contains)) } }) - } } diff --git a/x/hard/types/borrow.go b/x/hard/types/borrow.go index 834c72da..c439c89d 100644 --- a/x/hard/types/borrow.go +++ b/x/hard/types/borrow.go @@ -122,7 +122,6 @@ func (bif BorrowInterestFactor) Validate() error { } if bif.Value.IsNegative() { return fmt.Errorf("borrow interest factor value cannot be negative: %s", bif) - } return nil } diff --git a/x/hard/types/borrow_test.go b/x/hard/types/borrow_test.go index 5f7994bb..107bf1f2 100644 --- a/x/hard/types/borrow_test.go +++ b/x/hard/types/borrow_test.go @@ -113,5 +113,4 @@ func TestBorrow_NormalizedBorrow(t *testing.T) { } }) } - } diff --git a/x/hard/types/deposit.go b/x/hard/types/deposit.go index 8a13cdf5..8850739d 100644 --- a/x/hard/types/deposit.go +++ b/x/hard/types/deposit.go @@ -122,7 +122,6 @@ func (sif SupplyInterestFactor) Validate() error { } if sif.Value.IsNegative() { return fmt.Errorf("supply interest factor value cannot be negative: %s", sif) - } return nil } diff --git a/x/hard/types/deposit_test.go b/x/hard/types/deposit_test.go index 7247c13b..7776fb40 100644 --- a/x/hard/types/deposit_test.go +++ b/x/hard/types/deposit_test.go @@ -113,5 +113,4 @@ func TestDeposit_NormalizedDeposit(t *testing.T) { } }) } - } diff --git a/x/hard/types/genesis.go b/x/hard/types/genesis.go index 0e4441b0..e138b16a 100644 --- a/x/hard/types/genesis.go +++ b/x/hard/types/genesis.go @@ -10,7 +10,8 @@ import ( // NewGenesisState returns a new genesis state func NewGenesisState( params Params, prevAccumulationTimes GenesisAccumulationTimes, deposits Deposits, - borrows Borrows, totalSupplied, totalBorrowed, totalReserves sdk.Coins) GenesisState { + borrows Borrows, totalSupplied, totalBorrowed, totalReserves sdk.Coins, +) GenesisState { return GenesisState{ Params: params, PreviousAccumulationTimes: prevAccumulationTimes, @@ -38,7 +39,6 @@ func DefaultGenesisState() GenesisState { // Validate performs basic validation of genesis data returning an // error for any failed validation criteria. func (gs GenesisState) Validate() error { - if err := gs.Params.Validate(); err != nil { return err } diff --git a/x/hard/types/params.go b/x/hard/types/params.go index 359f7817..61015889 100644 --- a/x/hard/types/params.go +++ b/x/hard/types/params.go @@ -61,7 +61,8 @@ func (bl BorrowLimit) Equal(blCompareTo BorrowLimit) bool { // NewMoneyMarket returns a new MoneyMarket func NewMoneyMarket(denom string, borrowLimit BorrowLimit, spotMarketID string, conversionFactor sdk.Int, - interestRateModel InterestRateModel, reserveFactor, keeperRewardPercentage sdk.Dec) MoneyMarket { + interestRateModel InterestRateModel, reserveFactor, keeperRewardPercentage sdk.Dec, +) MoneyMarket { return MoneyMarket{ Denom: denom, BorrowLimit: borrowLimit, diff --git a/x/incentive/client/cli/tx.go b/x/incentive/client/cli/tx.go index a692e01d..81579df2 100644 --- a/x/incentive/client/cli/tx.go +++ b/x/incentive/client/cli/tx.go @@ -14,8 +14,10 @@ import ( "github.com/kava-labs/kava/x/incentive/types" ) -const multiplierFlag = "multiplier" -const multiplierFlagShort = "m" +const ( + multiplierFlag = "multiplier" + multiplierFlagShort = "m" +) // GetTxCmd returns the transaction cli commands for the incentive module func GetTxCmd() *cobra.Command { @@ -42,7 +44,6 @@ func GetTxCmd() *cobra.Command { } func getCmdClaimCdp() *cobra.Command { - cmd := &cobra.Command{ Use: "claim-cdp [multiplier]", Short: "claim USDX minting rewards using a given multiplier", diff --git a/x/incentive/client/rest/query.go b/x/incentive/client/rest/query.go index 701397c8..fa086bbb 100644 --- a/x/incentive/client/rest/query.go +++ b/x/incentive/client/rest/query.go @@ -183,7 +183,6 @@ func executeSwapRewardsQuery(w http.ResponseWriter, cliCtx client.Context, param } func executeAllRewardQueries(w http.ResponseWriter, cliCtx client.Context, params types.QueryRewardsParams) { - paramsBz, err := cliCtx.LegacyAmino.MarshalJSON(params) if err != nil { rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err)) diff --git a/x/incentive/client/rest/tx.go b/x/incentive/client/rest/tx.go index 1108f6fa..dd7fe70a 100644 --- a/x/incentive/client/rest/tx.go +++ b/x/incentive/client/rest/tx.go @@ -29,14 +29,17 @@ func usdxMintingGenerator(req PostClaimReq) (sdk.Msg, error) { msg := types.NewMsgClaimUSDXMintingReward(req.Sender.String(), req.DenomsToClaim[0].MultiplierName) return &msg, nil } + func hardGenerator(req PostClaimReq) (sdk.Msg, error) { msg := types.NewMsgClaimHardReward(req.Sender.String(), req.DenomsToClaim) return &msg, nil } + func delegatorGenerator(req PostClaimReq) (sdk.Msg, error) { msg := types.NewMsgClaimDelegatorReward(req.Sender.String(), req.DenomsToClaim) return &msg, nil } + func swapGenerator(req PostClaimReq) (sdk.Msg, error) { msg := types.NewMsgClaimSwapReward(req.Sender.String(), req.DenomsToClaim) return &msg, nil diff --git a/x/incentive/keeper/hooks.go b/x/incentive/keeper/hooks.go index 3b9425f3..b52e95f5 100644 --- a/x/incentive/keeper/hooks.go +++ b/x/incentive/keeper/hooks.go @@ -15,11 +15,13 @@ type Hooks struct { k Keeper } -var _ cdptypes.CDPHooks = Hooks{} -var _ hardtypes.HARDHooks = Hooks{} -var _ stakingtypes.StakingHooks = Hooks{} -var _ swaptypes.SwapHooks = Hooks{} -var _ savingstypes.SavingsHooks = Hooks{} +var ( + _ cdptypes.CDPHooks = Hooks{} + _ hardtypes.HARDHooks = Hooks{} + _ stakingtypes.StakingHooks = Hooks{} + _ swaptypes.SwapHooks = Hooks{} + _ savingstypes.SavingsHooks = Hooks{} +) // Hooks create new incentive hooks func (k Keeper) Hooks() Hooks { return Hooks{k} } diff --git a/x/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index a9385725..28964acf 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -30,7 +30,6 @@ func NewKeeper( cdpk types.CdpKeeper, hk types.HardKeeper, ak types.AccountKeeper, stk types.StakingKeeper, swpk types.SwapKeeper, svk types.SavingsKeeper, ) Keeper { - if !paramstore.HasKeyTable() { paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) } @@ -66,7 +65,6 @@ func (k Keeper) SetUSDXMintingClaim(ctx sdk.Context, c types.USDXMintingClaim) { store := prefix.NewStore(ctx.KVStore(k.key), types.USDXMintingClaimKeyPrefix) bz := k.cdc.MustMarshal(&c) store.Set(c.Owner, bz) - } // DeleteUSDXMintingClaim deletes the claim in the store corresponding to the input address, collateral type, and id diff --git a/x/incentive/keeper/payout_test.go b/x/incentive/keeper/payout_test.go index 90ba9e88..2dd5378e 100644 --- a/x/incentive/keeper/payout_test.go +++ b/x/incentive/keeper/payout_test.go @@ -55,7 +55,6 @@ func (suite *PayoutTestSuite) SetupApp() { suite.cdpKeeper = suite.app.GetCDPKeeper() suite.ctx = suite.app.NewContext(true, tmprototypes.Header{Time: suite.genesisTime}) - } func (suite *PayoutTestSuite) SetupWithGenState(authBuilder app.AuthBankGenesisBuilder, incentBuilder testutil.IncentiveGenesisBuilder, hardBuilder testutil.HardGenesisBuilder) { @@ -117,7 +116,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, origVestingCoins: cs(c("ukava", 20)), startTime: 100, endTime: 120, @@ -130,7 +130,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 2, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, expectedStartTime: 100, expectedEndTime: 120, }, @@ -147,7 +148,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, origVestingCoins: cs(c("ukava", 20)), startTime: 100, endTime: 120, @@ -160,7 +162,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 18, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, expectedStartTime: 80, expectedEndTime: 120, }, @@ -177,7 +180,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, origVestingCoins: cs(c("ukava", 20)), startTime: 100, endTime: 120, @@ -190,7 +194,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 3, Amount: cs(c("ukava", 6))}, {Length: 2, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, expectedStartTime: 100, expectedEndTime: 120, }, @@ -207,7 +212,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, origVestingCoins: cs(c("ukava", 20)), startTime: 100, endTime: 120, @@ -220,7 +226,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 12, Amount: cs(c("ukava", 6))}}, + {Length: 12, Amount: cs(c("ukava", 6))}, + }, expectedStartTime: 100, expectedEndTime: 132, }, @@ -237,7 +244,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, origVestingCoins: cs(c("ukava", 20)), startTime: 100, endTime: 120, @@ -249,7 +257,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 11))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, expectedStartTime: 100, expectedEndTime: 120, }, @@ -266,7 +275,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, origVestingCoins: cs(c("ukava", 20)), startTime: 100, endTime: 120, @@ -279,7 +289,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 12, Amount: cs(c("ukava", 6))}}, + {Length: 12, Amount: cs(c("ukava", 6))}, + }, expectedStartTime: 100, expectedEndTime: 132, }, @@ -296,7 +307,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 5, Amount: cs(c("ukava", 5))}}, + {Length: 5, Amount: cs(c("ukava", 5))}, + }, origVestingCoins: cs(c("ukava", 20)), startTime: 100, endTime: 120, @@ -309,7 +321,8 @@ func (suite *PayoutTestSuite) TestSendCoinsToPeriodicVestingAccount() { {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, {Length: 5, Amount: cs(c("ukava", 5))}, - {Length: 40, Amount: cs(c("ukava", 6))}}, + {Length: 40, Amount: cs(c("ukava", 6))}, + }, expectedStartTime: 100, expectedEndTime: 160, }, diff --git a/x/incentive/keeper/querier.go b/x/incentive/keeper/querier.go index 3f94d54f..1ca93cb6 100644 --- a/x/incentive/keeper/querier.go +++ b/x/incentive/keeper/querier.go @@ -262,7 +262,6 @@ func queryGetSavingsRewards(ctx sdk.Context, req abci.RequestQuery, k Keeper, le } func queryGetRewardFactors(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var usdxFactors types.RewardIndexes k.IterateUSDXMintingRewardFactors(ctx, func(collateralType string, factor sdk.Dec) (stop bool) { usdxFactors = usdxFactors.With(collateralType, factor) diff --git a/x/incentive/keeper/rewards_borrow.go b/x/incentive/keeper/rewards_borrow.go index eb534b94..a4edb690 100644 --- a/x/incentive/keeper/rewards_borrow.go +++ b/x/incentive/keeper/rewards_borrow.go @@ -13,7 +13,6 @@ import ( // AccumulateHardBorrowRewards calculates new rewards to distribute this block and updates the global indexes to reflect this. // The provided rewardPeriod must be valid to avoid panics in calculating time durations. func (k Keeper) AccumulateHardBorrowRewards(ctx sdk.Context, rewardPeriod types.MultiRewardPeriod) { - previousAccrualTime, found := k.GetPreviousHardBorrowRewardAccrualTime(ctx, rewardPeriod.CollateralType) if !found { previousAccrualTime = ctx.BlockTime() @@ -100,7 +99,6 @@ func (k Keeper) SynchronizeHardBorrowReward(ctx sdk.Context, borrow hardtypes.Bo } for _, normedBorrow := range normalizedBorrows { - claim = k.synchronizeSingleHardBorrowReward(ctx, claim, normedBorrow.Denom, normedBorrow.Amount) } k.SetHardLiquidityProviderClaim(ctx, claim) diff --git a/x/incentive/keeper/rewards_borrow_init_test.go b/x/incentive/keeper/rewards_borrow_init_test.go index 39d3815e..4c8f0b58 100644 --- a/x/incentive/keeper/rewards_borrow_init_test.go +++ b/x/incentive/keeper/rewards_borrow_init_test.go @@ -41,6 +41,7 @@ func (suite *InitializeHardBorrowRewardTests) TestClaimIndexesAreSetWhenClaimExi syncedClaim, _ := suite.keeper.GetHardLiquidityProviderClaim(suite.ctx, claim.Owner) suite.Equal(globalIndexes, syncedClaim.BorrowRewardIndexes) } + func (suite *InitializeHardBorrowRewardTests) TestClaimIndexesAreSetWhenClaimDoesNotExist() { globalIndexes := nonEmptyMultiRewardIndexes suite.storeGlobalBorrowIndexes(globalIndexes) @@ -56,8 +57,8 @@ func (suite *InitializeHardBorrowRewardTests) TestClaimIndexesAreSetWhenClaimDoe suite.True(found) suite.Equal(globalIndexes, syncedClaim.BorrowRewardIndexes) } -func (suite *InitializeHardBorrowRewardTests) TestClaimIndexesAreSetEmptyForMissingIndexes() { +func (suite *InitializeHardBorrowRewardTests) TestClaimIndexesAreSetEmptyForMissingIndexes() { globalIndexes := nonEmptyMultiRewardIndexes suite.storeGlobalBorrowIndexes(globalIndexes) diff --git a/x/incentive/keeper/rewards_borrow_sync_test.go b/x/incentive/keeper/rewards_borrow_sync_test.go index 728f3974..63f0d70c 100644 --- a/x/incentive/keeper/rewards_borrow_sync_test.go +++ b/x/incentive/keeper/rewards_borrow_sync_test.go @@ -45,6 +45,7 @@ func (suite *SynchronizeHardBorrowRewardTests) TestClaimIndexesAreUpdatedWhenGlo syncedClaim, _ := suite.keeper.GetHardLiquidityProviderClaim(suite.ctx, claim.Owner) suite.Equal(globalIndexes, syncedClaim.BorrowRewardIndexes) } + func (suite *SynchronizeHardBorrowRewardTests) TestClaimIndexesAreUnchangedWhenGlobalIndexesUnchanged() { // It should be safe to call SynchronizeHardBorrowReward multiple times @@ -69,6 +70,7 @@ func (suite *SynchronizeHardBorrowRewardTests) TestClaimIndexesAreUnchangedWhenG syncedClaim, _ := suite.keeper.GetHardLiquidityProviderClaim(suite.ctx, claim.Owner) suite.Equal(unchangingIndexes, syncedClaim.BorrowRewardIndexes) } + func (suite *SynchronizeHardBorrowRewardTests) TestClaimIndexesAreUpdatedWhenNewRewardAdded() { // When a new reward is added (via gov) for a hard borrow denom the user has already borrowed, and the claim is synced; // Then the new reward's index should be added to the claim. @@ -235,6 +237,7 @@ func (suite *SynchronizeHardBorrowRewardTests) TestRewardIsIncrementedWhenNewRew syncedClaim.Reward, ) } + func (suite *SynchronizeHardBorrowRewardTests) TestRewardIsIncrementedWhenNewRewardDenomAdded() { // When a new reward coin is added (via gov) to an already rewarded borrow denom (that the user has already borrowed), and the claim is synced; // Then the user earns rewards for the time since the reward was added @@ -304,7 +307,8 @@ func NewBorrowBuilder(borrower sdk.AccAddress) BorrowBuilder { return BorrowBuilder{ Borrow: hardtypes.Borrow{ Borrower: borrower, - }} + }, + } } // Build assembles and returns the final borrow. @@ -500,6 +504,7 @@ func TestCalculateRewards(t *testing.T) { }) } } + func TestCalculateSingleReward(t *testing.T) { type expected struct { err error diff --git a/x/incentive/keeper/rewards_borrow_test.go b/x/incentive/keeper/rewards_borrow_test.go index f1373bf1..27674779 100644 --- a/x/incentive/keeper/rewards_borrow_test.go +++ b/x/incentive/keeper/rewards_borrow_test.go @@ -274,7 +274,6 @@ func (suite *BorrowRewardsTestSuite) TestAccumulateHardBorrowRewards() { } func (suite *BorrowRewardsTestSuite) TestInitializeHardBorrowRewards() { - type args struct { moneyMarketRewardDenoms map[string]sdk.Coins deposit sdk.Coins diff --git a/x/incentive/keeper/rewards_delegator.go b/x/incentive/keeper/rewards_delegator.go index ae37daf8..c8926abe 100644 --- a/x/incentive/keeper/rewards_delegator.go +++ b/x/incentive/keeper/rewards_delegator.go @@ -12,7 +12,6 @@ import ( // AccumulateDelegatorRewards calculates new rewards to distribute this block and updates the global indexes to reflect this. // The provided rewardPeriod must be valid to avoid panics in calculating time durations. func (k Keeper) AccumulateDelegatorRewards(ctx sdk.Context, rewardPeriod types.MultiRewardPeriod) { - previousAccrualTime, found := k.GetPreviousDelegatorRewardAccrualTime(ctx, rewardPeriod.CollateralType) if !found { previousAccrualTime = ctx.BlockTime() diff --git a/x/incentive/keeper/rewards_delegator_accum_test.go b/x/incentive/keeper/rewards_delegator_accum_test.go index d2d54b48..2f050e2b 100644 --- a/x/incentive/keeper/rewards_delegator_accum_test.go +++ b/x/incentive/keeper/rewards_delegator_accum_test.go @@ -35,7 +35,6 @@ func TestAccumulateDelegatorRewards(t *testing.T) { } func (suite *AccumulateDelegatorRewardsTests) TestStateUpdatedWhenBlockTimeHasIncreased() { - stakingKeeper := newFakeStakingKeeper().addBondedTokens(1e6) suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, stakingKeeper, nil, nil) @@ -86,7 +85,6 @@ func (suite *AccumulateDelegatorRewardsTests) TestStateUpdatedWhenBlockTimeHasIn } func (suite *AccumulateDelegatorRewardsTests) TestStateUnchangedWhenBlockTimeHasNotIncreased() { - stakingKeeper := newFakeStakingKeeper().addBondedTokens(1e6) suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, stakingKeeper, nil, nil) @@ -130,7 +128,6 @@ func (suite *AccumulateDelegatorRewardsTests) TestStateUnchangedWhenBlockTimeHas } func (suite *AccumulateDelegatorRewardsTests) TestNoAccumulationWhenSourceSharesAreZero() { - stakingKeeper := newFakeStakingKeeper() // zero total bonded suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, stakingKeeper, nil, nil) @@ -175,7 +172,6 @@ func (suite *AccumulateDelegatorRewardsTests) TestNoAccumulationWhenSourceShares } func (suite *AccumulateDelegatorRewardsTests) TestStateAddedWhenStateDoesNotExist() { - stakingKeeper := newFakeStakingKeeper().addBondedTokens(1e6) suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, stakingKeeper, nil, nil) @@ -217,7 +213,6 @@ func (suite *AccumulateDelegatorRewardsTests) TestStateAddedWhenStateDoesNotExis } func (suite *AccumulateDelegatorRewardsTests) TestNoPanicWhenStateDoesNotExist() { - stakingKeeper := newFakeStakingKeeper() suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, stakingKeeper, nil, nil) @@ -244,7 +239,6 @@ func (suite *AccumulateDelegatorRewardsTests) TestNoPanicWhenStateDoesNotExist() } func (suite *AccumulateDelegatorRewardsTests) TestNoAccumulationWhenBeforeStartTime() { - stakingKeeper := newFakeStakingKeeper().addBondedTokens(1e6) suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, stakingKeeper, nil, nil) @@ -289,7 +283,6 @@ func (suite *AccumulateDelegatorRewardsTests) TestNoAccumulationWhenBeforeStartT } func (suite *AccumulateDelegatorRewardsTests) TestPanicWhenCurrentTimeLessThanPrevious() { - stakingKeeper := newFakeStakingKeeper().addBondedTokens(1e6) suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, stakingKeeper, nil, nil) diff --git a/x/incentive/keeper/rewards_delegator_sync_test.go b/x/incentive/keeper/rewards_delegator_sync_test.go index fdb77b02..735ebfde 100644 --- a/x/incentive/keeper/rewards_delegator_sync_test.go +++ b/x/incentive/keeper/rewards_delegator_sync_test.go @@ -250,6 +250,7 @@ func unslashedBondedValidator(address sdk.ValAddress) stakingtypes.Validator { DelegatorShares: i(1e12).ToDec(), } } + func unslashedNotBondedValidator(address sdk.ValAddress) stakingtypes.Validator { return stakingtypes.Validator{ OperatorAddress: address.String(), @@ -268,7 +269,7 @@ func (suite *SynchronizeDelegatorRewardTests) TestGetDelegatedWhenValAddrIsNil() validatorAddresses := generateValidatorAddresses(4) stakingKeeper := &fakeStakingKeeper{ delegations: stakingtypes.Delegations{ - //bonded + // bonded { DelegatorAddress: delegator.String(), ValidatorAddress: validatorAddresses[0].String(), @@ -305,13 +306,14 @@ func (suite *SynchronizeDelegatorRewardTests) TestGetDelegatedWhenValAddrIsNil() suite.keeper.GetTotalDelegated(suite.ctx, delegator, nil, false), ) } + func (suite *SynchronizeDelegatorRewardTests) TestGetDelegatedWhenExcludingAValidator() { // when valAddr is x, get total delegated to bonded validators excluding those to x delegator := arbitraryAddress() validatorAddresses := generateValidatorAddresses(4) stakingKeeper := &fakeStakingKeeper{ delegations: stakingtypes.Delegations{ - //bonded + // bonded { DelegatorAddress: delegator.String(), ValidatorAddress: validatorAddresses[0].String(), @@ -348,13 +350,14 @@ func (suite *SynchronizeDelegatorRewardTests) TestGetDelegatedWhenExcludingAVali suite.keeper.GetTotalDelegated(suite.ctx, delegator, validatorAddresses[0], false), ) } + func (suite *SynchronizeDelegatorRewardTests) TestGetDelegatedWhenIncludingAValidator() { // when valAddr is x, get total delegated to bonded validators including those to x delegator := arbitraryAddress() validatorAddresses := generateValidatorAddresses(4) stakingKeeper := &fakeStakingKeeper{ delegations: stakingtypes.Delegations{ - //bonded + // bonded { DelegatorAddress: delegator.String(), ValidatorAddress: validatorAddresses[0].String(), diff --git a/x/incentive/keeper/rewards_savings.go b/x/incentive/keeper/rewards_savings.go index cbe4fab5..517647a8 100644 --- a/x/incentive/keeper/rewards_savings.go +++ b/x/incentive/keeper/rewards_savings.go @@ -11,7 +11,6 @@ import ( // AccumulateSavingsRewards calculates new rewards to distribute this block and updates the global indexes func (k Keeper) AccumulateSavingsRewards(ctx sdk.Context, rewardPeriod types.MultiRewardPeriod) { - previousAccrualTime, found := k.GetSavingsRewardAccrualTime(ctx, rewardPeriod.CollateralType) if !found { previousAccrualTime = ctx.BlockTime() diff --git a/x/incentive/keeper/rewards_savings_accum_test.go b/x/incentive/keeper/rewards_savings_accum_test.go index cd03e4d7..802f6026 100644 --- a/x/incentive/keeper/rewards_savings_accum_test.go +++ b/x/incentive/keeper/rewards_savings_accum_test.go @@ -51,7 +51,8 @@ func (suite *SavingsRewardsTestSuite) SetupApp() { } func (suite *SavingsRewardsTestSuite) SetupWithGenState(authBuilder *app.AuthBankGenesisBuilder, incentBuilder testutil.IncentiveGenesisBuilder, - savingsGenesis savingstypes.GenesisState) { + savingsGenesis savingstypes.GenesisState, +) { suite.SetupApp() suite.app.InitializeFromGenesisStatesWithTime( diff --git a/x/incentive/keeper/rewards_supply.go b/x/incentive/keeper/rewards_supply.go index d8c31ed8..734ef85f 100644 --- a/x/incentive/keeper/rewards_supply.go +++ b/x/incentive/keeper/rewards_supply.go @@ -12,7 +12,6 @@ import ( // AccumulateHardSupplyRewards calculates new rewards to distribute this block and updates the global indexes to reflect this. // The provided rewardPeriod must be valid to avoid panics in calculating time durations. func (k Keeper) AccumulateHardSupplyRewards(ctx sdk.Context, rewardPeriod types.MultiRewardPeriod) { - previousAccrualTime, found := k.GetPreviousHardSupplyRewardAccrualTime(ctx, rewardPeriod.CollateralType) if !found { previousAccrualTime = ctx.BlockTime() @@ -93,7 +92,6 @@ func (k Keeper) SynchronizeHardSupplyReward(ctx sdk.Context, deposit hardtypes.D } for _, normedDeposit := range normalizedDeposit { - claim = k.synchronizeSingleHardSupplyReward(ctx, claim, normedDeposit.Denom, normedDeposit.Amount) } k.SetHardLiquidityProviderClaim(ctx, claim) diff --git a/x/incentive/keeper/rewards_supply_init_test.go b/x/incentive/keeper/rewards_supply_init_test.go index e8476819..4075cfb1 100644 --- a/x/incentive/keeper/rewards_supply_init_test.go +++ b/x/incentive/keeper/rewards_supply_init_test.go @@ -41,6 +41,7 @@ func (suite *InitializeHardSupplyRewardTests) TestClaimIndexesAreSetWhenClaimExi syncedClaim, _ := suite.keeper.GetHardLiquidityProviderClaim(suite.ctx, claim.Owner) suite.Equal(globalIndexes, syncedClaim.SupplyRewardIndexes) } + func (suite *InitializeHardSupplyRewardTests) TestClaimIndexesAreSetWhenClaimDoesNotExist() { globalIndexes := nonEmptyMultiRewardIndexes suite.storeGlobalSupplyIndexes(globalIndexes) @@ -56,8 +57,8 @@ func (suite *InitializeHardSupplyRewardTests) TestClaimIndexesAreSetWhenClaimDoe suite.True(found) suite.Equal(globalIndexes, syncedClaim.SupplyRewardIndexes) } -func (suite *InitializeHardSupplyRewardTests) TestClaimIndexesAreSetEmptyForMissingIndexes() { +func (suite *InitializeHardSupplyRewardTests) TestClaimIndexesAreSetEmptyForMissingIndexes() { globalIndexes := nonEmptyMultiRewardIndexes suite.storeGlobalSupplyIndexes(globalIndexes) diff --git a/x/incentive/keeper/rewards_supply_sync_test.go b/x/incentive/keeper/rewards_supply_sync_test.go index e443241e..4e4032de 100644 --- a/x/incentive/keeper/rewards_supply_sync_test.go +++ b/x/incentive/keeper/rewards_supply_sync_test.go @@ -41,6 +41,7 @@ func (suite *SynchronizeHardSupplyRewardTests) TestClaimIndexesAreUpdatedWhenGlo syncedClaim, _ := suite.keeper.GetHardLiquidityProviderClaim(suite.ctx, claim.Owner) suite.Equal(globalIndexes, syncedClaim.SupplyRewardIndexes) } + func (suite *SynchronizeHardSupplyRewardTests) TestClaimIndexesAreUnchangedWhenGlobalIndexesUnchanged() { // It should be safe to call SynchronizeHardSupplyReward multiple times @@ -65,6 +66,7 @@ func (suite *SynchronizeHardSupplyRewardTests) TestClaimIndexesAreUnchangedWhenG syncedClaim, _ := suite.keeper.GetHardLiquidityProviderClaim(suite.ctx, claim.Owner) suite.Equal(unchangingIndexes, syncedClaim.SupplyRewardIndexes) } + func (suite *SynchronizeHardSupplyRewardTests) TestClaimIndexesAreUpdatedWhenNewRewardAdded() { // When a new reward is added (via gov) for a hard deposit denom the user has already deposited, and the claim is synced; // Then the new reward's index should be added to the claim. @@ -231,6 +233,7 @@ func (suite *SynchronizeHardSupplyRewardTests) TestRewardIsIncrementedWhenNewRew syncedClaim.Reward, ) } + func (suite *SynchronizeHardSupplyRewardTests) TestRewardIsIncrementedWhenNewRewardDenomAdded() { // When a new reward coin is added (via gov) to an already rewarded deposit denom (that the user has already deposited), and the claim is synced; // Then the user earns rewards for the time since the reward was added @@ -300,7 +303,8 @@ func NewHardDepositBuilder(depositor sdk.AccAddress) HardDepositBuilder { return HardDepositBuilder{ Deposit: hardtypes.Deposit{ Depositor: depositor, - }} + }, + } } // Build assembles and returns the final deposit. diff --git a/x/incentive/keeper/rewards_supply_test.go b/x/incentive/keeper/rewards_supply_test.go index 4311c3ec..bc2b9190 100644 --- a/x/incentive/keeper/rewards_supply_test.go +++ b/x/incentive/keeper/rewards_supply_test.go @@ -35,7 +35,6 @@ func TestSupplyIntegration(t *testing.T) { // SetupTest is run automatically before each suite test func (suite *SupplyIntegrationTests) SetupTest() { - _, suite.addrs = app.GeneratePrivKeyAddressPairs(5) suite.genesisTime = time.Date(2020, 12, 15, 14, 0, 0, 0, time.UTC) @@ -278,13 +277,11 @@ func (suite *SupplyRewardsTestSuite) TestAccumulateHardSupplyRewards() { } else { suite.Require().False(found) } - }) } } func (suite *SupplyRewardsTestSuite) TestInitializeHardSupplyRewards() { - type args struct { moneyMarketRewardDenoms map[string]sdk.Coins deposit sdk.Coins @@ -626,7 +623,6 @@ func (suite *SupplyRewardsTestSuite) TestSynchronizeHardSupplyReward() { multiRewardPeriod, found := suite.keeper.GetHardSupplyRewardPeriods(blockCtx, tc.args.deposit.Denom) if found { suite.keeper.AccumulateHardSupplyRewards(blockCtx, multiRewardPeriod) - } } updatedBlockTime := suite.ctx.BlockTime().Add(time.Duration(int(time.Second) * timeElapsed)) diff --git a/x/incentive/keeper/rewards_swap.go b/x/incentive/keeper/rewards_swap.go index c2e527ff..2a1fb508 100644 --- a/x/incentive/keeper/rewards_swap.go +++ b/x/incentive/keeper/rewards_swap.go @@ -11,7 +11,6 @@ import ( // AccumulateSwapRewards calculates new rewards to distribute this block and updates the global indexes to reflect this. // The provided rewardPeriod must be valid to avoid panics in calculating time durations. func (k Keeper) AccumulateSwapRewards(ctx sdk.Context, rewardPeriod types.MultiRewardPeriod) { - previousAccrualTime, found := k.GetSwapRewardAccrualTime(ctx, rewardPeriod.CollateralType) if !found { previousAccrualTime = ctx.BlockTime() diff --git a/x/incentive/keeper/rewards_swap_sync_test.go b/x/incentive/keeper/rewards_swap_sync_test.go index a2901967..feb5f597 100644 --- a/x/incentive/keeper/rewards_swap_sync_test.go +++ b/x/incentive/keeper/rewards_swap_sync_test.go @@ -115,6 +115,7 @@ func (suite *SynchronizeSwapRewardTests) TestClaimUnchangedWhenGlobalIndexesUnch // claim should have the same rewards and indexes as before suite.Equal(claim, syncedClaim) } + func (suite *SynchronizeSwapRewardTests) TestClaimUpdatedWhenNewRewardAdded() { // When a new reward is added (via gov) for a pool the user has already deposited to, and the claim is synced; // Then the user earns rewards for the time since the reward was added, and the indexes are added to the claim. diff --git a/x/incentive/keeper/rewards_usdx.go b/x/incentive/keeper/rewards_usdx.go index 927a6947..c5d5a78f 100644 --- a/x/incentive/keeper/rewards_usdx.go +++ b/x/incentive/keeper/rewards_usdx.go @@ -76,7 +76,6 @@ func (k Keeper) InitializeUSDXMintingClaim(ctx sdk.Context, cdp cdptypes.CDP) { // SynchronizeUSDXMintingReward updates the claim object by adding any accumulated rewards and updating the reward index value. // this should be called before a cdp is modified. func (k Keeper) SynchronizeUSDXMintingReward(ctx sdk.Context, cdp cdptypes.CDP) { - claim, found := k.GetUSDXMintingClaim(ctx, cdp.Owner) if !found { return @@ -96,7 +95,6 @@ func (k Keeper) SynchronizeUSDXMintingReward(ctx sdk.Context, cdp cdptypes.CDP) // It returns the claim without setting in the store. // The public methods for accessing and modifying claims are preferred over this one. Direct modification of claims is easy to get wrong. func (k Keeper) synchronizeSingleUSDXMintingReward(ctx sdk.Context, claim types.USDXMintingClaim, ctype string, sourceShares sdk.Dec) types.USDXMintingClaim { - globalRewardFactor, found := k.GetUSDXMintingRewardFactor(ctx, ctype) if !found { // The global factor is only not found if diff --git a/x/incentive/keeper/rewards_usdx_test.go b/x/incentive/keeper/rewards_usdx_test.go index 50302e61..02f1bb6f 100644 --- a/x/incentive/keeper/rewards_usdx_test.go +++ b/x/incentive/keeper/rewards_usdx_test.go @@ -31,7 +31,6 @@ func TestUSDXIntegration(t *testing.T) { // SetupTest is run automatically before each suite test func (suite *USDXIntegrationTests) SetupTest() { - _, suite.addrs = app.GeneratePrivKeyAddressPairs(5) suite.genesisTime = time.Date(2020, 12, 15, 14, 0, 0, 0, time.UTC) @@ -104,7 +103,6 @@ func (suite *USDXIntegrationTests) TestSingleUserAccumulatesRewardsAfterSyncing( } func (suite *USDXIntegrationTests) TestSingleUserAccumulatesRewardsWithoutSyncing() { - user := suite.addrs[0] initialCollateral := c("bnb", 1e9) @@ -152,7 +150,6 @@ func (suite *USDXIntegrationTests) TestSingleUserAccumulatesRewardsWithoutSyncin } func (suite *USDXIntegrationTests) TestReinstatingRewardParamsDoesNotTriggerOverPayments() { - userA := suite.addrs[0] userB := suite.addrs[1] diff --git a/x/incentive/keeper/rewards_usdx_unit_test.go b/x/incentive/keeper/rewards_usdx_unit_test.go index 048672fe..3f1a23aa 100644 --- a/x/incentive/keeper/rewards_usdx_unit_test.go +++ b/x/incentive/keeper/rewards_usdx_unit_test.go @@ -20,6 +20,7 @@ func (suite *usdxRewardsUnitTester) storeGlobalUSDXIndexes(indexes types.RewardI suite.keeper.SetUSDXMintingRewardFactor(suite.ctx, ri.CollateralType, ri.RewardFactor) } } + func (suite *usdxRewardsUnitTester) storeClaim(claim types.USDXMintingClaim) { suite.keeper.SetUSDXMintingClaim(suite.ctx, claim) } @@ -85,6 +86,7 @@ type SynchronizeUSDXMintingRewardTests struct { func TestSynchronizeUSDXMintingReward(t *testing.T) { suite.Run(t, new(SynchronizeUSDXMintingRewardTests)) } + func (suite *SynchronizeUSDXMintingRewardTests) TestRewardUnchangedWhenGlobalIndexesUnchanged() { unchangingRewardIndexes := nonEmptyRewardIndexes collateralType := extractFirstCollateralType(unchangingRewardIndexes) @@ -247,7 +249,8 @@ func NewCDPBuilder(owner sdk.AccAddress, collateralType string) CDPBuilder { AccumulatedFees: c(cdptypes.DefaultStableDenom, 0), // zero value of sdk.Dec causes nil pointer panics InterestFactor: sdk.OneDec(), - }} + }, + } } // Build assembles and returns the final deposit. diff --git a/x/incentive/keeper/unit_test.go b/x/incentive/keeper/unit_test.go index f471fd69..fe53c092 100644 --- a/x/incentive/keeper/unit_test.go +++ b/x/incentive/keeper/unit_test.go @@ -36,7 +36,6 @@ func NewTestContext(requiredStoreKeys ...sdk.StoreKey) sdk.Context { } return sdk.NewContext(cms, tmprototypes.Header{}, false, log.NewNopLogger()) - } // unitTester is a wrapper around suite.Suite, with common functionality for keeper unit tests. @@ -55,7 +54,6 @@ func (suite *unitTester) SetupSuite() { suite.cdc = tApp.AppCodec() suite.incentiveStoreKey = sdk.NewKVStoreKey(types.StoreKey) - } func (suite *unitTester) SetupTest() { @@ -77,21 +75,25 @@ func (suite *unitTester) storeGlobalBorrowIndexes(indexes types.MultiRewardIndex suite.keeper.SetHardBorrowRewardIndexes(suite.ctx, i.CollateralType, i.RewardIndexes) } } + func (suite *unitTester) storeGlobalSupplyIndexes(indexes types.MultiRewardIndexes) { for _, i := range indexes { suite.keeper.SetHardSupplyRewardIndexes(suite.ctx, i.CollateralType, i.RewardIndexes) } } + func (suite *unitTester) storeGlobalDelegatorIndexes(multiRewardIndexes types.MultiRewardIndexes) { // Hardcoded to use bond denom multiRewardIndex, _ := multiRewardIndexes.GetRewardIndex(types.BondDenom) suite.keeper.SetDelegatorRewardIndexes(suite.ctx, types.BondDenom, multiRewardIndex.RewardIndexes) } + func (suite *unitTester) storeGlobalSwapIndexes(indexes types.MultiRewardIndexes) { for _, i := range indexes { suite.keeper.SetSwapRewardIndexes(suite.ctx, i.CollateralType, i.RewardIndexes) } } + func (suite *unitTester) storeGlobalSavingsIndexes(indexes types.MultiRewardIndexes) { for _, i := range indexes { suite.keeper.SetSavingsRewardIndexes(suite.ctx, i.CollateralType, i.RewardIndexes) @@ -101,12 +103,15 @@ func (suite *unitTester) storeGlobalSavingsIndexes(indexes types.MultiRewardInde func (suite *unitTester) storeHardClaim(claim types.HardLiquidityProviderClaim) { suite.keeper.SetHardLiquidityProviderClaim(suite.ctx, claim) } + func (suite *unitTester) storeDelegatorClaim(claim types.DelegatorClaim) { suite.keeper.SetDelegatorClaim(suite.ctx, claim) } + func (suite *unitTester) storeSwapClaim(claim types.SwapClaim) { suite.keeper.SetSwapClaim(suite.ctx, claim) } + func (suite *unitTester) storeSavingsClaim(claim types.SavingsClaim) { suite.keeper.SetSavingsClaim(suite.ctx, claim) } @@ -119,13 +124,16 @@ type fakeParamSubspace struct { func (subspace *fakeParamSubspace) GetParamSet(_ sdk.Context, ps paramtypes.ParamSet) { *(ps.(*types.Params)) = subspace.params } + func (subspace *fakeParamSubspace) SetParamSet(_ sdk.Context, ps paramtypes.ParamSet) { subspace.params = *(ps.(*types.Params)) } + func (subspace *fakeParamSubspace) HasKeyTable() bool { // return true so the keeper does not try to call WithKeyTable, which does nothing return true } + func (subspace *fakeParamSubspace) WithKeyTable(paramtypes.KeyTable) paramtypes.Subspace { // return an non-functional subspace to satisfy the interface return paramtypes.Subspace{} @@ -146,10 +154,12 @@ func newFakeSwapKeeper() *fakeSwapKeeper { depositShares: map[string](map[string]sdk.Int){}, } } + func (k *fakeSwapKeeper) addPool(id string, shares sdk.Int) *fakeSwapKeeper { k.poolShares[id] = shares return k } + func (k *fakeSwapKeeper) addDeposit(poolID string, depositor sdk.AccAddress, shares sdk.Int) *fakeSwapKeeper { if k.depositShares[poolID] == nil { k.depositShares[poolID] = map[string]sdk.Int{} @@ -157,10 +167,12 @@ func (k *fakeSwapKeeper) addDeposit(poolID string, depositor sdk.AccAddress, sha k.depositShares[poolID][depositor.String()] = shares return k } + func (k *fakeSwapKeeper) GetPoolShares(_ sdk.Context, poolID string) (sdk.Int, bool) { shares, ok := k.poolShares[poolID] return shares, ok } + func (k *fakeSwapKeeper) GetDepositorSharesAmount(_ sdk.Context, depositor sdk.AccAddress, poolID string) (sdk.Int, bool) { shares, found := k.depositShares[poolID][depositor.String()] return shares, found @@ -199,6 +211,7 @@ func (k *fakeHardKeeper) addTotalBorrow(coin sdk.Coin, factor sdk.Dec) *fakeHard k.borrows.interestFactors[coin.Denom] = factor return k } + func (k *fakeHardKeeper) addTotalSupply(coin sdk.Coin, factor sdk.Dec) *fakeHardKeeper { k.deposits.total = k.deposits.total.Add(coin) k.deposits.interestFactors[coin.Denom] = factor @@ -211,23 +224,28 @@ func (k *fakeHardKeeper) GetBorrowedCoins(_ sdk.Context) (sdk.Coins, bool) { } return k.borrows.total, true } + func (k *fakeHardKeeper) GetSuppliedCoins(_ sdk.Context) (sdk.Coins, bool) { if k.deposits.total == nil { return nil, false } return k.deposits.total, true } + func (k *fakeHardKeeper) GetBorrowInterestFactor(_ sdk.Context, denom string) (sdk.Dec, bool) { f, ok := k.borrows.interestFactors[denom] return f, ok } + func (k *fakeHardKeeper) GetSupplyInterestFactor(_ sdk.Context, denom string) (sdk.Dec, bool) { f, ok := k.deposits.interestFactors[denom] return f, ok } + func (k *fakeHardKeeper) GetBorrow(_ sdk.Context, _ sdk.AccAddress) (hardtypes.Borrow, bool) { panic("unimplemented") } + func (k *fakeHardKeeper) GetDeposit(_ sdk.Context, _ sdk.AccAddress) (hardtypes.Deposit, bool) { panic("unimplemented") } @@ -264,9 +282,11 @@ func (k *fakeStakingKeeper) TotalBondedTokens(_ sdk.Context) sdk.Int { } return total } + func (k *fakeStakingKeeper) GetDelegatorDelegations(_ sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) []stakingtypes.Delegation { return k.delegations } + func (k *fakeStakingKeeper) GetValidator(_ sdk.Context, addr sdk.ValAddress) (stakingtypes.Validator, bool) { for _, val := range k.validators { if val.GetOperator().Equals(addr) { @@ -275,6 +295,7 @@ func (k *fakeStakingKeeper) GetValidator(_ sdk.Context, addr sdk.ValAddress) (st } return stakingtypes.Validator{}, false } + func (k *fakeStakingKeeper) GetValidatorDelegations(_ sdk.Context, valAddr sdk.ValAddress) []stakingtypes.Delegation { var delegations stakingtypes.Delegations for _, d := range k.delegations { @@ -305,6 +326,7 @@ func (k *fakeCDPKeeper) addInterestFactor(f sdk.Dec) *fakeCDPKeeper { k.interestFactor = &f return k } + func (k *fakeCDPKeeper) addTotalPrincipal(p sdk.Int) *fakeCDPKeeper { k.totalPrincipal = p return k @@ -316,12 +338,15 @@ func (k *fakeCDPKeeper) GetInterestFactor(_ sdk.Context, collateralType string) } return sdk.Dec{}, false } + func (k *fakeCDPKeeper) GetTotalPrincipal(_ sdk.Context, collateralType string, principalDenom string) sdk.Int { return k.totalPrincipal } + func (k *fakeCDPKeeper) GetCdpByOwnerAndCollateralType(_ sdk.Context, owner sdk.AccAddress, collateralType string) (cdptypes.CDP, bool) { return cdptypes.CDP{}, false } + func (k *fakeCDPKeeper) GetCollateral(_ sdk.Context, collateralType string) (cdptypes.CollateralParam, bool) { return cdptypes.CollateralParam{}, false } @@ -339,9 +364,11 @@ func arbitraryAddress() sdk.AccAddress { _, addresses := app.GeneratePrivKeyAddressPairs(1) return addresses[0] } + func arbitraryValidatorAddress() sdk.ValAddress { return generateValidatorAddresses(1)[0] } + func generateValidatorAddresses(n int) []sdk.ValAddress { _, addresses := app.GeneratePrivKeyAddressPairs(n) var valAddresses []sdk.ValAddress diff --git a/x/incentive/simulation/genesis.go b/x/incentive/simulation/genesis.go index c3700e0a..14416125 100644 --- a/x/incentive/simulation/genesis.go +++ b/x/incentive/simulation/genesis.go @@ -18,7 +18,6 @@ var ( // RandomizedGenState generates a random GenesisState for incentive module func RandomizedGenState(simState *module.SimulationState) { - // New genesis state holds valid, linked reward periods, claim periods, and claim period IDs incentiveGenesis := types.DefaultGenesisState() diff --git a/x/incentive/simulation/operations.go b/x/incentive/simulation/operations.go index 9a5db04e..b4cb1103 100644 --- a/x/incentive/simulation/operations.go +++ b/x/incentive/simulation/operations.go @@ -44,7 +44,6 @@ func SimulateMsgClaimReward(ak auth.AccountKeeper, sk types.SupplyKeeper, k keep return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string, ) (simulation.OperationMsg, []simulation.FutureOperation, error) { - return simulation.NewOperationMsgBasic(types.ModuleName, "no-operation (no accounts currently have fulfillable claims)", "", false, nil), nil, nil } diff --git a/x/incentive/testutil/builder.go b/x/incentive/testutil/builder.go index 201e6b2e..9c7d9b78 100644 --- a/x/incentive/testutil/builder.go +++ b/x/incentive/testutil/builder.go @@ -205,9 +205,11 @@ func NewHardGenesisBuilder() HardGenesisBuilder { GenesisState: hardtypes.DefaultGenesisState(), } } + func (builder HardGenesisBuilder) Build() hardtypes.GenesisState { return builder.GenesisState } + func (builder HardGenesisBuilder) BuildMarshalled(cdc codec.JSONCodec) app.GenesisState { built := builder.Build() @@ -215,10 +217,12 @@ func (builder HardGenesisBuilder) BuildMarshalled(cdc codec.JSONCodec) app.Genes hardtypes.ModuleName: cdc.MustMarshalJSON(&built), } } + func (builder HardGenesisBuilder) WithGenesisTime(genTime time.Time) HardGenesisBuilder { builder.genesisTime = genTime return builder } + func (builder HardGenesisBuilder) WithInitializedMoneyMarket(market hardtypes.MoneyMarket) HardGenesisBuilder { builder.Params.MoneyMarkets = append(builder.Params.MoneyMarkets, market) @@ -228,10 +232,12 @@ func (builder HardGenesisBuilder) WithInitializedMoneyMarket(market hardtypes.Mo ) return builder } + func (builder HardGenesisBuilder) WithMinBorrow(minUSDValue sdk.Dec) HardGenesisBuilder { builder.Params.MinimumBorrowUSDValue = minUSDValue return builder } + func NewStandardMoneyMarket(denom string) hardtypes.MoneyMarket { return hardtypes.NewMoneyMarket( denom, diff --git a/x/incentive/types/accumulator.go b/x/incentive/types/accumulator.go index faf6f5c1..69c774eb 100644 --- a/x/incentive/types/accumulator.go +++ b/x/incentive/types/accumulator.go @@ -31,7 +31,6 @@ func NewAccumulator(previousAccrual time.Time, indexes RewardIndexes) *Accumulat // // totalSourceShares is the sum of all users' source shares. For example:total btcb supplied to hard, total usdx borrowed from all bnb CDPs, or total shares in a swap pool. func (acc *Accumulator) Accumulate(period MultiRewardPeriod, totalSourceShares sdk.Dec, currentTime time.Time) { - accumulationDuration := acc.getTimeElapsedWithinLimits(acc.PreviousAccumulationTime, currentTime, period.Start, period.End) indexesIncrement := acc.calculateNewRewards(period.RewardsPerSecond, totalSourceShares, accumulationDuration) diff --git a/x/incentive/types/accumulator_test.go b/x/incentive/types/accumulator_test.go index b770cc4b..17cecca1 100644 --- a/x/incentive/types/accumulator_test.go +++ b/x/incentive/types/accumulator_test.go @@ -365,6 +365,7 @@ func TestMinTime(t *testing.T) { }) } } + func TestMaxTime(t *testing.T) { type args struct { t1, t2 time.Time diff --git a/x/incentive/types/claims.go b/x/incentive/types/claims.go index 24d7b918..9d1ce889 100644 --- a/x/incentive/types/claims.go +++ b/x/incentive/types/claims.go @@ -112,7 +112,8 @@ func (cs USDXMintingClaims) Validate() error { // NewHardLiquidityProviderClaim returns a new HardLiquidityProviderClaim func NewHardLiquidityProviderClaim(owner sdk.AccAddress, rewards sdk.Coins, - supplyRewardIndexes, borrowRewardIndexes MultiRewardIndexes) HardLiquidityProviderClaim { + supplyRewardIndexes, borrowRewardIndexes MultiRewardIndexes, +) HardLiquidityProviderClaim { return HardLiquidityProviderClaim{ BaseMultiClaim: BaseMultiClaim{ Owner: owner, diff --git a/x/incentive/types/claims_test.go b/x/incentive/types/claims_test.go index 14b82d84..0e147e2f 100644 --- a/x/incentive/types/claims_test.go +++ b/x/incentive/types/claims_test.go @@ -22,7 +22,6 @@ func TestClaims_Validate(t *testing.T) { owner := sdk.AccAddress(crypto.AddressHash([]byte("KavaTestUser1"))) t.Run("USDXMintingClaims", func(t *testing.T) { - testCases := []struct { name string claims USDXMintingClaims @@ -85,7 +84,6 @@ func TestClaims_Validate(t *testing.T) { } }) t.Run("SwapClaims", func(t *testing.T) { - validRewardIndexes := RewardIndexes{}.With("swap", d("0.002")) validMultiRewardIndexes := MultiRewardIndexes{}.With("btcb/usdx", validRewardIndexes) invalidRewardIndexes := RewardIndexes{}.With("swap", d("-0.002")) @@ -139,7 +137,6 @@ func TestClaims_Validate(t *testing.T) { }) t.Run("SavingsClaims", func(t *testing.T) { - validRewardIndexes := RewardIndexes{}.With("ukava", d("0.002")) validMultiRewardIndexes := MultiRewardIndexes{}.With("btcb/usdx", validRewardIndexes) invalidRewardIndexes := RewardIndexes{}.With("ukava", d("-0.002")) @@ -195,7 +192,7 @@ func TestClaims_Validate(t *testing.T) { func TestRewardIndexes(t *testing.T) { t.Run("With", func(t *testing.T) { - var arbitraryDec = sdk.MustNewDecFromStr("0.1") + arbitraryDec := sdk.MustNewDecFromStr("0.1") type args struct { denom string @@ -246,7 +243,7 @@ func TestRewardIndexes(t *testing.T) { } }) t.Run("Get", func(t *testing.T) { - var arbitraryDec = sdk.MustNewDecFromStr("0.1") + arbitraryDec := sdk.MustNewDecFromStr("0.1") type expected struct { factor sdk.Dec @@ -291,7 +288,6 @@ func TestRewardIndexes(t *testing.T) { } }) t.Run("Mul", func(t *testing.T) { - testcases := []struct { name string rewardIndexes RewardIndexes @@ -411,7 +407,6 @@ func TestRewardIndexes(t *testing.T) { } }) t.Run("Add", func(t *testing.T) { - testcases := []struct { name string rewardIndexes RewardIndexes diff --git a/x/incentive/types/genesis_test.go b/x/incentive/types/genesis_test.go index 9b8cea99..87a70bad 100644 --- a/x/incentive/types/genesis_test.go +++ b/x/incentive/types/genesis_test.go @@ -148,7 +148,6 @@ func TestGenesisState_Validate(t *testing.T) { } func TestGenesisAccumulationTimes_Validate(t *testing.T) { - testCases := []struct { name string gats AccumulationTimes diff --git a/x/incentive/types/msg.go b/x/incentive/types/msg.go index 0c138537..4b0578d1 100644 --- a/x/incentive/types/msg.go +++ b/x/incentive/types/msg.go @@ -9,10 +9,13 @@ const MaxDenomsToClaim = 1000 // ensure Msg interface compliance at compile time var _ sdk.Msg = &MsgClaimUSDXMintingReward{} -var _ sdk.Msg = &MsgClaimHardReward{} -var _ sdk.Msg = &MsgClaimDelegatorReward{} -var _ sdk.Msg = &MsgClaimSwapReward{} -var _ sdk.Msg = &MsgClaimSavingsReward{} + +var ( + _ sdk.Msg = &MsgClaimHardReward{} + _ sdk.Msg = &MsgClaimDelegatorReward{} + _ sdk.Msg = &MsgClaimSwapReward{} + _ sdk.Msg = &MsgClaimSavingsReward{} +) // NewMsgClaimUSDXMintingReward returns a new MsgClaimUSDXMintingReward. func NewMsgClaimUSDXMintingReward(sender string, multiplierName string) MsgClaimUSDXMintingReward { diff --git a/x/incentive/types/msg_test.go b/x/incentive/types/msg_test.go index 01c22c84..2c2898bd 100644 --- a/x/incentive/types/msg_test.go +++ b/x/incentive/types/msg_test.go @@ -29,7 +29,6 @@ func TestMsgClaim_Validate(t *testing.T) { msgArgs msgArgs expect expectedErr }{ - { name: "normal multiplier is valid", msgArgs: msgArgs{ @@ -149,7 +148,6 @@ func TestMsgClaim_Validate(t *testing.T) { msgs := []sdk.Msg{&msgClaimHardReward, &msgClaimDelegatorReward, &msgClaimSwapReward, &msgClaimSavingsReward} for _, msg := range msgs { t.Run(tc.name, func(t *testing.T) { - err := msg.ValidateBasic() if tc.expect.pass { require.NoError(t, err) diff --git a/x/incentive/types/params.go b/x/incentive/types/params.go index e9c771c0..62394944 100644 --- a/x/incentive/types/params.go +++ b/x/incentive/types/params.go @@ -38,7 +38,8 @@ var ( // NewParams returns a new params object func NewParams(usdxMinting RewardPeriods, hardSupply, hardBorrow, delegator, swap, - savings MultiRewardPeriods, multipliers MultipliersPerDenoms, claimEnd time.Time) Params { + savings MultiRewardPeriods, multipliers MultipliersPerDenoms, claimEnd time.Time, +) Params { return Params{ USDXMintingRewardPeriods: usdxMinting, HardSupplyRewardPeriods: hardSupply, @@ -86,7 +87,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { // Validate checks that the parameters have valid values. func (p Params) Validate() error { - if err := validateMultipliersPerDenomParam(p.ClaimMultipliers); err != nil { return err } diff --git a/x/incentive/types/params_test.go b/x/incentive/types/params_test.go index f6b1d30c..187a4c47 100644 --- a/x/incentive/types/params_test.go +++ b/x/incentive/types/params_test.go @@ -25,6 +25,7 @@ var rewardPeriodWithInvalidRewardsPerSecond = types.NewRewardPeriod( time.Date(2024, 10, 15, 14, 0, 0, 0, time.UTC), sdk.Coin{Denom: "INVALID!@#😫", Amount: sdk.ZeroInt()}, ) + var rewardMultiPeriodWithInvalidRewardsPerSecond = types.NewMultiRewardPeriod( true, "bnb", @@ -32,6 +33,7 @@ var rewardMultiPeriodWithInvalidRewardsPerSecond = types.NewMultiRewardPeriod( time.Date(2024, 10, 15, 14, 0, 0, 0, time.UTC), sdk.Coins{sdk.Coin{Denom: "INVALID!@#😫", Amount: sdk.ZeroInt()}}, ) + var validMultiRewardPeriod = types.NewMultiRewardPeriod( true, "bnb", @@ -39,6 +41,7 @@ var validMultiRewardPeriod = types.NewMultiRewardPeriod( time.Date(2024, 10, 15, 14, 0, 0, 0, time.UTC), sdk.NewCoins(sdk.NewInt64Coin("swap", 1e9)), ) + var validRewardPeriod = types.NewRewardPeriod( true, "bnb-a", @@ -76,7 +79,8 @@ func (suite *ParamTestSuite) TestParamValidation() { time.Date(2020, 10, 15, 14, 0, 0, 0, time.UTC), time.Date(2024, 10, 15, 14, 0, 0, 0, time.UTC), sdk.NewCoin(types.USDXMintingRewardDenom, sdk.NewInt(122354)), - )}, + ), + }, HardSupplyRewardPeriods: types.DefaultMultiRewardPeriods, HardBorrowRewardPeriods: types.DefaultMultiRewardPeriods, DelegatorRewardPeriods: types.DefaultMultiRewardPeriods, diff --git a/x/incentive/types/querier.go b/x/incentive/types/querier.go index 08c99cf8..f46435a8 100644 --- a/x/incentive/types/querier.go +++ b/x/incentive/types/querier.go @@ -50,7 +50,8 @@ type QueryGetRewardFactorsResponse struct { // NewQueryGetRewardFactorsResponse returns a new instance of QueryAllRewardFactorsResponse func NewQueryGetRewardFactorsResponse(usdxMintingFactors RewardIndexes, supplyFactors, - hardBorrowFactors, delegatorFactors, swapFactors, savingsFactors MultiRewardIndexes) QueryGetRewardFactorsResponse { + hardBorrowFactors, delegatorFactors, swapFactors, savingsFactors MultiRewardIndexes, +) QueryGetRewardFactorsResponse { return QueryGetRewardFactorsResponse{ USDXMintingRewardFactors: usdxMintingFactors, HardSupplyRewardFactors: supplyFactors, diff --git a/x/issuance/client/cli/query.go b/x/issuance/client/cli/query.go index 849203dc..8035de6e 100644 --- a/x/issuance/client/cli/query.go +++ b/x/issuance/client/cli/query.go @@ -30,7 +30,6 @@ func GetQueryCmd() *cobra.Command { issuanceQueryCmd.AddCommand(cmds...) return issuanceQueryCmd - } // GetCmdQueryParams queries the issuance module parameters diff --git a/x/issuance/client/cli/tx.go b/x/issuance/client/cli/tx.go index aeb14003..b284b25f 100644 --- a/x/issuance/client/cli/tx.go +++ b/x/issuance/client/cli/tx.go @@ -36,7 +36,6 @@ func GetTxCmd() *cobra.Command { issuanceTxCmd.AddCommand(cmds...) return issuanceTxCmd - } func GetCmdIssueTokens() *cobra.Command { diff --git a/x/issuance/genesis.go b/x/issuance/genesis.go index 6b5a8ba6..5681d8f3 100644 --- a/x/issuance/genesis.go +++ b/x/issuance/genesis.go @@ -11,7 +11,6 @@ import ( // InitGenesis initializes the store state from a genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, accountKeeper types.AccountKeeper, gs types.GenesisState) { - if err := gs.Validate(); err != nil { panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err)) } @@ -36,7 +35,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, accountKeeper types.AccountKe } } } - } // ExportGenesis export genesis state for issuance module diff --git a/x/issuance/types/genesis.go b/x/issuance/types/genesis.go index 9dd35bef..4b4e91b7 100644 --- a/x/issuance/types/genesis.go +++ b/x/issuance/types/genesis.go @@ -1,9 +1,7 @@ package types -var ( - // DefaultSupplies is used to set default asset supplies in default genesis state - DefaultSupplies = []AssetSupply{} -) +// DefaultSupplies is used to set default asset supplies in default genesis state +var DefaultSupplies = []AssetSupply{} // NewGenesisState returns a new GenesisState func NewGenesisState(params Params, supplies []AssetSupply) GenesisState { diff --git a/x/kavadist/client/rest/rest.go b/x/kavadist/client/rest/rest.go index f4fe972c..4ca748cf 100644 --- a/x/kavadist/client/rest/rest.go +++ b/x/kavadist/client/rest/rest.go @@ -28,6 +28,7 @@ func ProposalRESTHandler(cliCtx client.Context) govrest.ProposalRESTHandler { Handler: postProposalHandlerFn(cliCtx), } } + func postProposalHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req CommunityPoolMultiSpendProposalReq diff --git a/x/kavadist/keeper/querier.go b/x/kavadist/keeper/querier.go index 8059fc2f..7f1a0da0 100644 --- a/x/kavadist/keeper/querier.go +++ b/x/kavadist/keeper/querier.go @@ -42,7 +42,6 @@ func queryGetBalance(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQue acc := k.accountKeeper.GetModuleAccount(ctx, types.KavaDistMacc) balance := k.bankKeeper.GetAllBalances(ctx, acc.GetAddress()) bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, balance) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/kavadist/types/params.go b/x/kavadist/types/params.go index efb04064..77fe4d3e 100644 --- a/x/kavadist/types/params.go +++ b/x/kavadist/types/params.go @@ -129,7 +129,7 @@ func validatePeriodsParams(i interface{}) error { return fmt.Errorf("start or end time cannot be zero: %s", pr) } - //TODO: validate period Inflation? + // TODO: validate period Inflation? } return nil diff --git a/x/pricefeed/client/rest/tx.go b/x/pricefeed/client/rest/tx.go index f373a8b9..e29a08c3 100644 --- a/x/pricefeed/client/rest/tx.go +++ b/x/pricefeed/client/rest/tx.go @@ -18,7 +18,6 @@ import ( func registerTxRoutes(cliCtx client.Context, r *mux.Router) { r.HandleFunc(fmt.Sprintf("/%s/postprice", types.ModuleName), postPriceHandlerFn(cliCtx)).Methods("POST") - } func postPriceHandlerFn(cliCtx client.Context) http.HandlerFunc { diff --git a/x/pricefeed/genesis.go b/x/pricefeed/genesis.go index ebafb5ca..f7774704 100644 --- a/x/pricefeed/genesis.go +++ b/x/pricefeed/genesis.go @@ -42,7 +42,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { // ExportGenesis returns a GenesisState for a given context and keeper. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState { - // Get the params for markets and oracles params := k.GetParams(ctx) diff --git a/x/pricefeed/keeper/grpc_query.go b/x/pricefeed/keeper/grpc_query.go index 48a92bae..a329792c 100644 --- a/x/pricefeed/keeper/grpc_query.go +++ b/x/pricefeed/keeper/grpc_query.go @@ -48,7 +48,8 @@ func (s queryServer) Price(c context.Context, req *types.QueryPriceRequest) (*ty } return &types.QueryPriceResponse{ - Price: types.CurrentPriceResponse(currentPrice)}, nil + Price: types.CurrentPriceResponse(currentPrice), + }, nil } func (s queryServer) Prices(c context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error) { diff --git a/x/pricefeed/keeper/keeper.go b/x/pricefeed/keeper/keeper.go index c7e35aea..ee580c5e 100644 --- a/x/pricefeed/keeper/keeper.go +++ b/x/pricefeed/keeper/keeper.go @@ -51,7 +51,8 @@ func (k Keeper) SetPrice( oracle sdk.AccAddress, marketID string, price sdk.Dec, - expiry time.Time) (types.PostedPrice, error) { + expiry time.Time, +) (types.PostedPrice, error) { // If the expiry is less than or equal to the current blockheight, we consider the price valid if !expiry.After(ctx.BlockTime()) { return types.PostedPrice{}, types.ErrExpired diff --git a/x/pricefeed/keeper/params_test.go b/x/pricefeed/keeper/params_test.go index 5edec228..9bc00317 100644 --- a/x/pricefeed/keeper/params_test.go +++ b/x/pricefeed/keeper/params_test.go @@ -66,6 +66,7 @@ func (suite *KeeperTestSuite) TestGetAuthorizedAddresses() { suite.Require().ElementsMatch(oracles, actualOracles) } + func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } diff --git a/x/pricefeed/keeper/querier.go b/x/pricefeed/keeper/querier.go index 755eb440..78c0fe60 100644 --- a/x/pricefeed/keeper/querier.go +++ b/x/pricefeed/keeper/querier.go @@ -30,7 +30,6 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint", types.ModuleName) } } - } func queryPrice(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) (res []byte, sdkErr error) { diff --git a/x/savings/keeper/deposit.go b/x/savings/keeper/deposit.go index e57d7d80..df97e611 100644 --- a/x/savings/keeper/deposit.go +++ b/x/savings/keeper/deposit.go @@ -9,7 +9,6 @@ import ( // Deposit deposit func (k Keeper) Deposit(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Coins) error { - err := k.ValidateDeposit(ctx, coins) if err != nil { return err diff --git a/x/savings/keeper/grpcquery_test.go b/x/savings/keeper/grpcquery_test.go index 85c777ba..0f37b3a3 100644 --- a/x/savings/keeper/grpcquery_test.go +++ b/x/savings/keeper/grpcquery_test.go @@ -61,7 +61,6 @@ func (suite *grpcQueryTestSuite) SetupTest() { addrs, ), ) - } func (suite *grpcQueryTestSuite) TestGrpcQueryParams() { diff --git a/x/savings/types/genesis.go b/x/savings/types/genesis.go index be3c6ae5..c0027ad0 100644 --- a/x/savings/types/genesis.go +++ b/x/savings/types/genesis.go @@ -19,7 +19,6 @@ func DefaultGenesisState() GenesisState { // Validate performs basic validation of genesis data returning an // error for any failed validation criteria. func (gs GenesisState) Validate() error { - if err := gs.Params.Validate(); err != nil { return err } diff --git a/x/savings/types/key.go b/x/savings/types/key.go index eb5ea17e..6d0f484d 100644 --- a/x/savings/types/key.go +++ b/x/savings/types/key.go @@ -20,6 +20,4 @@ const ( ModuleAccountName = ModuleName ) -var ( - DepositsKeyPrefix = []byte{0x01} -) +var DepositsKeyPrefix = []byte{0x01} diff --git a/x/swap/keeper/grpc_query.go b/x/swap/keeper/grpc_query.go index febe656c..ba697c54 100644 --- a/x/swap/keeper/grpc_query.go +++ b/x/swap/keeper/grpc_query.go @@ -97,7 +97,6 @@ func (s queryServer) Deposits(c context.Context, req *types.QueryDepositsRequest store, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { - var record types.ShareRecord err := s.keeper.cdc.Unmarshal(value, &record) if err != nil { diff --git a/x/swap/keeper/invariants_test.go b/x/swap/keeper/invariants_test.go index a1b4fe22..af628591 100644 --- a/x/swap/keeper/invariants_test.go +++ b/x/swap/keeper/invariants_test.go @@ -103,7 +103,6 @@ func (suite *invariantTestSuite) runInvariant(route string, invariant func(k kee } func (suite *invariantTestSuite) TestPoolRecordsInvariant() { - // default state is valid message, broken := suite.runInvariant("pool-records", keeper.PoolRecordsInvariant) suite.Equal("swap: validate pool records broken invariant\npool record invalid\n", message) diff --git a/x/swap/keeper/querier.go b/x/swap/keeper/querier.go index 030477a5..20a6ec23 100644 --- a/x/swap/keeper/querier.go +++ b/x/swap/keeper/querier.go @@ -80,7 +80,6 @@ func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQu } func queryGetPool(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryPoolParams err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) if err != nil { @@ -90,7 +89,6 @@ func queryGetPool(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerie hasPoolParam := len(params.Pool) > 0 if !hasPoolParam { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "must specify pool param") - } pool, err := k.loadDenominatedPool(ctx, params.Pool) diff --git a/x/swap/types/base_pool.go b/x/swap/types/base_pool.go index 643c1e3e..db71eda5 100644 --- a/x/swap/types/base_pool.go +++ b/x/swap/types/base_pool.go @@ -8,9 +8,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -var ( - zero = sdk.ZeroInt() -) +var zero = sdk.ZeroInt() // calculateInitialShares calculates initial shares as sqrt(A*B), the geometric mean of A and B func calculateInitialShares(reservesA, reservesB sdk.Int) sdk.Int { diff --git a/x/swap/types/base_pool_test.go b/x/swap/types/base_pool_test.go index 0592f4c8..73da74da 100644 --- a/x/swap/types/base_pool_test.go +++ b/x/swap/types/base_pool_test.go @@ -3,7 +3,6 @@ package types_test import ( "fmt" "math/big" - "testing" types "github.com/kava-labs/kava/x/swap/types" @@ -387,7 +386,8 @@ func TestBasePool_ReservesOnlyDepletedWithLastShare(t *testing.T) { {i(5), i(5)}, {i(100), i(100)}, {i(100), i(10000000)}, - {i(1e5), i(5e6)}, {i(1e6), i(5e6)}, + {i(1e5), i(5e6)}, + {i(1e6), i(5e6)}, {i(1e15), i(7e15)}, {i(1), i(6e18)}, {i(1.345678e18), i(4.313456e18)}, diff --git a/x/validator-vesting/client/cli/query.go b/x/validator-vesting/client/cli/query.go index 674f1837..baafa84f 100644 --- a/x/validator-vesting/client/cli/query.go +++ b/x/validator-vesting/client/cli/query.go @@ -34,7 +34,6 @@ func GetQueryCmd() *cobra.Command { valVestingQueryCmd.AddCommand(cmds...) return valVestingQueryCmd - } func queryCirculatingSupply() *cobra.Command { diff --git a/x/validator-vesting/querier.go b/x/validator-vesting/querier.go index 3b945c80..9182fd11 100644 --- a/x/validator-vesting/querier.go +++ b/x/validator-vesting/querier.go @@ -59,7 +59,6 @@ func queryGetCirculatingSupply(ctx sdk.Context, req abci.RequestQuery, bk types. } func getCirculatingSupply(blockTime time.Time, totalSupply sdk.Int) sdk.Int { - vestingDates := []time.Time{ time.Date(2022, 2, 5, 14, 0, 0, 0, time.UTC), time.Date(2022, 5, 5, 14, 0, 0, 0, time.UTC),