remove x/mint (#1416)

* use kavamint in incentive to calculate staking apy

* use kavamint minting: rewards_earn_staking_integration_test

* update incentive tests to mint only with kavamint

* remove x/mint from incentive tests

* remove x/mint from kava app

* fix minting in x/auction tests

* replace simapp fund calls with test helper

* remove mint state from genesis.json
This commit is contained in:
Robert Pirtle 2022-12-09 14:31:31 -08:00 committed by GitHub
parent f37321839b
commit 016eecfcc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 124 additions and 335 deletions

View File

@ -49,9 +49,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
@ -167,7 +164,6 @@ var (
bank.AppModuleBasic{},
capability.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler,
@ -218,7 +214,6 @@ var (
mAccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
@ -282,7 +277,6 @@ type App struct {
bankKeeper bankkeeper.Keeper
capabilityKeeper *capabilitykeeper.Keeper
stakingKeeper stakingkeeper.Keeper
mintKeeper mintkeeper.Keeper
distrKeeper distrkeeper.Keeper
govKeeper govkeeper.Keeper
paramsKeeper paramskeeper.Keeper
@ -357,7 +351,7 @@ func NewApp(
keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey,
upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey,
evmtypes.StoreKey, feemarkettypes.StoreKey, authzkeeper.StoreKey,
@ -390,7 +384,6 @@ func NewApp(
authSubspace := app.paramsKeeper.Subspace(authtypes.ModuleName)
bankSubspace := app.paramsKeeper.Subspace(banktypes.ModuleName)
stakingSubspace := app.paramsKeeper.Subspace(stakingtypes.ModuleName)
mintSubspace := app.paramsKeeper.Subspace(minttypes.ModuleName)
distrSubspace := app.paramsKeeper.Subspace(distrtypes.ModuleName)
slashingSubspace := app.paramsKeeper.Subspace(slashingtypes.ModuleName)
govSubspace := app.paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
@ -448,15 +441,6 @@ func NewApp(
appCodec,
app.BaseApp.MsgServiceRouter(),
)
app.mintKeeper = mintkeeper.NewKeeper(
appCodec,
keys[minttypes.StoreKey],
mintSubspace,
&app.stakingKeeper,
app.accountKeeper,
app.bankKeeper,
authtypes.FeeCollectorName,
)
app.distrKeeper = distrkeeper.NewKeeper(
appCodec,
keys[distrtypes.StoreKey],
@ -660,7 +644,7 @@ func NewApp(
&savingsKeeper,
&app.liquidKeeper,
&earnKeeper,
app.mintKeeper,
app.kavamintKeeper,
app.distrKeeper,
app.pricefeedKeeper,
)
@ -736,7 +720,6 @@ func NewApp(
bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper),
capability.NewAppModule(appCodec, *app.capabilityKeeper),
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper),
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
gov.NewAppModule(appCodec, app.govKeeper, app.accountKeeper, app.bankKeeper),
params.NewAppModule(app.paramsKeeper),
@ -779,9 +762,7 @@ func NewApp(
// Committee begin blocker changes module params by enacting proposals.
// Run before to ensure params are updated together before state changes.
committeetypes.ModuleName,
minttypes.ModuleName,
// Kavamint registers with the vanilla mint module.
// Must be run before distribution module in order to generate block staking rewards.
// Kavamint must be registered before distribution module in order to generate block staking rewards.
kavaminttypes.ModuleName,
distrtypes.ModuleName,
// During begin block slashing happens after distr.BeginBlocker so that
@ -836,7 +817,6 @@ func NewApp(
capabilitytypes.ModuleName,
incentivetypes.ModuleName,
issuancetypes.ModuleName,
minttypes.ModuleName,
slashingtypes.ModuleName,
distrtypes.ModuleName,
auctiontypes.ModuleName,
@ -875,7 +855,6 @@ func NewApp(
stakingtypes.ModuleName,
slashingtypes.ModuleName, // iterates over validators, run after staking
govtypes.ModuleName,
minttypes.ModuleName,
kavaminttypes.ModuleName,
ibchost.ModuleName,
evidencetypes.ModuleName,

View File

@ -18,8 +18,6 @@ import (
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
distkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
@ -44,6 +42,7 @@ import (
issuancekeeper "github.com/kava-labs/kava/x/issuance/keeper"
kavadistkeeper "github.com/kava-labs/kava/x/kavadist/keeper"
kavamintkeeper "github.com/kava-labs/kava/x/kavamint/keeper"
kavaminttypes "github.com/kava-labs/kava/x/kavamint/types"
liquidkeeper "github.com/kava-labs/kava/x/liquid/keeper"
pricefeedkeeper "github.com/kava-labs/kava/x/pricefeed/keeper"
routerkeeper "github.com/kava-labs/kava/x/router/keeper"
@ -98,7 +97,6 @@ func (tApp TestApp) GetAccountKeeper() authkeeper.AccountKeeper { return tApp.ac
func (tApp TestApp) GetBankKeeper() bankkeeper.Keeper { return tApp.bankKeeper }
func (tApp TestApp) GetStakingKeeper() stakingkeeper.Keeper { return tApp.stakingKeeper }
func (tApp TestApp) GetSlashingKeeper() slashingkeeper.Keeper { return tApp.slashingKeeper }
func (tApp TestApp) GetMintKeeper() mintkeeper.Keeper { return tApp.mintKeeper }
func (tApp TestApp) GetDistrKeeper() distkeeper.Keeper { return tApp.distrKeeper }
func (tApp TestApp) GetGovKeeper() govkeeper.Keeper { return tApp.govKeeper }
func (tApp TestApp) GetCrisisKeeper() crisiskeeper.Keeper { return tApp.crisisKeeper }
@ -212,11 +210,11 @@ func (tApp TestApp) GetModuleAccountBalance(ctx sdk.Context, moduleName string,
// FundAccount is a utility function that funds an account by minting and sending the coins to the address.
func (tApp TestApp) FundAccount(ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error {
if err := tApp.bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil {
if err := tApp.bankKeeper.MintCoins(ctx, kavaminttypes.ModuleAccountName, amounts); err != nil {
return err
}
return tApp.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, amounts)
return tApp.bankKeeper.SendCoinsFromModuleToAccount(ctx, kavaminttypes.ModuleAccountName, addr, amounts)
}
// NewQueryServerTestHelper creates a new QueryServiceTestHelper that wraps the provided sdk.Context.
@ -226,11 +224,11 @@ func (tApp TestApp) NewQueryServerTestHelper(ctx sdk.Context) *baseapp.QueryServ
// FundModuleAccount is a utility function that funds a module account by minting and sending the coins to the address.
func (tApp TestApp) FundModuleAccount(ctx sdk.Context, recipientMod string, amounts sdk.Coins) error {
if err := tApp.bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil {
if err := tApp.bankKeeper.MintCoins(ctx, kavaminttypes.ModuleAccountName, amounts); err != nil {
return err
}
return tApp.bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, recipientMod, amounts)
return tApp.bankKeeper.SendCoinsFromModuleToModule(ctx, kavaminttypes.ModuleAccountName, recipientMod, amounts)
}
// CreateNewUnbondedValidator creates a new validator in the staking module.

View File

@ -2319,20 +2319,6 @@
"liquid": {
"params": {}
},
"mint": {
"minter": {
"inflation": "0.000000000000000000",
"annual_provisions": "0.000000000000000000"
},
"params": {
"mint_denom": "ukava",
"inflation_rate_change": "0.130000000000000000",
"inflation_max": "0.000000000000000000",
"inflation_min": "0.000000000000000000",
"goal_bonded": "0.670000000000000000",
"blocks_per_year": "6311520"
}
},
"params": null,
"pricefeed": {
"params": {

View File

@ -3,7 +3,6 @@ package testutil
import (
"github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
@ -78,48 +77,15 @@ func (suite *Suite) SetupTest(numAddrs int) {
suite.AccountKeeper = tApp.GetAccountKeeper()
}
// CreateAccount adds coins to an account address
func (suite *Suite) AddCoinsToAccount(addr sdk.AccAddress, coins sdk.Coins) {
ak := suite.App.GetAccountKeeper()
acc := ak.NewAccountWithAddress(suite.Ctx, addr)
ak.SetAccount(suite.Ctx, acc)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), coins)
suite.Require().NoError(err)
}
// AddCoinsToModule adds coins to a named module account
func (suite *Suite) AddCoinsToNamedModule(moduleName string, amount sdk.Coins) {
// Does not use suite.BankKeeper.MintCoins as module account would not have permission to mint
err := simapp.FundModuleAccount(suite.BankKeeper, suite.Ctx, moduleName, amount)
err := suite.App.FundModuleAccount(suite.Ctx, moduleName, amount)
suite.Require().NoError(err)
}
// NewModuleAccountFromAddr creates a new module account from the provided address with the provided balance
// func (suite *Suite) NewModuleAccount(moduleName string, balance sdk.Coins) authtypes.AccountI {
// ak := suite.App.GetAccountKeeper()
// modAccAddr := authtypes.NewModuleAddress(moduleName)
// acc := ak.NewAccountWithAddress(suite.Ctx, modAccAddr)
// ak.SetAccount(suite.Ctx, acc)
// err := simapp.FundModuleAccount(suite.BankKeeper, suite.Ctx, moduleName, balance)
// suite.Require().NoError(err)
// return acc
// }
// CheckAccountBalanceEqual asserts that
func (suite *Suite) CheckAccountBalanceEqual(owner sdk.AccAddress, expectedCoins sdk.Coins) {
balances := suite.BankKeeper.GetAllBalances(suite.Ctx, owner)
suite.Equal(expectedCoins, balances)
}
// // CheckModuleAccountBalanceEqual asserts that a named module account balance matches the provided coins
// func (suite *Suite) CheckModuleAccountBalanceEqual(moduleName string, coins sdk.Coins) {
// balance := suite.BankKeeper.GetAllBalances(
// suite.Ctx,
// suite.AccountKeeper.GetModuleAddress(moduleName),
// )
// suite.Equal(coins, balance, fmt.Sprintf("expected module account balance to equal coins %s, but got %s", coins, balance))
// }

View File

@ -17,7 +17,6 @@ import (
savingskeeper "github.com/kava-labs/kava/x/savings/keeper"
savingstypes "github.com/kava-labs/kava/x/savings/types"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@ -205,7 +204,7 @@ func (suite *Suite) GetEvents() sdk.Events {
// AddCoinsToModule adds coins to the earn module account
func (suite *Suite) AddCoinsToModule(amount sdk.Coins) {
// Does not use suite.BankKeeper.MintCoins as module account would not have permission to mint
err := simapp.FundModuleAccount(suite.BankKeeper, suite.Ctx, types.ModuleName, amount)
err := suite.App.FundModuleAccount(suite.Ctx, types.ModuleName, amount)
suite.Require().NoError(err)
}
@ -227,7 +226,7 @@ func (suite *Suite) CreateAccount(initialBalance sdk.Coins, index int) authtypes
acc := ak.NewAccountWithAddress(suite.Ctx, addrs[index])
ak.SetAccount(suite.Ctx, acc)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), initialBalance)
err := suite.App.FundAccount(suite.Ctx, acc.GetAddress(), initialBalance)
suite.Require().NoError(err)
return acc
@ -240,7 +239,7 @@ func (suite *Suite) NewAccountFromAddr(addr sdk.AccAddress, balance sdk.Coins) a
acc := ak.NewAccountWithAddress(suite.Ctx, addr)
ak.SetAccount(suite.Ctx, acc)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), balance)
err := suite.App.FundAccount(suite.Ctx, acc.GetAddress(), balance)
suite.Require().NoError(err)
return acc

View File

@ -5,7 +5,6 @@ import (
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/stretchr/testify/suite"
"github.com/kava-labs/kava/x/evmutil/keeper"
@ -130,9 +129,8 @@ func (suite *invariantTestSuite) TestSmallBalances() {
// add same number of ukava to avoid breaking other invariants
amt := sdk.NewCoins(sdk.NewInt64Coin(keeper.CosmosDenom, 1))
suite.Require().NoError(
suite.BankKeeper.MintCoins(suite.Ctx, minttypes.ModuleName, amt),
suite.App.FundModuleAccount(suite.Ctx, types.ModuleName, amt),
)
suite.BankKeeper.SendCoinsFromModuleToModule(suite.Ctx, minttypes.ModuleName, types.ModuleName, amt)
message, broken := suite.runInvariant("small-balances", keeper.SmallBalancesInvariant)
suite.Equal("evmutil: small balances broken invariant\nminor balances not all less than overflow\n", message)

View File

@ -14,7 +14,6 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
@ -39,6 +38,7 @@ import (
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/evmutil/keeper"
"github.com/kava-labs/kava/x/evmutil/types"
kavaminttypes "github.com/kava-labs/kava/x/kavamint/types"
)
type Suite struct {
@ -348,11 +348,11 @@ func (suite *Suite) SendTx(
}
func (suite *Suite) MintFeeCollector(coins sdk.Coins) {
err := suite.App.GetBankKeeper().MintCoins(suite.Ctx, minttypes.ModuleName, coins)
err := suite.App.GetBankKeeper().MintCoins(suite.Ctx, kavaminttypes.ModuleAccountName, coins)
suite.Require().NoError(err)
err = suite.App.GetBankKeeper().SendCoinsFromModuleToModule(
suite.Ctx,
minttypes.ModuleName,
kavaminttypes.ModuleAccountName,
authtypes.FeeCollectorName,
coins,
)

View File

@ -73,11 +73,9 @@ func (suite *BasicAccumulatorTestSuite) SetupTest() {
stakingBuilder := testutil.NewStakingGenesisBuilder()
mintBuilder := testutil.NewMintGenesisBuilder().
WithInflationMax(sdk.OneDec()).
WithInflationMin(sdk.OneDec()).
WithMinter(sdk.OneDec(), sdk.ZeroDec()).
WithMintDenom("ukava")
kavamintBuilder := testutil.NewKavamintGenesisBuilder().
WithStakingRewardsApy(sdk.MustNewDecFromStr("0.2")).
WithPreviousBlockTime(suite.GenesisTime)
suite.StartChainWithBuilders(
authBuilder,
@ -85,7 +83,7 @@ func (suite *BasicAccumulatorTestSuite) SetupTest() {
savingsBuilder,
earnBuilder,
stakingBuilder,
mintBuilder,
kavamintBuilder,
)
suite.pool = swaptypes.PoolID(poolDenomA, poolDenomB)

View File

@ -65,11 +65,9 @@ func (suite *AccumulateEarnRewardsIntegrationTests) SetupTest() {
stakingBuilder := testutil.NewStakingGenesisBuilder()
mintBuilder := testutil.NewMintGenesisBuilder().
WithInflationMax(sdk.OneDec()).
WithInflationMin(sdk.OneDec()).
WithMinter(sdk.OneDec(), sdk.ZeroDec()).
WithMintDenom("ukava")
kavamintBuilder := testutil.NewKavamintGenesisBuilder().
WithStakingRewardsApy(sdk.MustNewDecFromStr("0.2")).
WithPreviousBlockTime(suite.GenesisTime)
suite.StartChainWithBuilders(
authBuilder,
@ -77,7 +75,7 @@ func (suite *AccumulateEarnRewardsIntegrationTests) SetupTest() {
savingsBuilder,
earnBuilder,
stakingBuilder,
mintBuilder,
kavamintBuilder,
)
}
@ -316,7 +314,7 @@ func (suite *AccumulateEarnRewardsIntegrationTests) TestStateUpdatedWhenBlockTim
},
{
CollateralType: "ukava",
RewardFactor: d("4.154285714285714285").Add(stakingRewardIndexes0),
RewardFactor: d("4.154285714285714286").Add(stakingRewardIndexes0),
},
})

View File

@ -63,11 +63,9 @@ func (suite *EarnAccumulatorStakingRewardsTestSuite) SetupTest() {
stakingBuilder := testutil.NewStakingGenesisBuilder()
mintBuilder := testutil.NewMintGenesisBuilder().
WithInflationMax(sdk.OneDec()).
WithInflationMin(sdk.OneDec()).
WithMinter(sdk.OneDec(), sdk.ZeroDec()).
WithMintDenom("ukava")
kavamintBuilder := testutil.NewKavamintGenesisBuilder().
WithStakingRewardsApy(sdk.MustNewDecFromStr("0.2")).
WithPreviousBlockTime(suite.GenesisTime)
suite.StartChainWithBuilders(
authBuilder,
@ -75,7 +73,7 @@ func (suite *EarnAccumulatorStakingRewardsTestSuite) SetupTest() {
savingsBuilder,
earnBuilder,
stakingBuilder,
mintBuilder,
kavamintBuilder,
)
}
@ -136,6 +134,7 @@ func (suite *EarnAccumulatorStakingRewardsTestSuite) TestStakingRewardsDistribut
suite.keeper.Store.SetRewardAccrualTime(suite.Ctx, types.CLAIM_TYPE_EARN, vaultDenom1, suite.Ctx.BlockTime())
suite.keeper.Store.SetRewardAccrualTime(suite.Ctx, types.CLAIM_TYPE_EARN, vaultDenom2, suite.Ctx.BlockTime())
suite.App.GetKavamintKeeper().SetPreviousBlockTime(suite.Ctx, suite.Ctx.BlockTime())
val := suite.GetAbciValidator(suite.valAddrs[0])

View File

@ -31,7 +31,7 @@ type Keeper struct {
Store store.IncentiveStore
// Keepers used for APY queries
mintKeeper types.MintKeeper
kavamintKeeper types.KavamintKeeper
distrKeeper types.DistrKeeper
pricefeedKeeper types.PricefeedKeeper
}
@ -41,7 +41,7 @@ func NewKeeper(
cdc codec.Codec, key sdk.StoreKey, paramstore types.ParamSubspace, bk types.BankKeeper,
cdpk types.CdpKeeper, hk types.HardKeeper, ak types.AccountKeeper, stk types.StakingKeeper,
swpk types.SwapKeeper, svk types.SavingsKeeper, lqk types.LiquidKeeper, ek types.EarnKeeper,
mk types.MintKeeper, dk types.DistrKeeper, pfk types.PricefeedKeeper,
kmk types.KavamintKeeper, dk types.DistrKeeper, pfk types.PricefeedKeeper,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
@ -67,7 +67,7 @@ func NewKeeper(
),
Store: store.NewIncentiveStore(cdc, key),
mintKeeper: mk,
kavamintKeeper: kmk,
distrKeeper: dk,
pricefeedKeeper: pfk,
}

View File

@ -8,11 +8,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/mint"
earntypes "github.com/kava-labs/kava/x/earn/types"
"github.com/kava-labs/kava/x/incentive"
"github.com/kava-labs/kava/x/incentive/testutil"
"github.com/kava-labs/kava/x/incentive/types"
"github.com/kava-labs/kava/x/kavamint"
liquidtypes "github.com/kava-labs/kava/x/liquid/types"
)
@ -53,7 +53,7 @@ func (suite *HandlerTestSuite) TestEarnLiquidClaim() {
// bk := suite.App.GetBankKeeper()
sk := suite.App.GetStakingKeeper()
lq := suite.App.GetLiquidKeeper()
mk := suite.App.GetMintKeeper()
mk := suite.App.GetKavamintKeeper()
dk := suite.App.GetDistrKeeper()
ik := suite.App.GetIncentiveKeeper()
@ -62,9 +62,9 @@ func (suite *HandlerTestSuite) TestEarnLiquidClaim() {
suite.Require().True(found)
suite.Require().Equal("bkava", period.CollateralType)
// Use ukava for mint denom
// Ensure nonzero staking APY
mParams := mk.GetParams(suite.Ctx)
mParams.MintDenom = "ukava"
mParams.StakingRewardsApy = sdk.NewDecWithPrec(20, 2)
mk.SetParams(suite.Ctx, mParams)
bkavaDenom1 := lq.GetLiquidStakingTokenDenom(valAddr1)
@ -138,10 +138,7 @@ func (suite *HandlerTestSuite) TestEarnLiquidClaim() {
WithBlockTime(suite.Ctx.BlockTime().Add(7 * time.Second))
// Mint tokens
mint.BeginBlocker(
suite.Ctx,
suite.App.GetMintKeeper(),
)
kavamint.BeginBlocker(suite.Ctx, suite.App.GetKavamintKeeper())
// Distribute to validators, block needs votes
distribution.BeginBlocker(
suite.Ctx,
@ -166,10 +163,10 @@ func (suite *HandlerTestSuite) TestEarnLiquidClaim() {
// Zero rewards since this block is the same as the block it was last claimed
// This needs to run **after** staking rewards are minted/distributed in
// x/mint + x/distribution but **before** the x/incentive BeginBlocker.
// x/kavamint + x/distribution but **before** the x/incentive BeginBlocker.
// Order of operations:
// 1. x/mint + x/distribution BeginBlocker
// 1. x/kavamint + x/distribution BeginBlocker
// 2. CalculateDelegationRewards
// 3. x/incentive BeginBlocker to claim staking rewards
delegationRewards := dk.CalculateDelegationRewards(suite.Ctx, validator1, delegation, endingPeriod)

View File

@ -422,18 +422,8 @@ func queryGetAPYs(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerie
// GetStakingAPR returns the total APR for staking and incentive rewards
func GetStakingAPR(ctx sdk.Context, k Keeper, params types.Params) (sdk.Dec, error) {
// Get staking APR + incentive APR
inflationRate := k.mintKeeper.GetMinter(ctx).Inflation
communityTax := k.distrKeeper.GetCommunityTax(ctx)
bondedTokens := k.stakingKeeper.TotalBondedTokens(ctx)
circulatingSupply := k.bankKeeper.GetSupply(ctx, types.BondDenom)
// Staking APR = (Inflation Rate * (1 - Community Tax)) / (Bonded Tokens / Circulating Supply)
stakingAPR := inflationRate.
Mul(sdk.OneDec().Sub(communityTax)).
Quo(bondedTokens.ToDec().
Quo(circulatingSupply.Amount.ToDec()))
// Get staking APR
stakingAPR := k.kavamintKeeper.GetStakingApy(ctx)
// Get incentive APR
bkavaRewardPeriod, found := params.EarnRewardPeriods.GetMultiRewardPeriod(liquidtypes.DefaultDerivativeDenom)

View File

@ -5,7 +5,6 @@ import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
earntypes "github.com/kava-labs/kava/x/earn/types"
@ -30,6 +29,18 @@ func (suite *QuerierTestSuite) TestGetStakingAPR() {
liquidStakedTokens := int64(60_000_000_000000)
totalSupply := int64(289_138_414_286684)
// inflation values below are used to regression test the switch from x/mint to x/kavamint
// rather than define the total inflation w/ a community tax, we now directly define
// inflation for staking rewards & inflation for the community pool.
// derive these values from the above values in order to verify no change to output
bondedRatio := sdk.NewDec(bondedTokens).Quo(sdk.NewDec(totalSupply))
communityInflation := inflation.
Mul(communityTax).
Quo(bondedRatio)
stakingRewardsApy := inflation.
Mul(sdk.OneDec().Sub(communityTax)).
Quo(bondedRatio)
usdcDenom := "erc20/multichain/usdc"
usdcSupply := int64(2_500_000_000000)
@ -38,12 +49,10 @@ func (suite *QuerierTestSuite) TestGetStakingAPR() {
addVault(usdcDenom, earntypes.NewVaultShare(usdcDenom, sdk.NewDec(usdcSupply)))
suite.keeper = suite.NewTestKeeper(&fakeParamSubspace{}).
WithDistrKeeper(
newFakeDistrKeeper().setCommunityTax(communityTax),
).
WithMintKeeper(
newFakeMintKeeper().
setMinter(minttypes.NewMinter(inflation, sdk.OneDec())),
WithKavamintKeeper(
newFakeKavamintKeeper().
setCommunityInflation(communityInflation).
setStakingApy(stakingRewardsApy),
).
WithStakingKeeper(
newFakeStakingKeeper().addBondedTokens(bondedTokens),

View File

@ -64,11 +64,9 @@ func (suite *AccumulateEarnRewardsIntegrationTests) SetupTest() {
stakingBuilder := testutil.NewStakingGenesisBuilder()
mintBuilder := testutil.NewMintGenesisBuilder().
WithInflationMax(sdk.OneDec()).
WithInflationMin(sdk.OneDec()).
WithMinter(sdk.OneDec(), sdk.ZeroDec()).
WithMintDenom("ukava")
kavamintBuilder := testutil.NewKavamintGenesisBuilder().
WithStakingRewardsApy(sdk.MustNewDecFromStr("0.2")).
WithPreviousBlockTime(suite.GenesisTime)
suite.StartChainWithBuilders(
authBuilder,
@ -76,7 +74,7 @@ func (suite *AccumulateEarnRewardsIntegrationTests) SetupTest() {
savingsBuilder,
earnBuilder,
stakingBuilder,
mintBuilder,
kavamintBuilder,
)
}
@ -313,7 +311,7 @@ func (suite *AccumulateEarnRewardsIntegrationTests) TestStateUpdatedWhenBlockTim
},
{
CollateralType: "ukava",
RewardFactor: d("4.154285714285714285").Add(stakingRewardIndexes0),
RewardFactor: d("4.154285714285714286").Add(stakingRewardIndexes0),
},
})

View File

@ -63,13 +63,9 @@ func (suite *EarnStakingRewardsIntegrationTestSuite) SetupTest() {
stakingBuilder := testutil.NewStakingGenesisBuilder()
mintBuilder := testutil.NewMintGenesisBuilder().
WithInflationMax(sdk.OneDec()).
WithInflationMin(sdk.OneDec()).
WithMinter(sdk.OneDec(), sdk.ZeroDec()).
WithMintDenom("ukava")
kavamintBuilder := testutil.NewKavamintGenesisBuilder()
kavamintBuilder := testutil.NewKavamintGenesisBuilder().
WithStakingRewardsApy(sdk.MustNewDecFromStr("0.2")).
WithPreviousBlockTime(suite.GenesisTime)
suite.StartChainWithBuilders(
authBuilder,
@ -77,7 +73,6 @@ func (suite *EarnStakingRewardsIntegrationTestSuite) SetupTest() {
savingsBuilder,
earnBuilder,
stakingBuilder,
mintBuilder,
kavamintBuilder,
)
}
@ -139,6 +134,7 @@ func (suite *EarnStakingRewardsIntegrationTestSuite) TestStakingRewardsDistribut
suite.keeper.SetEarnRewardAccrualTime(suite.Ctx, vaultDenom1, suite.Ctx.BlockTime())
suite.keeper.SetEarnRewardAccrualTime(suite.Ctx, vaultDenom2, suite.Ctx.BlockTime())
suite.App.GetKavamintKeeper().SetPreviousBlockTime(suite.Ctx, suite.Ctx.BlockTime())
val := suite.GetAbciValidator(suite.valAddrs[0])

View File

@ -8,7 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
@ -160,7 +159,7 @@ type TestKeeperBuilder struct {
earnKeeper types.EarnKeeper
// Keepers used for APY queries
mintKeeper types.MintKeeper
kavamintKeeper types.KavamintKeeper
distrKeeper types.DistrKeeper
pricefeedKeeper types.PricefeedKeeper
}
@ -185,7 +184,6 @@ func (suite *unitTester) NewTestKeeper(
savingsKeeper: nil,
liquidKeeper: nil,
earnKeeper: nil,
mintKeeper: nil,
distrKeeper: nil,
pricefeedKeeper: nil,
}
@ -211,8 +209,8 @@ func (tk *TestKeeperBuilder) WithStakingKeeper(k types.StakingKeeper) *TestKeepe
return tk
}
func (tk *TestKeeperBuilder) WithMintKeeper(k types.MintKeeper) *TestKeeperBuilder {
tk.mintKeeper = k
func (tk *TestKeeperBuilder) WithKavamintKeeper(k types.KavamintKeeper) *TestKeeperBuilder {
tk.kavamintKeeper = k
return tk
}
@ -231,7 +229,7 @@ func (tk *TestKeeperBuilder) Build() keeper.Keeper {
tk.cdc, tk.key, tk.paramSubspace,
tk.bankKeeper, tk.cdpKeeper, tk.hardKeeper, tk.accountKeeper,
tk.stakingKeeper, tk.swapKeeper, tk.savingsKeeper, tk.liquidKeeper,
tk.earnKeeper, tk.mintKeeper, tk.distrKeeper, tk.pricefeedKeeper,
tk.earnKeeper, tk.kavamintKeeper, tk.distrKeeper, tk.pricefeedKeeper,
)
}
@ -649,23 +647,29 @@ func (k *fakeDistrKeeper) GetCommunityTax(ctx sdk.Context) (percent sdk.Dec) {
return k.communityTax
}
type fakeMintKeeper struct {
minter minttypes.Minter
type fakeKavamintKeeper struct {
stakingApy sdk.Dec
communityInflation sdk.Dec
}
var _ types.MintKeeper = newFakeMintKeeper()
var _ types.KavamintKeeper = newFakeKavamintKeeper()
func newFakeMintKeeper() *fakeMintKeeper {
return &fakeMintKeeper{}
func newFakeKavamintKeeper() *fakeKavamintKeeper {
return &fakeKavamintKeeper{}
}
func (k *fakeMintKeeper) setMinter(minter minttypes.Minter) *fakeMintKeeper {
k.minter = minter
func (k *fakeKavamintKeeper) setStakingApy(apy sdk.Dec) *fakeKavamintKeeper {
k.stakingApy = apy
return k
}
func (k *fakeMintKeeper) GetMinter(ctx sdk.Context) (minter minttypes.Minter) {
return k.minter
func (k *fakeKavamintKeeper) setCommunityInflation(inflation sdk.Dec) *fakeKavamintKeeper {
k.communityInflation = inflation
return k
}
func (k *fakeKavamintKeeper) GetStakingApy(ctx sdk.Context) (apy sdk.Dec) {
return k.stakingApy
}
type fakePricefeedKeeper struct {

View File

@ -1,6 +1,8 @@
package testutil
import (
"time"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
@ -38,3 +40,20 @@ func (builder KavamintGenesisBuilder) BuildMarshalled(cdc codec.JSONCodec) app.G
kavaminttypes.ModuleName: cdc.MustMarshalJSON(&built),
}
}
func (builder KavamintGenesisBuilder) WithPreviousBlockTime(t time.Time) KavamintGenesisBuilder {
builder.PreviousBlockTime = t
return builder
}
func (builder KavamintGenesisBuilder) WithStakingRewardsApy(apy sdk.Dec) KavamintGenesisBuilder {
builder.Params.StakingRewardsApy = apy
return builder
}
func (builder KavamintGenesisBuilder) WithCommunityPoolInflation(
inflation sdk.Dec,
) KavamintGenesisBuilder {
builder.Params.CommunityPoolInflation = inflation
return builder
}

View File

@ -1,68 +0,0 @@
package testutil
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)
// MintGenesisBuilder is a tool for creating a mint genesis state.
// Helper methods add values onto a default genesis state.
// All methods are immutable and return updated copies of the builder.
type MintGenesisBuilder struct {
minttypes.GenesisState
}
var _ GenesisBuilder = (*MintGenesisBuilder)(nil)
func NewMintGenesisBuilder() MintGenesisBuilder {
gen := minttypes.DefaultGenesisState()
gen.Params.MintDenom = "ukava"
return MintGenesisBuilder{
GenesisState: *gen,
}
}
func (builder MintGenesisBuilder) Build() minttypes.GenesisState {
return builder.GenesisState
}
func (builder MintGenesisBuilder) BuildMarshalled(cdc codec.JSONCodec) app.GenesisState {
built := builder.Build()
return app.GenesisState{
minttypes.ModuleName: cdc.MustMarshalJSON(&built),
}
}
func (builder MintGenesisBuilder) WithMinter(
inflation sdk.Dec,
annualProvisions sdk.Dec,
) MintGenesisBuilder {
builder.Minter = minttypes.NewMinter(inflation, annualProvisions)
return builder
}
func (builder MintGenesisBuilder) WithInflationMax(
inflationMax sdk.Dec,
) MintGenesisBuilder {
builder.Params.InflationMax = inflationMax
return builder
}
func (builder MintGenesisBuilder) WithInflationMin(
inflationMin sdk.Dec,
) MintGenesisBuilder {
builder.Params.InflationMin = inflationMin
return builder
}
func (builder MintGenesisBuilder) WithMintDenom(
mintDenom string,
) MintGenesisBuilder {
builder.Params.MintDenom = mintDenom
return builder
}

View File

@ -3,7 +3,6 @@ package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
cdptypes "github.com/kava-labs/kava/x/cdp/types"
@ -94,9 +93,9 @@ type AccountKeeper interface {
GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI
}
// MintKeeper defines the required methods needed by this modules keeper
type MintKeeper interface {
GetMinter(ctx sdk.Context) (minter minttypes.Minter)
// KavamintKeeper defines the required methods needed by this modules keeper
type KavamintKeeper interface {
GetStakingApy(ctx sdk.Context) sdk.Dec
}
// DistrKeeper defines the required methods needed by this modules keeper

View File

@ -87,6 +87,12 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramSpace.SetParamSet(ctx, &params)
}
// GetStakingApy returns the APY minted for staking rewards
func (k Keeper) GetStakingApy(ctx sdk.Context) sdk.Dec {
params := k.GetParams(ctx)
return params.StakingRewardsApy
}
// BondDenom implements an alias call to the underlying staking keeper's BondDenom.
func (k Keeper) BondDenom(ctx sdk.Context) string {
return k.stakingKeeper.BondDenom(ctx)

View File

@ -6,7 +6,6 @@ import (
"testing"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
@ -60,7 +59,7 @@ func (suite *KeeperTestSuite) CreateAccountWithAddress(addr sdk.AccAddress, init
acc := ak.NewAccountWithAddress(suite.Ctx, addr)
ak.SetAccount(suite.Ctx, acc)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), initialBalance)
err := suite.App.FundAccount(suite.Ctx, acc.GetAddress(), initialBalance)
suite.Require().NoError(err)
return acc
@ -87,7 +86,7 @@ func (suite *KeeperTestSuite) CreateVestingAccountWithAddress(addr sdk.AccAddres
// AddCoinsToModule adds coins to the a module account, creating it if it doesn't exist.
func (suite *KeeperTestSuite) AddCoinsToModule(module string, amount sdk.Coins) {
err := simapp.FundModuleAccount(suite.BankKeeper, suite.Ctx, module, amount)
err := suite.App.FundModuleAccount(suite.Ctx, module, amount)
suite.Require().NoError(err)
}

View File

@ -5,7 +5,6 @@ import (
"reflect"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
@ -58,7 +57,7 @@ func (suite *Suite) CreateAccountWithAddress(addr sdk.AccAddress, initialBalance
acc := ak.NewAccountWithAddress(suite.Ctx, addr)
ak.SetAccount(suite.Ctx, acc)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), initialBalance)
err := suite.App.FundAccount(suite.Ctx, acc.GetAddress(), initialBalance)
suite.Require().NoError(err)
return acc
@ -85,7 +84,7 @@ func (suite *Suite) CreateVestingAccountWithAddress(addr sdk.AccAddress, initial
// AddCoinsToModule adds coins to the a module account, creating it if it doesn't exist.
func (suite *Suite) AddCoinsToModule(module string, amount sdk.Coins) {
err := simapp.FundModuleAccount(suite.BankKeeper, suite.Ctx, module, amount)
err := suite.App.FundModuleAccount(suite.Ctx, module, amount)
suite.Require().NoError(err)
}

View File

@ -7,7 +7,6 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
@ -37,6 +36,7 @@ func (suite *invariantTestSuite) SetupTest() {
_, addrs := app.GeneratePrivKeyAddressPairs(1)
suite.addrs = addrs
suite.tApp = tApp
suite.ctx = ctx
suite.keeper = tApp.GetSavingsKeeper()
suite.bankKeeper = tApp.GetBankKeeper()
@ -63,7 +63,7 @@ func (suite *invariantTestSuite) SetupValidState() {
depositAmt,
))
err := simapp.FundModuleAccount(suite.bankKeeper, suite.ctx, types.ModuleName, depositAmt)
err := suite.tApp.FundModuleAccount(suite.ctx, types.ModuleName, depositAmt)
suite.Require().NoError(err)
}

View File

@ -8,7 +8,6 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
@ -116,7 +115,7 @@ func (suite *KeeperTestSuite) CreateAccountWithAddress(addr sdk.AccAddress, init
acc := ak.NewAccountWithAddress(suite.ctx, addr)
ak.SetAccount(suite.ctx, acc)
err := simapp.FundAccount(suite.app.GetBankKeeper(), suite.ctx, acc.GetAddress(), initialBalance)
err := suite.app.FundAccount(suite.ctx, acc.GetAddress(), initialBalance)
suite.Require().NoError(err)
return acc

View File

@ -9,7 +9,6 @@ import (
"github.com/kava-labs/kava/x/swap/keeper"
"github.com/kava-labs/kava/x/swap/types"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@ -54,7 +53,7 @@ func (suite *Suite) GetEvents() sdk.Events {
// AddCoinsToModule adds coins to the swap module account
func (suite *Suite) AddCoinsToModule(amount sdk.Coins) {
// Does not use suite.BankKeeper.MintCoins as module account would not have permission to mint
err := simapp.FundModuleAccount(suite.BankKeeper, suite.Ctx, types.ModuleName, amount)
err := suite.App.FundModuleAccount(suite.Ctx, types.ModuleName, amount)
suite.Require().NoError(err)
}
@ -67,12 +66,6 @@ func (suite *Suite) RemoveCoinsFromModule(amount sdk.Coins) {
suite.Require().NoError(err)
}
// // GetAccount gets an existing account
// func (suite *Suite) GetAccount(addr sdk.AccAddress) authexported.Account {
// ak := suite.App.GetAccountKeeper()
// return ak.GetAccount(suite.Ctx, addr)
// }
// CreateAccount creates a new account from the provided balance
func (suite *Suite) CreateAccount(initialBalance sdk.Coins) authtypes.AccountI {
_, addrs := app.GeneratePrivKeyAddressPairs(1)
@ -81,7 +74,7 @@ func (suite *Suite) CreateAccount(initialBalance sdk.Coins) authtypes.AccountI {
acc := ak.NewAccountWithAddress(suite.Ctx, addrs[0])
ak.SetAccount(suite.Ctx, acc)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), initialBalance)
err := suite.App.FundAccount(suite.Ctx, acc.GetAddress(), initialBalance)
suite.Require().NoError(err)
return acc
@ -94,7 +87,7 @@ func (suite *Suite) NewAccountFromAddr(addr sdk.AccAddress, balance sdk.Coins) a
acc := ak.NewAccountWithAddress(suite.Ctx, addr)
ak.SetAccount(suite.Ctx, acc)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), balance)
err := suite.App.FundAccount(suite.Ctx, acc.GetAddress(), balance)
suite.Require().NoError(err)
return acc
@ -132,22 +125,6 @@ func (suite *Suite) AccountBalanceEqual(addr sdk.AccAddress, coins sdk.Coins) {
suite.Equal(coins, balance, fmt.Sprintf("expected account balance to equal coins %s, but got %s", coins, balance))
}
// // AccountBalanceDelta asserts that the coins are within delta of the account balance
// func (suite *Suite) AccountBalanceDelta(acc authexported.Account, coins sdk.Coins, delta float64) {
// ak := suite.App.GetAccountKeeper()
// acc = ak.GetAccount(suite.Ctx, acc.GetAddress())
// accCoins := acc.GetCoins()
// allCoins := coins.Add(accCoins...)
// for _, coin := range allCoins {
// suite.InDelta(
// coins.AmountOf(coin.Denom).Int64(),
// accCoins.AmountOf(coin.Denom).Int64(),
// delta,
// fmt.Sprintf("expected module account balance to be in delta %f of coins %s, but got %s", delta, coins, accCoins),
// )
// }
// }
// ModuleAccountBalanceEqual asserts that the swap module account balance matches the provided coins
func (suite *Suite) ModuleAccountBalanceEqual(coins sdk.Coins) {
balance := suite.BankKeeper.GetAllBalances(
@ -157,22 +134,6 @@ func (suite *Suite) ModuleAccountBalanceEqual(coins sdk.Coins) {
suite.Equal(coins, balance, fmt.Sprintf("expected module account balance to equal coins %s, but got %s", coins, balance))
}
// // ModuleAccountBalanceDelta asserts that the swap module account balance is within acceptable delta of the provided coins
// func (suite *Suite) ModuleAccountBalanceDelta(coins sdk.Coins, delta float64) {
// macc, _ := suite.supplyKeeper.GetModuleAccountAndPermissions(suite.Ctx, types.ModuleName)
// suite.Require().NotNil(macc, "expected module account to be defined")
// allCoins := coins.Add(macc.GetCoins()...)
// for _, coin := range allCoins {
// suite.InDelta(
// coins.AmountOf(coin.Denom).Int64(),
// macc.GetCoins().AmountOf(coin.Denom).Int64(),
// delta,
// fmt.Sprintf("expected module account balance to be in delta %f of coins %s, but got %s", delta, coins, macc.GetCoins()),
// )
// }
// }
// PoolLiquidityEqual asserts that the pool matching the provided coins has those reserves
func (suite *Suite) PoolLiquidityEqual(coins sdk.Coins) {
poolRecord, ok := suite.Keeper.GetPool(suite.Ctx, types.PoolIDFromCoins(coins))
@ -187,25 +148,6 @@ func (suite *Suite) PoolDeleted(denomA, denomB string) {
suite.Require().False(ok, "expected pool to not exist")
}
// // PoolLiquidityDelta asserts that the pool matching the provided coins has those reserves within delta
// func (suite *Suite) PoolLiquidityDelta(coins sdk.Coins, delta float64) {
// poolRecord, ok := suite.Keeper.GetPool(suite.Ctx, types.PoolIDFromCoins(coins))
// suite.Require().True(ok, "expected pool to exist")
// suite.InDelta(
// poolRecord.ReservesA.Amount.Int64(),
// coins.AmountOf(poolRecord.ReservesA.Denom).Int64(),
// delta,
// fmt.Sprintf("expected pool reserves within delta %f of %s, got %s", delta, coins, poolRecord.Reserves()),
// )
// suite.InDelta(
// poolRecord.ReservesB.Amount.Int64(),
// coins.AmountOf(poolRecord.ReservesB.Denom).Int64(),
// delta,
// fmt.Sprintf("expected pool reserves within delta %f of %s, got %s", delta, coins, poolRecord.Reserves()),
// )
// }
// PoolShareTotalEqual asserts the total shares match the stored pool
func (suite *Suite) PoolShareTotalEqual(poolID string, totalShares sdk.Int) {
poolRecord, found := suite.Keeper.GetPool(suite.Ctx, poolID)
@ -240,27 +182,6 @@ func (suite *Suite) PoolShareValueEqual(depositor authtypes.AccountI, pool types
suite.Equal(coins, value, fmt.Sprintf("expected shares to equal %s, but got %s", coins, value))
}
// // PoolShareValueDelta asserts that the depositor shares are in state and the value is within delta of the expected coins
// func (suite *Suite) PoolShareValueDelta(depositor authexported.Account, pool types.AllowedPool, coins sdk.Coins, delta float64) {
// poolRecord, ok := suite.Keeper.GetPool(suite.Ctx, pool.Name())
// suite.Require().True(ok, fmt.Sprintf("expected pool %s to exist", pool.Name()))
// shares, ok := suite.Keeper.GetDepositorShares(suite.Ctx, depositor.GetAddress(), poolRecord.PoolID)
// suite.Require().True(ok, fmt.Sprintf("expected shares to exist for depositor %s", depositor.GetAddress()))
// storedPool, err := types.NewDenominatedPoolWithExistingShares(sdk.NewCoins(poolRecord.ReservesA, poolRecord.ReservesB), poolRecord.TotalShares)
// suite.Nil(err)
// value := storedPool.ShareValue(shares.SharesOwned)
// for _, coin := range coins {
// suite.InDelta(
// coin.Amount.Int64(),
// value.AmountOf(coin.Denom).Int64(),
// delta,
// fmt.Sprintf("expected shares to be within delta %f of %s, but got %s", delta, coins, value),
// )
// }
// }
// PoolSharesDeleted asserts that the pool shares have been removed
func (suite *Suite) PoolSharesDeleted(depositor sdk.AccAddress, denomA, denomB string) {
_, ok := suite.Keeper.GetDepositorShares(suite.Ctx, depositor, types.PoolID(denomA, denomB))