remove code and files

This commit is contained in:
Solovyov1796 2024-04-24 11:56:00 +08:00
parent 7e7049c289
commit 4dc6a77045
865 changed files with 21 additions and 225094 deletions

View File

@ -108,33 +108,10 @@ import (
"github.com/kava-labs/kava/app/ante"
kavaparams "github.com/kava-labs/kava/app/params"
// "github.com/kava-labs/kava/x/auction"
// "github.com/kava-labs/kava/x/bep3"
// bep3keeper "github.com/kava-labs/kava/x/bep3/keeper"
// bep3types "github.com/kava-labs/kava/x/bep3/types"
// "github.com/kava-labs/kava/x/cdp"
// "github.com/kava-labs/kava/x/committee"
// "github.com/kava-labs/kava/x/community"
// "github.com/kava-labs/kava/x/earn"
// "github.com/kava-labs/kava/x/hard"
// "github.com/kava-labs/kava/x/incentive"
// "github.com/kava-labs/kava/x/issuance"
// "github.com/kava-labs/kava/x/kavadist"
// "github.com/kava-labs/kava/x/liquid"
// "github.com/kava-labs/kava/x/pricefeed"
// "github.com/kava-labs/kava/x/router"
// "github.com/kava-labs/kava/x/savings"
// "github.com/kava-labs/kava/x/swap"
"github.com/kava-labs/kava/x/bep3"
evmutil "github.com/kava-labs/kava/x/evmutil"
evmutilkeeper "github.com/kava-labs/kava/x/evmutil/keeper"
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
// metrics "github.com/kava-labs/kava/x/metrics"
// metricstypes "github.com/kava-labs/kava/x/metrics/types"
validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
validatorvestingrest "github.com/kava-labs/kava/x/validator-vesting/client/rest"
validatorvestingtypes "github.com/kava-labs/kava/x/validator-vesting/types"
@ -163,12 +140,6 @@ var (
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
// kavadistclient.ProposalHandler,
// committeeclient.ProposalHandler,
// earnclient.DepositProposalHandler,
// earnclient.WithdrawProposalHandler,
// communityclient.LendDepositProposalHandler,
// communityclient.LendWithdrawProposalHandler,
}),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
@ -184,25 +155,9 @@ var (
vesting.AppModuleBasic{},
evm.AppModuleBasic{},
feemarket.AppModuleBasic{},
// kavadist.AppModuleBasic{},
// auction.AppModuleBasic{},
// issuance.AppModuleBasic{},
bep3.AppModuleBasic{},
// pricefeed.AppModuleBasic{},
// swap.AppModuleBasic{},
// cdp.AppModuleBasic{},
// hard.AppModuleBasic{},
// committee.AppModuleBasic{},
// incentive.AppModuleBasic{},
// savings.AppModuleBasic{},
validatorvesting.AppModuleBasic{},
evmutil.AppModuleBasic{},
// liquid.AppModuleBasic{},
// earn.AppModuleBasic{},
// router.AppModuleBasic{},
mint.AppModuleBasic{},
// community.AppModuleBasic{},
// metrics.AppModuleBasic{},
consensus.AppModuleBasic{},
)
@ -218,20 +173,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
evmutiltypes.ModuleName: {authtypes.Minter, authtypes.Burner},
// kavadisttypes.KavaDistMacc: {authtypes.Minter},
// auctiontypes.ModuleName: nil,
// issuancetypes.ModuleAccountName: {authtypes.Minter, authtypes.Burner},
// bep3types.ModuleName: {authtypes.Burner, authtypes.Minter},
// swaptypes.ModuleName: nil,
// cdptypes.ModuleName: {authtypes.Minter, authtypes.Burner},
// cdptypes.LiquidatorMacc: {authtypes.Minter, authtypes.Burner},
// hardtypes.ModuleAccountName: {authtypes.Minter},
// savingstypes.ModuleAccountName: nil,
// liquidtypes.ModuleAccountName: {authtypes.Minter, authtypes.Burner},
// earntypes.ModuleAccountName: nil,
// kavadisttypes.FundModuleAccount: nil,
minttypes.ModuleName: {authtypes.Minter},
// communitytypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
}
)
@ -250,7 +192,6 @@ type Options struct {
MempoolAuthAddresses []sdk.AccAddress
EVMTrace string
EVMMaxGasWanted uint64
// TelemetryOptions metricstypes.TelemetryOptions
}
// DefaultOptions is a sensible default Options value.
@ -274,40 +215,25 @@ type App struct {
memKeys map[string]*storetypes.MemoryStoreKey
// keepers from all the modules
accountKeeper authkeeper.AccountKeeper
bankKeeper bankkeeper.Keeper
capabilityKeeper *capabilitykeeper.Keeper
stakingKeeper *stakingkeeper.Keeper
distrKeeper distrkeeper.Keeper
govKeeper govkeeper.Keeper
paramsKeeper paramskeeper.Keeper
authzKeeper authzkeeper.Keeper
crisisKeeper crisiskeeper.Keeper
slashingKeeper slashingkeeper.Keeper
ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
packetForwardKeeper *packetforwardkeeper.Keeper
evmKeeper *evmkeeper.Keeper
evmutilKeeper evmutilkeeper.Keeper
feeMarketKeeper feemarketkeeper.Keeper
upgradeKeeper upgradekeeper.Keeper
evidenceKeeper evidencekeeper.Keeper
transferKeeper ibctransferkeeper.Keeper
// kavadistKeeper kavadistkeeper.Keeper
// auctionKeeper auctionkeeper.Keeper
// issuanceKeeper issuancekeeper.Keeper
// bep3Keeper bep3keeper.Keeper
// pricefeedKeeper pricefeedkeeper.Keeper
// swapKeeper swapkeeper.Keeper
// cdpKeeper cdpkeeper.Keeper
// hardKeeper hardkeeper.Keeper
// committeeKeeper committeekeeper.Keeper
// incentiveKeeper incentivekeeper.Keeper
// savingsKeeper savingskeeper.Keeper
// liquidKeeper liquidkeeper.Keeper
// earnKeeper earnkeeper.Keeper
// routerKeeper routerkeeper.Keeper
mintKeeper mintkeeper.Keeper
// communityKeeper communitykeeper.Keeper
accountKeeper authkeeper.AccountKeeper
bankKeeper bankkeeper.Keeper
capabilityKeeper *capabilitykeeper.Keeper
stakingKeeper *stakingkeeper.Keeper
distrKeeper distrkeeper.Keeper
govKeeper govkeeper.Keeper
paramsKeeper paramskeeper.Keeper
authzKeeper authzkeeper.Keeper
crisisKeeper crisiskeeper.Keeper
slashingKeeper slashingkeeper.Keeper
ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
packetForwardKeeper *packetforwardkeeper.Keeper
evmKeeper *evmkeeper.Keeper
evmutilKeeper evmutilkeeper.Keeper
feeMarketKeeper feemarketkeeper.Keeper
upgradeKeeper upgradekeeper.Keeper
evidenceKeeper evidencekeeper.Keeper
transferKeeper ibctransferkeeper.Keeper
mintKeeper mintkeeper.Keeper
consensusParamsKeeper consensusparamkeeper.Keeper
// make scoped keepers public for test purposes
@ -369,20 +295,7 @@ func NewApp(
feemarkettypes.StoreKey,
authzkeeper.StoreKey,
capabilitytypes.StoreKey,
// kavadisttypes.StoreKey,
// auctiontypes.StoreKey,
// issuancetypes.StoreKey,
// bep3types.StoreKey,
// pricefeedtypes.StoreKey,
// swaptypes.StoreKey,
// cdptypes.StoreKey,
// hardtypes.StoreKey,
// communitytypes.StoreKey,
// committeetypes.StoreKey,
// incentivetypes.StoreKey,
evmutiltypes.StoreKey,
// savingstypes.StoreKey,
// earntypes.StoreKey,
minttypes.StoreKey,
consensusparamtypes.StoreKey,
crisistypes.StoreKey,
@ -418,23 +331,12 @@ func NewApp(
slashingSubspace := app.paramsKeeper.Subspace(slashingtypes.ModuleName)
govSubspace := app.paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
crisisSubspace := app.paramsKeeper.Subspace(crisistypes.ModuleName)
// kavadistSubspace := app.paramsKeeper.Subspace(kavadisttypes.ModuleName)
// auctionSubspace := app.paramsKeeper.Subspace(auctiontypes.ModuleName)
// issuanceSubspace := app.paramsKeeper.Subspace(issuancetypes.ModuleName)
// bep3Subspace := app.paramsKeeper.Subspace(bep3types.ModuleName)
// pricefeedSubspace := app.paramsKeeper.Subspace(pricefeedtypes.ModuleName)
// swapSubspace := app.paramsKeeper.Subspace(swaptypes.ModuleName)
// cdpSubspace := app.paramsKeeper.Subspace(cdptypes.ModuleName)
// hardSubspace := app.paramsKeeper.Subspace(hardtypes.ModuleName)
// incentiveSubspace := app.paramsKeeper.Subspace(incentivetypes.ModuleName)
// savingsSubspace := app.paramsKeeper.Subspace(savingstypes.ModuleName)
ibcSubspace := app.paramsKeeper.Subspace(ibcexported.ModuleName)
ibctransferSubspace := app.paramsKeeper.Subspace(ibctransfertypes.ModuleName)
packetforwardSubspace := app.paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())
feemarketSubspace := app.paramsKeeper.Subspace(feemarkettypes.ModuleName)
evmSubspace := app.paramsKeeper.Subspace(evmtypes.ModuleName)
evmutilSubspace := app.paramsKeeper.Subspace(evmutiltypes.ModuleName)
// earnSubspace := app.paramsKeeper.Subspace(earntypes.ModuleName)
mintSubspace := app.paramsKeeper.Subspace(minttypes.ModuleName)
// set the BaseApp's parameter store
@ -598,96 +500,6 @@ func NewApp(
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
app.ibcKeeper.SetRouter(ibcRouter)
// app.auctionKeeper = auctionkeeper.NewKeeper(
// appCodec,
// keys[auctiontypes.StoreKey],
// auctionSubspace,
// app.bankKeeper,
// app.accountKeeper,
// )
// app.issuanceKeeper = issuancekeeper.NewKeeper(
// appCodec,
// keys[issuancetypes.StoreKey],
// issuanceSubspace,
// app.accountKeeper,
// app.bankKeeper,
// )
// app.bep3Keeper = bep3keeper.NewKeeper(
// appCodec,
// keys[bep3types.StoreKey],
// app.bankKeeper,
// app.accountKeeper,
// bep3Subspace,
// app.ModuleAccountAddrs(),
// )
// app.pricefeedKeeper = pricefeedkeeper.NewKeeper(
// appCodec,
// keys[pricefeedtypes.StoreKey],
// pricefeedSubspace,
// )
// swapKeeper := swapkeeper.NewKeeper(
// appCodec,
// keys[swaptypes.StoreKey],
// swapSubspace,
// app.accountKeeper,
// app.bankKeeper,
// )
// cdpKeeper := cdpkeeper.NewKeeper(
// appCodec,
// keys[cdptypes.StoreKey],
// cdpSubspace,
// app.pricefeedKeeper,
// app.auctionKeeper,
// app.bankKeeper,
// app.accountKeeper,
// mAccPerms,
// )
// hardKeeper := hardkeeper.NewKeeper(
// appCodec,
// keys[hardtypes.StoreKey],
// hardSubspace,
// app.accountKeeper,
// app.bankKeeper,
// app.pricefeedKeeper,
// app.auctionKeeper,
// )
// app.liquidKeeper = liquidkeeper.NewDefaultKeeper(
// appCodec,
// app.accountKeeper,
// app.bankKeeper,
// app.stakingKeeper,
// &app.distrKeeper,
// )
// savingsKeeper := savingskeeper.NewKeeper(
// appCodec,
// keys[savingstypes.StoreKey],
// savingsSubspace,
// app.accountKeeper,
// app.bankKeeper,
// app.liquidKeeper,
// )
// earnKeeper := earnkeeper.NewKeeper(
// appCodec,
// keys[earntypes.StoreKey],
// earnSubspace,
// app.accountKeeper,
// app.bankKeeper,
// &app.liquidKeeper,
// &hardKeeper,
// &savingsKeeper,
// &app.distrKeeper,
// )
// app.kavadistKeeper = kavadistkeeper.NewKeeper(
// appCodec,
// keys[kavadisttypes.StoreKey],
// kavadistSubspace,
// app.bankKeeper,
// app.accountKeeper,
// app.distrKeeper,
// app.loadBlockedMaccAddrs(),
// )
app.mintKeeper = mintkeeper.NewKeeper(
appCodec,
keys[minttypes.StoreKey],
@ -698,76 +510,13 @@ func NewApp(
govAuthAddrStr,
)
// x/community's deposit/withdraw to lend proposals depend on hard keeper.
// app.communityKeeper = communitykeeper.NewKeeper(
// appCodec,
// keys[communitytypes.StoreKey],
// app.accountKeeper,
// app.bankKeeper,
// &cdpKeeper,
// app.distrKeeper,
// &hardKeeper,
// &app.mintKeeper,
// &app.kavadistKeeper,
// app.stakingKeeper,
// govAuthAddr,
// )
// app.incentiveKeeper = incentivekeeper.NewKeeper(
// appCodec,
// keys[incentivetypes.StoreKey],
// incentiveSubspace,
// app.bankKeeper,
// &cdpKeeper,
// &hardKeeper,
// app.accountKeeper,
// app.stakingKeeper,
// &swapKeeper,
// &savingsKeeper,
// &app.liquidKeeper,
// &earnKeeper,
// app.mintKeeper,
// app.distrKeeper,
// app.pricefeedKeeper,
// )
// app.routerKeeper = routerkeeper.NewKeeper(
// &app.earnKeeper,
// app.liquidKeeper,
// app.stakingKeeper,
// )
// create committee keeper with router
// committeeGovRouter := govv1beta1.NewRouter()
// committeeGovRouter.
// AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
// AddRoute(communitytypes.RouterKey, community.NewCommunityPoolProposalHandler(app.communityKeeper)).
// AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
// AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.upgradeKeeper))
// // Note: the committee proposal handler is not registered on the committee router. This means committees cannot create or update other committees.
// // Adding the committee proposal handler to the router is possible but awkward as the handler depends on the keeper which depends on the handler.
// app.committeeKeeper = committeekeeper.NewKeeper(
// appCodec,
// keys[committeetypes.StoreKey],
// committeeGovRouter,
// app.paramsKeeper,
// app.accountKeeper,
// app.bankKeeper,
// )
// register the staking hooks
app.stakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(
app.distrKeeper.Hooks(),
app.slashingKeeper.Hooks(),
// app.incentiveKeeper.Hooks(),
))
// app.swapKeeper = *swapKeeper.SetHooks(app.incentiveKeeper.Hooks())
// app.cdpKeeper = *cdpKeeper.SetHooks(cdptypes.NewMultiCDPHooks(app.incentiveKeeper.Hooks()))
// app.hardKeeper = *hardKeeper.SetHooks(hardtypes.NewMultiHARDHooks(app.incentiveKeeper.Hooks()))
// app.savingsKeeper = savingsKeeper // savings incentive hooks disabled
// app.earnKeeper = *earnKeeper.SetHooks(app.incentiveKeeper.Hooks())
// create gov keeper with router
// NOTE this must be done after any keepers referenced in the gov router (ie committee) are defined
govRouter := govv1beta1.NewRouter()
@ -776,12 +525,6 @@ func NewApp(
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.upgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper))
// .
// AddRoute(kavadisttypes.RouterKey, kavadist.NewCommunityPoolMultiSpendProposalHandler(app.kavadistKeeper)).
// AddRoute(earntypes.RouterKey, earn.NewCommunityPoolProposalHandler(app.earnKeeper))
// .
// AddRoute(communitytypes.RouterKey, community.NewCommunityPoolProposalHandler(app.communityKeeper))
// .AddRoute(committeetypes.RouterKey, committee.NewProposalHandler(app.committeeKeeper))
govConfig := govtypes.DefaultConfig()
govKeeper := govkeeper.NewKeeper(
@ -797,13 +540,6 @@ func NewApp(
govKeeper.SetLegacyRouter(govRouter)
app.govKeeper = *govKeeper
// override x/gov tally handler with custom implementation
// tallyHandler := NewTallyHandler(
// app.govKeeper, *app.stakingKeeper, app.savingsKeeper, app.earnKeeper,
// app.liquidKeeper, app.bankKeeper,
// )
// app.govKeeper.SetTallyHandler(tallyHandler)
// create the module manager (Note: Any module instantiated in the module manager that is later modified
// must be passed by reference here.)
app.mm = module.NewManager(
@ -827,41 +563,17 @@ func NewApp(
transferModule,
vesting.NewAppModule(app.accountKeeper, app.bankKeeper),
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
// kavadist.NewAppModule(app.kavadistKeeper, app.accountKeeper),
// auction.NewAppModule(app.auctionKeeper, app.accountKeeper, app.bankKeeper),
// issuance.NewAppModule(app.issuanceKeeper, app.accountKeeper, app.bankKeeper),
// bep3.NewAppModule(app.bep3Keeper, app.accountKeeper, app.bankKeeper),
// pricefeed.NewAppModule(app.pricefeedKeeper, app.accountKeeper),
validatorvesting.NewAppModule(app.bankKeeper),
// swap.NewAppModule(app.swapKeeper, app.accountKeeper),
// cdp.NewAppModule(app.cdpKeeper, app.accountKeeper, app.pricefeedKeeper, app.bankKeeper),
// hard.NewAppModule(app.hardKeeper, app.accountKeeper, app.bankKeeper, app.pricefeedKeeper),
// committee.NewAppModule(app.committeeKeeper, app.accountKeeper),
// incentive.NewAppModule(app.incentiveKeeper, app.accountKeeper, app.bankKeeper, app.cdpKeeper),
evmutil.NewAppModule(app.evmutilKeeper, app.bankKeeper, app.accountKeeper),
// savings.NewAppModule(app.savingsKeeper, app.accountKeeper, app.bankKeeper),
// liquid.NewAppModule(app.liquidKeeper),
// earn.NewAppModule(app.earnKeeper, app.accountKeeper, app.bankKeeper),
// router.NewAppModule(app.routerKeeper),
// nil InflationCalculationFn, use SDK's default inflation function
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, nil, mintSubspace),
// community.NewAppModule(app.communityKeeper, app.accountKeeper),
// metrics.NewAppModule(options.TelemetryOptions),
)
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
app.mm.SetOrderBeginBlockers(
// metricstypes.ModuleName,
// Upgrade begin blocker runs migrations on the first block after an upgrade. It should run before any other module.
upgradetypes.ModuleName,
// Capability begin blocker runs non state changing initialization.
capabilitytypes.ModuleName,
// Committee begin blocker changes module params by enacting proposals.
// Run before to ensure params are updated together before state changes.
// committeetypes.ModuleName,
// Community begin blocker should run before x/mint and x/kavadist since
// the disable inflation upgrade will update those modules' params.
// communitytypes.ModuleName,
minttypes.ModuleName,
distrtypes.ModuleName,
// During begin block slashing happens after distr.BeginBlocker so that
@ -872,20 +584,9 @@ func NewApp(
stakingtypes.ModuleName,
feemarkettypes.ModuleName,
evmtypes.ModuleName,
// kavadisttypes.ModuleName,
// Auction begin blocker will close out expired auctions and pay debt back to cdp.
// It should be run before cdp begin blocker which cancels out debt with stable and starts more auctions.
// auctiontypes.ModuleName,
// cdptypes.ModuleName,
// bep3types.ModuleName,
// hardtypes.ModuleName,
// issuancetypes.ModuleName,
// incentivetypes.ModuleName,
ibcexported.ModuleName,
// Add all remaining modules with an empty begin blocker below since cosmos 0.45.0 requires it
// swaptypes.ModuleName,
vestingtypes.ModuleName,
// pricefeedtypes.ModuleName,
validatorvestingtypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
@ -896,10 +597,6 @@ func NewApp(
paramstypes.ModuleName,
authz.ModuleName,
evmutiltypes.ModuleName,
// savingstypes.ModuleName,
// liquidtypes.ModuleName,
// earntypes.ModuleName,
// routertypes.ModuleName,
consensusparamtypes.ModuleName,
packetforwardtypes.ModuleName,
)
@ -912,22 +609,12 @@ func NewApp(
evmtypes.ModuleName,
// fee market module must go after evm module in order to retrieve the block gas used.
feemarkettypes.ModuleName,
// pricefeedtypes.ModuleName,
// Add all remaining modules with an empty end blocker below since cosmos 0.45.0 requires it
capabilitytypes.ModuleName,
// incentivetypes.ModuleName,
// issuancetypes.ModuleName,
slashingtypes.ModuleName,
distrtypes.ModuleName,
// auctiontypes.ModuleName,
// bep3types.ModuleName,
// cdptypes.ModuleName,
// hardtypes.ModuleName,
// committeetypes.ModuleName,
upgradetypes.ModuleName,
evidencetypes.ModuleName,
// kavadisttypes.ModuleName,
// swaptypes.ModuleName,
vestingtypes.ModuleName,
ibcexported.ModuleName,
validatorvestingtypes.ModuleName,
@ -938,13 +625,7 @@ func NewApp(
paramstypes.ModuleName,
authz.ModuleName,
evmutiltypes.ModuleName,
// savingstypes.ModuleName,
// liquidtypes.ModuleName,
// earntypes.ModuleName,
// routertypes.ModuleName,
minttypes.ModuleName,
// communitytypes.ModuleName,
// metricstypes.ModuleName,
consensusparamtypes.ModuleName,
packetforwardtypes.ModuleName,
)
@ -965,29 +646,13 @@ func NewApp(
ibctransfertypes.ModuleName,
evmtypes.ModuleName,
feemarkettypes.ModuleName,
// kavadisttypes.ModuleName,
// auctiontypes.ModuleName,
// issuancetypes.ModuleName,
// savingstypes.ModuleName,
// bep3types.ModuleName,
// pricefeedtypes.ModuleName,
// swaptypes.ModuleName,
// cdptypes.ModuleName, // reads market prices, so must run after pricefeed genesis
// hardtypes.ModuleName,
// incentivetypes.ModuleName, // reads cdp params, so must run after cdp genesis
// committeetypes.ModuleName,
evmutiltypes.ModuleName,
// earntypes.ModuleName,
// communitytypes.ModuleName,
genutiltypes.ModuleName, // runs arbitrary txs included in genisis state, so run after modules have been initialized
// Add all remaining modules with an empty InitGenesis below since cosmos 0.45.0 requires it
vestingtypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
validatorvestingtypes.ModuleName,
// liquidtypes.ModuleName,
// routertypes.ModuleName,
// metricstypes.ModuleName,
consensusparamtypes.ModuleName,
packetforwardtypes.ModuleName,
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
@ -1029,8 +694,6 @@ func NewApp(
if options.MempoolEnableAuth {
fetchers = append(fetchers,
func(sdk.Context) []sdk.AccAddress { return options.MempoolAuthAddresses },
// app.bep3Keeper.GetAuthorizedAddresses,
// app.pricefeedKeeper.GetAuthorizedAddresses,
)
}
@ -1194,19 +857,7 @@ func (app *App) RegisterNodeService(clientCtx client.Context) {
// loadBlockedMaccAddrs returns a map indicating the blocked status of each module account address
func (app *App) loadBlockedMaccAddrs() map[string]bool {
modAccAddrs := app.ModuleAccountAddrs()
allowedMaccs := map[string]bool{
// kavadist
// app.accountKeeper.GetModuleAddress(kavadisttypes.ModuleName).String(): true,
// earn
// app.accountKeeper.GetModuleAddress(earntypes.ModuleName).String(): true,
// liquid
// app.accountKeeper.GetModuleAddress(liquidtypes.ModuleName).String(): true,
// kavadist fund
// app.accountKeeper.GetModuleAddress(kavadisttypes.FundModuleAccount).String(): true,
// community
// app.accountKeeper.GetModuleAddress(communitytypes.ModuleAccountName).String(): true,
// NOTE: if adding evmutil, adjust the cosmos-coins-fully-backed-invariant accordingly.
}
allowedMaccs := map[string]bool{}
for addr := range modAccAddrs {
// Set allowed module accounts as unblocked

View File

@ -1,256 +0,0 @@
package app
import (
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
earnkeeper "github.com/kava-labs/kava/x/earn/keeper"
liquidkeeper "github.com/kava-labs/kava/x/liquid/keeper"
liquidtypes "github.com/kava-labs/kava/x/liquid/types"
savingskeeper "github.com/kava-labs/kava/x/savings/keeper"
)
var _ govv1.TallyHandler = TallyHandler{}
// TallyHandler is the tally handler for kava
type TallyHandler struct {
gk govkeeper.Keeper
stk stakingkeeper.Keeper
svk savingskeeper.Keeper
ek earnkeeper.Keeper
lk liquidkeeper.Keeper
bk bankkeeper.Keeper
}
// NewTallyHandler creates a new tally handler.
func NewTallyHandler(
gk govkeeper.Keeper, stk stakingkeeper.Keeper, svk savingskeeper.Keeper,
ek earnkeeper.Keeper, lk liquidkeeper.Keeper, bk bankkeeper.Keeper,
) TallyHandler {
return TallyHandler{
gk: gk,
stk: stk,
svk: svk,
ek: ek,
lk: lk,
bk: bk,
}
}
func (th TallyHandler) Tally(
ctx sdk.Context,
proposal govv1.Proposal,
) (passes bool, burnDeposits bool, tallyResults govv1.TallyResult) {
results := make(map[govv1.VoteOption]sdk.Dec)
results[govv1.OptionYes] = sdk.ZeroDec()
results[govv1.OptionAbstain] = sdk.ZeroDec()
results[govv1.OptionNo] = sdk.ZeroDec()
results[govv1.OptionNoWithVeto] = sdk.ZeroDec()
totalVotingPower := sdk.ZeroDec()
currValidators := make(map[string]govv1.ValidatorGovInfo)
// fetch all the bonded validators, insert them into currValidators
th.stk.IterateBondedValidatorsByPower(ctx, func(index int64, validator stakingtypes.ValidatorI) (stop bool) {
currValidators[validator.GetOperator().String()] = govv1.NewValidatorGovInfo(
validator.GetOperator(),
validator.GetBondedTokens(),
validator.GetDelegatorShares(),
sdk.ZeroDec(),
govv1.WeightedVoteOptions{},
)
return false
})
th.gk.IterateVotes(ctx, proposal.Id, func(vote govv1.Vote) bool {
// if validator, just record it in the map
voter, err := sdk.AccAddressFromBech32(vote.Voter)
if err != nil {
panic(err)
}
valAddrStr := sdk.ValAddress(voter.Bytes()).String()
if val, ok := currValidators[valAddrStr]; ok {
val.Vote = vote.Options
currValidators[valAddrStr] = val
}
// iterate over all delegations from voter, deduct from any delegated-to validators
th.stk.IterateDelegations(ctx, voter, func(index int64, delegation stakingtypes.DelegationI) (stop bool) {
valAddrStr := delegation.GetValidatorAddr().String()
if val, ok := currValidators[valAddrStr]; ok {
// There is no need to handle the special case that validator address equal to voter address.
// Because voter's voting power will tally again even if there will deduct voter's voting power from validator.
val.DelegatorDeductions = val.DelegatorDeductions.Add(delegation.GetShares())
currValidators[valAddrStr] = val
// delegation shares * bonded / total shares
votingPower := delegation.GetShares().MulInt(val.BondedTokens).Quo(val.DelegatorShares)
for _, option := range vote.Options {
subPower := votingPower.Mul(sdk.MustNewDecFromStr(option.Weight))
results[option.Option] = results[option.Option].Add(subPower)
}
totalVotingPower = totalVotingPower.Add(votingPower)
}
return false
})
// get voter bkava and update total voting power and results
addrBkava := th.getAddrBkava(ctx, voter).toCoins()
for _, coin := range addrBkava {
valAddr, err := liquidtypes.ParseLiquidStakingTokenDenom(coin.Denom)
if err != nil {
break
}
// reduce delegator shares by the amount of voter bkava for the validator
valAddrStr := valAddr.String()
if val, ok := currValidators[valAddrStr]; ok {
val.DelegatorDeductions = val.DelegatorDeductions.Add(sdk.NewDecFromInt(coin.Amount))
currValidators[valAddrStr] = val
}
// votingPower = amount of ukava coin
stakedCoins, err := th.lk.GetStakedTokensForDerivatives(ctx, sdk.NewCoins(coin))
if err != nil {
// error is returned only if the bkava denom is incorrect, which should never happen here.
panic(err)
}
votingPower := sdk.NewDecFromInt(stakedCoins.Amount)
for _, option := range vote.Options {
subPower := votingPower.Mul(sdk.MustNewDecFromStr(option.Weight))
results[option.Option] = results[option.Option].Add(subPower)
}
totalVotingPower = totalVotingPower.Add(votingPower)
}
th.gk.DeleteVote(ctx, vote.ProposalId, voter)
return false
})
// iterate over the validators again to tally their voting power
for _, val := range currValidators {
if len(val.Vote) == 0 {
continue
}
sharesAfterDeductions := val.DelegatorShares.Sub(val.DelegatorDeductions)
votingPower := sharesAfterDeductions.MulInt(val.BondedTokens).Quo(val.DelegatorShares)
for _, option := range val.Vote {
subPower := votingPower.Mul(sdk.MustNewDecFromStr(option.Weight))
results[option.Option] = results[option.Option].Add(subPower)
}
totalVotingPower = totalVotingPower.Add(votingPower)
}
tallyParams := th.gk.GetParams(ctx)
tallyResults = govv1.NewTallyResultFromMap(results)
// TODO: Upgrade the spec to cover all of these cases & remove pseudocode.
// If there is no staked coins, the proposal fails
if th.stk.TotalBondedTokens(ctx).IsZero() {
return false, false, tallyResults
}
// If there is not enough quorum of votes, the proposal fails
percentVoting := totalVotingPower.Quo(sdk.NewDecFromInt(th.stk.TotalBondedTokens(ctx)))
if percentVoting.LT(sdk.MustNewDecFromStr(tallyParams.Quorum)) {
return false, tallyParams.BurnVoteQuorum, tallyResults
}
// If no one votes (everyone abstains), proposal fails
if totalVotingPower.Sub(results[govv1.OptionAbstain]).Equal(sdk.ZeroDec()) {
return false, false, tallyResults
}
// If more than 1/3 of voters veto, proposal fails
if results[govv1.OptionNoWithVeto].Quo(totalVotingPower).GT(sdk.MustNewDecFromStr(tallyParams.VetoThreshold)) {
return false, tallyParams.BurnVoteVeto, tallyResults
}
// If more than 1/2 of non-abstaining voters vote Yes, proposal passes
if results[govv1.OptionYes].Quo(totalVotingPower.Sub(results[govv1.OptionAbstain])).GT(sdk.MustNewDecFromStr(tallyParams.Threshold)) {
return true, false, tallyResults
}
// If more than 1/2 of non-abstaining voters vote No, proposal fails
return false, false, tallyResults
}
// bkavaByDenom a map of the bkava denom and the amount of bkava for that denom.
type bkavaByDenom map[string]sdkmath.Int
func (bkavaMap bkavaByDenom) add(coin sdk.Coin) {
_, found := bkavaMap[coin.Denom]
if !found {
bkavaMap[coin.Denom] = sdk.ZeroInt()
}
bkavaMap[coin.Denom] = bkavaMap[coin.Denom].Add(coin.Amount)
}
func (bkavaMap bkavaByDenom) toCoins() sdk.Coins {
coins := sdk.Coins{}
for denom, amt := range bkavaMap {
coins = coins.Add(sdk.NewCoin(denom, amt))
}
return coins.Sort()
}
// getAddrBkava returns a map of validator address & the amount of bkava
// of the addr for each validator.
func (th TallyHandler) getAddrBkava(ctx sdk.Context, addr sdk.AccAddress) bkavaByDenom {
results := make(bkavaByDenom)
th.addBkavaFromWallet(ctx, addr, results)
th.addBkavaFromSavings(ctx, addr, results)
th.addBkavaFromEarn(ctx, addr, results)
return results
}
// addBkavaFromWallet adds all addr balances of bkava in x/bank.
func (th TallyHandler) addBkavaFromWallet(ctx sdk.Context, addr sdk.AccAddress, bkava bkavaByDenom) {
coins := th.bk.GetAllBalances(ctx, addr)
for _, coin := range coins {
if th.lk.IsDerivativeDenom(ctx, coin.Denom) {
bkava.add(coin)
}
}
}
// addBkavaFromSavings adds all addr deposits of bkava in x/savings.
func (th TallyHandler) addBkavaFromSavings(ctx sdk.Context, addr sdk.AccAddress, bkava bkavaByDenom) {
deposit, found := th.svk.GetDeposit(ctx, addr)
if !found {
return
}
for _, coin := range deposit.Amount {
if th.lk.IsDerivativeDenom(ctx, coin.Denom) {
bkava.add(coin)
}
}
}
// addBkavaFromEarn adds all addr deposits of bkava in x/earn.
func (th TallyHandler) addBkavaFromEarn(ctx sdk.Context, addr sdk.AccAddress, bkava bkavaByDenom) {
shares, found := th.ek.GetVaultAccountShares(ctx, addr)
if !found {
return
}
for _, share := range shares {
if th.lk.IsDerivativeDenom(ctx, share.Denom) {
if coin, err := th.ek.ConvertToAssets(ctx, share); err == nil {
bkava.add(coin)
}
}
}
}

View File

@ -1,415 +0,0 @@
package app
import (
"testing"
"time"
sdkmath "cosmossdk.io/math"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/suite"
earntypes "github.com/kava-labs/kava/x/earn/types"
liquidtypes "github.com/kava-labs/kava/x/liquid/types"
)
// d is an alias for sdk.MustNewDecFromStr
var d = sdk.MustNewDecFromStr
type tallyHandlerSuite struct {
suite.Suite
app TestApp
ctx sdk.Context
staking stakingHelper
tallier TallyHandler
}
func TestTallyHandlerSuite(t *testing.T) {
suite.Run(t, new(tallyHandlerSuite))
}
func (suite *tallyHandlerSuite) SetupTest() {
suite.app = NewTestApp()
suite.app.InitializeFromGenesisStates()
genesisTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
suite.ctx = suite.app.NewContext(false, tmproto.Header{Height: 1, Time: genesisTime})
stakingKeeper := *suite.app.GetStakingKeeper()
suite.staking = stakingHelper{stakingKeeper}
suite.staking.setBondDenom(suite.ctx, "ukava")
suite.tallier = NewTallyHandler(
suite.app.GetGovKeeper(),
stakingKeeper,
suite.app.GetSavingsKeeper(),
suite.app.GetEarnKeeper(),
suite.app.GetLiquidKeeper(),
suite.app.GetBankKeeper(),
)
}
func (suite *tallyHandlerSuite) TestVotePower_AllSourcesCounted() {
user := suite.createAccount(suite.newBondCoin(sdkmath.NewInt(1e9)))
validator := suite.delegateToNewBondedValidator(user.GetAddress(), sdkmath.NewInt(1e9))
derivatives := suite.mintDerivative(user.GetAddress(), validator.GetOperator(), sdkmath.NewInt(500e6))
suite.allowBKavaEarnDeposits()
suite.earnDeposit(
user.GetAddress(),
sdk.NewCoin(derivatives.Denom, sdkmath.NewInt(250e6)),
)
proposal := suite.createProposal()
suite.voteOnProposal(user.GetAddress(), proposal.Id, govv1beta1.OptionYes)
_, _, results := suite.tallier.Tally(suite.ctx, proposal)
suite.Equal(sdkmath.NewInt(500e6+250e6+250e6).String(), results.YesCount)
suite.Equal(sdk.ZeroInt().String(), results.NoCount)
suite.Equal(sdk.ZeroInt().String(), results.NoWithVetoCount)
suite.Equal(sdk.ZeroInt().String(), results.AbstainCount)
}
func (suite *tallyHandlerSuite) TestVotePower_UserOverridesValidator() {
user := suite.createAccount(suite.newBondCoin(sdkmath.NewInt(1e9)))
delegated := sdkmath.NewInt(1e9)
validator := suite.delegateToNewBondedValidator(user.GetAddress(), delegated)
selfDelegated := validator.GetTokens().Sub(delegated)
derivatives := suite.mintDerivative(user.GetAddress(), validator.GetOperator(), sdkmath.NewInt(500e6))
suite.allowBKavaEarnDeposits()
suite.earnDeposit(
user.GetAddress(),
sdk.NewCoin(derivatives.Denom, sdkmath.NewInt(250e6)),
)
proposal := suite.createProposal()
// Validator votes, inheriting user's stake and bkava.
suite.voteOnProposal(validator.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionYes)
// use wrapped context to discard the state changes
readOnlyCtx, _ := suite.ctx.CacheContext()
_, _, results := suite.tallier.Tally(readOnlyCtx, proposal)
userPower := sdkmath.NewInt(500e6 + 250e6 + 250e6)
suite.Equal(
selfDelegated.Add(userPower).String(),
results.YesCount,
)
suite.Equal(sdk.ZeroInt().String(), results.NoCount)
suite.Equal(sdk.ZeroInt().String(), results.NoWithVetoCount)
suite.Equal(sdk.ZeroInt().String(), results.AbstainCount)
// User votes, taking power away from validator.
suite.voteOnProposal(user.GetAddress(), proposal.Id, govv1beta1.OptionNo)
_, _, results = suite.tallier.Tally(suite.ctx, proposal)
suite.Equal(selfDelegated.String(), results.YesCount)
suite.Equal(userPower.String(), results.NoCount)
suite.Equal(sdk.ZeroInt().String(), results.NoWithVetoCount)
suite.Equal(sdk.ZeroInt().String(), results.AbstainCount)
}
func (suite *tallyHandlerSuite) TestTallyOutcomes() {
suite.Run("VotedPowerBelowQuorumFails", func() {
suite.SetupTest()
suite.setTallyParams(d("0.4"), d("0.5"), d("0.334"))
proposal := suite.createProposal()
v1 := suite.createNewBondedValidator(sdkmath.NewInt(399_999_999))
suite.createNewBondedValidator(sdkmath.NewInt(600_000_001))
suite.voteOnProposal(v1.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionYes)
passes, burns, tally := suite.tallier.Tally(suite.ctx, proposal)
suite.Falsef(passes, "expected proposal to fail, tally: %v", tally)
suite.Truef(burns, "expected desposit to be burned, tally: %v", tally)
})
suite.Run("VetoedFails", func() {
suite.SetupTest()
suite.setTallyParams(d("0.4"), d("0.5"), d("0.334"))
proposal := suite.createProposal()
v1 := suite.createNewBondedValidator(sdkmath.NewInt(334_000_001))
v2 := suite.createNewBondedValidator(sdkmath.NewInt(665_999_999))
suite.voteOnProposal(v1.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionNoWithVeto)
suite.voteOnProposal(v2.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionYes)
passes, burns, tally := suite.tallier.Tally(suite.ctx, proposal)
suite.Falsef(passes, "expected proposal to fail, tally: %v", tally)
suite.Truef(burns, "expected desposit to be burned, tally: %v", tally)
})
suite.Run("UnvetoedAndYesAboveThresholdPasses", func() {
suite.SetupTest()
suite.setTallyParams(d("0.4"), d("0.5"), d("0.334"))
proposal := suite.createProposal()
v1 := suite.createNewBondedValidator(sdkmath.NewInt(900_000_000))
v2 := suite.createNewBondedValidator(sdkmath.NewInt(50_000_001))
v3 := suite.createNewBondedValidator(sdkmath.NewInt(49_999_999))
suite.voteOnProposal(v1.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionAbstain)
suite.voteOnProposal(v2.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionYes)
suite.voteOnProposal(v3.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionNo)
passes, burns, tally := suite.tallier.Tally(suite.ctx, proposal)
suite.Truef(passes, "expected proposal to pass, tally: %v", tally)
suite.Falsef(burns, "expected desposit to not burn, tally: %v", tally)
})
suite.Run("UnvetoedAndYesBelowThresholdFails", func() {
suite.SetupTest()
suite.setTallyParams(d("0.4"), d("0.5"), d("0.334"))
proposal := suite.createProposal()
v1 := suite.createNewBondedValidator(sdkmath.NewInt(900_000_000))
v2 := suite.createNewBondedValidator(sdkmath.NewInt(49_999_999))
v3 := suite.createNewBondedValidator(sdkmath.NewInt(50_000_001))
suite.voteOnProposal(v1.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionAbstain)
suite.voteOnProposal(v2.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionYes)
suite.voteOnProposal(v3.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionNo)
passes, burns, tally := suite.tallier.Tally(suite.ctx, proposal)
suite.Falsef(passes, "expected proposal to pass, tally: %v", tally)
suite.Falsef(burns, "expected desposit to not burn, tally: %v", tally)
})
suite.Run("NotEnoughStakeFails", func() {
suite.SetupTest()
suite.setTallyParams(d("0.4"), d("0.5"), d("0.334"))
proposal := suite.createProposal()
// no stake
suite.app.DeleteGenesisValidator(suite.T(), suite.ctx)
passes, burns, tally := suite.tallier.Tally(suite.ctx, proposal)
suite.Falsef(passes, "expected proposal to pass, tally: %v", tally)
suite.Falsef(burns, "expected desposit to not burn, tally: %v", tally)
})
suite.Run("UnvetoedAndAllAbstainedFails", func() {
suite.SetupTest()
suite.setTallyParams(d("0.4"), d("0.5"), d("0.334"))
proposal := suite.createProposal()
v1 := suite.createNewBondedValidator(sdkmath.NewInt(1e9))
suite.voteOnProposal(v1.GetOperator().Bytes(), proposal.Id, govv1beta1.OptionAbstain)
passes, burns, tally := suite.tallier.Tally(suite.ctx, proposal)
suite.Falsef(passes, "expected proposal to pass, tally: %v", tally)
suite.Falsef(burns, "expected desposit to not burn, tally: %v", tally)
})
}
func (suite *tallyHandlerSuite) setTallyParams(quorum, threshold, veto sdk.Dec) {
params := suite.app.GetGovKeeper().GetParams(suite.ctx)
params.Quorum = quorum.String()
params.Threshold = threshold.String()
params.VetoThreshold = veto.String()
params.BurnVoteQuorum = true
suite.app.GetGovKeeper().SetParams(suite.ctx, params)
}
func (suite *tallyHandlerSuite) voteOnProposal(
voter sdk.AccAddress,
proposalID uint64,
option govv1beta1.VoteOption,
) {
gk := suite.app.GetGovKeeper()
err := gk.AddVote(suite.ctx,
proposalID,
voter,
govv1.NewNonSplitVoteOption(govv1.VoteOption(option)),
"",
)
suite.Require().NoError(err)
}
func (suite *tallyHandlerSuite) createProposal() govv1.Proposal {
gk := suite.app.GetGovKeeper()
deposit := gk.GetParams(suite.ctx).MinDeposit
proposer := suite.createAccount(deposit...)
msg, err := govv1beta1.NewMsgSubmitProposal(
govv1beta1.NewTextProposal("a title", "a description"),
deposit,
proposer.GetAddress(),
)
suite.Require().NoError(err)
msgServerv1 := govkeeper.NewMsgServerImpl(&gk)
govAcct := gk.GetGovernanceAccount(suite.ctx).GetAddress()
msgServer := govkeeper.NewLegacyMsgServerImpl(govAcct.String(), msgServerv1)
res, err := msgServer.SubmitProposal(sdk.WrapSDKContext(suite.ctx), msg)
suite.Require().NoError(err)
proposal, found := gk.GetProposal(suite.ctx, res.ProposalId)
if !found {
panic("proposal not found")
}
return proposal
}
func (suite *tallyHandlerSuite) newBondCoin(amount sdkmath.Int) sdk.Coin {
return suite.staking.newBondCoin(suite.ctx, amount)
}
func (suite *tallyHandlerSuite) allowBKavaEarnDeposits() {
ek := suite.app.GetEarnKeeper()
earnParams := ek.GetParams(suite.ctx)
vault := earntypes.NewAllowedVault(
liquidtypes.DefaultDerivativeDenom,
earntypes.StrategyTypes{earntypes.STRATEGY_TYPE_SAVINGS},
false,
nil,
)
earnParams.AllowedVaults = append(earnParams.AllowedVaults, vault)
ek.SetParams(suite.ctx, earnParams)
sk := suite.app.GetSavingsKeeper()
savingsParams := sk.GetParams(suite.ctx)
savingsParams.SupportedDenoms = append(savingsParams.SupportedDenoms, liquidtypes.DefaultDerivativeDenom)
sk.SetParams(suite.ctx, savingsParams)
}
func (suite *tallyHandlerSuite) earnDeposit(owner sdk.AccAddress, derivative sdk.Coin) {
ek := suite.app.GetEarnKeeper()
err := ek.Deposit(suite.ctx, owner, derivative, earntypes.STRATEGY_TYPE_SAVINGS)
suite.Require().NoError(err)
}
func (suite *tallyHandlerSuite) mintDerivative(owner sdk.AccAddress, validator sdk.ValAddress, amount sdkmath.Int) sdk.Coin {
lk := suite.app.GetLiquidKeeper()
minted, err := lk.MintDerivative(suite.ctx, owner, validator, suite.newBondCoin(amount))
suite.Require().NoError(err)
return minted
}
func (suite *tallyHandlerSuite) delegateToNewBondedValidator(delegator sdk.AccAddress, amount sdkmath.Int) stakingtypes.ValidatorI {
valAcc := suite.createAccount(suite.newBondCoin(sdkmath.NewInt(1e9)))
validator, err := suite.staking.createUnbondedValidator(suite.ctx, valAcc.GetAddress().Bytes(), sdkmath.NewInt(1e9))
suite.Require().NoError(err)
_, err = suite.staking.delegate(suite.ctx, delegator, validator.GetOperator(), amount)
suite.Require().NoError(err)
// bond the validator
sk := suite.app.GetStakingKeeper()
staking.EndBlocker(suite.ctx, sk)
validator, found := sk.GetValidator(suite.ctx, validator.GetOperator())
if !found {
panic("validator not found")
}
return validator
}
func (suite *tallyHandlerSuite) createNewBondedValidator(selfDelegation sdkmath.Int) stakingtypes.ValidatorI {
valAcc := suite.createAccount(suite.newBondCoin(selfDelegation))
validator, err := suite.staking.createUnbondedValidator(suite.ctx, valAcc.GetAddress().Bytes(), selfDelegation)
suite.Require().NoError(err)
// bond the validator
sk := suite.app.GetStakingKeeper()
staking.EndBlocker(suite.ctx, sk)
validator, found := sk.GetValidator(suite.ctx, validator.GetOperator())
if !found {
panic("validator not found")
}
return validator
}
func (suite *tallyHandlerSuite) createAccount(initialBalance ...sdk.Coin) authtypes.AccountI {
ak := suite.app.GetAccountKeeper()
acc := ak.NewAccountWithAddress(suite.ctx, RandomAddress())
ak.SetAccount(suite.ctx, acc)
err := suite.app.FundAccount(suite.ctx, acc.GetAddress(), initialBalance)
suite.Require().NoError(err)
return acc
}
// stakingHelper wraps the staking keeper with helper functions for testing.
type stakingHelper struct {
keeper stakingkeeper.Keeper
}
func (h stakingHelper) createUnbondedValidator(ctx sdk.Context, address sdk.ValAddress, selfDelegation sdkmath.Int) (stakingtypes.ValidatorI, error) {
msg, err := stakingtypes.NewMsgCreateValidator(
address,
ed25519.GenPrivKey().PubKey(),
h.newBondCoin(ctx, selfDelegation),
stakingtypes.Description{},
stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
sdkmath.NewInt(1e6),
)
if err != nil {
return nil, err
}
msgServer := stakingkeeper.NewMsgServerImpl(&h.keeper)
_, err = msgServer.CreateValidator(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return nil, err
}
validator, found := h.keeper.GetValidator(ctx, address)
if !found {
panic("validator not found")
}
return validator, nil
}
func (h stakingHelper) delegate(ctx sdk.Context, delegator sdk.AccAddress, validator sdk.ValAddress, amount sdkmath.Int) (sdk.Dec, error) {
msg := stakingtypes.NewMsgDelegate(
delegator,
validator,
h.newBondCoin(ctx, amount),
)
msgServer := stakingkeeper.NewMsgServerImpl(&h.keeper)
_, err := msgServer.Delegate(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return sdk.Dec{}, err
}
del, found := h.keeper.GetDelegation(ctx, delegator, validator)
if !found {
panic("delegation not found")
}
return del.Shares, nil
}
func (h stakingHelper) newBondCoin(ctx sdk.Context, amount sdkmath.Int) sdk.Coin {
return sdk.NewCoin(h.keeper.BondDenom(ctx), amount)
}
func (h stakingHelper) setBondDenom(ctx sdk.Context, denom string) {
params := h.keeper.GetParams(ctx)
params.BondDenom = denom
h.keeper.SetParams(ctx, params)
}

View File

@ -1,98 +0,0 @@
syntax = "proto3";
package kava.auction.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/auction/types";
option (gogoproto.goproto_getters_all) = false;
// BaseAuction defines common attributes of all auctions
message BaseAuction {
option (cosmos_proto.implements_interface) = "Auction";
uint64 id = 1 [(gogoproto.customname) = "ID"];
string initiator = 2;
cosmos.base.v1beta1.Coin lot = 3 [(gogoproto.nullable) = false];
bytes bidder = 4 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
cosmos.base.v1beta1.Coin bid = 5 [(gogoproto.nullable) = false];
bool has_received_bids = 6;
google.protobuf.Timestamp end_time = 7 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
google.protobuf.Timestamp max_end_time = 8 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
}
// SurplusAuction is a forward auction that burns what it receives from bids.
// It is normally used to sell off excess pegged asset acquired by the CDP system.
message SurplusAuction {
option (cosmos_proto.implements_interface) = "Auction";
BaseAuction base_auction = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
}
// DebtAuction is a reverse auction that mints what it pays out.
// It is normally used to acquire pegged asset to cover the CDP system's debts that were not covered by selling
// collateral.
message DebtAuction {
option (cosmos_proto.implements_interface) = "Auction";
BaseAuction base_auction = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
cosmos.base.v1beta1.Coin corresponding_debt = 2 [(gogoproto.nullable) = false];
}
// CollateralAuction is a two phase auction.
// Initially, in forward auction phase, bids can be placed up to a max bid.
// Then it switches to a reverse auction phase, where the initial amount up for auction is bid down.
// Unsold Lot is sent to LotReturns, being divided among the addresses by weight.
// Collateral auctions are normally used to sell off collateral seized from CDPs.
message CollateralAuction {
option (cosmos_proto.implements_interface) = "Auction";
BaseAuction base_auction = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
cosmos.base.v1beta1.Coin corresponding_debt = 2 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin max_bid = 3 [(gogoproto.nullable) = false];
WeightedAddresses lot_returns = 4 [(gogoproto.nullable) = false];
}
// WeightedAddresses is a type for storing some addresses and associated weights.
message WeightedAddresses {
repeated bytes addresses = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
repeated bytes weights = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

View File

@ -1,55 +0,0 @@
syntax = "proto3";
package kava.auction.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
option go_package = "github.com/kava-labs/kava/x/auction/types";
option (gogoproto.goproto_getters_all) = false;
// GenesisState defines the auction module's genesis state.
message GenesisState {
uint64 next_auction_id = 1;
Params params = 2 [(gogoproto.nullable) = false];
// Genesis auctions
repeated google.protobuf.Any auctions = 3 [(cosmos_proto.accepts_interface) = "GenesisAuction"];
}
// Params defines the parameters for the issuance module.
message Params {
reserved 2;
reserved "bid_duration";
google.protobuf.Duration max_auction_duration = 1 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
google.protobuf.Duration forward_bid_duration = 6 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
google.protobuf.Duration reverse_bid_duration = 7 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
bytes increment_surplus = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bytes increment_debt = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bytes increment_collateral = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

View File

@ -1,84 +0,0 @@
syntax = "proto3";
package kava.auction.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";
import "kava/auction/v1beta1/genesis.proto";
option go_package = "github.com/kava-labs/kava/x/auction/types";
// Query defines the gRPC querier service for auction module
service Query {
// Params queries all parameters of the auction module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/auction/v1beta1/params";
}
// Auction queries an individual Auction by auction ID
rpc Auction(QueryAuctionRequest) returns (QueryAuctionResponse) {
option (google.api.http).get = "/kava/auction/v1beta1/auctions/{auction_id}";
}
// Auctions queries auctions filtered by asset denom, owner address, phase, and auction type
rpc Auctions(QueryAuctionsRequest) returns (QueryAuctionsResponse) {
option (google.api.http).get = "/kava/auction/v1beta1/auctions";
}
// NextAuctionID queries the next auction ID
rpc NextAuctionID(QueryNextAuctionIDRequest) returns (QueryNextAuctionIDResponse) {
option (google.api.http).get = "/kava/auction/v1beta1/next-auction-id";
}
}
// QueryParamsRequest defines the request type for querying x/auction parameters.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/auction parameters.
message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryAuctionRequest is the request type for the Query/Auction RPC method.
message QueryAuctionRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
uint64 auction_id = 1;
}
// QueryAuctionResponse is the response type for the Query/Auction RPC method.
message QueryAuctionResponse {
google.protobuf.Any auction = 1;
}
// QueryAuctionsRequest is the request type for the Query/Auctions RPC method.
message QueryAuctionsRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string type = 1;
string owner = 2;
string denom = 3;
string phase = 4;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 5;
}
// QueryAuctionsResponse is the response type for the Query/Auctions RPC method.
message QueryAuctionsResponse {
repeated google.protobuf.Any auctions = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryNextAuctionIDRequest defines the request type for querying x/auction next auction ID.
message QueryNextAuctionIDRequest {}
// QueryNextAuctionIDResponse defines the response type for querying x/auction next auction ID.
message QueryNextAuctionIDResponse {
uint64 id = 1;
}

View File

@ -1,28 +0,0 @@
syntax = "proto3";
package kava.auction.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/auction/types";
// Msg defines the auction Msg service.
service Msg {
// PlaceBid message type used by bidders to place bids on auctions
rpc PlaceBid(MsgPlaceBid) returns (MsgPlaceBidResponse);
}
// MsgPlaceBid represents a message used by bidders to place bids on auctions
message MsgPlaceBid {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
uint64 auction_id = 1;
string bidder = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// MsgPlaceBidResponse defines the Msg/PlaceBid response type.
message MsgPlaceBidResponse {}

View File

@ -1,160 +0,0 @@
syntax = "proto3";
package kava.bep3.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
option go_package = "github.com/kava-labs/kava/x/bep3/types";
// Params defines the parameters for the bep3 module.
message Params {
// asset_params define the parameters for each bep3 asset
repeated AssetParam asset_params = 1 [
(gogoproto.castrepeated) = "AssetParams",
(gogoproto.nullable) = false
];
}
// AssetParam defines parameters for each bep3 asset.
message AssetParam {
// denom represents the denominatin for this asset
string denom = 1;
// coin_id represents the registered coin type to use (https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
int64 coin_id = 2 [(gogoproto.customname) = "CoinID"];
// supply_limit defines the maximum supply allowed for the asset - a total or time based rate limit
SupplyLimit supply_limit = 3 [(gogoproto.nullable) = false];
// active specifies if the asset is live or paused
bool active = 4;
// deputy_address the kava address of the deputy
bytes deputy_address = 5 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
// fixed_fee defines the fee for incoming swaps
string fixed_fee = 6 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// min_swap_amount defines the minimum amount able to be swapped in a single message
string min_swap_amount = 7 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// max_swap_amount defines the maximum amount able to be swapped in a single message
string max_swap_amount = 8 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// min_block_lock defined the minimum blocks to lock
uint64 min_block_lock = 9;
// min_block_lock defined the maximum blocks to lock
uint64 max_block_lock = 10;
}
// SupplyLimit define the absolute and time-based limits for an assets's supply.
message SupplyLimit {
// limit defines the total supply allowed
string limit = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// time_limited enables or disables time based supply limiting
bool time_limited = 2;
// time_period specifies the duration that time_based_limit is evalulated
google.protobuf.Duration time_period = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
// time_based_limit defines the maximum supply that can be swapped within time_period
string time_based_limit = 4 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// SwapStatus is the status of an AtomicSwap
enum SwapStatus {
option (gogoproto.goproto_enum_prefix) = false;
// SWAP_STATUS_UNSPECIFIED represents an unspecified status
SWAP_STATUS_UNSPECIFIED = 0;
// SWAP_STATUS_OPEN represents an open swap
SWAP_STATUS_OPEN = 1;
// SWAP_STATUS_COMPLETED represents a completed swap
SWAP_STATUS_COMPLETED = 2;
// SWAP_STATUS_EXPIRED represents an expired swap
SWAP_STATUS_EXPIRED = 3;
}
// SwapDirection is the direction of an AtomicSwap
enum SwapDirection {
option (gogoproto.goproto_enum_prefix) = false;
// SWAP_DIRECTION_UNSPECIFIED represents unspecified or invalid swap direcation
SWAP_DIRECTION_UNSPECIFIED = 0;
// SWAP_DIRECTION_INCOMING represents is incoming swap (to the kava chain)
SWAP_DIRECTION_INCOMING = 1;
// SWAP_DIRECTION_OUTGOING represents an outgoing swap (from the kava chain)
SWAP_DIRECTION_OUTGOING = 2;
}
// AtomicSwap defines an atomic swap between chains for the pricefeed module.
message AtomicSwap {
// amount represents the amount being swapped
repeated cosmos.base.v1beta1.Coin amount = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
// random_number_hash represents the hash of the random number
bytes random_number_hash = 2 [(gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes"];
// expire_height represents the height when the swap expires
uint64 expire_height = 3;
// timestamp represents the timestamp of the swap
int64 timestamp = 4;
// sender is the kava chain sender of the swap
bytes sender = 5 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
// recipient is the kava chain recipient of the swap
bytes recipient = 6 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
// sender_other_chain is the sender on the other chain
string sender_other_chain = 7;
// recipient_other_chain is the recipient on the other chain
string recipient_other_chain = 8;
// closed_block is the block when the swap is closed
int64 closed_block = 9;
// status represents the current status of the swap
SwapStatus status = 10;
// cross_chain identifies whether the atomic swap is cross chain
bool cross_chain = 11;
// direction identifies if the swap is incoming or outgoing
SwapDirection direction = 12;
}
// AssetSupply defines information about an asset's supply.
message AssetSupply {
// incoming_supply represents the incoming supply of an asset
cosmos.base.v1beta1.Coin incoming_supply = 1 [(gogoproto.nullable) = false];
// outgoing_supply represents the outgoing supply of an asset
cosmos.base.v1beta1.Coin outgoing_supply = 2 [(gogoproto.nullable) = false];
// current_supply represents the current on-chain supply of an asset
cosmos.base.v1beta1.Coin current_supply = 3 [(gogoproto.nullable) = false];
// time_limited_current_supply represents the time limited current supply of an asset
cosmos.base.v1beta1.Coin time_limited_current_supply = 4 [(gogoproto.nullable) = false];
// time_elapsed represents the time elapsed
google.protobuf.Duration time_elapsed = 5 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
}

View File

@ -1,32 +0,0 @@
syntax = "proto3";
package kava.bep3.v1beta1;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "kava/bep3/v1beta1/bep3.proto";
option go_package = "github.com/kava-labs/kava/x/bep3/types";
// GenesisState defines the pricefeed module's genesis state.
message GenesisState {
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
// atomic_swaps represents the state of stored atomic swaps
repeated AtomicSwap atomic_swaps = 2 [
(gogoproto.castrepeated) = "AtomicSwaps",
(gogoproto.nullable) = false
];
// supplies represents the supply information of each atomic swap
repeated AssetSupply supplies = 3 [
(gogoproto.castrepeated) = "AssetSupplies",
(gogoproto.nullable) = false
];
// previous_block_time represents the time of the previous block
google.protobuf.Timestamp previous_block_time = 4 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
}

View File

@ -1,165 +0,0 @@
syntax = "proto3";
package kava.bep3.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/duration.proto";
import "kava/bep3/v1beta1/bep3.proto";
option go_package = "github.com/kava-labs/kava/x/bep3/types";
// Query defines the gRPC querier service for bep3 module
service Query {
// Params queries module params
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/bep3/v1beta1/params";
}
// AssetSupply queries info about an asset's supply
rpc AssetSupply(QueryAssetSupplyRequest) returns (QueryAssetSupplyResponse) {
option (google.api.http).get = "/kava/bep3/v1beta1/assetsupply/{denom}";
}
// AssetSupplies queries a list of asset supplies
rpc AssetSupplies(QueryAssetSuppliesRequest) returns (QueryAssetSuppliesResponse) {
option (google.api.http).get = "/kava/bep3/v1beta1/assetsupplies";
}
// AtomicSwap queries info about an atomic swap
rpc AtomicSwap(QueryAtomicSwapRequest) returns (QueryAtomicSwapResponse) {
option (google.api.http).get = "/kava/bep3/v1beta1/atomicswap/{swap_id}";
}
// AtomicSwaps queries a list of atomic swaps
rpc AtomicSwaps(QueryAtomicSwapsRequest) returns (QueryAtomicSwapsResponse) {
option (google.api.http).get = "/kava/bep3/v1beta1/atomicswaps";
}
}
// QueryParamsRequest defines the request type for querying x/bep3 parameters.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/bep3 parameters.
message QueryParamsResponse {
// params represents the parameters of the module
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryAssetSupplyRequest is the request type for the Query/AssetSupply RPC method.
message QueryAssetSupplyRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// denom filters the asset response for the specified denom
string denom = 1;
}
// AssetSupplyResponse defines information about an asset's supply.
message AssetSupplyResponse {
// incoming_supply represents the incoming supply of an asset
cosmos.base.v1beta1.Coin incoming_supply = 1 [(gogoproto.nullable) = false];
// outgoing_supply represents the outgoing supply of an asset
cosmos.base.v1beta1.Coin outgoing_supply = 2 [(gogoproto.nullable) = false];
// current_supply represents the current on-chain supply of an asset
cosmos.base.v1beta1.Coin current_supply = 3 [(gogoproto.nullable) = false];
// time_limited_current_supply represents the time limited current supply of an asset
cosmos.base.v1beta1.Coin time_limited_current_supply = 4 [(gogoproto.nullable) = false];
// time_elapsed represents the time elapsed
google.protobuf.Duration time_elapsed = 5 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
}
// QueryAssetSupplyResponse is the response type for the Query/AssetSupply RPC method.
message QueryAssetSupplyResponse {
// asset_supply represents the supply of the asset
AssetSupplyResponse asset_supply = 1 [(gogoproto.nullable) = false];
}
// QueryAssetSuppliesRequest is the request type for the Query/AssetSupplies RPC method.
message QueryAssetSuppliesRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
}
// QueryAssetSuppliesResponse is the response type for the Query/AssetSupplies RPC method.
message QueryAssetSuppliesResponse {
// asset_supplies represents the supplies of returned assets
repeated AssetSupplyResponse asset_supplies = 1 [(gogoproto.nullable) = false];
}
// QueryAtomicSwapRequest is the request type for the Query/AtomicSwap RPC method.
message QueryAtomicSwapRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// swap_id represents the id of the swap to query
string swap_id = 1;
}
// QueryAtomicSwapResponse is the response type for the Query/AtomicSwap RPC method.
message QueryAtomicSwapResponse {
AtomicSwapResponse atomic_swap = 2 [(gogoproto.nullable) = false];
}
// AtomicSwapResponse represents the returned atomic swap properties
message AtomicSwapResponse {
// id represents the id of the atomic swap
string id = 1;
// amount represents the amount being swapped
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
// random_number_hash represents the hash of the random number
string random_number_hash = 3;
// expire_height represents the height when the swap expires
uint64 expire_height = 4;
// timestamp represents the timestamp of the swap
int64 timestamp = 5;
// sender is the kava chain sender of the swap
string sender = 6 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// recipient is the kava chain recipient of the swap
string recipient = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// sender_other_chain is the sender on the other chain
string sender_other_chain = 8;
// recipient_other_chain is the recipient on the other chain
string recipient_other_chain = 9;
// closed_block is the block when the swap is closed
int64 closed_block = 10;
// status represents the current status of the swap
SwapStatus status = 11;
// cross_chain identifies whether the atomic swap is cross chain
bool cross_chain = 12;
// direction identifies if the swap is incoming or outgoing
SwapDirection direction = 13;
}
// QueryAtomicSwapsRequest is the request type for the Query/AtomicSwaps RPC method.
message QueryAtomicSwapsRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// involve filters by address
string involve = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// expiration filters by expiration block height
uint64 expiration = 2;
// status filters by swap status
SwapStatus status = 3;
// direction fitlers by swap direction
SwapDirection direction = 4;
cosmos.base.query.v1beta1.PageRequest pagination = 5;
}
// QueryAtomicSwapsResponse is the response type for the Query/AtomicSwaps RPC method.
message QueryAtomicSwapsResponse {
// atomic_swap represents the returned atomic swaps for the request
repeated AtomicSwapResponse atomic_swaps = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 3;
}

View File

@ -1,69 +0,0 @@
syntax = "proto3";
package kava.bep3.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/bep3/types";
// Msg defines the bep3 Msg service.
service Msg {
// CreateAtomicSwap defines a method for creating an atomic swap
rpc CreateAtomicSwap(MsgCreateAtomicSwap) returns (MsgCreateAtomicSwapResponse);
// ClaimAtomicSwap defines a method for claiming an atomic swap
rpc ClaimAtomicSwap(MsgClaimAtomicSwap) returns (MsgClaimAtomicSwapResponse);
// RefundAtomicSwap defines a method for refunding an atomic swap
rpc RefundAtomicSwap(MsgRefundAtomicSwap) returns (MsgRefundAtomicSwapResponse);
}
// MsgCreateAtomicSwap defines the Msg/CreateAtomicSwap request type.
message MsgCreateAtomicSwap {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string to = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string recipient_other_chain = 3;
string sender_other_chain = 4;
string random_number_hash = 5;
int64 timestamp = 6;
repeated cosmos.base.v1beta1.Coin amount = 7 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
uint64 height_span = 8;
}
// MsgCreateAtomicSwapResponse defines the Msg/CreateAtomicSwap response type.
message MsgCreateAtomicSwapResponse {}
// MsgClaimAtomicSwap defines the Msg/ClaimAtomicSwap request type.
message MsgClaimAtomicSwap {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string swap_id = 2 [(gogoproto.customname) = "SwapID"];
string random_number = 3;
}
// MsgClaimAtomicSwapResponse defines the Msg/ClaimAtomicSwap response type.
message MsgClaimAtomicSwapResponse {}
// MsgRefundAtomicSwap defines the Msg/RefundAtomicSwap request type.
message MsgRefundAtomicSwap {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string swap_id = 2 [(gogoproto.customname) = "SwapID"];
}
// MsgRefundAtomicSwapResponse defines the Msg/RefundAtomicSwap response type.
message MsgRefundAtomicSwapResponse {}

View File

@ -1,59 +0,0 @@
syntax = "proto3";
package kava.cdp.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/cdp/types";
option (gogoproto.goproto_getters_all) = false;
// CDP defines the state of a single collateralized debt position.
message CDP {
uint64 id = 1 [(gogoproto.customname) = "ID"];
bytes owner = 2 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
string type = 3;
cosmos.base.v1beta1.Coin collateral = 4 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin principal = 5 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin accumulated_fees = 6 [(gogoproto.nullable) = false];
google.protobuf.Timestamp fees_updated = 7 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
string interest_factor = 8 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// Deposit defines an amount of coins deposited by an account to a cdp
message Deposit {
uint64 cdp_id = 1 [(gogoproto.customname) = "CdpID"];
string depositor = 2 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// TotalPrincipal defines the total principal of a given collateral type
message TotalPrincipal {
string collateral_type = 1;
cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
}
// TotalCollateral defines the total collateral of a given collateral type
message TotalCollateral {
string collateral_type = 1;
cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
}
// OwnerCDPIndex defines the cdp ids for a single cdp owner
message OwnerCDPIndex {
repeated uint64 cdp_ids = 1 [(gogoproto.customname) = "CdpIDs"];
}

View File

@ -1,155 +0,0 @@
syntax = "proto3";
package kava.cdp.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "kava/cdp/v1beta1/cdp.proto";
option go_package = "github.com/kava-labs/kava/x/cdp/types";
// GenesisState defines the cdp module's genesis state.
message GenesisState {
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
repeated CDP cdps = 2 [
(gogoproto.customname) = "CDPs",
(gogoproto.castrepeated) = "CDPs",
(gogoproto.nullable) = false
];
repeated Deposit deposits = 3 [
(gogoproto.castrepeated) = "Deposits",
(gogoproto.nullable) = false
];
uint64 starting_cdp_id = 4 [(gogoproto.customname) = "StartingCdpID"];
string debt_denom = 5;
string gov_denom = 6;
repeated GenesisAccumulationTime previous_accumulation_times = 7 [
(gogoproto.castrepeated) = "GenesisAccumulationTimes",
(gogoproto.nullable) = false
];
repeated GenesisTotalPrincipal total_principals = 8 [
(gogoproto.castrepeated) = "GenesisTotalPrincipals",
(gogoproto.nullable) = false
];
}
// Params defines the parameters for the cdp module.
message Params {
repeated CollateralParam collateral_params = 1 [
(gogoproto.castrepeated) = "CollateralParams",
(gogoproto.nullable) = false
];
DebtParam debt_param = 2 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin global_debt_limit = 3 [(gogoproto.nullable) = false];
string surplus_auction_threshold = 4 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string surplus_auction_lot = 5 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string debt_auction_threshold = 6 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string debt_auction_lot = 7 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
bool circuit_breaker = 8;
int64 liquidation_block_interval = 9;
}
// DebtParam defines governance params for debt assets
message DebtParam {
string denom = 1;
string reference_asset = 2;
string conversion_factor = 3 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string debt_floor = 4 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// CollateralParam defines governance parameters for each collateral type within the cdp module
message CollateralParam {
string denom = 1;
string type = 2;
string liquidation_ratio = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
cosmos.base.v1beta1.Coin debt_limit = 4 [(gogoproto.nullable) = false];
string stability_fee = 5 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string auction_size = 6 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string liquidation_penalty = 7 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string spot_market_id = 8 [(gogoproto.customname) = "SpotMarketID"];
string liquidation_market_id = 9 [(gogoproto.customname) = "LiquidationMarketID"];
string keeper_reward_percentage = 10 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string check_collateralization_index_count = 11 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string conversion_factor = 12 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// GenesisAccumulationTime defines the previous distribution time and its corresponding denom
message GenesisAccumulationTime {
string collateral_type = 1;
google.protobuf.Timestamp previous_accumulation_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
string interest_factor = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// GenesisTotalPrincipal defines the total principal and its corresponding collateral type
message GenesisTotalPrincipal {
string collateral_type = 1;
string total_principal = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

View File

@ -1,160 +0,0 @@
syntax = "proto3";
package kava.cdp.v1beta1;
import "cosmos/auth/v1beta1/auth.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "kava/cdp/v1beta1/cdp.proto";
import "kava/cdp/v1beta1/genesis.proto";
option go_package = "github.com/kava-labs/kava/x/cdp/types";
// Query defines the gRPC querier service for cdp module
service Query {
// Params queries all parameters of the cdp module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/cdp/v1beta1/params";
}
// Accounts queries the CDP module accounts.
rpc Accounts(QueryAccountsRequest) returns (QueryAccountsResponse) {
option (google.api.http).get = "/kava/cdp/v1beta1/accounts";
}
// TotalPrincipal queries the total principal of a given collateral type.
rpc TotalPrincipal(QueryTotalPrincipalRequest) returns (QueryTotalPrincipalResponse) {
option (google.api.http).get = "/kava/cdp/v1beta1/totalPrincipal";
}
// TotalCollateral queries the total collateral of a given collateral type.
rpc TotalCollateral(QueryTotalCollateralRequest) returns (QueryTotalCollateralResponse) {
option (google.api.http).get = "/kava/cdp/v1beta1/totalCollateral";
}
// Cdps queries all active CDPs.
rpc Cdps(QueryCdpsRequest) returns (QueryCdpsResponse) {
option (google.api.http).get = "/kava/cdp/v1beta1/cdps";
}
// Cdp queries a CDP with the input owner address and collateral type.
rpc Cdp(QueryCdpRequest) returns (QueryCdpResponse) {
option (google.api.http).get = "/kava/cdp/v1beta1/cdps/{owner}/{collateral_type}";
}
// Deposits queries deposits associated with the CDP owned by an address for a collateral type.
rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) {
option (google.api.http).get = "/kava/cdp/v1beta1/cdps/deposits/{owner}/{collateral_type}";
}
}
// QueryParamsRequest defines the request type for the Query/Params RPC method.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for the Query/Params RPC method.
message QueryParamsResponse {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryAccountsRequest defines the request type for the Query/Accounts RPC method.
message QueryAccountsRequest {}
// QueryAccountsResponse defines the response type for the Query/Accounts RPC method.
message QueryAccountsResponse {
repeated cosmos.auth.v1beta1.ModuleAccount accounts = 1 [(gogoproto.nullable) = false];
}
// QueryCdpRequest defines the request type for the Query/Cdp RPC method.
message QueryCdpRequest {
string collateral_type = 1;
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryCdpResponse defines the response type for the Query/Cdp RPC method.
message QueryCdpResponse {
CDPResponse cdp = 1 [(gogoproto.nullable) = false];
}
// QueryCdpsRequest is the params for a filtered CDP query, the request type for the Query/Cdps RPC method.
message QueryCdpsRequest {
string collateral_type = 1;
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint64 id = 3 [(gogoproto.customname) = "ID"];
// sdk.Dec as a string
string ratio = 4;
cosmos.base.query.v1beta1.PageRequest pagination = 5;
}
// QueryCdpsResponse defines the response type for the Query/Cdps RPC method.
message QueryCdpsResponse {
repeated CDPResponse cdps = 1 [
(gogoproto.castrepeated) = "CDPResponses",
(gogoproto.nullable) = false
];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryDepositsRequest defines the request type for the Query/Deposits RPC method.
message QueryDepositsRequest {
string collateral_type = 1;
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// QueryDepositsResponse defines the response type for the Query/Deposits RPC method.
message QueryDepositsResponse {
repeated Deposit deposits = 1 [
(gogoproto.castrepeated) = "Deposits",
(gogoproto.nullable) = false
];
}
// QueryTotalPrincipalRequest defines the request type for the Query/TotalPrincipal RPC method.
message QueryTotalPrincipalRequest {
string collateral_type = 1;
}
// QueryTotalPrincipalResponse defines the response type for the Query/TotalPrincipal RPC method.
message QueryTotalPrincipalResponse {
repeated TotalPrincipal total_principal = 1 [
(gogoproto.castrepeated) = "TotalPrincipals",
(gogoproto.nullable) = false
];
}
// QueryTotalCollateralRequest defines the request type for the Query/TotalCollateral RPC method.
message QueryTotalCollateralRequest {
string collateral_type = 1;
}
// QueryTotalCollateralResponse defines the response type for the Query/TotalCollateral RPC method.
message QueryTotalCollateralResponse {
repeated TotalCollateral total_collateral = 1 [
(gogoproto.castrepeated) = "TotalCollaterals",
(gogoproto.nullable) = false
];
}
// CDPResponse defines the state of a single collateralized debt position.
message CDPResponse {
uint64 id = 1 [(gogoproto.customname) = "ID"];
string owner = 2;
string type = 3;
cosmos.base.v1beta1.Coin collateral = 4 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin principal = 5 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin accumulated_fees = 6 [(gogoproto.nullable) = false];
google.protobuf.Timestamp fees_updated = 7 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
string interest_factor = 8;
cosmos.base.v1beta1.Coin collateral_value = 9 [(gogoproto.nullable) = false];
string collateralization_ratio = 10;
}

View File

@ -1,91 +0,0 @@
syntax = "proto3";
package kava.cdp.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/cdp/types";
// Msg defines the cdp Msg service.
service Msg {
// CreateCDP defines a method to create a new CDP.
rpc CreateCDP(MsgCreateCDP) returns (MsgCreateCDPResponse);
// Deposit defines a method to deposit to a CDP.
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);
// Withdraw defines a method to withdraw collateral from a CDP.
rpc Withdraw(MsgWithdraw) returns (MsgWithdrawResponse);
// DrawDebt defines a method to draw debt from a CDP.
rpc DrawDebt(MsgDrawDebt) returns (MsgDrawDebtResponse);
// RepayDebt defines a method to repay debt from a CDP.
rpc RepayDebt(MsgRepayDebt) returns (MsgRepayDebtResponse);
// Liquidate defines a method to attempt to liquidate a CDP whos
// collateralization ratio is under its liquidation ratio.
rpc Liquidate(MsgLiquidate) returns (MsgLiquidateResponse);
}
// MsgCreateCDP defines a message to create a new CDP.
message MsgCreateCDP {
string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin collateral = 2 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin principal = 3 [(gogoproto.nullable) = false];
string collateral_type = 4;
}
// MsgCreateCDPResponse defines the Msg/CreateCDP response type.
message MsgCreateCDPResponse {
uint64 cdp_id = 1 [(gogoproto.customname) = "CdpID"];
}
// MsgDeposit defines a message to deposit to a CDP.
message MsgDeposit {
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin collateral = 3 [(gogoproto.nullable) = false];
string collateral_type = 4;
}
// MsgDepositResponse defines the Msg/Deposit response type.
message MsgDepositResponse {}
// MsgWithdraw defines a message to withdraw collateral from a CDP.
message MsgWithdraw {
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin collateral = 3 [(gogoproto.nullable) = false];
string collateral_type = 4;
}
// MsgWithdrawResponse defines the Msg/Withdraw response type.
message MsgWithdrawResponse {}
// MsgDrawDebt defines a message to draw debt from a CDP.
message MsgDrawDebt {
string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string collateral_type = 2;
cosmos.base.v1beta1.Coin principal = 3 [(gogoproto.nullable) = false];
}
// MsgDrawDebtResponse defines the Msg/DrawDebt response type.
message MsgDrawDebtResponse {}
// MsgRepayDebt defines a message to repay debt from a CDP.
message MsgRepayDebt {
string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string collateral_type = 2;
cosmos.base.v1beta1.Coin payment = 3 [(gogoproto.nullable) = false];
}
// MsgRepayDebtResponse defines the Msg/RepayDebt response type.
message MsgRepayDebtResponse {}
// MsgLiquidate defines a message to attempt to liquidate a CDP whos
// collateralization ratio is under its liquidation ratio.
message MsgLiquidate {
string keeper = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string borrower = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string collateral_type = 3;
}
// MsgLiquidateResponse defines the Msg/Liquidate response type.
message MsgLiquidateResponse {}

View File

@ -1,70 +0,0 @@
syntax = "proto3";
package kava.committee.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
option go_package = "github.com/kava-labs/kava/x/committee/types";
option (gogoproto.goproto_getters_all) = false;
// BaseCommittee is a common type shared by all Committees
message BaseCommittee {
option (cosmos_proto.implements_interface) = "Committee";
option (gogoproto.goproto_stringer) = false;
uint64 id = 1 [(gogoproto.customname) = "ID"];
string description = 2;
repeated bytes members = 3 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
repeated google.protobuf.Any permissions = 4 [(cosmos_proto.accepts_interface) = "Permission"];
// Smallest percentage that must vote for a proposal to pass
string vote_threshold = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// The length of time a proposal remains active for. Proposals will close earlier if they get enough votes.
google.protobuf.Duration proposal_duration = 6 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
TallyOption tally_option = 7;
}
// MemberCommittee is an alias of BaseCommittee
message MemberCommittee {
option (cosmos_proto.implements_interface) = "Committee";
option (gogoproto.goproto_stringer) = false;
BaseCommittee base_committee = 1 [(gogoproto.embed) = true];
}
// TokenCommittee supports voting on proposals by token holders
message TokenCommittee {
option (cosmos_proto.implements_interface) = "Committee";
option (gogoproto.goproto_stringer) = false;
BaseCommittee base_committee = 1 [(gogoproto.embed) = true];
string quorum = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string tally_denom = 3;
}
// TallyOption enumerates the valid types of a tally.
enum TallyOption {
option (gogoproto.goproto_enum_prefix) = false;
// TALLY_OPTION_UNSPECIFIED defines a null tally option.
TALLY_OPTION_UNSPECIFIED = 0;
// Votes are tallied each block and the proposal passes as soon as the vote threshold is reached
TALLY_OPTION_FIRST_PAST_THE_POST = 1;
// Votes are tallied exactly once, when the deadline time is reached
TALLY_OPTION_DEADLINE = 2;
}

View File

@ -1,62 +0,0 @@
syntax = "proto3";
package kava.committee.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/committee/types";
// GenesisState defines the committee module's genesis state.
message GenesisState {
option (gogoproto.goproto_getters) = false;
uint64 next_proposal_id = 1 [(gogoproto.customname) = "NextProposalID"];
repeated google.protobuf.Any committees = 2 [(cosmos_proto.accepts_interface) = "Committee"];
repeated Proposal proposals = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "Proposals"
];
repeated Vote votes = 4 [(gogoproto.nullable) = false];
}
// Proposal is an internal record of a governance proposal submitted to a committee.
message Proposal {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content"];
uint64 id = 2 [(gogoproto.customname) = "ID"];
uint64 committee_id = 3 [(gogoproto.customname) = "CommitteeID"];
google.protobuf.Timestamp deadline = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
}
// Vote is an internal record of a single governance vote.
message Vote {
option (gogoproto.goproto_getters) = false;
uint64 proposal_id = 1 [(gogoproto.customname) = "ProposalID"];
bytes voter = 2 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
VoteType vote_type = 3;
}
// VoteType enumerates the valid types of a vote.
enum VoteType {
option (gogoproto.goproto_enum_prefix) = false;
// VOTE_TYPE_UNSPECIFIED defines a no-op vote option.
VOTE_TYPE_UNSPECIFIED = 0;
// VOTE_TYPE_YES defines a yes vote option.
VOTE_TYPE_YES = 1;
// VOTE_TYPE_NO defines a no vote option.
VOTE_TYPE_NO = 2;
// VOTE_TYPE_ABSTAIN defines an abstain vote option.
VOTE_TYPE_ABSTAIN = 3;
}

View File

@ -1,72 +0,0 @@
syntax = "proto3";
package kava.committee.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/committee/types";
// GodPermission allows any governance proposal. It is used mainly for testing.
message GodPermission {
option (cosmos_proto.implements_interface) = "Permission";
}
// SoftwareUpgradePermission permission type for software upgrade proposals
message SoftwareUpgradePermission {
option (cosmos_proto.implements_interface) = "Permission";
}
// TextPermission allows any text governance proposal.
message TextPermission {
option (cosmos_proto.implements_interface) = "Permission";
}
// CommunityCDPRepayDebtPermission allows submission of CommunityCDPRepayDebtProposal
message CommunityCDPRepayDebtPermission {
option (cosmos_proto.implements_interface) = "Permission";
}
// CommunityCDPWithdrawCollateralPermission allows submission of CommunityCDPWithdrawCollateralProposal
message CommunityCDPWithdrawCollateralPermission {
option (cosmos_proto.implements_interface) = "Permission";
}
// CommunityPoolLendWithdrawPermission allows submission of CommunityPoolLendWithdrawProposal
message CommunityPoolLendWithdrawPermission {
option (cosmos_proto.implements_interface) = "Permission";
}
// ParamsChangePermission allows any parameter or sub parameter change proposal.
message ParamsChangePermission {
option (cosmos_proto.implements_interface) = "Permission";
repeated AllowedParamsChange allowed_params_changes = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "AllowedParamsChanges"
];
}
// AllowedParamsChange contains data on the allowed parameter changes for subspace, key, and sub params requirements.
message AllowedParamsChange {
string subspace = 1;
string key = 2;
// Requirements for when the subparam value is a single record. This contains list of allowed attribute keys that can
// be changed on the subparam record.
repeated string single_subparam_allowed_attrs = 3;
// Requirements for when the subparam value is a list of records. The requirements contains requirements for each
// record in the list.
repeated SubparamRequirement multi_subparams_requirements = 4 [(gogoproto.nullable) = false];
}
// SubparamRequirement contains requirements for a single record in a subparam value list
message SubparamRequirement {
// The required attr key of the param record.
string key = 1;
// The required param value for the param record key. The key and value is used to match to the target param record.
string val = 2;
// The sub param attrs that are allowed to be changed.
repeated string allowed_subparam_attr_changes = 3;
}

View File

@ -1,27 +0,0 @@
syntax = "proto3";
package kava.committee.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
option go_package = "github.com/kava-labs/kava/x/committee/types";
option (gogoproto.goproto_getters_all) = false;
// CommitteeChangeProposal is a gov proposal for creating a new committee or modifying an existing one.
message CommitteeChangeProposal {
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";
string title = 1;
string description = 2;
google.protobuf.Any new_committee = 3 [(cosmos_proto.accepts_interface) = "Committee"];
}
// CommitteeDeleteProposal is a gov proposal for removing a committee.
message CommitteeDeleteProposal {
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";
string title = 1;
string description = 2;
uint64 committee_id = 3 [(gogoproto.customname) = "CommitteeID"];
}

View File

@ -1,181 +0,0 @@
syntax = "proto3";
package kava.committee.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "kava/committee/v1beta1/genesis.proto";
option go_package = "github.com/kava-labs/kava/x/committee/types";
option (gogoproto.goproto_getters_all) = false;
// Query defines the gRPC querier service for committee module
service Query {
// Committees queries all committess of the committee module.
rpc Committees(QueryCommitteesRequest) returns (QueryCommitteesResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/committees";
}
// Committee queries a committee based on committee ID.
rpc Committee(QueryCommitteeRequest) returns (QueryCommitteeResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/committees/{committee_id}";
}
// Proposals queries proposals based on committee ID.
rpc Proposals(QueryProposalsRequest) returns (QueryProposalsResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/proposals";
}
// Deposits queries a proposal based on proposal ID.
rpc Proposal(QueryProposalRequest) returns (QueryProposalResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/proposals/{proposal_id}";
}
// NextProposalID queries the next proposal ID of the committee module.
rpc NextProposalID(QueryNextProposalIDRequest) returns (QueryNextProposalIDResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/next-proposal-id";
}
// Votes queries all votes for a single proposal ID.
rpc Votes(QueryVotesRequest) returns (QueryVotesResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/proposals/{proposal_id}/votes";
}
// Vote queries the vote of a single voter for a single proposal ID.
rpc Vote(QueryVoteRequest) returns (QueryVoteResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/proposals/{proposal_id}/votes/{voter}";
}
// Tally queries the tally of a single proposal ID.
rpc Tally(QueryTallyRequest) returns (QueryTallyResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/proposals/{proposal_id}/tally";
}
// RawParams queries the raw params data of any subspace and key.
rpc RawParams(QueryRawParamsRequest) returns (QueryRawParamsResponse) {
option (google.api.http).get = "/kava/committee/v1beta1/raw-params";
}
}
// QueryCommitteesRequest defines the request type for querying x/committee committees.
message QueryCommitteesRequest {}
// QueryCommitteesResponse defines the response type for querying x/committee committees.
message QueryCommitteesResponse {
repeated google.protobuf.Any committees = 1 [(cosmos_proto.accepts_interface) = "Committee"];
}
// QueryCommitteeRequest defines the request type for querying x/committee committee.
message QueryCommitteeRequest {
uint64 committee_id = 1;
}
// QueryCommitteeResponse defines the response type for querying x/committee committee.
message QueryCommitteeResponse {
google.protobuf.Any committee = 1 [(cosmos_proto.accepts_interface) = "Committee"];
}
// QueryProposalsRequest defines the request type for querying x/committee proposals.
message QueryProposalsRequest {
uint64 committee_id = 1;
}
// QueryProposalsResponse defines the response type for querying x/committee proposals.
message QueryProposalsResponse {
repeated QueryProposalResponse proposals = 1 [(gogoproto.nullable) = false];
}
// QueryProposalRequest defines the request type for querying x/committee proposal.
message QueryProposalRequest {
uint64 proposal_id = 1;
}
// QueryProposalResponse defines the response type for querying x/committee proposal.
message QueryProposalResponse {
google.protobuf.Any pub_proposal = 1 [
(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content",
(gogoproto.customname) = "PubProposal"
];
uint64 id = 2 [(gogoproto.customname) = "ID"];
uint64 committee_id = 3 [(gogoproto.customname) = "CommitteeID"];
google.protobuf.Timestamp deadline = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
}
// QueryNextProposalIDRequest defines the request type for querying x/committee NextProposalID.
message QueryNextProposalIDRequest {}
// QueryNextProposalIDRequest defines the response type for querying x/committee NextProposalID.
message QueryNextProposalIDResponse {
uint64 next_proposal_id = 1 [(gogoproto.customname) = "NextProposalID"];
}
// QueryVotesRequest defines the request type for querying x/committee votes.
message QueryVotesRequest {
uint64 proposal_id = 1;
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// QueryVotesResponse defines the response type for querying x/committee votes.
message QueryVotesResponse {
// votes defined the queried votes.
repeated QueryVoteResponse votes = 1 [(gogoproto.nullable) = false];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryVoteRequest defines the request type for querying x/committee vote.
message QueryVoteRequest {
uint64 proposal_id = 1;
string voter = 2;
}
// QueryVoteResponse defines the response type for querying x/committee vote.
message QueryVoteResponse {
uint64 proposal_id = 1 [(gogoproto.customname) = "ProposalID"];
string voter = 2;
VoteType vote_type = 3;
}
// QueryTallyRequest defines the request type for querying x/committee tally.
message QueryTallyRequest {
uint64 proposal_id = 1;
}
// QueryTallyResponse defines the response type for querying x/committee tally.
message QueryTallyResponse {
uint64 proposal_id = 1 [(gogoproto.customname) = "ProposalID"];
string yes_votes = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string no_votes = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string current_votes = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string possible_votes = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string vote_threshold = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string quorum = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// QueryRawParamsRequest defines the request type for querying x/committee raw params.
message QueryRawParamsRequest {
string subspace = 1;
string key = 2;
}
// QueryRawParamsResponse defines the response type for querying x/committee raw params.
message QueryRawParamsResponse {
string raw_data = 1;
}

View File

@ -1,40 +0,0 @@
syntax = "proto3";
package kava.committee.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "kava/committee/v1beta1/genesis.proto";
option go_package = "github.com/kava-labs/kava/x/committee/types";
option (gogoproto.goproto_getters_all) = false;
// Msg defines the committee Msg service
service Msg {
// SubmitProposal defines a method for submitting a committee proposal
rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse);
// Vote defines a method for voting on a proposal
rpc Vote(MsgVote) returns (MsgVoteResponse);
}
// MsgSubmitProposal is used by committee members to create a new proposal that they can vote on.
message MsgSubmitProposal {
google.protobuf.Any pub_proposal = 1 [(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content"];
string proposer = 2;
uint64 committee_id = 3 [(gogoproto.customname) = "CommitteeID"];
}
// MsgSubmitProposalResponse defines the SubmitProposal response type
message MsgSubmitProposalResponse {
uint64 proposal_id = 1 [(gogoproto.customname) = "ProposalID"];
}
// MsgVote is submitted by committee members to vote on proposals.
message MsgVote {
uint64 proposal_id = 1 [(gogoproto.customname) = "ProposalID"];
string voter = 2;
VoteType vote_type = 3;
}
// MsgVoteResponse defines the Vote response type
message MsgVoteResponse {}

View File

@ -1,18 +0,0 @@
syntax = "proto3";
package kava.community.v1beta1;
import "gogoproto/gogo.proto";
import "kava/community/v1beta1/params.proto";
import "kava/community/v1beta1/staking.proto";
option go_package = "github.com/kava-labs/kava/x/community/types";
// GenesisState defines the community module's genesis state.
message GenesisState {
// params defines all the parameters related to commmunity
Params params = 1 [(gogoproto.nullable) = false];
// StakingRewardsState stores the internal staking reward data required to
// track staking rewards across blocks
StakingRewardsState staking_rewards_state = 2 [(gogoproto.nullable) = false];
}

View File

@ -1,35 +0,0 @@
syntax = "proto3";
package kava.community.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/community/types";
// Params defines the parameters of the community module.
message Params {
option (gogoproto.equal) = true;
// upgrade_time_disable_inflation is the time at which to disable mint and kavadist module inflation.
// If set to 0, inflation will be disabled from block 1.
google.protobuf.Timestamp upgrade_time_disable_inflation = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
// staking_rewards_per_second is the amount paid out to delegators each block from the community account
string staking_rewards_per_second = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// upgrade_time_set_staking_rewards_per_second is the initial staking_rewards_per_second to set
// and use when the disable inflation time is reached
string upgrade_time_set_staking_rewards_per_second = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}

View File

@ -1,57 +0,0 @@
syntax = "proto3";
package kava.community.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/community/types";
// CommunityPoolLendDepositProposal deposits from the community pool into lend
message CommunityPoolLendDepositProposal {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
repeated cosmos.base.v1beta1.Coin amount = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
// CommunityPoolLendWithdrawProposal withdraws a lend position back to the community pool
message CommunityPoolLendWithdrawProposal {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
repeated cosmos.base.v1beta1.Coin amount = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
// CommunityCDPRepayDebtProposal repays a cdp debt position owned by the community module
// This proposal exists primarily to allow committees to repay community module cdp debts.
message CommunityCDPRepayDebtProposal {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
string collateral_type = 3;
cosmos.base.v1beta1.Coin payment = 4 [(gogoproto.nullable) = false];
}
// CommunityCDPWithdrawCollateralProposal withdraws cdp collateral owned by the community module
// This proposal exists primarily to allow committees to withdraw community module cdp collateral.
message CommunityCDPWithdrawCollateralProposal {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
string collateral_type = 3;
cosmos.base.v1beta1.Coin collateral = 4 [(gogoproto.nullable) = false];
}

View File

@ -1,81 +0,0 @@
syntax = "proto3";
package kava.community.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kava/community/v1beta1/params.proto";
option go_package = "github.com/kava-labs/kava/x/community/types";
// Query defines the gRPC querier service for x/community.
service Query {
// Params queires the module params.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/community/v1beta1/params";
}
// Balance queries the balance of all coins of x/community module.
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
option (google.api.http).get = "/kava/community/v1beta1/balance";
}
// TotalBalance queries the balance of all coins, including x/distribution,
// x/community, and supplied balances.
rpc TotalBalance(QueryTotalBalanceRequest) returns (QueryTotalBalanceResponse) {
option (google.api.http).get = "/kava/community/v1beta1/total_balance";
}
// AnnualizedRewards calculates and returns the current annualized reward percentages,
// like staking rewards, for the chain.
rpc AnnualizedRewards(QueryAnnualizedRewardsRequest) returns (QueryAnnualizedRewardsResponse) {
option (google.api.http).get = "/kava/community/v1beta1/annualized_rewards";
}
}
// QueryParams defines the request type for querying x/community params.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/community params.
message QueryParamsResponse {
// params represents the community module parameters
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryBalanceRequest defines the request type for querying x/community balance.
message QueryBalanceRequest {}
// QueryBalanceResponse defines the response type for querying x/community balance.
message QueryBalanceResponse {
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
// QueryTotalBalanceRequest defines the request type for querying total community pool balance.
message QueryTotalBalanceRequest {}
// QueryTotalBalanceResponse defines the response type for querying total
// community pool balance. This matches the x/distribution CommunityPool query response.
message QueryTotalBalanceResponse {
// pool defines community pool's coins.
repeated cosmos.base.v1beta1.DecCoin pool = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(gogoproto.nullable) = false
];
}
// QueryAnnualizedRewardsRequest defines the request type for querying the annualized rewards.
message QueryAnnualizedRewardsRequest {}
// QueryAnnualizedRewardsResponse defines the response type for querying the annualized rewards.
message QueryAnnualizedRewardsResponse {
// staking_rewards is the calculated annualized staking rewards percentage rate
string staking_rewards = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}

View File

@ -1,26 +0,0 @@
syntax = "proto3";
package kava.community.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/community/types";
// StakingRewardsState represents the state of staking reward accumulation between blocks.
message StakingRewardsState {
// last_accumulation_time represents the last block time which rewards where calculated and distributed.
// This may be zero to signal accumulation should start on the next interval.
google.protobuf.Timestamp last_accumulation_time = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
// accumulated_truncation_error represents the sum of previous errors due to truncation on payout
// This value will always be on the interval [0, 1).
string last_truncation_error = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}

View File

@ -1,47 +0,0 @@
syntax = "proto3";
package kava.community.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "kava/community/v1beta1/params.proto";
option go_package = "github.com/kava-labs/kava/x/community/types";
option (gogoproto.equal_all) = true;
// Msg defines the community Msg service.
service Msg {
// FundCommunityPool defines a method to allow an account to directly fund the community module account.
rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse);
// UpdateParams defines a method to allow an account to update the community module parameters.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}
// MsgFundCommunityPool allows an account to directly fund the community module account.
message MsgFundCommunityPool {
option (gogoproto.goproto_getters) = false;
repeated cosmos.base.v1beta1.Coin amount = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type.
message MsgFundCommunityPoolResponse {}
// MsgUpdateParams allows an account to update the community module parameters.
message MsgUpdateParams {
option (gogoproto.goproto_getters) = false;
// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// params defines the x/community parameters to update.
Params params = 2 [(gogoproto.nullable) = false];
}
// MsgUpdateParamsResponse defines the Msg/UpdateParams response type.
message MsgUpdateParamsResponse {}

View File

@ -1,24 +0,0 @@
syntax = "proto3";
package kava.earn.v1beta1;
import "gogoproto/gogo.proto";
import "kava/earn/v1beta1/params.proto";
import "kava/earn/v1beta1/vault.proto";
option go_package = "github.com/kava-labs/kava/x/earn/types";
// GenesisState defines the earn module's genesis state.
message GenesisState {
// params defines all the parameters related to earn
Params params = 1 [(gogoproto.nullable) = false];
// vault_records defines the available vaults
repeated VaultRecord vault_records = 2 [
(gogoproto.castrepeated) = "VaultRecords",
(gogoproto.nullable) = false
];
// share_records defines the owned shares of each vault
repeated VaultShareRecord vault_share_records = 3 [
(gogoproto.castrepeated) = "VaultShareRecords",
(gogoproto.nullable) = false
];
}

View File

@ -1,15 +0,0 @@
syntax = "proto3";
package kava.earn.v1beta1;
import "gogoproto/gogo.proto";
import "kava/earn/v1beta1/vault.proto";
option go_package = "github.com/kava-labs/kava/x/earn/types";
// Params defines the parameters of the earn module.
message Params {
repeated AllowedVault allowed_vaults = 1 [
(gogoproto.castrepeated) = "AllowedVaults",
(gogoproto.nullable) = false
];
}

View File

@ -1,55 +0,0 @@
syntax = "proto3";
package kava.earn.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/earn/types";
// CommunityPoolDepositProposal deposits from the community pool into an earn vault
message CommunityPoolDepositProposal {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// CommunityPoolDepositProposalJSON defines a CommunityPoolDepositProposal with a deposit
message CommunityPoolDepositProposalJSON {
option (gogoproto.goproto_stringer) = true;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin deposit = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
// CommunityPoolWithdrawProposal withdraws from an earn vault back to community pool
message CommunityPoolWithdrawProposal {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// CommunityPoolWithdrawProposalJSON defines a CommunityPoolWithdrawProposal with a deposit
message CommunityPoolWithdrawProposalJSON {
option (gogoproto.goproto_stringer) = true;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin deposit = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

View File

@ -1,160 +0,0 @@
syntax = "proto3";
package kava.earn.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kava/earn/v1beta1/params.proto";
import "kava/earn/v1beta1/strategy.proto";
import "kava/earn/v1beta1/vault.proto";
option go_package = "github.com/kava-labs/kava/x/earn/types";
option (gogoproto.goproto_getters_all) = false;
// Query defines the gRPC querier service for earn module
service Query {
// Params queries all parameters of the earn module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/earn/v1beta1/params";
}
// Vaults queries all vaults
rpc Vaults(QueryVaultsRequest) returns (QueryVaultsResponse) {
option (google.api.http).get = "/kava/earn/v1beta1/vaults";
}
// Vault queries a single vault based on the vault denom
rpc Vault(QueryVaultRequest) returns (QueryVaultResponse) {
option (google.api.http).get = "/kava/earn/v1beta1/vaults/{denom=**}";
}
// Deposits queries deposit details based on depositor address and vault
rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) {
option (google.api.http).get = "/kava/earn/v1beta1/deposits";
}
// TotalSupply returns the total sum of all coins currently locked into the earn module.
rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) {
option (google.api.http).get = "/kava/earn/v1beta1/total_supply";
}
}
// QueryParamsRequest defines the request type for querying x/earn parameters.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/earn parameters.
message QueryParamsResponse {
// params represents the earn module parameters
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryVaultsRequest is the request type for the Query/Vaults RPC method.
message QueryVaultsRequest {}
// QueryVaultsResponse is the response type for the Query/Vaults RPC method.
message QueryVaultsResponse {
// vaults represents the earn module vaults
repeated VaultResponse vaults = 1 [(gogoproto.nullable) = false];
}
// QueryVaultRequest is the request type for the Query/Vault RPC method.
message QueryVaultRequest {
// vault filters vault by denom
string denom = 1;
}
// QueryVaultResponse is the response type for the Query/Vault RPC method.
message QueryVaultResponse {
// vault represents the queried earn module vault
VaultResponse vault = 1 [(gogoproto.nullable) = false];
}
// VaultResponse is the response type for a vault.
message VaultResponse {
// denom represents the denom of the vault
string denom = 1;
// VaultStrategy is the strategy used for this vault.
repeated StrategyType strategies = 2 [(gogoproto.castrepeated) = "StrategyTypes"];
// IsPrivateVault is true if the vault only allows depositors contained in
// AllowedDepositors.
bool is_private_vault = 3;
// AllowedDepositors is a list of addresses that are allowed to deposit to
// this vault if IsPrivateVault is true. Addresses not contained in this list
// are not allowed to deposit into this vault. If IsPrivateVault is false,
// this should be empty and ignored.
repeated string allowed_depositors = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// TotalShares is the total amount of shares issued to depositors.
string total_shares = 5;
// TotalValue is the total value of denom coins supplied to the vault if the
// vault were to be liquidated.
string total_value = 6 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// QueryDepositsRequest is the request type for the Query/Deposits RPC method.
message QueryDepositsRequest {
// depositor optionally filters deposits by depositor
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// denom optionally filters deposits by vault denom
string denom = 2;
// respond with vault value in ukava for bkava vaults
bool value_in_staked_tokens = 3;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 4;
}
// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
message QueryDepositsResponse {
// deposits returns the deposits matching the requested parameters
repeated DepositResponse deposits = 1 [(gogoproto.nullable) = false];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// DepositResponse defines a deposit query response type.
message DepositResponse {
// depositor represents the owner of the deposit.
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Shares represent the issued shares from their corresponding vaults.
repeated VaultShare shares = 2 [
(gogoproto.castrepeated) = "VaultShares",
(gogoproto.nullable) = false
];
// Value represents the total accumulated value of denom coins supplied to
// vaults. This may be greater than or equal to amount_supplied depending on
// the strategy.
repeated cosmos.base.v1beta1.Coin value = 3 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// QueryTotalSupplyRequest defines the request type for Query/TotalSupply method.
message QueryTotalSupplyRequest {}
// TotalSupplyResponse defines the response type for the Query/TotalSupply method.
message QueryTotalSupplyResponse {
// Height is the block height at which these totals apply
int64 height = 1;
// Result is a list of coins supplied to earn
repeated cosmos.base.v1beta1.Coin result = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

View File

@ -1,20 +0,0 @@
syntax = "proto3";
package kava.earn.v1beta1;
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/earn/types";
// StrategyType is the type of strategy that a vault uses to optimize yields.
enum StrategyType {
option (gogoproto.goproto_enum_prefix) = false;
// STRATEGY_TYPE_UNSPECIFIED represents an unspecified or invalid strategy type.
STRATEGY_TYPE_UNSPECIFIED = 0;
// STRATEGY_TYPE_HARD represents the strategy that deposits assets in the Hard
// module.
STRATEGY_TYPE_HARD = 1;
// STRATEGY_TYPE_SAVINGS represents the strategy that deposits assets in the
// Savings module.
STRATEGY_TYPE_SAVINGS = 2;
}

View File

@ -1,57 +0,0 @@
syntax = "proto3";
package kava.earn.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "kava/earn/v1beta1/strategy.proto";
import "kava/earn/v1beta1/vault.proto";
option go_package = "github.com/kava-labs/kava/x/earn/types";
// Msg defines the earn Msg service.
service Msg {
// Deposit defines a method for depositing assets into a vault
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);
// Withdraw defines a method for withdrawing assets into a vault
rpc Withdraw(MsgWithdraw) returns (MsgWithdrawResponse);
}
// MsgDeposit represents a message for depositing assedts into a vault
message MsgDeposit {
option (gogoproto.goproto_getters) = false;
// depositor represents the address to deposit funds from
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Amount represents the token to deposit. The vault corresponds to the denom
// of the amount coin.
cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
// Strategy is the vault strategy to use.
StrategyType strategy = 3;
}
// MsgDepositResponse defines the Msg/Deposit response type.
message MsgDepositResponse {
VaultShare shares = 1 [(gogoproto.nullable) = false];
}
// MsgWithdraw represents a message for withdrawing liquidity from a vault
message MsgWithdraw {
option (gogoproto.goproto_getters) = false;
// from represents the address we are withdrawing for
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Amount represents the token to withdraw. The vault corresponds to the denom
// of the amount coin.
cosmos.base.v1beta1.Coin amount = 2 [(gogoproto.nullable) = false];
// Strategy is the vault strategy to use.
StrategyType strategy = 3;
}
// MsgWithdrawResponse defines the Msg/Withdraw response type.
message MsgWithdrawResponse {
VaultShare shares = 1 [(gogoproto.nullable) = false];
}

View File

@ -1,63 +0,0 @@
syntax = "proto3";
package kava.earn.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "kava/earn/v1beta1/strategy.proto";
option go_package = "github.com/kava-labs/kava/x/earn/types";
// AllowedVault is a vault that is allowed to be created. These can be
// modified via parameter governance.
message AllowedVault {
// Denom is the only supported denomination of the vault for deposits and withdrawals.
string denom = 1;
// VaultStrategy is the strategy used for this vault.
repeated StrategyType strategies = 2 [(gogoproto.castrepeated) = "StrategyTypes"];
// IsPrivateVault is true if the vault only allows depositors contained in
// AllowedDepositors.
bool is_private_vault = 3;
// AllowedDepositors is a list of addresses that are allowed to deposit to
// this vault if IsPrivateVault is true. Addresses not contained in this list
// are not allowed to deposit into this vault. If IsPrivateVault is false,
// this should be empty and ignored.
repeated bytes allowed_depositors = 4 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
}
// VaultRecord is the state of a vault.
message VaultRecord {
// TotalShares is the total distributed number of shares in the vault.
VaultShare total_shares = 1 [(gogoproto.nullable) = false];
}
// VaultShareRecord defines the vault shares owned by a depositor.
message VaultShareRecord {
// Depositor represents the owner of the shares
bytes depositor = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
// Shares represent the vault shares owned by the depositor.
repeated VaultShare shares = 2 [
(gogoproto.castrepeated) = "VaultShares",
(gogoproto.nullable) = false
];
}
// VaultShare defines shares of a vault owned by a depositor.
message VaultShare {
option (gogoproto.goproto_stringer) = false;
string denom = 1;
string amount = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

View File

@ -1,58 +0,0 @@
syntax = "proto3";
package kava.hard.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "kava/hard/v1beta1/hard.proto";
option go_package = "github.com/kava-labs/kava/x/hard/types";
// GenesisState defines the hard module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
repeated GenesisAccumulationTime previous_accumulation_times = 2 [
(gogoproto.castrepeated) = "GenesisAccumulationTimes",
(gogoproto.nullable) = false
];
repeated Deposit deposits = 3 [
(gogoproto.castrepeated) = "Deposits",
(gogoproto.nullable) = false
];
repeated Borrow borrows = 4 [
(gogoproto.castrepeated) = "Borrows",
(gogoproto.nullable) = false
];
repeated cosmos.base.v1beta1.Coin total_supplied = 5 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
repeated cosmos.base.v1beta1.Coin total_borrowed = 6 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
repeated cosmos.base.v1beta1.Coin total_reserves = 7 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// GenesisAccumulationTime stores the previous distribution time and its corresponding denom.
message GenesisAccumulationTime {
string collateral_type = 1;
google.protobuf.Timestamp previous_accumulation_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
string supply_interest_factor = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string borrow_interest_factor = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

View File

@ -1,146 +0,0 @@
syntax = "proto3";
package kava.hard.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/hard/types";
option (gogoproto.goproto_getters_all) = false;
// Params defines the parameters for the hard module.
message Params {
repeated MoneyMarket money_markets = 1 [
(gogoproto.castrepeated) = "MoneyMarkets",
(gogoproto.nullable) = false
];
string minimum_borrow_usd_value = 2 [
(gogoproto.customname) = "MinimumBorrowUSDValue",
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// MoneyMarket is a money market for an individual asset.
message MoneyMarket {
string denom = 1;
BorrowLimit borrow_limit = 2 [(gogoproto.nullable) = false];
string spot_market_id = 3 [(gogoproto.customname) = "SpotMarketID"];
string conversion_factor = 4 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
InterestRateModel interest_rate_model = 5 [(gogoproto.nullable) = false];
string reserve_factor = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string keeper_reward_percentage = 7 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// BorrowLimit enforces restrictions on a money market.
message BorrowLimit {
bool has_max_limit = 1 [(gogoproto.jsontag) = "has_max_limit"];
string maximum_limit = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string loan_to_value = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// InterestRateModel contains information about an asset's interest rate.
message InterestRateModel {
string base_rate_apy = 1 [
(gogoproto.customname) = "BaseRateAPY",
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string base_multiplier = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string kink = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string jump_multiplier = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// Deposit defines an amount of coins deposited into a hard module account.
message Deposit {
string depositor = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
repeated SupplyInterestFactor index = 3 [
(gogoproto.castrepeated) = "SupplyInterestFactors",
(gogoproto.nullable) = false
];
}
// Borrow defines an amount of coins borrowed from a hard module account.
message Borrow {
string borrower = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
repeated BorrowInterestFactor index = 3 [
(gogoproto.castrepeated) = "BorrowInterestFactors",
(gogoproto.nullable) = false
];
}
// SupplyInterestFactor defines an individual borrow interest factor.
message SupplyInterestFactor {
string denom = 1;
string value = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// BorrowInterestFactor defines an individual borrow interest factor.
message BorrowInterestFactor {
string denom = 1;
string value = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// CoinsProto defines a Protobuf wrapper around a Coins slice
message CoinsProto {
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}

View File

@ -1,281 +0,0 @@
syntax = "proto3";
package kava.hard.v1beta1;
import "cosmos/auth/v1beta1/auth.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kava/hard/v1beta1/hard.proto";
option go_package = "github.com/kava-labs/kava/x/hard/types";
// Query defines the gRPC querier service for bep3 module.
service Query {
// Params queries module params.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/params";
}
// Accounts queries module accounts.
rpc Accounts(QueryAccountsRequest) returns (QueryAccountsResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/accounts";
}
// Deposits queries hard deposits.
rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/deposits";
}
// UnsyncedDeposits queries unsynced deposits.
rpc UnsyncedDeposits(QueryUnsyncedDepositsRequest) returns (QueryUnsyncedDepositsResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/unsynced-deposits";
}
// TotalDeposited queries total coins deposited to hard liquidity pools.
rpc TotalDeposited(QueryTotalDepositedRequest) returns (QueryTotalDepositedResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/total-deposited";
}
// Borrows queries hard borrows.
rpc Borrows(QueryBorrowsRequest) returns (QueryBorrowsResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/borrows";
}
// UnsyncedBorrows queries unsynced borrows.
rpc UnsyncedBorrows(QueryUnsyncedBorrowsRequest) returns (QueryUnsyncedBorrowsResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/unsynced-borrows";
}
// TotalBorrowed queries total coins borrowed from hard liquidity pools.
rpc TotalBorrowed(QueryTotalBorrowedRequest) returns (QueryTotalBorrowedResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/total-borrowed";
}
// InterestRate queries the hard module interest rates.
rpc InterestRate(QueryInterestRateRequest) returns (QueryInterestRateResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/interest-rate";
}
// Reserves queries total hard reserve coins.
rpc Reserves(QueryReservesRequest) returns (QueryReservesResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/reserves";
}
// InterestFactors queries hard module interest factors.
rpc InterestFactors(QueryInterestFactorsRequest) returns (QueryInterestFactorsResponse) {
option (google.api.http).get = "/kava/hard/v1beta1/interest-factors";
}
}
// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryAccountsRequest is the request type for the Query/Accounts RPC method.
message QueryAccountsRequest {}
// QueryAccountsResponse is the response type for the Query/Accounts RPC method.
message QueryAccountsResponse {
repeated cosmos.auth.v1beta1.ModuleAccount accounts = 1 [(gogoproto.nullable) = false];
}
// QueryDepositsRequest is the request type for the Query/Deposits RPC method.
message QueryDepositsRequest {
string denom = 1;
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
message QueryDepositsResponse {
repeated DepositResponse deposits = 1 [
(gogoproto.castrepeated) = "DepositResponses",
(gogoproto.nullable) = false
];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryUnsyncedDepositsRequest is the request type for the Query/UnsyncedDeposits RPC method.
message QueryUnsyncedDepositsRequest {
string denom = 1;
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryUnsyncedDepositsResponse is the response type for the Query/UnsyncedDeposits RPC method.
message QueryUnsyncedDepositsResponse {
repeated DepositResponse deposits = 1 [
(gogoproto.castrepeated) = "DepositResponses",
(gogoproto.nullable) = false
];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryTotalDepositedRequest is the request type for the Query/TotalDeposited RPC method.
message QueryTotalDepositedRequest {
string denom = 1;
}
// QueryTotalDepositedResponse is the response type for the Query/TotalDeposited RPC method.
message QueryTotalDepositedResponse {
repeated cosmos.base.v1beta1.Coin supplied_coins = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// QueryBorrowsRequest is the request type for the Query/Borrows RPC method.
message QueryBorrowsRequest {
string denom = 1;
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryBorrowsResponse is the response type for the Query/Borrows RPC method.
message QueryBorrowsResponse {
repeated BorrowResponse borrows = 1 [
(gogoproto.castrepeated) = "BorrowResponses",
(gogoproto.nullable) = false
];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryUnsyncedBorrowsRequest is the request type for the Query/UnsyncedBorrows RPC method.
message QueryUnsyncedBorrowsRequest {
string denom = 1;
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryUnsyncedBorrowsResponse is the response type for the Query/UnsyncedBorrows RPC method.
message QueryUnsyncedBorrowsResponse {
repeated BorrowResponse borrows = 1 [
(gogoproto.castrepeated) = "BorrowResponses",
(gogoproto.nullable) = false
];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryTotalBorrowedRequest is the request type for the Query/TotalBorrowed RPC method.
message QueryTotalBorrowedRequest {
string denom = 1;
}
// QueryTotalBorrowedResponse is the response type for the Query/TotalBorrowed RPC method.
message QueryTotalBorrowedResponse {
repeated cosmos.base.v1beta1.Coin borrowed_coins = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// QueryInterestRateRequest is the request type for the Query/InterestRate RPC method.
message QueryInterestRateRequest {
string denom = 1;
}
// QueryInterestRateResponse is the response type for the Query/InterestRate RPC method.
message QueryInterestRateResponse {
repeated MoneyMarketInterestRate interest_rates = 1 [
(gogoproto.castrepeated) = "MoneyMarketInterestRates",
(gogoproto.nullable) = false
];
}
// QueryReservesRequest is the request type for the Query/Reserves RPC method.
message QueryReservesRequest {
string denom = 1;
}
// QueryReservesResponse is the response type for the Query/Reserves RPC method.
message QueryReservesResponse {
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// QueryInterestFactorsRequest is the request type for the Query/InterestFactors RPC method.
message QueryInterestFactorsRequest {
string denom = 1;
}
// QueryInterestFactorsResponse is the response type for the Query/InterestFactors RPC method.
message QueryInterestFactorsResponse {
repeated InterestFactor interest_factors = 1 [
(gogoproto.castrepeated) = "InterestFactors",
(gogoproto.nullable) = false
];
}
// DepositResponse defines an amount of coins deposited into a hard module account.
message DepositResponse {
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
repeated SupplyInterestFactorResponse index = 3 [
(gogoproto.castrepeated) = "SupplyInterestFactorResponses",
(gogoproto.nullable) = false
];
}
// SupplyInterestFactorResponse defines an individual borrow interest factor.
message SupplyInterestFactorResponse {
string denom = 1;
// sdk.Dec as string
string value = 2;
}
// BorrowResponse defines an amount of coins borrowed from a hard module account.
message BorrowResponse {
string borrower = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
repeated BorrowInterestFactorResponse index = 3 [
(gogoproto.castrepeated) = "BorrowInterestFactorResponses",
(gogoproto.nullable) = false
];
}
// BorrowInterestFactorResponse defines an individual borrow interest factor.
message BorrowInterestFactorResponse {
string denom = 1;
// sdk.Dec as string
string value = 2;
}
// MoneyMarketInterestRate is a unique type returned by interest rate queries
message MoneyMarketInterestRate {
string denom = 1;
// sdk.Dec as String
string supply_interest_rate = 2;
// sdk.Dec as String
string borrow_interest_rate = 3;
}
// InterestFactor is a unique type returned by interest factor queries
message InterestFactor {
string denom = 1;
// sdk.Dec as String
string borrow_interest_factor = 2;
// sdk.Dec as String
string supply_interest_factor = 3;
}

View File

@ -1,80 +0,0 @@
syntax = "proto3";
package kava.hard.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/hard/types";
// Msg defines the hard Msg service.
service Msg {
// Deposit defines a method for depositing funds to hard liquidity pool.
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);
// Withdraw defines a method for withdrawing funds from hard liquidity pool.
rpc Withdraw(MsgWithdraw) returns (MsgWithdrawResponse);
// Borrow defines a method for borrowing funds from hard liquidity pool.
rpc Borrow(MsgBorrow) returns (MsgBorrowResponse);
// Repay defines a method for repaying funds borrowed from hard liquidity pool.
rpc Repay(MsgRepay) returns (MsgRepayResponse);
// Liquidate defines a method for attempting to liquidate a borrower that is over their loan-to-value.
rpc Liquidate(MsgLiquidate) returns (MsgLiquidateResponse);
}
// MsgDeposit defines the Msg/Deposit request type.
message MsgDeposit {
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// MsgDepositResponse defines the Msg/Deposit response type.
message MsgDepositResponse {}
// MsgWithdraw defines the Msg/Withdraw request type.
message MsgWithdraw {
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// MsgWithdrawResponse defines the Msg/Withdraw response type.
message MsgWithdrawResponse {}
// MsgBorrow defines the Msg/Borrow request type.
message MsgBorrow {
string borrower = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// MsgBorrowResponse defines the Msg/Borrow response type.
message MsgBorrowResponse {}
// MsgRepay defines the Msg/Repay request type.
message MsgRepay {
string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 3 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// MsgRepayResponse defines the Msg/Repay response type.
message MsgRepayResponse {}
// MsgLiquidate defines the Msg/Liquidate request type.
message MsgLiquidate {
string keeper = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string borrower = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// MsgLiquidateResponse defines the Msg/Liquidate response type.
message MsgLiquidateResponse {}

View File

@ -1,18 +0,0 @@
syntax = "proto3";
package kava.incentive.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/incentive/types";
// Apy contains the calculated APY for a given collateral type at a specific
// instant in time.
message Apy {
string collateral_type = 1;
string apy = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

View File

@ -1,171 +0,0 @@
syntax = "proto3";
package kava.incentive.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/incentive/types";
option (gogoproto.goproto_getters_all) = false;
// -------------- Base Claim Types, Reward Indexes --------------
// BaseClaim is a claim with a single reward coin types
message BaseClaim {
option (cosmos_proto.implements_interface) = "Claim";
bytes owner = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
cosmos.base.v1beta1.Coin reward = 2 [(gogoproto.nullable) = false];
}
// BaseMultiClaim is a claim with multiple reward coin types
message BaseMultiClaim {
option (cosmos_proto.implements_interface) = "Claim";
bytes owner = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
repeated cosmos.base.v1beta1.Coin reward = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// RewardIndex stores reward accumulation information
message RewardIndex {
string collateral_type = 1;
bytes reward_factor = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// RewardIndexesProto defines a Protobuf wrapper around a RewardIndexes slice
message RewardIndexesProto {
repeated RewardIndex reward_indexes = 1 [
(gogoproto.castrepeated) = "RewardIndexes",
(gogoproto.nullable) = false
];
}
// MultiRewardIndex stores reward accumulation information on multiple reward types
message MultiRewardIndex {
string collateral_type = 1;
repeated RewardIndex reward_indexes = 2 [
(gogoproto.castrepeated) = "RewardIndexes",
(gogoproto.nullable) = false
];
}
// MultiRewardIndexesProto defines a Protobuf wrapper around a MultiRewardIndexes slice
message MultiRewardIndexesProto {
repeated MultiRewardIndex multi_reward_indexes = 1 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
}
// -------------- Custom Claim Types --------------
// USDXMintingClaim is for USDX minting rewards
message USDXMintingClaim {
option (cosmos_proto.implements_interface) = "Claim";
BaseClaim base_claim = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
repeated RewardIndex reward_indexes = 2 [
(gogoproto.castrepeated) = "RewardIndexes",
(gogoproto.nullable) = false
];
}
// HardLiquidityProviderClaim stores the hard liquidity provider rewards that can be claimed by owner
message HardLiquidityProviderClaim {
option (cosmos_proto.implements_interface) = "Claim";
BaseMultiClaim base_claim = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
repeated MultiRewardIndex supply_reward_indexes = 2 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
repeated MultiRewardIndex borrow_reward_indexes = 3 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
}
// DelegatorClaim stores delegation rewards that can be claimed by owner
message DelegatorClaim {
option (cosmos_proto.implements_interface) = "Claim";
BaseMultiClaim base_claim = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
repeated MultiRewardIndex reward_indexes = 2 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
}
// SwapClaim stores the swap rewards that can be claimed by owner
message SwapClaim {
option (cosmos_proto.implements_interface) = "Claim";
BaseMultiClaim base_claim = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
repeated MultiRewardIndex reward_indexes = 2 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
}
// SavingsClaim stores the savings rewards that can be claimed by owner
message SavingsClaim {
option (cosmos_proto.implements_interface) = "Claim";
BaseMultiClaim base_claim = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
repeated MultiRewardIndex reward_indexes = 2 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
}
// EarnClaim stores the earn rewards that can be claimed by owner
message EarnClaim {
option (cosmos_proto.implements_interface) = "Claim";
BaseMultiClaim base_claim = 1 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
repeated MultiRewardIndex reward_indexes = 2 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
}

View File

@ -1,89 +0,0 @@
syntax = "proto3";
package kava.incentive.v1beta1;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "kava/incentive/v1beta1/claims.proto";
import "kava/incentive/v1beta1/params.proto";
// import "cosmos/base/v1beta1/coin.proto";
// import "cosmos/base/v1beta1/coins.proto";
option go_package = "github.com/kava-labs/kava/x/incentive/types";
option (gogoproto.goproto_getters_all) = false;
// AccumulationTime stores the previous reward distribution time and its corresponding collateral type
message AccumulationTime {
string collateral_type = 1;
google.protobuf.Timestamp previous_accumulation_time = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
}
// GenesisRewardState groups together the global state for a particular reward so it can be exported in genesis.
message GenesisRewardState {
repeated AccumulationTime accumulation_times = 1 [
(gogoproto.castrepeated) = "AccumulationTimes",
(gogoproto.nullable) = false
];
repeated MultiRewardIndex multi_reward_indexes = 2 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
}
// GenesisState is the state that must be provided at genesis.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
GenesisRewardState usdx_reward_state = 2 [
(gogoproto.customname) = "USDXRewardState",
(gogoproto.nullable) = false
];
GenesisRewardState hard_supply_reward_state = 3 [(gogoproto.nullable) = false];
GenesisRewardState hard_borrow_reward_state = 4 [(gogoproto.nullable) = false];
GenesisRewardState delegator_reward_state = 5 [(gogoproto.nullable) = false];
GenesisRewardState swap_reward_state = 6 [(gogoproto.nullable) = false];
repeated USDXMintingClaim usdx_minting_claims = 7 [
(gogoproto.customname) = "USDXMintingClaims",
(gogoproto.castrepeated) = "USDXMintingClaims",
(gogoproto.nullable) = false
];
repeated HardLiquidityProviderClaim hard_liquidity_provider_claims = 8 [
(gogoproto.castrepeated) = "HardLiquidityProviderClaims",
(gogoproto.nullable) = false
];
repeated DelegatorClaim delegator_claims = 9 [
(gogoproto.castrepeated) = "DelegatorClaims",
(gogoproto.nullable) = false
];
repeated SwapClaim swap_claims = 10 [
(gogoproto.castrepeated) = "SwapClaims",
(gogoproto.nullable) = false
];
GenesisRewardState savings_reward_state = 11 [(gogoproto.nullable) = false];
repeated SavingsClaim savings_claims = 12 [
(gogoproto.castrepeated) = "SavingsClaims",
(gogoproto.nullable) = false
];
GenesisRewardState earn_reward_state = 13 [(gogoproto.nullable) = false];
repeated EarnClaim earn_claims = 14 [
(gogoproto.castrepeated) = "EarnClaims",
(gogoproto.nullable) = false
];
}

View File

@ -1,121 +0,0 @@
syntax = "proto3";
package kava.incentive.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/incentive/types";
option (gogoproto.goproto_getters_all) = false;
// RewardPeriod stores the state of an ongoing reward
message RewardPeriod {
bool active = 1;
string collateral_type = 2;
google.protobuf.Timestamp start = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
google.protobuf.Timestamp end = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
cosmos.base.v1beta1.Coin rewards_per_second = 5 [(gogoproto.nullable) = false];
}
// MultiRewardPeriod supports multiple reward types
message MultiRewardPeriod {
bool active = 1;
string collateral_type = 2;
google.protobuf.Timestamp start = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
google.protobuf.Timestamp end = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
repeated cosmos.base.v1beta1.Coin rewards_per_second = 5 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// Multiplier amount the claim rewards get increased by, along with how long the claim rewards are locked
message Multiplier {
string name = 1;
int64 months_lockup = 2;
bytes factor = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// MultipliersPerDenom is a map of denoms to a set of multipliers
message MultipliersPerDenom {
string denom = 1;
repeated Multiplier multipliers = 2 [
(gogoproto.castrepeated) = "Multipliers",
(gogoproto.nullable) = false
];
}
// Params
message Params {
repeated RewardPeriod usdx_minting_reward_periods = 1 [
(gogoproto.customname) = "USDXMintingRewardPeriods",
(gogoproto.castrepeated) = "RewardPeriods",
(gogoproto.nullable) = false
];
repeated MultiRewardPeriod hard_supply_reward_periods = 2 [
(gogoproto.castrepeated) = "MultiRewardPeriods",
(gogoproto.nullable) = false
];
repeated MultiRewardPeriod hard_borrow_reward_periods = 3 [
(gogoproto.castrepeated) = "MultiRewardPeriods",
(gogoproto.nullable) = false
];
repeated MultiRewardPeriod delegator_reward_periods = 4 [
(gogoproto.castrepeated) = "MultiRewardPeriods",
(gogoproto.nullable) = false
];
repeated MultiRewardPeriod swap_reward_periods = 5 [
(gogoproto.castrepeated) = "MultiRewardPeriods",
(gogoproto.nullable) = false
];
repeated MultipliersPerDenom claim_multipliers = 6 [
(gogoproto.castrepeated) = "MultipliersPerDenoms",
(gogoproto.nullable) = false
];
google.protobuf.Timestamp claim_end = 7 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
repeated MultiRewardPeriod savings_reward_periods = 8 [
(gogoproto.castrepeated) = "MultiRewardPeriods",
(gogoproto.nullable) = false
];
repeated MultiRewardPeriod earn_reward_periods = 9 [
(gogoproto.castrepeated) = "MultiRewardPeriods",
(gogoproto.nullable) = false
];
}

View File

@ -1,130 +0,0 @@
syntax = "proto3";
package kava.incentive.v1beta1;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kava/incentive/v1beta1/apy.proto";
import "kava/incentive/v1beta1/claims.proto";
import "kava/incentive/v1beta1/params.proto";
option go_package = "github.com/kava-labs/kava/x/incentive/types";
// Query defines the gRPC querier service for incentive module.
service Query {
// Params queries module params.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/incentive/v1beta1/params";
}
// Rewards queries reward information for a given user.
rpc Rewards(QueryRewardsRequest) returns (QueryRewardsResponse) {
option (google.api.http).get = "/kava/incentive/v1beta1/rewards";
}
// Rewards queries the reward factors.
rpc RewardFactors(QueryRewardFactorsRequest) returns (QueryRewardFactorsResponse) {
option (google.api.http).get = "/kava/incentive/v1beta1/reward_factors";
}
// Apy queries incentive reward apy for a reward.
rpc Apy(QueryApyRequest) returns (QueryApyResponse) {
option (google.api.http).get = "/kava/incentive/v1beta1/apy";
}
}
// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryRewardsRequest is the request type for the Query/Rewards RPC method.
message QueryRewardsRequest {
// owner is the address of the user to query rewards for.
string owner = 1;
// reward_type is the type of reward to query rewards for, e.g. hard, earn,
// swap.
string reward_type = 2;
// unsynchronized is a flag to query rewards that are not simulated for reward
// synchronized for the current block.
bool unsynchronized = 3;
}
// QueryRewardsResponse is the response type for the Query/Rewards RPC method.
message QueryRewardsResponse {
repeated USDXMintingClaim usdx_minting_claims = 1 [
(gogoproto.customname) = "USDXMintingClaims",
(gogoproto.castrepeated) = "USDXMintingClaims",
(gogoproto.nullable) = false
];
repeated HardLiquidityProviderClaim hard_liquidity_provider_claims = 2 [
(gogoproto.castrepeated) = "HardLiquidityProviderClaims",
(gogoproto.nullable) = false
];
repeated DelegatorClaim delegator_claims = 3 [
(gogoproto.castrepeated) = "DelegatorClaims",
(gogoproto.nullable) = false
];
repeated SwapClaim swap_claims = 4 [
(gogoproto.castrepeated) = "SwapClaims",
(gogoproto.nullable) = false
];
repeated SavingsClaim savings_claims = 5 [
(gogoproto.castrepeated) = "SavingsClaims",
(gogoproto.nullable) = false
];
repeated EarnClaim earn_claims = 6 [
(gogoproto.castrepeated) = "EarnClaims",
(gogoproto.nullable) = false
];
}
// QueryRewardFactorsRequest is the request type for the Query/RewardFactors RPC method.
message QueryRewardFactorsRequest {}
// QueryRewardFactorsResponse is the response type for the Query/RewardFactors RPC method.
message QueryRewardFactorsResponse {
repeated RewardIndex usdx_minting_reward_factors = 1 [
(gogoproto.castrepeated) = "RewardIndexes",
(gogoproto.nullable) = false
];
repeated MultiRewardIndex hard_supply_reward_factors = 2 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
repeated MultiRewardIndex hard_borrow_reward_factors = 3 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
repeated MultiRewardIndex delegator_reward_factors = 4 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
repeated MultiRewardIndex swap_reward_factors = 5 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
repeated MultiRewardIndex savings_reward_factors = 6 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
repeated MultiRewardIndex earn_reward_factors = 7 [
(gogoproto.castrepeated) = "MultiRewardIndexes",
(gogoproto.nullable) = false
];
}
// QueryApysRequest is the request type for the Query/Apys RPC method.
message QueryApyRequest {}
// QueryApysResponse is the response type for the Query/Apys RPC method.
message QueryApyResponse {
repeated Apy earn = 1 [(gogoproto.nullable) = false];
}

View File

@ -1,124 +0,0 @@
syntax = "proto3";
package kava.incentive.v1beta1;
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/incentive/types";
// Msg defines the incentive Msg service.
service Msg {
// ClaimUSDXMintingReward is a message type used to claim USDX minting rewards
rpc ClaimUSDXMintingReward(MsgClaimUSDXMintingReward) returns (MsgClaimUSDXMintingRewardResponse);
// ClaimHardReward is a message type used to claim Hard liquidity provider rewards
rpc ClaimHardReward(MsgClaimHardReward) returns (MsgClaimHardRewardResponse);
// ClaimDelegatorReward is a message type used to claim delegator rewards
rpc ClaimDelegatorReward(MsgClaimDelegatorReward) returns (MsgClaimDelegatorRewardResponse);
// ClaimSwapReward is a message type used to claim swap rewards
rpc ClaimSwapReward(MsgClaimSwapReward) returns (MsgClaimSwapRewardResponse);
// ClaimSavingsReward is a message type used to claim savings rewards
rpc ClaimSavingsReward(MsgClaimSavingsReward) returns (MsgClaimSavingsRewardResponse);
// ClaimEarnReward is a message type used to claim earn rewards
rpc ClaimEarnReward(MsgClaimEarnReward) returns (MsgClaimEarnRewardResponse);
}
// Selection is a pair of denom and multiplier name. It holds the choice of multiplier a user makes when they claim a
// denom.
message Selection {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string denom = 1;
string multiplier_name = 2;
}
// MsgClaimUSDXMintingReward message type used to claim USDX minting rewards
message MsgClaimUSDXMintingReward {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
string multiplier_name = 2;
}
// MsgClaimUSDXMintingRewardResponse defines the Msg/ClaimUSDXMintingReward response type.
message MsgClaimUSDXMintingRewardResponse {}
// MsgClaimHardReward message type used to claim Hard liquidity provider rewards
message MsgClaimHardReward {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
repeated Selection denoms_to_claim = 2 [
(gogoproto.castrepeated) = "Selections",
(gogoproto.nullable) = false
];
}
// MsgClaimHardRewardResponse defines the Msg/ClaimHardReward response type.
message MsgClaimHardRewardResponse {}
// MsgClaimDelegatorReward message type used to claim delegator rewards
message MsgClaimDelegatorReward {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
repeated Selection denoms_to_claim = 2 [
(gogoproto.castrepeated) = "Selections",
(gogoproto.nullable) = false
];
}
// MsgClaimDelegatorRewardResponse defines the Msg/ClaimDelegatorReward response type.
message MsgClaimDelegatorRewardResponse {}
// MsgClaimSwapReward message type used to claim delegator rewards
message MsgClaimSwapReward {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
repeated Selection denoms_to_claim = 2 [
(gogoproto.castrepeated) = "Selections",
(gogoproto.nullable) = false
];
}
// MsgClaimSwapRewardResponse defines the Msg/ClaimSwapReward response type.
message MsgClaimSwapRewardResponse {}
// MsgClaimSavingsReward message type used to claim savings rewards
message MsgClaimSavingsReward {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
repeated Selection denoms_to_claim = 2 [
(gogoproto.castrepeated) = "Selections",
(gogoproto.nullable) = false
];
}
// MsgClaimSavingsRewardResponse defines the Msg/ClaimSavingsReward response type.
message MsgClaimSavingsRewardResponse {}
// MsgClaimEarnReward message type used to claim earn rewards
message MsgClaimEarnReward {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
repeated Selection denoms_to_claim = 2 [
(gogoproto.castrepeated) = "Selections",
(gogoproto.nullable) = false
];
}
// MsgClaimEarnRewardResponse defines the Msg/ClaimEarnReward response type.
message MsgClaimEarnRewardResponse {}

View File

@ -1,64 +0,0 @@
syntax = "proto3";
package kava.issuance.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
option go_package = "github.com/kava-labs/kava/x/issuance/types";
// GenesisState defines the issuance module's genesis state.
message GenesisState {
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
repeated AssetSupply supplies = 2 [(gogoproto.nullable) = false];
}
// Params defines the parameters for the issuance module.
message Params {
option (gogoproto.goproto_stringer) = false;
repeated Asset assets = 1 [(gogoproto.nullable) = false];
}
// Asset type for assets in the issuance module
message Asset {
option (gogoproto.goproto_stringer) = false;
string owner = 1;
string denom = 2;
repeated string blocked_addresses = 3;
bool paused = 4;
bool blockable = 5;
RateLimit rate_limit = 6 [(gogoproto.nullable) = false];
}
// RateLimit parameters for rate-limiting the supply of an issued asset
message RateLimit {
bool active = 1;
bytes limit = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "limit,omitempty"
];
google.protobuf.Duration time_period = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
}
// AssetSupply contains information about an asset's rate-limited supply (the
// total supply of the asset is tracked in the top-level supply module)
message AssetSupply {
option (gogoproto.goproto_stringer) = false;
cosmos.base.v1beta1.Coin current_supply = 1 [(gogoproto.nullable) = false];
google.protobuf.Duration time_elapsed = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
}

View File

@ -1,24 +0,0 @@
syntax = "proto3";
package kava.issuance.v1beta1;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kava/issuance/v1beta1/genesis.proto";
option go_package = "github.com/kava-labs/kava/x/issuance/types";
// Query defines the gRPC querier service for issuance module
service Query {
// Params queries all parameters of the issuance module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/issuance/v1beta1/params";
}
}
// QueryParamsRequest defines the request type for querying x/issuance parameters.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/issuance parameters.
message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}

View File

@ -1,89 +0,0 @@
syntax = "proto3";
package kava.issuance.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/issuance/types";
// Msg defines the issuance Msg service.
service Msg {
// IssueTokens message type used by the issuer to issue new tokens
rpc IssueTokens(MsgIssueTokens) returns (MsgIssueTokensResponse);
// RedeemTokens message type used by the issuer to redeem (burn) tokens
rpc RedeemTokens(MsgRedeemTokens) returns (MsgRedeemTokensResponse);
// BlockAddress message type used by the issuer to block an address from holding or transferring tokens
rpc BlockAddress(MsgBlockAddress) returns (MsgBlockAddressResponse);
// UnblockAddress message type used by the issuer to unblock an address from holding or transferring tokens
rpc UnblockAddress(MsgUnblockAddress) returns (MsgUnblockAddressResponse);
// SetPauseStatus message type used to pause or unpause status
rpc SetPauseStatus(MsgSetPauseStatus) returns (MsgSetPauseStatusResponse);
}
// MsgIssueTokens represents a message used by the issuer to issue new tokens
message MsgIssueTokens {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
cosmos.base.v1beta1.Coin tokens = 2 [(gogoproto.nullable) = false];
string receiver = 3;
}
// MsgIssueTokensResponse defines the Msg/IssueTokens response type.
message MsgIssueTokensResponse {}
// MsgRedeemTokens represents a message used by the issuer to redeem (burn) tokens
message MsgRedeemTokens {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
cosmos.base.v1beta1.Coin tokens = 2 [(gogoproto.nullable) = false];
}
// MsgRedeemTokensResponse defines the Msg/RedeemTokens response type.
message MsgRedeemTokensResponse {}
// MsgBlockAddress represents a message used by the issuer to block an address from holding or transferring tokens
message MsgBlockAddress {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
string denom = 2;
string blocked_address = 3;
}
// MsgBlockAddressResponse defines the Msg/BlockAddress response type.
message MsgBlockAddressResponse {}
// MsgUnblockAddress message type used by the issuer to unblock an address from holding or transferring tokens
message MsgUnblockAddress {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
string denom = 2;
string blocked_address = 3;
}
// MsgUnblockAddressResponse defines the Msg/UnblockAddress response type.
message MsgUnblockAddressResponse {}
// MsgSetPauseStatus message type used by the issuer to pause or unpause status
message MsgSetPauseStatus {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string sender = 1;
string denom = 2;
bool status = 3;
}
// MsgSetPauseStatusResponse defines the Msg/SetPauseStatus response type.
message MsgSetPauseStatusResponse {}

View File

@ -1,18 +0,0 @@
syntax = "proto3";
package kava.kavadist.v1beta1;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "kava/kavadist/v1beta1/params.proto";
option go_package = "github.com/kava-labs/kava/x/kavadist/types";
// GenesisState defines the kavadist module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
google.protobuf.Timestamp previous_block_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
}

View File

@ -1,83 +0,0 @@
syntax = "proto3";
package kava.kavadist.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/kavadist/types";
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.goproto_stringer_all) = false;
// Params governance parameters for kavadist module
message Params {
bool active = 1;
repeated Period periods = 3 [(gogoproto.nullable) = false];
InfrastructureParams infrastructure_params = 4 [(gogoproto.nullable) = false];
}
// InfrastructureParams define the parameters for infrastructure rewards.
message InfrastructureParams {
repeated Period infrastructure_periods = 1 [
(gogoproto.castrepeated) = "Periods",
(gogoproto.nullable) = false
];
repeated CoreReward core_rewards = 2 [
(gogoproto.castrepeated) = "CoreRewards",
(gogoproto.nullable) = false
];
repeated PartnerReward partner_rewards = 3 [
(gogoproto.castrepeated) = "PartnerRewards",
(gogoproto.nullable) = false
];
option (gogoproto.goproto_stringer) = true;
}
// CoreReward defines the reward weights for core infrastructure providers.
message CoreReward {
bytes address = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
string weight = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
option (gogoproto.goproto_stringer) = true;
}
// PartnerRewards defines the reward schedule for partner infrastructure providers.
message PartnerReward {
bytes address = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
cosmos.base.v1beta1.Coin rewards_per_second = 2 [(gogoproto.nullable) = false];
option (gogoproto.goproto_stringer) = true;
}
// Period stores the specified start and end dates, and the inflation, expressed as a decimal
// representing the yearly APR of KAVA tokens that will be minted during that period
message Period {
option (gogoproto.equal) = true;
// example "2020-03-01T15:20:00Z"
google.protobuf.Timestamp start = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
// example "2020-06-01T15:20:00Z"
google.protobuf.Timestamp end = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
// example "1.000000003022265980" - 10% inflation
bytes inflation = 3 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec"
];
}

View File

@ -1,44 +0,0 @@
syntax = "proto3";
package kava.kavadist.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/kavadist/types";
// CommunityPoolMultiSpendProposal spends from the community pool by sending to one or more
// addresses
message CommunityPoolMultiSpendProposal {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
repeated MultiSpendRecipient recipient_list = 3 [(gogoproto.nullable) = false];
}
// CommunityPoolMultiSpendProposalJSON defines a CommunityPoolMultiSpendProposal with a deposit
message CommunityPoolMultiSpendProposalJSON {
option (gogoproto.goproto_stringer) = true;
option (gogoproto.goproto_getters) = false;
string title = 1;
string description = 2;
repeated MultiSpendRecipient recipient_list = 3 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin deposit = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
// MultiSpendRecipient defines a recipient and the amount of coins they are receiving
message MultiSpendRecipient {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
string address = 1;
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

View File

@ -1,41 +0,0 @@
syntax = "proto3";
package kava.kavadist.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kava/kavadist/v1beta1/params.proto";
option go_package = "github.com/kava-labs/kava/x/kavadist/types";
// Query defines the gRPC querier service.
service Query {
// Params queries the parameters of x/kavadist module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/kavadist/v1beta1/parameters";
}
// Balance queries the balance of all coins of x/kavadist module.
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
option (google.api.http).get = "/kava/kavadist/v1beta1/balance";
}
}
// QueryParamsRequest defines the request type for querying x/kavadist parameters.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/kavadist parameters.
message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryBalanceRequest defines the request type for querying x/kavadist balance.
message QueryBalanceRequest {}
// QueryBalanceResponse defines the response type for querying x/kavadist balance.
message QueryBalanceResponse {
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

View File

@ -1,52 +0,0 @@
syntax = "proto3";
package kava.liquid.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
option go_package = "github.com/kava-labs/kava/x/liquid/types";
option (gogoproto.goproto_getters_all) = false;
// Query defines the gRPC querier service for liquid module
service Query {
// DelegatedBalance returns an account's vesting and vested coins currently delegated to validators.
// It ignores coins in unbonding delegations.
rpc DelegatedBalance(QueryDelegatedBalanceRequest) returns (QueryDelegatedBalanceResponse) {
option (google.api.http).get = "/kava/liquid/v1beta1/delegated_balance/{delegator}";
}
// TotalSupply returns the total sum of all coins currently locked into the liquid module.
rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) {
option (google.api.http).get = "/kava/liquid/v1beta1/total_supply";
}
}
// QueryDelegatedBalanceRequest defines the request type for Query/DelegatedBalance method.
message QueryDelegatedBalanceRequest {
// delegator is the address of the account to query
string delegator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// DelegatedBalanceResponse defines the response type for the Query/DelegatedBalance method.
message QueryDelegatedBalanceResponse {
// vested is the amount of all delegated coins that have vested (ie not locked)
cosmos.base.v1beta1.Coin vested = 1 [(gogoproto.nullable) = false];
// vesting is the amount of all delegated coins that are still vesting (ie locked)
cosmos.base.v1beta1.Coin vesting = 2 [(gogoproto.nullable) = false];
}
// QueryTotalSupplyRequest defines the request type for Query/TotalSupply method.
message QueryTotalSupplyRequest {}
// TotalSupplyResponse defines the response type for the Query/TotalSupply method.
message QueryTotalSupplyResponse {
// Height is the block height at which these totals apply
int64 height = 1;
// Result is a list of coins supplied to liquid
repeated cosmos.base.v1beta1.Coin result = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

View File

@ -1,53 +0,0 @@
syntax = "proto3";
package kava.liquid.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/liquid/types";
// Msg defines the liquid Msg service.
service Msg {
// MintDerivative defines a method for converting a delegation into staking deriviatives.
rpc MintDerivative(MsgMintDerivative) returns (MsgMintDerivativeResponse);
// BurnDerivative defines a method for converting staking deriviatives into a delegation.
rpc BurnDerivative(MsgBurnDerivative) returns (MsgBurnDerivativeResponse);
}
// MsgMintDerivative defines the Msg/MintDerivative request type.
message MsgMintDerivative {
// sender is the owner of the delegation to be converted
string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator is the validator of the delegation to be converted
string validator = 2;
// amount is the quantity of staked assets to be converted
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// MsgMintDerivativeResponse defines the Msg/MintDerivative response type.
message MsgMintDerivativeResponse {
// received is the amount of staking derivative minted and sent to the sender
cosmos.base.v1beta1.Coin received = 1 [(gogoproto.nullable) = false];
}
// MsgBurnDerivative defines the Msg/BurnDerivative request type.
message MsgBurnDerivative {
// sender is the owner of the derivatives to be converted
string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator is the validator of the derivatives to be converted
string validator = 2;
// amount is the quantity of derivatives to be converted
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// MsgBurnDerivativeResponse defines the Msg/BurnDerivative response type.
message MsgBurnDerivativeResponse {
// received is the number of delegation shares sent to the sender
string received = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

View File

@ -1,20 +0,0 @@
syntax = "proto3";
package kava.pricefeed.v1beta1;
import "gogoproto/gogo.proto";
import "kava/pricefeed/v1beta1/store.proto";
option go_package = "github.com/kava-labs/kava/x/pricefeed/types";
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
// GenesisState defines the pricefeed module's genesis state.
message GenesisState {
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
repeated PostedPrice posted_prices = 2 [
(gogoproto.castrepeated) = "PostedPrices",
(gogoproto.nullable) = false
];
}

View File

@ -1,163 +0,0 @@
syntax = "proto3";
package kava.pricefeed.v1beta1;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "kava/pricefeed/v1beta1/store.proto";
option go_package = "github.com/kava-labs/kava/x/pricefeed/types";
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
// Query defines the gRPC querier service for pricefeed module
service Query {
// Params queries all parameters of the pricefeed module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/pricefeed/v1beta1/params";
}
// Price queries price details based on a market
rpc Price(QueryPriceRequest) returns (QueryPriceResponse) {
option (google.api.http).get = "/kava/pricefeed/v1beta1/prices/{market_id}";
}
// Prices queries all prices
rpc Prices(QueryPricesRequest) returns (QueryPricesResponse) {
option (google.api.http).get = "/kava/pricefeed/v1beta1/prices";
}
// RawPrices queries all raw prices based on a market
rpc RawPrices(QueryRawPricesRequest) returns (QueryRawPricesResponse) {
option (google.api.http).get = "/kava/pricefeed/v1beta1/rawprices/{market_id}";
}
// Oracles queries all oracles based on a market
rpc Oracles(QueryOraclesRequest) returns (QueryOraclesResponse) {
option (google.api.http).get = "/kava/pricefeed/v1beta1/oracles/{market_id}";
}
// Markets queries all markets
rpc Markets(QueryMarketsRequest) returns (QueryMarketsResponse) {
option (google.api.http).get = "/kava/pricefeed/v1beta1/markets";
}
}
// QueryParamsRequest defines the request type for querying x/pricefeed
// parameters.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/pricefeed
// parameters.
message QueryParamsResponse {
option (gogoproto.goproto_getters) = false;
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryPriceRequest is the request type for the Query/PriceRequest RPC method.
message QueryPriceRequest {
option (gogoproto.goproto_getters) = false;
string market_id = 1;
}
// QueryPriceResponse is the response type for the Query/Prices RPC method.
message QueryPriceResponse {
option (gogoproto.goproto_getters) = false;
CurrentPriceResponse price = 1 [(gogoproto.nullable) = false];
}
// QueryPricesRequest is the request type for the Query/Prices RPC method.
message QueryPricesRequest {}
// QueryPricesResponse is the response type for the Query/Prices RPC method.
message QueryPricesResponse {
option (gogoproto.goproto_getters) = false;
repeated CurrentPriceResponse prices = 1 [
(gogoproto.castrepeated) = "CurrentPriceResponses",
(gogoproto.nullable) = false
];
}
// QueryRawPricesRequest is the request type for the Query/RawPrices RPC method.
message QueryRawPricesRequest {
option (gogoproto.goproto_getters) = false;
string market_id = 1;
}
// QueryRawPricesResponse is the response type for the Query/RawPrices RPC
// method.
message QueryRawPricesResponse {
option (gogoproto.goproto_getters) = false;
repeated PostedPriceResponse raw_prices = 1 [
(gogoproto.castrepeated) = "PostedPriceResponses",
(gogoproto.nullable) = false
];
}
// QueryOraclesRequest is the request type for the Query/Oracles RPC method.
message QueryOraclesRequest {
option (gogoproto.goproto_getters) = false;
string market_id = 1;
}
// QueryOraclesResponse is the response type for the Query/Oracles RPC method.
message QueryOraclesResponse {
option (gogoproto.goproto_getters) = false;
// List of oracle addresses
repeated string oracles = 1;
}
// QueryMarketsRequest is the request type for the Query/Markets RPC method.
message QueryMarketsRequest {}
// QueryMarketsResponse is the response type for the Query/Markets RPC method.
message QueryMarketsResponse {
option (gogoproto.goproto_getters) = false;
// List of markets
repeated MarketResponse markets = 1 [
(gogoproto.castrepeated) = "MarketResponses",
(gogoproto.nullable) = false
];
}
// PostedPriceResponse defines a price for market posted by a specific oracle.
message PostedPriceResponse {
string market_id = 1 [(gogoproto.customname) = "MarketID"];
string oracle_address = 2;
string price = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
google.protobuf.Timestamp expiry = 4 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
}
// CurrentPriceResponse defines a current price for a particular market in the pricefeed
// module.
message CurrentPriceResponse {
string market_id = 1 [(gogoproto.customname) = "MarketID"];
string price = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// MarketResponse defines an asset in the pricefeed.
message MarketResponse {
string market_id = 1 [(gogoproto.customname) = "MarketID"];
string base_asset = 2;
string quote_asset = 3;
repeated string oracles = 4;
bool active = 5;
}

View File

@ -1,57 +0,0 @@
syntax = "proto3";
package kava.pricefeed.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/pricefeed/types";
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
// Params defines the parameters for the pricefeed module.
message Params {
repeated Market markets = 1 [
(gogoproto.castrepeated) = "Markets",
(gogoproto.nullable) = false
];
}
// Market defines an asset in the pricefeed.
message Market {
string market_id = 1 [(gogoproto.customname) = "MarketID"];
string base_asset = 2;
string quote_asset = 3;
repeated bytes oracles = 4 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
bool active = 5;
}
// PostedPrice defines a price for market posted by a specific oracle.
message PostedPrice {
string market_id = 1 [(gogoproto.customname) = "MarketID"];
bytes oracle_address = 2 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
string price = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
google.protobuf.Timestamp expiry = 4 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
}
// CurrentPrice defines a current price for a particular market in the pricefeed
// module.
message CurrentPrice {
string market_id = 1 [(gogoproto.customname) = "MarketID"];
string price = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

View File

@ -1,35 +0,0 @@
syntax = "proto3";
package kava.pricefeed.v1beta1;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/pricefeed/types";
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
// Msg defines the pricefeed Msg service.
service Msg {
// PostPrice defines a method for creating a new post price
rpc PostPrice(MsgPostPrice) returns (MsgPostPriceResponse);
}
// MsgPostPrice represents a method for creating a new post price
message MsgPostPrice {
option (gogoproto.goproto_getters) = false;
// address of client
string from = 1;
string market_id = 2 [(gogoproto.customname) = "MarketID"];
string price = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
google.protobuf.Timestamp expiry = 4 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
}
// MsgPostPriceResponse defines the Msg/PostPrice response type.
message MsgPostPriceResponse {}

View File

@ -1,80 +0,0 @@
syntax = "proto3";
package kava.router.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/router/types";
option (gogoproto.goproto_getters_all) = false;
// Msg defines the router Msg service.
service Msg {
// MintDeposit converts a delegation into staking derivatives and deposits it all into an earn vault.
rpc MintDeposit(MsgMintDeposit) returns (MsgMintDepositResponse);
// DelegateMintDeposit delegates tokens to a validator, then converts them into staking derivatives,
// then deposits to an earn vault.
rpc DelegateMintDeposit(MsgDelegateMintDeposit) returns (MsgDelegateMintDepositResponse);
// WithdrawBurn removes staking derivatives from an earn vault and converts them back to a staking delegation.
rpc WithdrawBurn(MsgWithdrawBurn) returns (MsgWithdrawBurnResponse);
// WithdrawBurnUndelegate removes staking derivatives from an earn vault, converts them to a staking delegation,
// then undelegates them from their validator.
rpc WithdrawBurnUndelegate(MsgWithdrawBurnUndelegate) returns (MsgWithdrawBurnUndelegateResponse);
}
// MsgMintDeposit converts a delegation into staking derivatives and deposits it all into an earn vault.
message MsgMintDeposit {
// depositor represents the owner of the delegation to convert
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator is the validator for the depositor's delegation
string validator = 2;
// amount is the delegation balance to convert
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// MsgMintDepositResponse defines the Msg/MsgMintDeposit response type.
message MsgMintDepositResponse {}
// MsgDelegateMintDeposit delegates tokens to a validator, then converts them into staking derivatives,
// then deposits to an earn vault.
message MsgDelegateMintDeposit {
// depositor represents the owner of the tokens to delegate
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator is the address of the validator to delegate to
string validator = 2;
// amount is the tokens to delegate
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// MsgDelegateMintDepositResponse defines the Msg/MsgDelegateMintDeposit response type.
message MsgDelegateMintDepositResponse {}
// MsgWithdrawBurn removes staking derivatives from an earn vault and converts them back to a staking delegation.
message MsgWithdrawBurn {
// from is the owner of the earn vault to withdraw from
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator is the address to select the derivative denom to withdraw
string validator = 2;
// amount is the staked token equivalent to withdraw
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// MsgWithdrawBurnResponse defines the Msg/MsgWithdrawBurn response type.
message MsgWithdrawBurnResponse {}
// MsgWithdrawBurnUndelegate removes staking derivatives from an earn vault, converts them to a staking delegation,
// then undelegates them from their validator.
message MsgWithdrawBurnUndelegate {
// from is the owner of the earn vault to withdraw from
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// validator is the address to select the derivative denom to withdraw
string validator = 2;
// amount is the staked token equivalent to withdraw
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
// MsgWithdrawBurnUndelegateResponse defines the Msg/MsgWithdrawBurnUndelegate response type.
message MsgWithdrawBurnUndelegateResponse {}

View File

@ -1,18 +0,0 @@
syntax = "proto3";
package kava.savings.v1beta1;
import "gogoproto/gogo.proto";
import "kava/savings/v1beta1/store.proto";
option go_package = "github.com/kava-labs/kava/x/savings/types";
// GenesisState defines the savings module's genesis state.
message GenesisState {
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
repeated Deposit deposits = 2 [
(gogoproto.castrepeated) = "Deposits",
(gogoproto.nullable) = false
];
}

View File

@ -1,75 +0,0 @@
syntax = "proto3";
package kava.savings.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kava/savings/v1beta1/store.proto";
option go_package = "github.com/kava-labs/kava/x/savings/types";
// Query defines the gRPC querier service for savings module
service Query {
// Params queries all parameters of the savings module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/savings/v1beta1/params";
}
// Deposits queries savings deposits.
rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) {
option (google.api.http).get = "/kava/savings/v1beta1/deposits";
}
// TotalSupply returns the total sum of all coins currently locked into the savings module.
rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) {
option (google.api.http).get = "/kava/savings/v1beta1/total_supply";
}
}
// QueryParamsRequest defines the request type for querying x/savings
// parameters.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/savings
// parameters.
message QueryParamsResponse {
option (gogoproto.goproto_getters) = false;
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryDepositsRequest defines the request type for querying x/savings
// deposits.
message QueryDepositsRequest {
string denom = 1;
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryDepositsResponse defines the response type for querying x/savings
// deposits.
message QueryDepositsResponse {
repeated Deposit deposits = 1 [
(gogoproto.castrepeated) = "Deposits",
(gogoproto.nullable) = false
];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryTotalSupplyRequest defines the request type for Query/TotalSupply method.
message QueryTotalSupplyRequest {}
// TotalSupplyResponse defines the response type for the Query/TotalSupply method.
message QueryTotalSupplyResponse {
// Height is the block height at which these totals apply
int64 height = 1;
// Result is a list of coins supplied to savings
repeated cosmos.base.v1beta1.Coin result = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

View File

@ -1,27 +0,0 @@
syntax = "proto3";
package kava.savings.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/savings/types";
option (gogoproto.goproto_getters_all) = false;
// Params defines the parameters for the savings module.
message Params {
repeated string supported_denoms = 1;
}
// Deposit defines an amount of coins deposited into a savings module account.
message Deposit {
string depositor = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}

View File

@ -1,41 +0,0 @@
syntax = "proto3";
package kava.savings.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/savings/types";
// Msg defines the savings Msg service.
service Msg {
// Deposit defines a method for depositing funds to the savings module account
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);
// Withdraw defines a method for withdrawing funds to the savings module account
rpc Withdraw(MsgWithdraw) returns (MsgWithdrawResponse);
}
// MsgDeposit defines the Msg/Deposit request type.
message MsgDeposit {
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// MsgDepositResponse defines the Msg/Deposit response type.
message MsgDepositResponse {}
// MsgWithdraw defines the Msg/Withdraw request type.
message MsgWithdraw {
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}
// MsgWithdrawResponse defines the Msg/Withdraw response type.
message MsgWithdrawResponse {}

View File

@ -1,23 +0,0 @@
syntax = "proto3";
package kava.swap.v1beta1;
import "gogoproto/gogo.proto";
import "kava/swap/v1beta1/swap.proto";
option go_package = "github.com/kava-labs/kava/x/swap/types";
// GenesisState defines the swap module's genesis state.
message GenesisState {
// params defines all the parameters related to swap
Params params = 1 [(gogoproto.nullable) = false];
// pool_records defines the available pools
repeated PoolRecord pool_records = 2 [
(gogoproto.castrepeated) = "PoolRecords",
(gogoproto.nullable) = false
];
// share_records defines the owned shares of each pool
repeated ShareRecord share_records = 3 [
(gogoproto.castrepeated) = "ShareRecords",
(gogoproto.nullable) = false
];
}

View File

@ -1,118 +0,0 @@
syntax = "proto3";
package kava.swap.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kava/swap/v1beta1/swap.proto";
option go_package = "github.com/kava-labs/kava/x/swap/types";
// Query defines the gRPC querier service for swap module
service Query {
// Params queries all parameters of the swap module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/swap/v1beta1/params";
}
// Pools queries pools based on pool ID
rpc Pools(QueryPoolsRequest) returns (QueryPoolsResponse) {
option (google.api.http).get = "/kava/swap/v1beta1/pools";
}
// Deposits queries deposit details based on owner address and pool
rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) {
option (google.api.http).get = "/kava/swap/v1beta1/deposits";
}
}
// QueryParamsRequest defines the request type for querying x/swap parameters.
message QueryParamsRequest {
option (gogoproto.goproto_getters) = false;
}
// QueryParamsResponse defines the response type for querying x/swap parameters.
message QueryParamsResponse {
option (gogoproto.goproto_getters) = false;
// params represents the swap module parameters
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryPoolsRequest is the request type for the Query/Pools RPC method.
message QueryPoolsRequest {
// pool_id filters pools by id
string pool_id = 1;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// QueryPoolsResponse is the response type for the Query/Pools RPC method.
message QueryPoolsResponse {
// pools represents returned pools
repeated PoolResponse pools = 1 [(gogoproto.nullable) = false];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// Pool represents the state of a single pool
message PoolResponse {
option (gogoproto.goproto_getters) = false;
// name represents the name of the pool
string name = 1;
// coins represents the total reserves of the pool
repeated cosmos.base.v1beta1.Coin coins = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
// total_shares represents the total shares of the pool
string total_shares = 3 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// QueryDepositsRequest is the request type for the Query/Deposits RPC method.
message QueryDepositsRequest {
option (gogoproto.goproto_getters) = false;
// owner optionally filters deposits by owner
string owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pool_id optionally fitlers deposits by pool id
string pool_id = 2;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
message QueryDepositsResponse {
option (gogoproto.goproto_getters) = false;
// deposits returns the deposits matching the requested parameters
repeated DepositResponse deposits = 1 [(gogoproto.nullable) = false];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// DepositResponse defines a single deposit query response type.
message DepositResponse {
option (gogoproto.goproto_getters) = false;
// depositor represents the owner of the deposit
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pool_id represents the pool the deposit is for
string pool_id = 2;
// shares_owned presents the shares owned by the depositor for the pool
string shares_owned = 3 [
(cosmos_proto.scalar) = "cosmos.AddressString",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// shares_value represents the coin value of the shares_owned
repeated cosmos.base.v1beta1.Coin shares_value = 4 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.nullable) = false
];
}

View File

@ -1,69 +0,0 @@
syntax = "proto3";
package kava.swap.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/swap/types";
// Params defines the parameters for the swap module.
message Params {
option (gogoproto.goproto_stringer) = false; // false here because we define Stringer method in params.go
// allowed_pools defines that pools that are allowed to be created
repeated AllowedPool allowed_pools = 1 [
(gogoproto.castrepeated) = "AllowedPools",
(gogoproto.nullable) = false
];
// swap_fee defines the swap fee for all pools
string swap_fee = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
// AllowedPool defines a pool that is allowed to be created
message AllowedPool {
option (gogoproto.goproto_stringer) = false; // false here because we define Stringer method in params.go
// token_a represents the a token allowed
string token_a = 1;
// token_b represents the b token allowed
string token_b = 2;
}
// PoolRecord represents the state of a liquidity pool
// and is used to store the state of a denominated pool
message PoolRecord {
// pool_id represents the unique id of the pool
string pool_id = 1 [(gogoproto.customname) = "PoolID"];
// reserves_a is the a token coin reserves
cosmos.base.v1beta1.Coin reserves_a = 2 [(gogoproto.nullable) = false];
// reserves_b is the a token coin reserves
cosmos.base.v1beta1.Coin reserves_b = 3 [(gogoproto.nullable) = false];
// total_shares is the total distrubuted shares of the pool
string total_shares = 4 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// ShareRecord stores the shares owned for a depositor and pool
message ShareRecord {
// depositor represents the owner of the shares
bytes depositor = 1 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
// pool_id represents the pool the shares belong to
string pool_id = 2 [(gogoproto.customname) = "PoolID"];
// shares_owned represents the number of shares owned by depsoitor for the pool_id
string shares_owned = 3 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

View File

@ -1,114 +0,0 @@
syntax = "proto3";
package kava.swap.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/swap/types";
// Msg defines the swap Msg service.
service Msg {
// Deposit defines a method for depositing liquidity into a pool
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);
// Withdraw defines a method for withdrawing liquidity into a pool
rpc Withdraw(MsgWithdraw) returns (MsgWithdrawResponse);
// SwapExactForTokens represents a message for trading exact coinA for coinB
rpc SwapExactForTokens(MsgSwapExactForTokens) returns (MsgSwapExactForTokensResponse);
// SwapForExactTokens represents a message for trading coinA for an exact coinB
rpc SwapForExactTokens(MsgSwapForExactTokens) returns (MsgSwapForExactTokensResponse);
}
// MsgDeposit represents a message for depositing liquidity into a pool
message MsgDeposit {
option (gogoproto.goproto_getters) = false;
// depositor represents the address to deposit funds from
string depositor = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// token_a represents one token of deposit pair
cosmos.base.v1beta1.Coin token_a = 2 [(gogoproto.nullable) = false];
// token_b represents one token of deposit pair
cosmos.base.v1beta1.Coin token_b = 3 [(gogoproto.nullable) = false];
// slippage represents the max decimal percentage price change
string slippage = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// deadline represents the unix timestamp to complete the deposit by
int64 deadline = 5;
}
// MsgDepositResponse defines the Msg/Deposit response type.
message MsgDepositResponse {}
// MsgWithdraw represents a message for withdrawing liquidity from a pool
message MsgWithdraw {
option (gogoproto.goproto_getters) = false;
// from represents the address we are withdrawing for
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// shares represents the amount of shares to withdraw
string shares = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// min_token_a represents the minimum a token to withdraw
cosmos.base.v1beta1.Coin min_token_a = 3 [(gogoproto.nullable) = false];
// min_token_a represents the minimum a token to withdraw
cosmos.base.v1beta1.Coin min_token_b = 4 [(gogoproto.nullable) = false];
// deadline represents the unix timestamp to complete the withdraw by
int64 deadline = 5;
}
// MsgWithdrawResponse defines the Msg/Withdraw response type.
message MsgWithdrawResponse {}
// MsgSwapExactForTokens represents a message for trading exact coinA for coinB
message MsgSwapExactForTokens {
option (gogoproto.goproto_getters) = false;
// represents the address swaping the tokens
string requester = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// exact_token_a represents the exact amount to swap for token_b
cosmos.base.v1beta1.Coin exact_token_a = 2 [(gogoproto.nullable) = false];
// token_b represents the desired token_b to swap for
cosmos.base.v1beta1.Coin token_b = 3 [(gogoproto.nullable) = false];
// slippage represents the maximum change in token_b allowed
string slippage = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// deadline represents the unix timestamp to complete the swap by
int64 deadline = 5;
}
// MsgSwapExactForTokensResponse defines the Msg/SwapExactForTokens response
// type.
message MsgSwapExactForTokensResponse {}
// MsgSwapForExactTokens represents a message for trading coinA for an exact
// coinB
message MsgSwapForExactTokens {
option (gogoproto.goproto_getters) = false;
// represents the address swaping the tokens
string requester = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// token_a represents the desired token_a to swap for
cosmos.base.v1beta1.Coin token_a = 2 [(gogoproto.nullable) = false];
// exact_token_b represents the exact token b amount to swap for token a
cosmos.base.v1beta1.Coin exact_token_b = 3 [(gogoproto.nullable) = false];
// slippage represents the maximum change in token_a allowed
string slippage = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// deadline represents the unix timestamp to complete the swap by
int64 deadline = 5;
}
// MsgSwapForExactTokensResponse defines the Msg/SwapForExactTokensResponse
// response type.
message MsgSwapForExactTokensResponse {}

View File

@ -1,23 +0,0 @@
package auction
import (
"errors"
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/auction/keeper"
"github.com/kava-labs/kava/x/auction/types"
)
// BeginBlocker closes all expired auctions at the end of each block. It panics if
// there's an error other than ErrAuctionNotFound.
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
err := k.CloseExpiredAuctions(ctx)
if err != nil && !errors.Is(err, types.ErrAuctionNotFound) {
panic(err)
}
}

View File

@ -1,58 +0,0 @@
package auction_test
import (
"testing"
"github.com/stretchr/testify/suite"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/auction"
"github.com/kava-labs/kava/x/auction/testutil"
types "github.com/kava-labs/kava/x/auction/types"
)
type abciTestSuite struct {
testutil.Suite
}
func (suite *abciTestSuite) SetupTest() {
suite.Suite.SetupTest(4)
}
func TestABCITestSuite(t *testing.T) {
suite.Run(t, new(abciTestSuite))
}
func (suite *abciTestSuite) TestKeeper_BeginBlocker() {
buyer := suite.Addrs[0]
returnAddrs := []sdk.AccAddress{suite.Addrs[1]}
returnWeights := []sdkmath.Int{sdkmath.NewInt(1)}
suite.AddCoinsToNamedModule(suite.ModAcc.Name, cs(c("token1", 100), c("token2", 100), c("debt", 100)))
// Start an auction and place a bid
auctionID, err := suite.Keeper.StartCollateralAuction(suite.Ctx, suite.ModAcc.Name, c("token1", 20), c("token2", 50), returnAddrs, returnWeights, c("debt", 40))
suite.Require().NoError(err)
suite.Require().NoError(suite.Keeper.PlaceBid(suite.Ctx, auctionID, buyer, c("token2", 30)))
// Run the beginblocker, simulating a block time 1ns before auction expiry
preExpiryTime := suite.Ctx.BlockTime().Add(types.DefaultForwardBidDuration - 1)
auction.BeginBlocker(suite.Ctx.WithBlockTime(preExpiryTime), suite.Keeper)
// Check auction has not been closed yet
_, found := suite.Keeper.GetAuction(suite.Ctx, auctionID)
suite.True(found)
// Run the endblocker, simulating a block time equal to auction expiry
expiryTime := suite.Ctx.BlockTime().Add(types.DefaultForwardBidDuration)
auction.BeginBlocker(suite.Ctx.WithBlockTime(expiryTime), suite.Keeper)
// Check auction has been closed
_, found = suite.Keeper.GetAuction(suite.Ctx, auctionID)
suite.False(found)
}
func c(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) }
func cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) }

View File

@ -1,212 +0,0 @@
package cli
import (
"context"
"fmt"
"strconv"
"strings"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/kava-labs/kava/x/auction/types"
)
// GetQueryCmd returns the cli query commands for the auction module
func GetQueryCmd() *cobra.Command {
auctionQueryCmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
}
cmds := []*cobra.Command{
GetCmdQueryParams(),
GetCmdQueryAuction(),
GetCmdQueryAuctions(),
}
for _, cmd := range cmds {
flags.AddQueryFlagsToCmd(cmd)
}
auctionQueryCmd.AddCommand(cmds...)
return auctionQueryCmd
}
// GetCmdQueryParams queries the issuance module parameters
func GetCmdQueryParams() *cobra.Command {
return &cobra.Command{
Use: "params",
Short: fmt.Sprintf("get the %s module parameters", types.ModuleName),
Long: "Get the current auction module parameters.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
if err != nil {
return err
}
return clientCtx.PrintProto(&res.Params)
},
}
}
// GetCmdQueryAuction queries one auction in the store
func GetCmdQueryAuction() *cobra.Command {
return &cobra.Command{
Use: "auction [auction-id]",
Short: "get info about an auction",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
auctionID, err := strconv.Atoi(args[0])
if err != nil {
return err
}
params := types.QueryAuctionRequest{
AuctionId: uint64(auctionID),
}
res, err := queryClient.Auction(context.Background(), &params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
}
// Query auction flags
const (
flagType = "type"
flagDenom = "denom"
flagPhase = "phase"
flagOwner = "owner"
)
// GetCmdQueryAuctions queries the auctions in the store
func GetCmdQueryAuctions() *cobra.Command {
cmd := &cobra.Command{
Use: "auctions",
Short: "query auctions with optional filters",
Long: "Query for all paginated auctions that match optional filters.",
Example: strings.Join([]string{
fmt.Sprintf(" $ %s q %s auctions --type=(collateral|surplus|debt)", version.AppName, types.ModuleName),
fmt.Sprintf(" $ %s q %s auctions --owner=kava1hatdq32u5x4wnxrtv5wzjzmq49sxgjgsj0mffm", version.AppName, types.ModuleName),
fmt.Sprintf(" $ %s q %s auctions --denom=bnb", version.AppName, types.ModuleName),
fmt.Sprintf(" $ %s q %s auctions --phase=(forward|reverse)", version.AppName, types.ModuleName),
fmt.Sprintf(" $ %s q %s auctions --page=2 --limit=100", version.AppName, types.ModuleName),
}, "\n"),
RunE: func(cmd *cobra.Command, args []string) error {
auctionType, err := cmd.Flags().GetString(flagType)
if err != nil {
return err
}
owner, err := cmd.Flags().GetString(flagOwner)
if err != nil {
return err
}
denom, err := cmd.Flags().GetString(flagDenom)
if err != nil {
return err
}
phase, err := cmd.Flags().GetString(flagPhase)
if err != nil {
return err
}
pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}
if len(auctionType) != 0 {
auctionType = strings.ToLower(auctionType)
if auctionType != types.CollateralAuctionType &&
auctionType != types.SurplusAuctionType &&
auctionType != types.DebtAuctionType {
return fmt.Errorf("invalid auction type %s", auctionType)
}
}
if len(owner) != 0 {
if auctionType != types.CollateralAuctionType {
return fmt.Errorf("cannot apply owner flag to non-collateral auction type")
}
_, err := sdk.AccAddressFromBech32(owner)
if err != nil {
return fmt.Errorf("cannot parse address from auction owner %s", owner)
}
}
if len(denom) != 0 {
err := sdk.ValidateDenom(denom)
if err != nil {
return err
}
}
if len(phase) != 0 {
phase = strings.ToLower(phase)
if len(auctionType) > 0 && auctionType != types.CollateralAuctionType {
return fmt.Errorf("cannot apply phase flag to non-collateral auction type")
}
if phase != types.ForwardAuctionPhase && phase != types.ReverseAuctionPhase {
return fmt.Errorf("invalid auction phase %s", phase)
}
}
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
request := types.QueryAuctionsRequest{
Type: auctionType,
Owner: owner,
Denom: denom,
Phase: phase,
Pagination: pageReq,
}
res, err := queryClient.Auctions(context.Background(), &request)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddPaginationFlagsToCmd(cmd, "auctions")
cmd.Flags().String(flagType, "", "(optional) filter by auction type, type: collateral, debt, surplus")
cmd.Flags().String(flagOwner, "", "(optional) filter by collateral auction owner")
cmd.Flags().String(flagDenom, "", "(optional) filter by auction denom")
cmd.Flags().String(flagPhase, "", "(optional) filter by collateral auction phase, phase: forward/reverse")
return cmd
}

View File

@ -1,70 +0,0 @@
package cli
import (
"fmt"
"strconv"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/kava-labs/kava/x/auction/types"
)
// GetTxCmd returns the transaction cli commands for this module
func GetTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: types.ModuleName,
Short: "transaction commands for the auction module",
}
cmds := []*cobra.Command{
GetCmdPlaceBid(),
}
for _, cmd := range cmds {
flags.AddTxFlagsToCmd(cmd)
}
txCmd.AddCommand(cmds...)
return txCmd
}
// GetCmdPlaceBid cli command for placing bids on auctions
func GetCmdPlaceBid() *cobra.Command {
return &cobra.Command{
Use: "bid [auction-id] [amount]",
Short: "place a bid on an auction",
Long: "Place a bid on any type of auction, updating the latest bid amount to [amount]. Collateral auctions must be bid up to their maxbid before entering reverse phase.",
Example: fmt.Sprintf(" $ %s tx %s bid 34 1000usdx --from myKeyName", version.AppName, types.ModuleName),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
id, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
return fmt.Errorf("auction-id '%s' not a valid uint", args[0])
}
amt, err := sdk.ParseCoinNormalized(args[1])
if err != nil {
return err
}
msg := types.NewMsgPlaceBid(id, clientCtx.GetFromAddress().String(), amt)
err = msg.ValidateBasic()
if err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
},
}
}

View File

@ -1,74 +0,0 @@
package auction
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/auction/keeper"
"github.com/kava-labs/kava/x/auction/types"
)
// InitGenesis initializes the store state from a genesis state.
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, bankKeeper types.BankKeeper, 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))
}
keeper.SetNextAuctionID(ctx, gs.NextAuctionId)
keeper.SetParams(ctx, gs.Params)
totalAuctionCoins := sdk.NewCoins()
auctions, err := types.UnpackGenesisAuctions(gs.Auctions)
if err != nil {
panic(fmt.Sprintf("failed to unpack genesis auctions: %s", err))
}
for _, a := range auctions {
keeper.SetAuction(ctx, a)
// find the total coins that should be present in the module account
totalAuctionCoins = totalAuctionCoins.Add(a.GetModuleAccountCoins()...)
}
// check if the module account exists
moduleAcc := accountKeeper.GetModuleAccount(ctx, types.ModuleName)
if moduleAcc == nil {
panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
}
maccCoins := bankKeeper.GetAllBalances(ctx, moduleAcc.GetAddress())
// check module coins match auction coins
// Note: Other sdk modules do not check this, instead just using the existing module account coins, or if zero, setting them.
if !maccCoins.IsEqual(totalAuctionCoins) {
panic(fmt.Sprintf("total auction coins (%s) do not equal (%s) module account (%s) ", maccCoins, types.ModuleName, totalAuctionCoins))
}
}
// ExportGenesis returns a GenesisState for a given context and keeper.
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState {
nextAuctionID, err := keeper.GetNextAuctionID(ctx)
if err != nil {
panic(err)
}
params := keeper.GetParams(ctx)
genAuctions := []types.GenesisAuction{} // return empty list instead of nil if no auctions
keeper.IterateAuctions(ctx, func(a types.Auction) bool {
ga, ok := a.(types.GenesisAuction)
if !ok {
panic("could not convert stored auction to GenesisAuction type")
}
genAuctions = append(genAuctions, ga)
return false
})
gs, err := types.NewGenesisState(nextAuctionID, params, genAuctions)
if err != nil {
panic(err)
}
return gs
}

View File

@ -1,159 +0,0 @@
package auction_test
import (
"sort"
"testing"
"time"
"github.com/stretchr/testify/require"
sdkmath "cosmossdk.io/math"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/auction"
"github.com/kava-labs/kava/x/auction/types"
)
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: []sdkmath.Int{sdk.OneInt(), sdk.OneInt()}},
c("debt", 1000),
).WithID(3).(types.GenesisAuction)
)
func TestInitGenesis(t *testing.T) {
t.Run("valid", func(t *testing.T) {
// setup keepers
tApp := app.NewTestApp()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
// setup module account
modBaseAcc := authtypes.NewBaseAccount(authtypes.NewModuleAddress(types.ModuleName), nil, 0, 0)
modAcc := authtypes.NewModuleAccount(modBaseAcc, types.ModuleName, []string{authtypes.Minter, authtypes.Burner}...)
tApp.GetAccountKeeper().SetModuleAccount(ctx, modAcc)
tApp.GetBankKeeper().MintCoins(ctx, types.ModuleName, testAuction.GetModuleAccountCoins())
// set up auction genesis state with module account
auctionGS, err := types.NewGenesisState(
10,
types.DefaultParams(),
[]types.GenesisAuction{testAuction},
)
require.NoError(t, err)
// run init
keeper := tApp.GetAuctionKeeper()
require.NotPanics(t, func() {
auction.InitGenesis(ctx, keeper, tApp.GetBankKeeper(), tApp.GetAccountKeeper(), auctionGS)
})
// check state is as expected
actualID, err := keeper.GetNextAuctionID(ctx)
require.NoError(t, err)
require.Equal(t, auctionGS.NextAuctionId, actualID)
require.Equal(t, auctionGS.Params, keeper.GetParams(ctx))
genesisAuctions, err := types.UnpackGenesisAuctions(auctionGS.Auctions)
if err != nil {
panic(err)
}
sort.Slice(genesisAuctions, func(i, j int) bool {
return genesisAuctions[i].GetID() > genesisAuctions[j].GetID()
})
i := 0
keeper.IterateAuctions(ctx, func(a types.Auction) bool {
require.Equal(t, genesisAuctions[i], a)
i++
return false
})
})
t.Run("invalid (invalid nextAuctionID)", func(t *testing.T) {
// setup keepers
tApp := app.NewTestApp()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
// setup module account
modBaseAcc := authtypes.NewBaseAccount(authtypes.NewModuleAddress(types.ModuleName), nil, 0, 0)
modAcc := authtypes.NewModuleAccount(modBaseAcc, types.ModuleName, []string{authtypes.Minter, authtypes.Burner}...)
tApp.GetAccountKeeper().SetModuleAccount(ctx, modAcc)
tApp.GetBankKeeper().MintCoins(ctx, types.ModuleName, testAuction.GetModuleAccountCoins())
// create invalid genesis
auctionGS, err := types.NewGenesisState(
0, // next id < testAuction ID
types.DefaultParams(),
[]types.GenesisAuction{testAuction},
)
require.NoError(t, err)
// check init fails
require.Panics(t, func() {
auction.InitGenesis(ctx, tApp.GetAuctionKeeper(), tApp.GetBankKeeper(), tApp.GetAccountKeeper(), auctionGS)
})
})
t.Run("invalid (missing mod account coins)", func(t *testing.T) {
// setup keepers
tApp := app.NewTestApp()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
// invalid as there is no module account setup
// create invalid genesis
auctionGS, err := types.NewGenesisState(
10,
types.DefaultParams(),
[]types.GenesisAuction{testAuction},
)
require.NoError(t, err)
// check init fails
require.Panics(t, func() {
auction.InitGenesis(ctx, tApp.GetAuctionKeeper(), tApp.GetBankKeeper(), tApp.GetAccountKeeper(), auctionGS)
})
})
}
func TestExportGenesis(t *testing.T) {
t.Run("default", func(t *testing.T) {
// setup state
tApp := app.NewTestApp()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
tApp.InitializeFromGenesisStates()
// export
gs := auction.ExportGenesis(ctx, tApp.GetAuctionKeeper())
// check state matches
defaultGS := types.DefaultGenesisState()
require.Equal(t, defaultGS, gs)
})
t.Run("one auction", func(t *testing.T) {
// setup state
tApp := app.NewTestApp()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
tApp.InitializeFromGenesisStates()
tApp.GetAuctionKeeper().SetAuction(ctx, testAuction)
// export
gs := auction.ExportGenesis(ctx, tApp.GetAuctionKeeper())
// check state matches
expectedGenesisState := types.DefaultGenesisState()
packedGenesisAuctions, err := types.PackGenesisAuctions([]types.GenesisAuction{testAuction})
require.NoError(t, err)
expectedGenesisState.Auctions = append(expectedGenesisState.Auctions, packedGenesisAuctions...)
require.Equal(t, expectedGenesisState, gs)
})
}

View File

@ -1,583 +0,0 @@
package keeper
import (
"errors"
"fmt"
"time"
errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/x/auction/types"
)
// StartSurplusAuction starts a new surplus (forward) auction.
func (k Keeper) StartSurplusAuction(ctx sdk.Context, seller string, lot sdk.Coin, bidDenom string) (uint64, error) {
auction := types.NewSurplusAuction(
seller,
lot,
bidDenom,
types.DistantFuture,
)
// NOTE: for the duration of the auction the auction module account holds the lot
err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, seller, types.ModuleName, sdk.NewCoins(lot))
if err != nil {
return 0, err
}
auctionID, err := k.StoreNewAuction(ctx, &auction)
if err != nil {
return 0, err
}
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAuctionStart,
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auctionID)),
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
sdk.NewAttribute(types.AttributeKeyBid, auction.Bid.String()),
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
),
)
return auctionID, nil
}
// 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,
initialLot,
types.DistantFuture,
debt,
)
// This auction type mints coins at close. Need to check module account has minting privileges to avoid potential err in endblocker.
macc := k.accountKeeper.GetModuleAccount(ctx, buyer)
if !macc.HasPermission(authtypes.Minter) {
panic(fmt.Errorf("module '%s' does not have '%s' permission", buyer, authtypes.Minter))
}
// NOTE: for the duration of the auction the auction module account holds the debt
err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, buyer, types.ModuleName, sdk.NewCoins(debt))
if err != nil {
return 0, err
}
auctionID, err := k.StoreNewAuction(ctx, &auction)
if err != nil {
return 0, err
}
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAuctionStart,
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auctionID)),
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
sdk.NewAttribute(types.AttributeKeyBid, auction.Bid.String()),
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
),
)
return auctionID, nil
}
// StartCollateralAuction starts a new collateral (2-phase) auction.
func (k Keeper) StartCollateralAuction(
ctx sdk.Context, seller string, lot, maxBid sdk.Coin,
lotReturnAddrs []sdk.AccAddress, lotReturnWeights []sdkmath.Int, debt sdk.Coin,
) (uint64, error) {
weightedAddresses, err := types.NewWeightedAddresses(lotReturnAddrs, lotReturnWeights)
if err != nil {
return 0, err
}
auction := types.NewCollateralAuction(
seller,
lot,
types.DistantFuture,
maxBid,
weightedAddresses,
debt,
)
// NOTE: for the duration of the auction the auction module account holds the debt and the lot
err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, seller, types.ModuleName, sdk.NewCoins(lot))
if err != nil {
return 0, err
}
err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, seller, types.ModuleName, sdk.NewCoins(debt))
if err != nil {
return 0, err
}
auctionID, err := k.StoreNewAuction(ctx, &auction)
if err != nil {
return 0, err
}
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAuctionStart,
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auctionID)),
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
sdk.NewAttribute(types.AttributeKeyBid, auction.Bid.String()),
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
sdk.NewAttribute(types.AttributeKeyMaxBid, auction.MaxBid.String()),
),
)
return auctionID, nil
}
// 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 errorsmod.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)
}
// validation common to all auctions
if ctx.BlockTime().After(auction.GetEndTime()) {
return errorsmod.Wrapf(types.ErrAuctionHasExpired, "%d", auctionID)
}
// move coins and return updated auction
var (
err error
updatedAuction types.Auction
)
switch auctionType := auction.(type) {
case *types.SurplusAuction:
updatedAuction, err = k.PlaceBidSurplus(ctx, auctionType, bidder, newAmount)
case *types.DebtAuction:
updatedAuction, err = k.PlaceBidDebt(ctx, auctionType, bidder, newAmount)
case *types.CollateralAuction:
if !auctionType.IsReversePhase() {
updatedAuction, err = k.PlaceForwardBidCollateral(ctx, auctionType, bidder, newAmount)
} else {
updatedAuction, err = k.PlaceReverseBidCollateral(ctx, auctionType, bidder, newAmount)
}
default:
err = errorsmod.Wrap(types.ErrUnrecognizedAuctionType, auction.GetType())
}
if err != nil {
return err
}
k.SetAuction(ctx, updatedAuction)
return nil
}
// PlaceBidSurplus places a forward bid on a surplus auction, moving coins and returning the updated auction.
func (k Keeper) PlaceBidSurplus(ctx sdk.Context, auction *types.SurplusAuction, bidder sdk.AccAddress, bid sdk.Coin) (*types.SurplusAuction, error) {
// Validate new bid
if bid.Denom != auction.Bid.Denom {
return auction, errorsmod.Wrapf(types.ErrInvalidBidDenom, "%s ≠ %s", bid.Denom, auction.Bid.Denom)
}
minNewBidAmt := auction.Bid.Amount.Add( // new bids must be some % greater than old bid, and at least 1 larger to avoid replacing an old bid at no cost
sdk.MaxInt(
sdkmath.NewInt(1),
sdk.NewDecFromInt(auction.Bid.Amount).Mul(k.GetParams(ctx).IncrementSurplus).RoundInt(),
),
)
if bid.Amount.LT(minNewBidAmt) {
return auction, errorsmod.Wrapf(types.ErrBidTooSmall, "%s < %s%s", bid, minNewBidAmt, auction.Bid.Denom)
}
// New bidder pays back old bidder
// Catch edge cases of a bidder replacing their own bid, or the amount being zero (sending zero coins produces meaningless send events).
if !bidder.Equals(auction.Bidder) && !auction.Bid.IsZero() { // bidder isn't same as before AND previous auction bid must exist
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, bidder, types.ModuleName, sdk.NewCoins(auction.Bid))
if err != nil {
return auction, err
}
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, auction.Bidder, sdk.NewCoins(auction.Bid))
if err != nil {
return auction, err
}
}
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, bidder, auction.Initiator, sdk.NewCoins(bid.Sub(auction.Bid)))
if err != nil {
return auction, err
}
// Received bid amount is burned from the module account
err = k.bankKeeper.BurnCoins(ctx, auction.Initiator, sdk.NewCoins(bid.Sub(auction.Bid)))
if err != nil {
return auction, err
}
// Update Auction
auction.Bidder = bidder
auction.Bid = bid
if !auction.HasReceivedBids {
auction.MaxEndTime = ctx.BlockTime().Add(k.GetParams(ctx).MaxAuctionDuration) // set maximum ending time on receipt of first bid
auction.HasReceivedBids = true
}
auction.EndTime = earliestTime(ctx.BlockTime().Add(k.GetParams(ctx).ForwardBidDuration), auction.MaxEndTime) // increment timeout, up to MaxEndTime
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAuctionBid,
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.ID)),
sdk.NewAttribute(types.AttributeKeyBidder, auction.Bidder.String()),
sdk.NewAttribute(types.AttributeKeyBid, auction.Bid.String()),
sdk.NewAttribute(types.AttributeKeyEndTime, fmt.Sprintf("%d", auction.EndTime.Unix())),
),
)
return auction, nil
}
// PlaceForwardBidCollateral places a forward bid on a collateral auction, moving coins and returning the updated auction.
func (k Keeper) PlaceForwardBidCollateral(ctx sdk.Context, auction *types.CollateralAuction, bidder sdk.AccAddress, bid sdk.Coin) (*types.CollateralAuction, error) {
// Validate new bid
if bid.Denom != auction.Bid.Denom {
return auction, errorsmod.Wrapf(types.ErrInvalidBidDenom, "%s ≠ %s", bid.Denom, auction.Bid.Denom)
}
if auction.IsReversePhase() {
panic("cannot place reverse bid on auction in forward phase")
}
minNewBidAmt := auction.Bid.Amount.Add( // new bids must be some % greater than old bid, and at least 1 larger to avoid replacing an old bid at no cost
sdk.MaxInt(
sdkmath.NewInt(1),
sdk.NewDecFromInt(auction.Bid.Amount).Mul(k.GetParams(ctx).IncrementCollateral).RoundInt(),
),
)
minNewBidAmt = sdk.MinInt(minNewBidAmt, auction.MaxBid.Amount) // allow new bids to hit MaxBid even though it may be less than the increment %
if bid.Amount.LT(minNewBidAmt) {
return auction, errorsmod.Wrapf(types.ErrBidTooSmall, "%s < %s%s", bid, minNewBidAmt, auction.Bid.Denom)
}
if auction.MaxBid.IsLT(bid) {
return auction, errorsmod.Wrapf(types.ErrBidTooLarge, "%s > %s", bid, auction.MaxBid)
}
// New bidder pays back old bidder
// Catch edge cases of a bidder replacing their own bid, and the amount being zero (sending zero coins produces meaningless send events).
if !bidder.Equals(auction.Bidder) && !auction.Bid.IsZero() {
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, bidder, types.ModuleName, sdk.NewCoins(auction.Bid))
if err != nil {
return auction, err
}
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, auction.Bidder, sdk.NewCoins(auction.Bid))
if err != nil {
return auction, err
}
}
// Increase in bid sent to auction initiator
bidIncrement := bid.Sub(auction.Bid)
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, bidder, auction.Initiator, sdk.NewCoins(bidIncrement))
if err != nil {
return auction, err
}
// Debt coins are sent to liquidator (until there is no CorrespondingDebt left). Amount sent is equal to bidIncrement (or whatever is left if < bidIncrement).
if auction.CorrespondingDebt.IsPositive() {
debtAmountToReturn := sdk.MinInt(bidIncrement.Amount, auction.CorrespondingDebt.Amount)
debtToReturn := sdk.NewCoin(auction.CorrespondingDebt.Denom, debtAmountToReturn)
err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, auction.Initiator, sdk.NewCoins(debtToReturn))
if err != nil {
return auction, err
}
auction.CorrespondingDebt = auction.CorrespondingDebt.Sub(debtToReturn) // debtToReturn will always be ≤ auction.CorrespondingDebt from the MinInt above
}
// Update Auction
auction.Bidder = bidder
auction.Bid = bid
if !auction.HasReceivedBids {
auction.MaxEndTime = ctx.BlockTime().Add(k.GetParams(ctx).MaxAuctionDuration) // set maximum ending time on receipt of first bid
auction.HasReceivedBids = true
}
// If this forward bid converts this to a reverse, increase timeout with ReverseBidDuration
if auction.IsReversePhase() {
auction.EndTime = earliestTime(ctx.BlockTime().Add(k.GetParams(ctx).ReverseBidDuration), auction.MaxEndTime) // increment timeout, up to MaxEndTime
} else {
auction.EndTime = earliestTime(ctx.BlockTime().Add(k.GetParams(ctx).ForwardBidDuration), auction.MaxEndTime) // increment timeout, up to MaxEndTime
}
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAuctionBid,
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.ID)),
sdk.NewAttribute(types.AttributeKeyBidder, auction.Bidder.String()),
sdk.NewAttribute(types.AttributeKeyBid, auction.Bid.String()),
sdk.NewAttribute(types.AttributeKeyEndTime, fmt.Sprintf("%d", auction.EndTime.Unix())),
),
)
return auction, nil
}
// PlaceReverseBidCollateral places a reverse bid on a collateral auction, moving coins and returning the updated auction.
func (k Keeper) PlaceReverseBidCollateral(ctx sdk.Context, auction *types.CollateralAuction, bidder sdk.AccAddress, lot sdk.Coin) (*types.CollateralAuction, error) {
// Validate new bid
if lot.Denom != auction.Lot.Denom {
return auction, errorsmod.Wrapf(types.ErrInvalidLotDenom, "%s ≠ %s", lot.Denom, auction.Lot.Denom)
}
if !auction.IsReversePhase() {
panic("cannot place forward bid on auction in reverse phase")
}
maxNewLotAmt := auction.Lot.Amount.Sub( // new lot must be some % less than old lot, and at least 1 smaller to avoid replacing an old bid at no cost
sdk.MaxInt(
sdkmath.NewInt(1),
sdk.NewDecFromInt(auction.Lot.Amount).Mul(k.GetParams(ctx).IncrementCollateral).RoundInt(),
),
)
if lot.Amount.GT(maxNewLotAmt) {
return auction, errorsmod.Wrapf(types.ErrLotTooLarge, "%s > %s%s", lot, maxNewLotAmt, auction.Lot.Denom)
}
if lot.IsNegative() {
return auction, errorsmod.Wrapf(types.ErrLotTooSmall, "%s < 0%s", lot, auction.Lot.Denom)
}
// New bidder pays back old bidder
// Catch edge cases of a bidder replacing their own bid
if !bidder.Equals(auction.Bidder) {
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, bidder, types.ModuleName, sdk.NewCoins(auction.Bid))
if err != nil {
return auction, err
}
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, auction.Bidder, sdk.NewCoins(auction.Bid))
if err != nil {
return auction, err
}
}
// Decrease in lot is sent to weighted addresses (normally the CDP depositors)
// Note: splitting an integer amount across weighted buckets results in small errors.
lotPayouts, err := splitCoinIntoWeightedBuckets(auction.Lot.Sub(lot), auction.LotReturns.Weights)
if err != nil {
return auction, err
}
for i, payout := range lotPayouts {
// if the payout amount is 0, don't send 0 coins
if !payout.IsPositive() {
continue
}
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, auction.LotReturns.Addresses[i], sdk.NewCoins(payout))
if err != nil {
return auction, err
}
}
// Update Auction
auction.Bidder = bidder
auction.Lot = lot
if !auction.HasReceivedBids {
auction.MaxEndTime = ctx.BlockTime().Add(k.GetParams(ctx).MaxAuctionDuration) // set maximum ending time on receipt of first bid
auction.HasReceivedBids = true
}
auction.EndTime = earliestTime(ctx.BlockTime().Add(k.GetParams(ctx).ReverseBidDuration), auction.MaxEndTime) // increment timeout, up to MaxEndTime
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAuctionBid,
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.ID)),
sdk.NewAttribute(types.AttributeKeyBidder, auction.Bidder.String()),
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
sdk.NewAttribute(types.AttributeKeyEndTime, fmt.Sprintf("%d", auction.EndTime.Unix())),
),
)
return auction, nil
}
// PlaceBidDebt places a reverse bid on a debt auction, moving coins and returning the updated auction.
func (k Keeper) PlaceBidDebt(ctx sdk.Context, auction *types.DebtAuction, bidder sdk.AccAddress, lot sdk.Coin) (*types.DebtAuction, error) {
// Validate new bid
if lot.Denom != auction.Lot.Denom {
return auction, errorsmod.Wrapf(types.ErrInvalidLotDenom, "%s ≠ %s", lot.Denom, auction.Lot.Denom)
}
maxNewLotAmt := auction.Lot.Amount.Sub( // new lot must be some % less than old lot, and at least 1 smaller to avoid replacing an old bid at no cost
sdk.MaxInt(
sdkmath.NewInt(1),
sdk.NewDecFromInt(auction.Lot.Amount).Mul(k.GetParams(ctx).IncrementDebt).RoundInt(),
),
)
if lot.Amount.GT(maxNewLotAmt) {
return auction, errorsmod.Wrapf(types.ErrLotTooLarge, "%s > %s%s", lot, maxNewLotAmt, auction.Lot.Denom)
}
if lot.IsNegative() {
return auction, errorsmod.Wrapf(types.ErrLotTooSmall, "%s ≤ %s%s", lot, sdk.ZeroInt(), auction.Lot.Denom)
}
// New bidder pays back old bidder
// Catch edge cases of a bidder replacing their own bid
if !bidder.Equals(auction.Bidder) {
// Bidder sends coins to module
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, bidder, types.ModuleName, sdk.NewCoins(auction.Bid))
if err != nil {
return auction, err
}
// Coins are sent from module to old bidder
oldBidder := auction.Bidder
if oldBidder.Equals(authtypes.NewModuleAddress(auction.Initiator)) { // First bid on auction (where there is no previous bidder)
err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, auction.Initiator, sdk.NewCoins(auction.Bid))
} else { // Second and later bids on auction (where previous bidder is a user account)
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, oldBidder, sdk.NewCoins(auction.Bid))
}
if err != nil {
return auction, err
}
}
// Debt coins are sent to liquidator the first time a bid is placed. Amount sent is equal to min of Bid and amount of debt.
if auction.Bidder.Equals(authtypes.NewModuleAddress(auction.Initiator)) {
// Handle debt coins for first bid
debtAmountToReturn := sdk.MinInt(auction.Bid.Amount, auction.CorrespondingDebt.Amount)
debtToReturn := sdk.NewCoin(auction.CorrespondingDebt.Denom, debtAmountToReturn)
err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, auction.Initiator, sdk.NewCoins(debtToReturn))
if err != nil {
return auction, err
}
auction.CorrespondingDebt = auction.CorrespondingDebt.Sub(debtToReturn) // debtToReturn will always be ≤ auction.CorrespondingDebt from the MinInt above
}
// Update Auction
auction.Bidder = bidder
auction.Lot = lot
if !auction.HasReceivedBids {
auction.MaxEndTime = ctx.BlockTime().Add(k.GetParams(ctx).MaxAuctionDuration) // set maximum ending time on receipt of first bid
auction.HasReceivedBids = true
}
auction.EndTime = earliestTime(ctx.BlockTime().Add(k.GetParams(ctx).ForwardBidDuration), auction.MaxEndTime) // increment timeout, up to MaxEndTime
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAuctionBid,
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.ID)),
sdk.NewAttribute(types.AttributeKeyBidder, auction.Bidder.String()),
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
sdk.NewAttribute(types.AttributeKeyEndTime, fmt.Sprintf("%d", auction.EndTime.Unix())),
),
)
return auction, nil
}
// CloseAuction closes an auction and distributes funds to the highest bidder.
func (k Keeper) CloseAuction(ctx sdk.Context, auctionID uint64) error {
auction, found := k.GetAuction(ctx, auctionID)
if !found {
return errorsmod.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)
}
if ctx.BlockTime().Before(auction.GetEndTime()) {
return errorsmod.Wrapf(types.ErrAuctionHasNotExpired, "block time %s, auction end time %s", ctx.BlockTime().UTC(), auction.GetEndTime().UTC())
}
// payout to the last bidder
var err error
switch auc := auction.(type) {
case *types.SurplusAuction:
err = k.PayoutSurplusAuction(ctx, auc)
case *types.DebtAuction:
err = k.PayoutDebtAuction(ctx, auc)
case *types.CollateralAuction:
err = k.PayoutCollateralAuction(ctx, auc)
default:
err = errorsmod.Wrap(types.ErrUnrecognizedAuctionType, auc.GetType())
}
if err != nil {
return err
}
k.DeleteAuction(ctx, auctionID)
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAuctionClose,
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auctionID)),
sdk.NewAttribute(types.AttributeKeyCloseBlock, fmt.Sprintf("%d", ctx.BlockHeight())),
),
)
return nil
}
// PayoutDebtAuction pays out the proceeds for a debt auction, first minting the coins.
func (k Keeper) PayoutDebtAuction(ctx sdk.Context, auction *types.DebtAuction) error {
// create the coins that are needed to pay off the debt
err := k.bankKeeper.MintCoins(ctx, auction.Initiator, sdk.NewCoins(auction.Lot))
if err != nil {
panic(fmt.Errorf("could not mint coins: %w", err))
}
// send the new coins from the initiator module to the bidder
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auction.Initiator, auction.Bidder, sdk.NewCoins(auction.Lot))
if err != nil {
return err
}
// if there is remaining debt, return it to the calling module to manage
if !auction.CorrespondingDebt.IsPositive() {
return nil
}
return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, auction.Initiator, sdk.NewCoins(auction.CorrespondingDebt))
}
// PayoutSurplusAuction pays out the proceeds for a surplus auction.
func (k Keeper) PayoutSurplusAuction(ctx sdk.Context, auction *types.SurplusAuction) error {
// Send the tokens from the auction module account where they are being managed to the bidder who won the auction
return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, auction.Bidder, sdk.NewCoins(auction.Lot))
}
// PayoutCollateralAuction pays out the proceeds for a collateral auction.
func (k Keeper) PayoutCollateralAuction(ctx sdk.Context, auction *types.CollateralAuction) error {
// Send the tokens from the auction module account where they are being managed to the bidder who won the auction
err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, auction.Bidder, sdk.NewCoins(auction.Lot))
if err != nil {
return err
}
// if there is remaining debt after the auction, send it back to the initiating module for management
if !auction.CorrespondingDebt.IsPositive() {
return nil
}
return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, auction.Initiator, sdk.NewCoins(auction.CorrespondingDebt))
}
// CloseExpiredAuctions iterates over all the auctions stored by until the current
// block timestamp and that are past (or at) their ending times and closes them,
// paying out to the highest bidder.
func (k Keeper) CloseExpiredAuctions(ctx sdk.Context) error {
var err error
k.IterateAuctionsByTime(ctx, ctx.BlockTime(), func(id uint64) (stop bool) {
err = k.CloseAuction(ctx, id)
if err != nil && !errors.Is(err, types.ErrAuctionNotFound) {
// stop iteration
return true
}
// reset error in case the last element had an ErrAuctionNotFound
err = nil
return false
})
return err
}
// earliestTime returns the earliest of two times.
func earliestTime(t1, t2 time.Time) time.Time {
if t1.Before(t2) {
return t1
}
return t2 // also returned if times are equal
}
// splitCoinIntoWeightedBuckets divides up some amount of coins according to some weights.
func splitCoinIntoWeightedBuckets(coin sdk.Coin, buckets []sdkmath.Int) ([]sdk.Coin, error) {
amounts := splitIntIntoWeightedBuckets(coin.Amount, buckets)
result := make([]sdk.Coin, len(amounts))
for i, a := range amounts {
result[i] = sdk.NewCoin(coin.Denom, a)
}
return result, nil
}

View File

@ -1,319 +0,0 @@
package keeper_test
import (
"testing"
"time"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/x/auction/testutil"
"github.com/kava-labs/kava/x/auction/types"
)
type auctionTestSuite struct {
testutil.Suite
}
func (suite *auctionTestSuite) SetupTest() {
suite.Suite.SetupTest(4)
}
func TestAuctionTestSuite(t *testing.T) {
suite.Run(t, new(auctionTestSuite))
}
func (suite *auctionTestSuite) TestSurplusAuctionBasic() {
buyer := suite.Addrs[0]
// TODO: use cdp.LiquidatorMacc once CDP module is available
// sellerModName := cdp.LiquidatorMacc
sellerAddr := authtypes.NewModuleAddress(suite.ModAcc.Name)
suite.AddCoinsToNamedModule(suite.ModAcc.Name, cs(c("token1", 100), c("token2", 100)))
// Create an auction (lot: 20 token1, initialBid: 0 token2)
auctionID, err := suite.Keeper.StartSurplusAuction(suite.Ctx, suite.ModAcc.Name, c("token1", 20), "token2") // lobid denom
suite.NoError(err)
// Check seller's coins have decreased
suite.CheckAccountBalanceEqual(sellerAddr, cs(c("token1", 80), c("token2", 100)))
// PlaceBid (bid: 10 token, lot: same as starting)
suite.NoError(suite.Keeper.PlaceBid(suite.Ctx, auctionID, buyer, c("token2", 10)))
// Check buyer's coins have decreased
suite.CheckAccountBalanceEqual(buyer, cs(c("token1", 100), c("token2", 90)))
// Check seller's coins have not increased (because proceeds are burned)
suite.CheckAccountBalanceEqual(sellerAddr, cs(c("token1", 80), c("token2", 100)))
// increment bid same bidder
err = suite.Keeper.PlaceBid(suite.Ctx, auctionID, buyer, c("token2", 20))
suite.NoError(err)
// Close auction just at auction expiry time
suite.Ctx = suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(types.DefaultForwardBidDuration))
suite.NoError(suite.Keeper.CloseAuction(suite.Ctx, auctionID))
// Check buyer's coins increased
suite.CheckAccountBalanceEqual(buyer, cs(c("token1", 120), c("token2", 80)))
}
func (suite *auctionTestSuite) TestDebtAuctionBasic() {
// Setup
seller := suite.Addrs[0]
suite.AddCoinsToNamedModule(suite.ModAcc.Name, cs(c("debt", 100)))
// Start auction
auctionID, err := suite.Keeper.StartDebtAuction(suite.Ctx, suite.ModAcc.Name, c("token1", 20), c("token2", 99999), c("debt", 20))
suite.NoError(err)
// Check buyer's coins have not decreased (except for debt), as lot is minted at the end
suite.CheckAccountBalanceEqual(suite.ModAcc.GetAddress(), cs(c("debt", 80)))
// Place a bid
suite.NoError(suite.Keeper.PlaceBid(suite.Ctx, auctionID, seller, c("token2", 10)))
// Check seller's coins have decreased
suite.CheckAccountBalanceEqual(seller, cs(c("token1", 80), c("token2", 100)))
// Check buyer's coins have increased
suite.CheckAccountBalanceEqual(suite.ModAcc.GetAddress(), cs(c("token1", 20), c("debt", 100)))
// Close auction at just after auction expiry
ctx := suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(types.DefaultForwardBidDuration))
suite.NoError(suite.Keeper.CloseAuction(ctx, auctionID))
// Check seller's coins increased
suite.CheckAccountBalanceEqual(seller, cs(c("token1", 80), c("token2", 110)))
}
func (suite *auctionTestSuite) TestDebtAuctionDebtRemaining() {
seller := suite.Addrs[0]
buyerAddr := authtypes.NewModuleAddress(suite.ModAcc.Name)
suite.AddCoinsToNamedModule(suite.ModAcc.Name, cs(c("debt", 100)))
// Start auction
auctionID, err := suite.Keeper.StartDebtAuction(suite.Ctx, suite.ModAcc.Name, c("token1", 10), c("token2", 99999), c("debt", 20))
suite.NoError(err)
// Check buyer's coins have not decreased (except for debt), as lot is minted at the end
suite.CheckAccountBalanceEqual(buyerAddr, cs(c("debt", 80)))
// Place a bid
suite.NoError(suite.Keeper.PlaceBid(suite.Ctx, auctionID, seller, c("token2", 10)))
// Check seller's coins have decreased
suite.CheckAccountBalanceEqual(seller, cs(c("token1", 90), c("token2", 100)))
// Check buyer's coins have increased
suite.CheckAccountBalanceEqual(buyerAddr, cs(c("token1", 10), c("debt", 90)))
// Close auction at just after auction expiry
ctx := suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(types.DefaultForwardBidDuration))
suite.NoError(suite.Keeper.CloseAuction(ctx, auctionID))
// Check seller's coins increased
suite.CheckAccountBalanceEqual(seller, cs(c("token1", 90), c("token2", 110)))
// check that debt has increased due to corresponding debt being greater than bid
suite.CheckAccountBalanceEqual(buyerAddr, cs(c("token1", 10), c("debt", 100)))
}
func (suite *auctionTestSuite) TestCollateralAuctionBasic() {
// Setup
buyer := suite.Addrs[0]
returnAddrs := suite.Addrs[1:]
returnWeights := is(30, 20, 10)
sellerModName := suite.ModAcc.Name
sellerAddr := suite.ModAcc.GetAddress()
suite.AddCoinsToNamedModule(sellerModName, cs(c("token1", 100), c("token2", 100), c("debt", 100)))
// Start auction
auctionID, err := suite.Keeper.StartCollateralAuction(suite.Ctx, sellerModName, c("token1", 20), c("token2", 50), returnAddrs, returnWeights, c("debt", 40))
suite.NoError(err)
// Check seller's coins have decreased
suite.CheckAccountBalanceEqual(sellerAddr, cs(c("token1", 80), c("token2", 100), c("debt", 60)))
// Place a forward bid
suite.NoError(suite.Keeper.PlaceBid(suite.Ctx, auctionID, buyer, c("token2", 10)))
// Check bidder's coins have decreased
suite.CheckAccountBalanceEqual(buyer, cs(c("token1", 100), c("token2", 90)))
// Check seller's coins have increased
suite.CheckAccountBalanceEqual(sellerAddr, cs(c("token1", 80), c("token2", 110), c("debt", 70)))
// Check return addresses have not received coins
for _, ra := range suite.Addrs[1:] {
suite.CheckAccountBalanceEqual(ra, cs(c("token1", 100), c("token2", 100)))
}
// Place a reverse bid
suite.NoError(suite.Keeper.PlaceBid(suite.Ctx, auctionID, buyer, c("token2", 50))) // first bid up to max bid to switch phases
suite.NoError(suite.Keeper.PlaceBid(suite.Ctx, auctionID, buyer, c("token1", 15)))
// Check bidder's coins have decreased
suite.CheckAccountBalanceEqual(buyer, cs(c("token1", 100), c("token2", 50)))
// Check seller's coins have increased
suite.CheckAccountBalanceEqual(sellerAddr, cs(c("token1", 80), c("token2", 150), c("debt", 100)))
// Check return addresses have received coins
suite.CheckAccountBalanceEqual(suite.Addrs[1], cs(c("token1", 102), c("token2", 100)))
suite.CheckAccountBalanceEqual(suite.Addrs[2], cs(c("token1", 102), c("token2", 100)))
suite.CheckAccountBalanceEqual(suite.Addrs[3], cs(c("token1", 101), c("token2", 100)))
// Close auction at just after auction expiry
ctx := suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(types.DefaultReverseBidDuration))
suite.NoError(suite.Keeper.CloseAuction(ctx, auctionID))
// Check buyer's coins increased
suite.CheckAccountBalanceEqual(buyer, cs(c("token1", 115), c("token2", 50)))
}
func (suite *auctionTestSuite) TestCollateralAuctionDebtRemaining() {
// Setup
buyer := suite.Addrs[0]
returnAddrs := suite.Addrs[1:]
returnWeights := is(30, 20, 10)
sellerModName := suite.ModAcc.Name
sellerAddr := suite.ModAcc.GetAddress()
suite.AddCoinsToNamedModule(sellerModName, cs(c("token1", 100), c("token2", 100), c("debt", 100)))
// Start auction
auctionID, err := suite.Keeper.StartCollateralAuction(suite.Ctx, sellerModName, c("token1", 20), c("token2", 50), returnAddrs, returnWeights, c("debt", 40))
suite.NoError(err)
// Check seller's coins have decreased
suite.CheckAccountBalanceEqual(sellerAddr, cs(c("token1", 80), c("token2", 100), c("debt", 60)))
// Place a forward bid
suite.NoError(suite.Keeper.PlaceBid(suite.Ctx, auctionID, buyer, c("token2", 10)))
// Check bidder's coins have decreased
suite.CheckAccountBalanceEqual(buyer, cs(c("token1", 100), c("token2", 90)))
// Check seller's coins have increased
suite.CheckAccountBalanceEqual(sellerAddr, cs(c("token1", 80), c("token2", 110), c("debt", 70)))
// Check return addresses have not received coins
for _, ra := range suite.Addrs[1:] {
suite.CheckAccountBalanceEqual(ra, cs(c("token1", 100), c("token2", 100)))
}
ctx := suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(types.DefaultForwardBidDuration))
suite.NoError(suite.Keeper.CloseAuction(ctx, auctionID))
// check that buyers coins have increased
suite.CheckAccountBalanceEqual(buyer, cs(c("token1", 120), c("token2", 90)))
// Check return addresses have not received coins
for _, ra := range suite.Addrs[1:] {
suite.CheckAccountBalanceEqual(ra, cs(c("token1", 100), c("token2", 100)))
}
// check that token2 has increased by 10, debt by 40, for a net debt increase of 30 debt
suite.CheckAccountBalanceEqual(sellerAddr, cs(c("token1", 80), c("token2", 110), c("debt", 100)))
}
func (suite *auctionTestSuite) TestStartSurplusAuction() {
someTime := time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC)
type args struct {
seller string
lot sdk.Coin
bidDenom string
}
testCases := []struct {
name string
blockTime time.Time
args args
expectPass bool
expPanic bool
}{
{
"normal",
someTime,
args{suite.ModAcc.Name, c("stable", 10), "gov"},
true, false,
},
{
"no module account",
someTime,
args{"nonExistentModule", c("stable", 10), "gov"},
false, true,
},
{
"not enough coins",
someTime,
args{suite.ModAcc.Name, c("stable", 101), "gov"},
false, false,
},
{
"incorrect denom",
someTime,
args{suite.ModAcc.Name, c("notacoin", 10), "gov"},
false, false,
},
}
for _, tc := range testCases {
suite.Run(tc.name, func() {
suite.SetupTest()
// setup
initialLiquidatorCoins := cs(c("stable", 100))
suite.AddCoinsToNamedModule(suite.ModAcc.Name, initialLiquidatorCoins)
// run function under test
var (
id uint64
err error
)
if tc.expPanic {
suite.Panics(func() {
_, _ = suite.Keeper.StartSurplusAuction(suite.Ctx, tc.args.seller, tc.args.lot, tc.args.bidDenom)
}, tc.name)
} else {
id, err = suite.Keeper.StartSurplusAuction(suite.Ctx, tc.args.seller, tc.args.lot, tc.args.bidDenom)
}
// check
liquidatorCoins := suite.BankKeeper.GetAllBalances(suite.Ctx, suite.ModAcc.GetAddress())
actualAuc, found := suite.Keeper.GetAuction(suite.Ctx, id)
if tc.expectPass {
suite.NoError(err, tc.name)
// check coins moved
suite.Equal(initialLiquidatorCoins.Sub(tc.args.lot), liquidatorCoins, tc.name)
// check auction in store and is correct
suite.True(found, tc.name)
surplusAuction := types.SurplusAuction{BaseAuction: types.BaseAuction{
ID: id,
Initiator: tc.args.seller,
Lot: tc.args.lot,
Bidder: nil,
Bid: c(tc.args.bidDenom, 0),
HasReceivedBids: false,
EndTime: types.DistantFuture,
MaxEndTime: types.DistantFuture,
}}
suite.Equal(&surplusAuction, actualAuc, tc.name)
} else if !tc.expPanic && !tc.expectPass {
suite.Error(err, tc.name)
// check coins not moved
suite.Equal(initialLiquidatorCoins, liquidatorCoins, tc.name)
// check auction not in store
suite.False(found, tc.name)
}
})
}
}
func (suite *auctionTestSuite) TestCloseAuction() {
suite.AddCoinsToNamedModule(suite.ModAcc.Name, cs(c("token1", 100), c("token2", 100)))
// Create an auction (lot: 20 token1, initialBid: 0 token2)
id, err := suite.Keeper.StartSurplusAuction(suite.Ctx, suite.ModAcc.Name, c("token1", 20), "token2") // lot, bid denom
suite.NoError(err)
// Attempt to close the auction before EndTime
suite.Error(suite.Keeper.CloseAuction(suite.Ctx, id))
// Attempt to close auction that does not exist
suite.Error(suite.Keeper.CloseAuction(suite.Ctx, 999))
}
func (suite *auctionTestSuite) TestCloseExpiredAuctions() {
suite.AddCoinsToNamedModule(suite.ModAcc.Name, cs(c("token1", 100), c("token2", 100)))
// Start auction 1
_, err := suite.Keeper.StartSurplusAuction(suite.Ctx, suite.ModAcc.Name, c("token1", 20), "token2") // lot, bid denom
suite.NoError(err)
// Start auction 2
_, err = suite.Keeper.StartSurplusAuction(suite.Ctx, suite.ModAcc.Name, c("token1", 20), "token2") // lot, bid denom
suite.NoError(err)
// Fast forward the block time
ctx := suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(types.DefaultMaxAuctionDuration).Add(1))
// Close expired auctions
err = suite.Keeper.CloseExpiredAuctions(ctx)
suite.NoError(err)
}

View File

@ -1,591 +0,0 @@
package keeper_test
import (
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
sdkmath "cosmossdk.io/math"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/auction/types"
)
type AuctionType int
const (
Invalid AuctionType = 0
Surplus AuctionType = 1
Debt AuctionType = 2
Collateral AuctionType = 3
)
func TestAuctionBidding(t *testing.T) {
config := sdk.GetConfig()
app.SetBech32AddressPrefixes(config)
someTime := time.Date(0o001, time.January, 1, 0, 0, 0, 0, time.UTC)
_, addrs := app.GeneratePrivKeyAddressPairs(5)
buyer := addrs[0]
secondBuyer := addrs[1]
modName := "liquidator"
collateralAddrs := addrs[2:]
collateralWeights := is(30, 20, 10)
initialBalance := cs(c("token1", 1000), c("token2", 1000))
type auctionArgs struct {
auctionType AuctionType
seller string
lot sdk.Coin
bid sdk.Coin
debt sdk.Coin
addresses []sdk.AccAddress
weights []sdkmath.Int
}
type bidArgs struct {
bidder sdk.AccAddress
amount sdk.Coin
}
tests := []struct {
name string
auctionArgs auctionArgs
setupBids []bidArgs
bidArgs bidArgs
expectedError error
expectedEndTime time.Time
expectedBidder sdk.AccAddress
expectedBid sdk.Coin
expectPass bool
expectPanic bool
}{
{
"basic: auction doesn't exist",
auctionArgs{Surplus, "", c("token1", 1), c("token2", 1), sdk.Coin{}, []sdk.AccAddress{}, []sdkmath.Int{}},
nil,
bidArgs{buyer, c("token2", 10)},
types.ErrAuctionNotFound,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 10),
false,
true,
},
{
"basic: closed auction",
auctionArgs{Surplus, modName, c("token1", 100), c("token2", 10), sdk.Coin{}, []sdk.AccAddress{}, []sdkmath.Int{}},
nil,
bidArgs{buyer, c("token2", 10)},
types.ErrAuctionHasExpired,
types.DistantFuture,
nil,
c("token2", 0),
false,
false,
},
{
// This is the first bid on an auction with NO bids
"surplus: normal",
auctionArgs{Surplus, modName, c("token1", 100), c("token2", 10), sdk.Coin{}, []sdk.AccAddress{}, []sdkmath.Int{}},
nil,
bidArgs{buyer, c("token2", 10)},
nil,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 10),
true,
false,
},
{
"surplus: second bidder",
auctionArgs{Surplus, modName, c("token1", 100), c("token2", 10), sdk.Coin{}, []sdk.AccAddress{}, []sdkmath.Int{}},
[]bidArgs{{buyer, c("token2", 10)}},
bidArgs{secondBuyer, c("token2", 11)},
nil,
someTime.Add(types.DefaultForwardBidDuration),
secondBuyer,
c("token2", 11),
true,
false,
},
{
"surplus: invalid bid denom",
auctionArgs{Surplus, modName, c("token1", 100), c("token2", 10), sdk.Coin{}, []sdk.AccAddress{}, []sdkmath.Int{}},
nil,
bidArgs{buyer, c("badtoken", 10)},
types.ErrInvalidBidDenom,
types.DistantFuture,
nil, // surplus auctions are created with initial bidder as a nil address
c("token2", 0),
false,
false,
},
{
"surplus: invalid bid (less than)",
auctionArgs{Surplus, modName, c("token1", 100), c("token2", 0), sdk.Coin{}, []sdk.AccAddress{}, []sdkmath.Int{}},
[]bidArgs{{buyer, c("token2", 100)}},
bidArgs{buyer, c("token2", 99)},
types.ErrBidTooSmall,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 100),
false,
false,
},
{
"surplus: invalid bid (equal)",
auctionArgs{Surplus, modName, c("token1", 100), c("token2", 0), sdk.Coin{}, []sdk.AccAddress{}, []sdkmath.Int{}},
nil,
bidArgs{buyer, c("token2", 0)}, // min bid is technically 0 at default 5%, but it's capped at 1
types.ErrBidTooSmall,
types.DistantFuture,
nil, // surplus auctions are created with initial bidder as a nil address
c("token2", 0),
false,
false,
},
{
"surplus: invalid bid (less than min increment)",
auctionArgs{Surplus, modName, c("token1", 100), c("token2", 0), sdk.Coin{}, []sdk.AccAddress{}, []sdkmath.Int{}},
[]bidArgs{{buyer, c("token2", 100)}},
bidArgs{buyer, c("token2", 104)}, // min bid is 105 at default 5%
types.ErrBidTooSmall,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 100),
false,
false,
},
{
"debt: normal",
auctionArgs{Debt, modName, c("token1", 20), c("token2", 100), c("debt", 100), []sdk.AccAddress{}, []sdkmath.Int{}}, // initial bid, lot
nil,
bidArgs{buyer, c("token1", 10)},
nil,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 100),
true,
false,
},
{
"debt: second bidder",
auctionArgs{Debt, modName, c("token1", 20), c("token2", 100), c("debt", 100), []sdk.AccAddress{}, []sdkmath.Int{}}, // initial bid, lot
[]bidArgs{{buyer, c("token1", 10)}},
bidArgs{secondBuyer, c("token1", 9)},
nil,
someTime.Add(types.DefaultForwardBidDuration),
secondBuyer,
c("token2", 100),
true,
false,
},
{
"debt: invalid lot denom",
auctionArgs{Debt, modName, c("token1", 20), c("token2", 100), c("debt", 100), []sdk.AccAddress{}, []sdkmath.Int{}}, // initial bid, lot
nil,
bidArgs{buyer, c("badtoken", 10)},
types.ErrInvalidLotDenom,
types.DistantFuture,
authtypes.NewModuleAddress(modName),
c("token2", 100),
false,
false,
},
{
"debt: invalid lot size (larger)",
auctionArgs{Debt, modName, c("token1", 20), c("token2", 100), c("debt", 100), []sdk.AccAddress{}, []sdkmath.Int{}},
nil,
bidArgs{buyer, c("token1", 21)},
types.ErrLotTooLarge,
types.DistantFuture,
authtypes.NewModuleAddress(modName),
c("token2", 100),
false,
false,
},
{
"debt: invalid lot size (equal)",
auctionArgs{Debt, modName, c("token1", 20), c("token2", 100), c("debt", 100), []sdk.AccAddress{}, []sdkmath.Int{}},
nil,
bidArgs{buyer, c("token1", 20)},
types.ErrLotTooLarge,
types.DistantFuture,
authtypes.NewModuleAddress(modName),
c("token2", 100),
false,
false,
},
{
"debt: invalid lot size (larger than min increment)",
auctionArgs{Debt, modName, c("token1", 60), c("token2", 100), c("debt", 100), []sdk.AccAddress{}, []sdkmath.Int{}},
nil,
bidArgs{buyer, c("token1", 58)}, // max lot at default 5% is 57
types.ErrLotTooLarge,
types.DistantFuture,
authtypes.NewModuleAddress(modName),
c("token2", 100),
false, false,
},
{
"collateral [forward]: normal",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
nil,
bidArgs{buyer, c("token2", 10)},
nil,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 10),
true,
false,
},
{
"collateral [forward]: second bidder",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 10)}},
bidArgs{secondBuyer, c("token2", 11)},
nil,
someTime.Add(types.DefaultForwardBidDuration),
secondBuyer,
c("token2", 11),
true,
false,
},
{
"collateral [forward]: convert to reverse (reach maxBid)",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 10)}},
bidArgs{secondBuyer, c("token2", 100)},
nil,
someTime.Add(types.DefaultReverseBidDuration),
secondBuyer,
c("token2", 100),
true,
false,
},
{
"collateral [forward]: invalid bid denom",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
nil,
bidArgs{buyer, c("badtoken", 10)},
types.ErrInvalidBidDenom,
types.DistantFuture,
nil,
c("token2", 0),
false,
false,
},
{
"collateral [forward]: invalid bid size (smaller)",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 10)}},
bidArgs{buyer, c("token2", 9)},
types.ErrBidTooSmall,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 10),
false,
false,
},
{
"collateral [forward]: invalid bid size (equal)",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
nil,
bidArgs{buyer, c("token2", 0)},
types.ErrBidTooSmall,
types.DistantFuture,
nil,
c("token2", 0),
false,
false,
},
{
"collateral [forward]: invalid bid size (less than min increment)",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 50)}},
bidArgs{buyer, c("token2", 51)},
types.ErrBidTooSmall,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 50),
false,
false,
},
{
"collateral [forward]: less than min increment but equal to maxBid",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 99)}},
bidArgs{buyer, c("token2", 100)}, // min bid at default 5% is 104
nil,
someTime.Add(types.DefaultReverseBidDuration), // Converts to a reverse bid when max reached
buyer,
c("token2", 100),
true,
false,
},
{
"collateral [forward]: invalid bid size (greater than max)",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 100), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
nil,
bidArgs{buyer, c("token2", 101)},
types.ErrBidTooLarge,
types.DistantFuture,
nil,
c("token2", 0),
false,
false,
},
{
"collateral [forward]: bidder replaces previous bid with only funds for difference",
auctionArgs{Collateral, modName, c("token1", 1000), c("token2", 2000), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 900)}},
bidArgs{buyer, c("token2", 1000)}, // buyer only has enough to cover the increase from previous bid
nil,
someTime.Add(types.DefaultForwardBidDuration),
buyer,
c("token2", 1000),
true,
false,
},
{
"collateral [reverse]: normal",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 50), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 50)}}, // put auction into reverse phase
bidArgs{buyer, c("token1", 15)},
nil,
someTime.Add(types.DefaultReverseBidDuration),
buyer,
c("token2", 50),
true,
false,
},
{
"collateral [reverse]: second bidder",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 50), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 50)}, {buyer, c("token1", 15)}}, // put auction into reverse phase, and add a reverse phase bid
bidArgs{secondBuyer, c("token1", 14)},
nil,
someTime.Add(types.DefaultReverseBidDuration),
secondBuyer,
c("token2", 50),
true,
false,
},
{
"collateral [reverse]: invalid lot denom",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 50), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 50)}}, // put auction into reverse phase
bidArgs{buyer, c("badtoken", 15)},
types.ErrInvalidLotDenom,
someTime.Add(types.DefaultReverseBidDuration),
buyer,
c("token2", 50),
false,
false,
},
{
"collateral [reverse]: invalid lot size (greater)",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 50), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 50)}}, // put auction into reverse phase
bidArgs{buyer, c("token1", 21)},
types.ErrLotTooLarge,
someTime.Add(types.DefaultReverseBidDuration),
buyer,
c("token2", 50),
false,
false,
},
{
"collateral [reverse]: invalid lot size (equal)",
auctionArgs{Collateral, modName, c("token1", 20), c("token2", 50), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 50)}}, // put auction into reverse phase
bidArgs{buyer, c("token1", 20)},
types.ErrLotTooLarge,
someTime.Add(types.DefaultReverseBidDuration),
buyer,
c("token2", 50),
false,
false,
},
{
"collateral [reverse]: invalid lot size (larger than min increment)",
auctionArgs{Collateral, modName, c("token1", 60), c("token2", 50), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 50)}}, // put auction into reverse phase
bidArgs{buyer, c("token1", 58)}, // max lot at default 5% is 57
types.ErrLotTooLarge,
someTime.Add(types.DefaultReverseBidDuration),
buyer,
c("token2", 50),
false,
false,
},
{
"collateral [reverse]: bidder replaces previous bid without funds",
auctionArgs{Collateral, modName, c("token1", 1000), c("token2", 1000), c("debt", 50), collateralAddrs, collateralWeights}, // lot, max bid
[]bidArgs{{buyer, c("token2", 1000)}},
bidArgs{buyer, c("token1", 100)}, // buyer has already bid all of their token2
nil,
someTime.Add(types.DefaultReverseBidDuration),
buyer,
c("token2", 1000),
true,
false,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
// Setup test
tApp := app.NewTestApp()
// Set up module account
modName := "liquidator"
modBaseAcc := authtypes.NewBaseAccount(authtypes.NewModuleAddress(modName), nil, 0, 0)
modAcc := authtypes.NewModuleAccount(modBaseAcc, modName, []string{authtypes.Minter, authtypes.Burner}...)
// Set up normal accounts
addrs := []sdk.AccAddress{buyer, secondBuyer, collateralAddrs[0], collateralAddrs[1], collateralAddrs[2]}
// Initialize app
authGS := app.NewFundedGenStateWithSameCoinsWithModuleAccount(tApp.AppCodec(), initialBalance, addrs, modAcc)
params := types.NewParams(
types.DefaultMaxAuctionDuration,
types.DefaultForwardBidDuration,
types.DefaultReverseBidDuration,
types.DefaultIncrement,
types.DefaultIncrement,
types.DefaultIncrement,
)
auctionGs, err := types.NewGenesisState(types.DefaultNextAuctionID, params, []types.GenesisAuction{})
require.NoError(t, err)
moduleGs := tApp.AppCodec().MustMarshalJSON(auctionGs)
gs := app.GenesisState{types.ModuleName: moduleGs}
tApp.InitializeFromGenesisStates(authGS, gs)
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: someTime})
keeper := tApp.GetAuctionKeeper()
bank := tApp.GetBankKeeper()
err = tApp.FundModuleAccount(ctx, modName, cs(c("token1", 1000), c("token2", 1000), c("debt", 1000)))
require.NoError(t, err)
// Start Auction
var id uint64
switch tc.auctionArgs.auctionType {
case Surplus:
if tc.expectPanic {
require.Panics(t, func() {
id, err = keeper.StartSurplusAuction(ctx, tc.auctionArgs.seller, tc.auctionArgs.lot, tc.auctionArgs.bid.Denom)
})
} else {
id, err = keeper.StartSurplusAuction(ctx, tc.auctionArgs.seller, tc.auctionArgs.lot, tc.auctionArgs.bid.Denom)
}
case Debt:
id, err = keeper.StartDebtAuction(ctx, tc.auctionArgs.seller, tc.auctionArgs.bid, tc.auctionArgs.lot, tc.auctionArgs.debt)
case Collateral:
id, err = keeper.StartCollateralAuction(ctx, tc.auctionArgs.seller, tc.auctionArgs.lot, tc.auctionArgs.bid, tc.auctionArgs.addresses, tc.auctionArgs.weights, tc.auctionArgs.debt) // seller, lot, maxBid, otherPerson
default:
t.Fail()
}
require.NoError(t, err)
// Place setup bids
for _, b := range tc.setupBids {
require.NoError(t, keeper.PlaceBid(ctx, id, b.bidder, b.amount))
}
// Close the auction early to test late bidding (if applicable)
if strings.Contains(tc.name, "closed") {
ctx = ctx.WithBlockTime(types.DistantFuture.Add(1))
}
// Store some state for use in checks
var oldBidder sdk.AccAddress
var oldBidderOldCoins sdk.Coins
oldAuction, found := keeper.GetAuction(ctx, id)
if found {
oldBidder = oldAuction.GetBidder()
}
if !oldBidder.Empty() {
oldBidderOldCoins = bank.GetAllBalances(ctx, oldBidder)
}
newBidderOldCoins := bank.GetAllBalances(ctx, tc.bidArgs.bidder)
// Place bid on auction
err = keeper.PlaceBid(ctx, id, tc.bidArgs.bidder, tc.bidArgs.amount)
// Check success/failure
if tc.expectPass {
require.NoError(t, err)
// Check auction was found
newAuction, found := keeper.GetAuction(ctx, id)
require.True(t, found)
// Check auction values
require.Equal(t, modName, newAuction.GetInitiator())
require.Equal(t, tc.expectedBidder, newAuction.GetBidder())
require.Equal(t, tc.expectedBid, newAuction.GetBid())
require.Equal(t, tc.expectedEndTime, newAuction.GetEndTime())
// Check coins have moved between bidder and previous bidder
bidAmt := tc.bidArgs.amount
switch tc.auctionArgs.auctionType {
case Debt:
bidAmt = oldAuction.GetBid()
case Collateral:
collatAuction, ok := oldAuction.(*types.CollateralAuction)
require.True(t, ok, tc.name)
if collatAuction.IsReversePhase() {
bidAmt = oldAuction.GetBid()
}
}
if oldBidder.Equals(tc.bidArgs.bidder) { // same bidder
require.Equal(t, newBidderOldCoins.Sub(bidAmt.Sub(oldAuction.GetBid())), bank.GetAllBalances(ctx, tc.bidArgs.bidder))
} else { // different bidder
require.Equal(t, newBidderOldCoins.Sub(bidAmt), bank.GetAllBalances(ctx, tc.bidArgs.bidder)) // wrapping in cs() to avoid comparing nil and empty coins
// handle checking debt coins for case debt auction has had no bids placed yet TODO make this less confusing
if oldBidder.Equals(authtypes.NewModuleAddress(oldAuction.GetInitiator())) {
require.Equal(t, oldBidderOldCoins.Add(oldAuction.GetBid()).Add(c("debt", oldAuction.GetBid().Amount.Int64())), bank.GetAllBalances(ctx, oldBidder))
} else if oldBidder.Empty() {
require.Equal(t, oldBidderOldCoins.Add(oldAuction.GetBid()).Add(c("debt", oldAuction.GetBid().Amount.Int64())).Empty(), oldBidderOldCoins.Empty())
} else {
require.Equal(t, cs(oldBidderOldCoins.Add(oldAuction.GetBid())...), bank.GetAllBalances(ctx, oldBidder))
}
}
} else {
// Check expected error code type
require.Error(t, err, "PlaceBid did not return an error")
require.ErrorIs(t, err, tc.expectedError)
// Check auction values
newAuction, found := keeper.GetAuction(ctx, id)
if found {
require.Equal(t, modName, newAuction.GetInitiator())
require.Equal(t, tc.expectedBidder, newAuction.GetBidder())
require.Equal(t, tc.expectedBid, newAuction.GetBid())
require.Equal(t, tc.expectedEndTime, newAuction.GetEndTime())
}
// Check coins have not moved
require.Equal(t, newBidderOldCoins, bank.GetAllBalances(ctx, tc.bidArgs.bidder))
if !oldBidder.Empty() {
require.Equal(t, oldBidderOldCoins, bank.GetAllBalances(ctx, oldBidder))
}
}
})
}
}

View File

@ -1,145 +0,0 @@
package keeper
import (
"context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
proto "github.com/cosmos/gogoproto/proto"
"github.com/kava-labs/kava/x/auction/types"
)
type queryServer struct {
keeper Keeper
}
// NewQueryServerImpl creates a new server for handling gRPC queries.
func NewQueryServerImpl(k Keeper) types.QueryServer {
return &queryServer{keeper: k}
}
var _ types.QueryServer = queryServer{}
// Params implements the gRPC service handler for querying x/auction parameters.
func (s queryServer) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}
sdkCtx := sdk.UnwrapSDKContext(ctx)
params := s.keeper.GetParams(sdkCtx)
return &types.QueryParamsResponse{Params: params}, nil
}
// Auction implements the Query/Auction gRPC method
func (s queryServer) Auction(c context.Context, req *types.QueryAuctionRequest) (*types.QueryAuctionResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}
ctx := sdk.UnwrapSDKContext(c)
auction, found := s.keeper.GetAuction(ctx, req.AuctionId)
if !found {
return &types.QueryAuctionResponse{}, nil
}
msg, ok := auction.(proto.Message)
if !ok {
return nil, status.Errorf(codes.Internal, "can't protomarshal %T", msg)
}
auctionAny, err := codectypes.NewAnyWithValue(msg)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
}
return &types.QueryAuctionResponse{
Auction: auctionAny,
}, nil
}
// Auctions implements the Query/Auctions gRPC method
func (s queryServer) Auctions(c context.Context, req *types.QueryAuctionsRequest) (*types.QueryAuctionsResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}
ctx := sdk.UnwrapSDKContext(c)
var auctions []*codectypes.Any
auctionStore := prefix.NewStore(ctx.KVStore(s.keeper.storeKey), types.AuctionKeyPrefix)
pageRes, err := query.FilteredPaginate(auctionStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) {
result, err := s.keeper.UnmarshalAuction(value)
if err != nil {
return false, err
}
// True if empty owner, otherwise check if auction contains owner
ownerIsMatch := req.Owner == ""
if req.Owner != "" {
if cAuc, ok := result.(*types.CollateralAuction); ok {
for _, addr := range cAuc.GetLotReturns().Addresses {
if addr.String() == req.Owner {
ownerIsMatch = true
break
}
}
}
}
phaseIsMatch := req.Phase == "" || req.Phase == result.GetPhase()
typeIsMatch := req.Type == "" || req.Type == result.GetType()
denomIsMatch := req.Denom == "" || req.Denom == result.GetBid().Denom || req.Denom == result.GetLot().Denom
if ownerIsMatch && phaseIsMatch && typeIsMatch && denomIsMatch {
if accumulate {
msg, ok := result.(proto.Message)
if !ok {
return false, status.Errorf(codes.Internal, "can't protomarshal %T", msg)
}
auctionAny, err := codectypes.NewAnyWithValue(msg)
if err != nil {
return false, err
}
auctions = append(auctions, auctionAny)
}
return true, nil
}
return false, nil
})
if err != nil {
return &types.QueryAuctionsResponse{}, err
}
return &types.QueryAuctionsResponse{
Auctions: auctions,
Pagination: pageRes,
}, nil
}
// NextAuctionID implements the gRPC service handler for querying x/auction next auction ID.
func (s queryServer) NextAuctionID(ctx context.Context, req *types.QueryNextAuctionIDRequest) (*types.QueryNextAuctionIDResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}
sdkCtx := sdk.UnwrapSDKContext(ctx)
nextAuctionID, err := s.keeper.GetNextAuctionID(sdkCtx)
if err != nil {
return &types.QueryNextAuctionIDResponse{}, err
}
return &types.QueryNextAuctionIDResponse{Id: nextAuctionID}, nil
}

View File

@ -1,137 +0,0 @@
package keeper_test
import (
"testing"
"time"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/auction/keeper"
"github.com/kava-labs/kava/x/auction/types"
"github.com/stretchr/testify/require"
)
func TestGrpcAuctionsFilter(t *testing.T) {
// setup
tApp := app.NewTestApp()
tApp.InitializeFromGenesisStates()
auctionsKeeper := tApp.GetAuctionKeeper()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
_, addrs := app.GeneratePrivKeyAddressPairs(2)
auctions := []types.Auction{
types.NewSurplusAuction(
"sellerMod",
c("swp", 12345678),
"usdx",
time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC),
).WithID(0),
types.NewDebtAuction(
"buyerMod",
c("hard", 12345678),
c("usdx", 12345678),
time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC),
c("debt", 12345678),
).WithID(1),
types.NewCollateralAuction(
"sellerMod",
c("ukava", 12345678),
time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC),
c("usdx", 12345678),
types.WeightedAddresses{
Addresses: addrs,
Weights: []sdkmath.Int{sdkmath.NewInt(100)},
},
c("debt", 12345678),
).WithID(2),
types.NewCollateralAuction(
"sellerMod",
c("hard", 12345678),
time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC),
c("usdx", 12345678),
types.WeightedAddresses{
Addresses: addrs,
Weights: []sdkmath.Int{sdkmath.NewInt(100)},
},
c("debt", 12345678),
).WithID(3),
}
for _, a := range auctions {
auctionsKeeper.SetAuction(ctx, a)
}
qs := keeper.NewQueryServerImpl(auctionsKeeper)
tests := []struct {
giveName string
giveRequest types.QueryAuctionsRequest
wantResponse []types.Auction
}{
{
"empty request",
types.QueryAuctionsRequest{},
auctions,
},
{
"denom query swp",
types.QueryAuctionsRequest{
Denom: "swp",
},
auctions[0:1],
},
{
"denom query usdx all",
types.QueryAuctionsRequest{
Denom: "usdx",
},
auctions,
},
{
"owner",
types.QueryAuctionsRequest{
Owner: addrs[0].String(),
},
auctions[2:4],
},
{
"owner and denom",
types.QueryAuctionsRequest{
Owner: addrs[0].String(),
Denom: "hard",
},
auctions[3:4],
},
{
"owner, denom, type, phase",
types.QueryAuctionsRequest{
Owner: addrs[0].String(),
Denom: "hard",
Type: types.CollateralAuctionType,
Phase: types.ForwardAuctionPhase,
},
auctions[3:4],
},
}
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)
var unpackedAuctions []types.Auction
for _, anyAuction := range res.Auctions {
var auction types.Auction
err := tApp.AppCodec().UnpackAny(anyAuction, &auction)
require.NoError(t, err)
unpackedAuctions = append(unpackedAuctions, auction)
}
require.Equal(t, tc.wantResponse, unpackedAuctions)
})
}
}

View File

@ -1,15 +0,0 @@
package keeper_test
import (
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func c(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) }
func cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) }
func is(ns ...int64) (is []sdkmath.Int) {
for _, n := range ns {
is = append(is, sdkmath.NewInt(n))
}
return
}

View File

@ -1,132 +0,0 @@
package keeper
import (
"fmt"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/x/auction/types"
)
// 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",
ValidAuctionInvariant(k))
ir.RegisterRoute(types.ModuleName, "valid-index",
ValidIndexInvariant(k))
}
// 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)
if !ok {
panic("stored auction type does not fulfill GenesisAuction interface")
}
totalAuctionCoins = totalAuctionCoins.Add(a.GetModuleAccountCoins()...)
return false
})
moduleAccCoins := k.bankKeeper.GetAllBalances(ctx, authtypes.NewModuleAddress(types.ModuleName))
broken := !moduleAccCoins.IsEqual(totalAuctionCoins)
invariantMessage := sdk.FormatInvariant(
types.ModuleName,
"module account",
fmt.Sprintf(
"\texpected ModuleAccount coins: %s\n"+
"\tactual ModuleAccount coins: %s\n",
totalAuctionCoins, moduleAccCoins),
)
return invariantMessage, broken
}
}
// ValidAuctionInvariant verifies that all auctions in the store are independently valid
func ValidAuctionInvariant(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
var validationErr error
var invalidAuction types.Auction
k.IterateAuctions(ctx, func(auction types.Auction) bool {
a, ok := auction.(types.GenesisAuction)
if !ok {
panic("stored auction type does not fulfill GenesisAuction interface")
}
if err := a.Validate(); err != nil {
validationErr = err
invalidAuction = a
return true
}
return false
})
broken := validationErr != nil
invariantMessage := sdk.FormatInvariant(
types.ModuleName,
"valid auctions",
fmt.Sprintf(
"\tfound invalid auction, reason: %s\n"+
"\tauction:\n\t%s\n",
validationErr, invalidAuction),
)
return invariantMessage, broken
}
}
// ValidIndexInvariant checks that all auctions in the store are also in the index and vice versa.
func ValidIndexInvariant(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
/* Method:
- check all the auction IDs in the index have a corresponding auction in the store
- index is now valid but there could be extra auction in the store
- check for these extra auctions by checking num items in the store equals that of index (store keys are always unique)
- doesn't check the IDs in the auction structs match the IDs in the keys
*/
// Check all auction IDs in the index are in the auction store
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionKeyPrefix)
indexIterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
defer indexIterator.Close()
var indexLength int
for ; indexIterator.Valid(); indexIterator.Next() {
indexLength++
idBytes := indexIterator.Value()
auctionBytes := store.Get(idBytes)
if auctionBytes == nil {
invariantMessage := sdk.FormatInvariant(
types.ModuleName,
"valid index",
fmt.Sprintf("\tauction with ID '%d' found in index but not in store", types.Uint64FromBytes(idBytes)))
return invariantMessage, true
}
}
// Check length of auction store matches the length of the index
storeIterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.AuctionKeyPrefix)
defer storeIterator.Close()
var storeLength int
for ; storeIterator.Valid(); storeIterator.Next() {
storeLength++
}
if storeLength != indexLength {
invariantMessage := sdk.FormatInvariant(
types.ModuleName,
"valid index",
fmt.Sprintf("\tmismatched number of items in auction store (%d) and index (%d)", storeLength, indexLength))
return invariantMessage, true
}
return "", false
}
}

View File

@ -1,217 +0,0 @@
package keeper
import (
"fmt"
"time"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cometbft/cometbft/libs/log"
"github.com/kava-labs/kava/x/auction/types"
)
type Keeper struct {
storeKey storetypes.StoreKey
cdc codec.Codec
paramSubspace paramtypes.Subspace
bankKeeper types.BankKeeper
accountKeeper types.AccountKeeper
}
// NewKeeper returns a new auction keeper.
func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, paramstore paramtypes.Subspace,
bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
}
return Keeper{
storeKey: storeKey,
cdc: cdc,
paramSubspace: paramstore,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
}
}
// MustUnmarshalAuction attempts to decode and return an Auction object from
// raw encoded bytes. It panics on error.
func (k Keeper) MustUnmarshalAuction(bz []byte) types.Auction {
auction, err := k.UnmarshalAuction(bz)
if err != nil {
panic(fmt.Errorf("failed to decode auction: %w", err))
}
return auction
}
// MustMarshalAuction attempts to encode an Auction object and returns the
// raw encoded bytes. It panics on error.
func (k Keeper) MustMarshalAuction(auction types.Auction) []byte {
bz, err := k.MarshalAuction(auction)
if err != nil {
panic(fmt.Errorf("failed to encode auction: %w", err))
}
return bz
}
// MarshalAuction protobuf serializes an Auction interface
func (k Keeper) MarshalAuction(auctionI types.Auction) ([]byte, error) {
return k.cdc.MarshalInterface(auctionI)
}
// UnmarshalAuction returns an Auction interface from raw encoded auction
// bytes of a Proto-based Auction type
func (k Keeper) UnmarshalAuction(bz []byte) (types.Auction, error) {
var evi types.Auction
return evi, k.cdc.UnmarshalInterface(bz, &evi)
}
// Logger returns a module-specific logger.
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}
// SetNextAuctionID stores an ID to be used for the next created auction
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
func (k Keeper) GetNextAuctionID(ctx sdk.Context) (uint64, error) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.NextAuctionIDKey)
bz := store.Get(types.NextAuctionIDKey)
if bz == nil {
return 0, types.ErrInvalidInitialAuctionID
}
return types.Uint64FromBytes(bz), nil
}
// IncrementNextAuctionID increments the next auction ID in the store by 1.
func (k Keeper) IncrementNextAuctionID(ctx sdk.Context) error {
id, err := k.GetNextAuctionID(ctx)
if err != nil {
return err
}
k.SetNextAuctionID(ctx, id+1)
return nil
}
// StoreNewAuction stores an auction, adding a new ID
func (k Keeper) StoreNewAuction(ctx sdk.Context, auction types.Auction) (uint64, error) {
newAuctionID, err := k.GetNextAuctionID(ctx)
if err != nil {
return 0, err
}
auction = auction.WithID(newAuctionID)
k.SetAuction(ctx, auction)
err = k.IncrementNextAuctionID(ctx)
if err != nil {
return 0, err
}
return newAuctionID, nil
}
// SetAuction puts the auction into the store, and updates any indexes.
func (k Keeper) SetAuction(ctx sdk.Context, auction types.Auction) {
// remove the auction from the byTime index if it is already in there
existingAuction, found := k.GetAuction(ctx, auction.GetID())
if found {
k.removeFromByTimeIndex(ctx, existingAuction.GetEndTime(), existingAuction.GetID())
}
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionKeyPrefix)
store.Set(types.GetAuctionKey(auction.GetID()), k.MustMarshalAuction(auction))
k.InsertIntoByTimeIndex(ctx, auction.GetEndTime(), auction.GetID())
}
// GetAuction gets an auction from the store.
func (k Keeper) GetAuction(ctx sdk.Context, auctionID uint64) (types.Auction, bool) {
var auction types.Auction
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionKeyPrefix)
bz := store.Get(types.GetAuctionKey(auctionID))
if bz == nil {
return auction, false
}
return k.MustUnmarshalAuction(bz), true
}
// DeleteAuction removes an auction from the store, and any indexes.
func (k Keeper) DeleteAuction(ctx sdk.Context, auctionID uint64) {
auction, found := k.GetAuction(ctx, auctionID)
if found {
k.removeFromByTimeIndex(ctx, auction.GetEndTime(), auctionID)
}
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionKeyPrefix)
store.Delete(types.GetAuctionKey(auctionID))
}
// InsertIntoByTimeIndex adds an auction ID and end time into the byTime index.
func (k Keeper) InsertIntoByTimeIndex(ctx sdk.Context, endTime time.Time, auctionID uint64) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
store.Set(types.GetAuctionByTimeKey(endTime, auctionID), types.Uint64ToBytes(auctionID))
}
// removeFromByTimeIndex removes an auction ID and end time from the byTime index.
func (k Keeper) removeFromByTimeIndex(ctx sdk.Context, endTime time.Time, auctionID uint64) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
store.Delete(types.GetAuctionByTimeKey(endTime, auctionID))
}
// IterateAuctionByTime provides an iterator over auctions ordered by auction.EndTime.
// For each auction cb will be callled. If cb returns true the iterator will close and stop.
func (k Keeper) IterateAuctionsByTime(ctx sdk.Context, inclusiveCutoffTime time.Time, cb func(auctionID uint64) (stop bool)) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
iterator := store.Iterator(
nil, // start at the very start of the prefix store
sdk.PrefixEndBytes(sdk.FormatTimeBytes(inclusiveCutoffTime)), // include any keys with times equal to inclusiveCutoffTime
)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
auctionID := types.Uint64FromBytes(iterator.Value())
if cb(auctionID) {
break
}
}
}
// IterateAuctions provides an iterator over all stored auctions.
// For each auction, cb will be called. If cb returns true, the iterator will close and stop.
func (k Keeper) IterateAuctions(ctx sdk.Context, cb func(auction types.Auction) (stop bool)) {
iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.AuctionKeyPrefix)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
auction := k.MustUnmarshalAuction(iterator.Value())
if cb(auction) {
break
}
}
}
// GetAllAuctions returns all auctions from the store
func (k Keeper) GetAllAuctions(ctx sdk.Context) (auctions []types.Auction) {
k.IterateAuctions(ctx, func(auction types.Auction) bool {
auctions = append(auctions, auction)
return false
})
return
}

View File

@ -1,135 +0,0 @@
package keeper_test
import (
"testing"
"time"
"github.com/stretchr/testify/require"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/auction/types"
)
func SetGetDeleteAuction(t *testing.T) {
// setup keeper, create auction
tApp := app.NewTestApp()
keeper := tApp.GetAuctionKeeper()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
someTime := time.Date(43, time.January, 1, 0, 0, 0, 0, time.UTC) // need to specify UTC as tz info is lost on unmarshal
var id uint64 = 5
auction := types.NewSurplusAuction("some_module", c("usdx", 100), "kava", someTime).WithID(id)
// write and read from store
keeper.SetAuction(ctx, auction)
readAuction, found := keeper.GetAuction(ctx, id)
// check before and after match
require.True(t, found)
require.Equal(t, auction, readAuction)
// check auction is in the index
keeper.IterateAuctionsByTime(ctx, auction.GetEndTime(), func(readID uint64) bool {
require.Equal(t, auction.GetID(), readID)
return false
})
// delete auction
keeper.DeleteAuction(ctx, id)
// check auction does not exist
_, found = keeper.GetAuction(ctx, id)
require.False(t, found)
// check auction not in index
keeper.IterateAuctionsByTime(ctx, time.Unix(999999999, 0), func(readID uint64) bool {
require.Fail(t, "index should be empty", " found auction ID '%s", readID)
return false
})
}
func TestIncrementNextAuctionID(t *testing.T) {
// setup keeper
tApp := app.NewTestApp()
keeper := tApp.GetAuctionKeeper()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
// store id
var id uint64 = 123456
keeper.SetNextAuctionID(ctx, id)
require.NoError(t, keeper.IncrementNextAuctionID(ctx))
// check id was incremented
readID, err := keeper.GetNextAuctionID(ctx)
require.NoError(t, err)
require.Equal(t, id+1, readID)
}
func TestIterateAuctions(t *testing.T) {
// setup
tApp := app.NewTestApp()
tApp.InitializeFromGenesisStates()
keeper := tApp.GetAuctionKeeper()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
auctions := []types.Auction{
types.NewSurplusAuction("sellerMod", c("denom", 12345678), "anotherdenom", time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC)).WithID(0),
types.NewDebtAuction("buyerMod", c("denom", 12345678), c("anotherdenom", 12345678), time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC), c("debt", 12345678)).WithID(1),
types.NewCollateralAuction("sellerMod", c("denom", 12345678), time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC), c("anotherdenom", 12345678), types.WeightedAddresses{}, c("debt", 12345678)).WithID(2),
}
for _, a := range auctions {
keeper.SetAuction(ctx, a)
}
// run
var readAuctions []types.Auction
keeper.IterateAuctions(ctx, func(a types.Auction) bool {
readAuctions = append(readAuctions, a)
return false
})
// check
require.Equal(t, auctions, readAuctions)
}
func TestIterateAuctionsByTime(t *testing.T) {
// setup keeper
tApp := app.NewTestApp()
keeper := tApp.GetAuctionKeeper()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1})
// setup byTime index
byTimeIndex := []struct {
endTime time.Time
auctionID uint64
}{
{time.Date(0, time.January, 1, 0, 0, 0, 0, time.UTC), 9999}, // distant past
{time.Date(1998, time.January, 1, 11, 59, 59, 999999999, time.UTC), 1}, // just before cutoff
{time.Date(1998, time.January, 1, 11, 59, 59, 999999999, time.UTC), 2}, //
{time.Date(1998, time.January, 1, 12, 0, 0, 0, time.UTC), 3}, // equal to cutoff
{time.Date(1998, time.January, 1, 12, 0, 0, 0, time.UTC), 4}, //
{time.Date(1998, time.January, 1, 12, 0, 0, 1, time.UTC), 5}, // just after cutoff
{time.Date(1998, time.January, 1, 12, 0, 0, 1, time.UTC), 6}, //
{time.Date(9999, time.January, 1, 0, 0, 0, 0, time.UTC), 0}, // distant future
}
for _, v := range byTimeIndex {
keeper.InsertIntoByTimeIndex(ctx, v.endTime, v.auctionID)
}
// read out values from index up to a cutoff time and check they are as expected
cutoffTime := time.Date(1998, time.January, 1, 12, 0, 0, 0, time.UTC)
var expectedIndex []uint64
for _, v := range byTimeIndex {
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 {
readIndex = append(readIndex, id)
return false
})
require.Equal(t, expectedIndex, readIndex)
}

View File

@ -1,81 +0,0 @@
package keeper
import (
"sort"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// splitIntIntoWeightedBuckets divides an initial +ve integer among several buckets in proportion to the buckets' weights
// It uses the largest remainder method: https://en.wikipedia.org/wiki/Largest_remainder_method
// See also: https://stackoverflow.com/questions/13483430/how-to-make-rounded-percentages-add-up-to-100
func splitIntIntoWeightedBuckets(amount sdkmath.Int, buckets []sdkmath.Int) []sdkmath.Int {
// Limit input to +ve numbers as algorithm hasn't been scoped to work with -ve numbers.
if amount.IsNegative() {
panic("negative amount")
}
if len(buckets) < 1 {
panic("no buckets")
}
for _, bucket := range buckets {
if bucket.IsNegative() {
panic("negative bucket")
}
}
// 1) Split the amount by weights, recording whole number part and remainder
totalWeights := totalInts(buckets...)
if !totalWeights.IsPositive() {
panic("total weights must sum to > 0")
}
quotients := make([]quoRem, len(buckets))
for i := range buckets {
// amount * ( weight/total_weight )
q := amount.Mul(buckets[i]).Quo(totalWeights)
r := amount.Mul(buckets[i]).Mod(totalWeights)
quotients[i] = quoRem{index: i, quo: q, rem: r}
}
// 2) Calculate total left over from remainders, and apportion it to buckets with the highest remainder (to minimize error)
// sort by decreasing remainder order
sort.Slice(quotients, func(i, j int) bool {
return quotients[i].rem.GT(quotients[j].rem)
})
// calculate total left over from remainders
allocated := sdk.ZeroInt()
for _, qr := range quotients {
allocated = allocated.Add(qr.quo)
}
leftToAllocate := amount.Sub(allocated)
// apportion according to largest remainder
results := make([]sdkmath.Int, len(quotients))
for _, qr := range quotients {
results[qr.index] = qr.quo
if !leftToAllocate.IsZero() {
results[qr.index] = results[qr.index].Add(sdk.OneInt())
leftToAllocate = leftToAllocate.Sub(sdk.OneInt())
}
}
return results
}
type quoRem struct {
index int
quo sdkmath.Int
rem sdkmath.Int
}
// totalInts adds together sdk.Ints
func totalInts(is ...sdkmath.Int) sdkmath.Int {
total := sdk.ZeroInt()
for _, i := range is {
total = total.Add(i)
}
return total
}

View File

@ -1,115 +0,0 @@
package keeper
import (
"testing"
"github.com/stretchr/testify/require"
sdkmath "cosmossdk.io/math"
)
func TestSplitIntIntoWeightedBuckets(t *testing.T) {
testCases := []struct {
name string
amount sdkmath.Int
buckets []sdkmath.Int
want []sdkmath.Int
expectPanic bool
}{
{
name: "0split0",
amount: i(0),
buckets: is(0),
expectPanic: true,
},
{
name: "5splitnil",
amount: i(5),
buckets: is(),
expectPanic: true,
},
{
name: "-2split1,1",
amount: i(-2),
buckets: is(1, 1),
expectPanic: true,
},
{
name: "2split1,-1",
amount: i(2),
buckets: is(1, -1),
expectPanic: true,
},
{
name: "0split0,0,0,1",
amount: i(0),
buckets: is(0, 0, 0, 1),
want: is(0, 0, 0, 0),
},
{
name: "2split1,1",
amount: i(2),
buckets: is(1, 1),
want: is(1, 1),
},
{
name: "100split1,9",
amount: i(100),
buckets: is(1, 9),
want: is(10, 90),
},
{
name: "100split9,1",
amount: i(100),
buckets: is(9, 1),
want: is(90, 10),
},
{
name: "7split1,2",
amount: i(7),
buckets: is(1, 2),
want: is(2, 5),
},
{
name: "17split1,1,1",
amount: i(17),
buckets: is(1, 1, 1),
want: is(6, 6, 5),
},
{
name: "10split1000000,1",
amount: i(10),
buckets: is(1000000, 1),
want: is(10, 0),
},
{
name: "334733353split730777,31547",
amount: i(334733353),
buckets: is(730777, 31547),
want: is(320881194, 13852159),
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
var got []sdkmath.Int
run := func() {
got = splitIntIntoWeightedBuckets(tc.amount, tc.buckets)
}
if tc.expectPanic {
require.Panics(t, run)
} else {
require.NotPanics(t, run)
}
require.Equal(t, tc.want, got)
})
}
}
func i(n int64) sdkmath.Int { return sdkmath.NewInt(n) }
func is(ns ...int64) (is []sdkmath.Int) {
for _, n := range ns {
is = append(is, sdkmath.NewInt(n))
}
return
}

View File

@ -1,43 +0,0 @@
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/auction/types"
)
type msgServer struct {
keeper Keeper
}
// NewMsgServerImpl returns an implementation of the auction MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{keeper: keeper}
}
var _ types.MsgServer = msgServer{}
func (k msgServer) PlaceBid(goCtx context.Context, msg *types.MsgPlaceBid) (*types.MsgPlaceBidResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
bidder, err := sdk.AccAddressFromBech32(msg.Bidder)
if err != nil {
return nil, err
}
err = k.keeper.PlaceBid(ctx, msg.AuctionId, bidder, msg.Amount)
if err != nil {
return nil, err
}
ctx.EventManager().EmitEvent(
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Bidder),
),
)
return &types.MsgPlaceBidResponse{}, nil
}

View File

@ -1,16 +0,0 @@
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/auction/types"
)
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramSubspace.SetParamSet(ctx, &params)
}
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
k.paramSubspace.GetParamSet(ctx, &params)
return
}

View File

@ -1,16 +0,0 @@
package types
import (
types "github.com/cosmos/cosmos-sdk/codec/types"
v017auction "github.com/kava-labs/kava/x/auction/types"
)
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterInterface(
"kava.auction.v1beta1.GenesisAuction",
(*v017auction.GenesisAuction)(nil),
&v017auction.SurplusAuction{},
&v017auction.DebtAuction{},
&v017auction.CollateralAuction{},
)
}

View File

@ -1,761 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: kava/auction/v1beta1/genesis.proto
package types
import (
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
types "github.com/cosmos/cosmos-sdk/codec/types"
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
_ "google.golang.org/protobuf/types/known/durationpb"
io "io"
math "math"
math_bits "math/bits"
time "time"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
var _ = time.Kitchen
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the auction module's genesis state.
type GenesisState struct {
NextAuctionId uint64 `protobuf:"varint,1,opt,name=next_auction_id,json=nextAuctionId,proto3" json:"next_auction_id,omitempty"`
Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
// Genesis auctions
Auctions []*types.Any `protobuf:"bytes,3,rep,name=auctions,proto3" json:"auctions,omitempty"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
func (m *GenesisState) String() string { return proto.CompactTextString(m) }
func (*GenesisState) ProtoMessage() {}
func (*GenesisState) Descriptor() ([]byte, []int) {
return fileDescriptor_d0e5cb58293042f7, []int{0}
}
func (m *GenesisState) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *GenesisState) XXX_Merge(src proto.Message) {
xxx_messageInfo_GenesisState.Merge(m, src)
}
func (m *GenesisState) XXX_Size() int {
return m.Size()
}
func (m *GenesisState) XXX_DiscardUnknown() {
xxx_messageInfo_GenesisState.DiscardUnknown(m)
}
var xxx_messageInfo_GenesisState proto.InternalMessageInfo
// Params defines the parameters for the issuance module.
type Params struct {
MaxAuctionDuration time.Duration `protobuf:"bytes,1,opt,name=max_auction_duration,json=maxAuctionDuration,proto3,stdduration" json:"max_auction_duration"`
BidDuration time.Duration `protobuf:"bytes,2,opt,name=bid_duration,json=bidDuration,proto3,stdduration" json:"bid_duration"`
IncrementSurplus github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=increment_surplus,json=incrementSurplus,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_surplus"`
IncrementDebt github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=increment_debt,json=incrementDebt,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_debt"`
IncrementCollateral github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=increment_collateral,json=incrementCollateral,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_collateral"`
}
func (m *Params) Reset() { *m = Params{} }
func (m *Params) String() string { return proto.CompactTextString(m) }
func (*Params) ProtoMessage() {}
func (*Params) Descriptor() ([]byte, []int) {
return fileDescriptor_d0e5cb58293042f7, []int{1}
}
func (m *Params) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Params.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Params) XXX_Merge(src proto.Message) {
xxx_messageInfo_Params.Merge(m, src)
}
func (m *Params) XXX_Size() int {
return m.Size()
}
func (m *Params) XXX_DiscardUnknown() {
xxx_messageInfo_Params.DiscardUnknown(m)
}
var xxx_messageInfo_Params proto.InternalMessageInfo
var fileDescriptor_d0e5cb58293042f7 = []byte{
// 466 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x31, 0x6f, 0xd3, 0x40,
0x14, 0xc7, 0x7d, 0x4d, 0x88, 0xaa, 0x4b, 0x5a, 0xe0, 0xf0, 0xe0, 0x56, 0xc8, 0x89, 0x32, 0x54,
0x61, 0xc8, 0x59, 0x0d, 0x1b, 0x5b, 0x4d, 0x44, 0xc5, 0x86, 0x5c, 0x75, 0x81, 0x21, 0xba, 0xb3,
0x0f, 0x63, 0xd5, 0xf6, 0x45, 0xbe, 0x73, 0x95, 0x7c, 0x0b, 0x46, 0x3e, 0x08, 0x03, 0x13, 0x73,
0xc4, 0xd4, 0x11, 0x31, 0x14, 0x48, 0xbe, 0x08, 0xf2, 0xdd, 0xe5, 0x82, 0x80, 0x01, 0x75, 0xca,
0xdd, 0x7b, 0xff, 0xff, 0xef, 0xfd, 0x9f, 0x2e, 0x86, 0xc3, 0x2b, 0x72, 0x4d, 0x02, 0x52, 0xc7,
0x32, 0xe3, 0x65, 0x70, 0x7d, 0x4a, 0x99, 0x24, 0xa7, 0x41, 0xca, 0x4a, 0x26, 0x32, 0x81, 0xe7,
0x15, 0x97, 0x1c, 0xb9, 0x8d, 0x06, 0x1b, 0x0d, 0x36, 0x9a, 0x63, 0x37, 0xe5, 0x29, 0x57, 0x82,
0xa0, 0x39, 0x69, 0xed, 0xf1, 0x51, 0xca, 0x79, 0x9a, 0xb3, 0x40, 0xdd, 0x68, 0xfd, 0x36, 0x20,
0xe5, 0x72, 0xdb, 0x8a, 0xb9, 0x28, 0xb8, 0x98, 0x69, 0x8f, 0xbe, 0x98, 0x96, 0xff, 0xa7, 0x2b,
0xa9, 0x2b, 0xa2, 0xa6, 0xa9, 0xca, 0xf0, 0x13, 0x80, 0xbd, 0x73, 0x9d, 0xe9, 0x42, 0x12, 0xc9,
0xd0, 0x09, 0xbc, 0x5f, 0xb2, 0x85, 0x9c, 0x99, 0x50, 0xb3, 0x2c, 0xf1, 0xc0, 0x00, 0x8c, 0xda,
0xd1, 0x41, 0x53, 0x3e, 0xd3, 0xd5, 0x97, 0x09, 0x7a, 0x06, 0x3b, 0x73, 0x52, 0x91, 0x42, 0x78,
0x7b, 0x03, 0x30, 0xea, 0x4e, 0x1e, 0xe3, 0x7f, 0xed, 0x82, 0x5f, 0x29, 0x4d, 0xd8, 0x5e, 0xdd,
0xf6, 0x9d, 0xc8, 0x38, 0xd0, 0x14, 0xee, 0x1b, 0x9d, 0xf0, 0x5a, 0x83, 0xd6, 0xa8, 0x3b, 0x71,
0xb1, 0xce, 0x89, 0xb7, 0x39, 0xf1, 0x59, 0xb9, 0x0c, 0xd1, 0x97, 0x8f, 0xe3, 0x43, 0x93, 0xce,
0x4c, 0x8e, 0xac, 0x73, 0xf8, 0xb9, 0x05, 0x3b, 0x1a, 0x8f, 0x2e, 0xa1, 0x5b, 0x90, 0x85, 0xcd,
0xbc, 0xdd, 0x51, 0x25, 0xef, 0x4e, 0x8e, 0xfe, 0x82, 0x4f, 0x8d, 0x20, 0xdc, 0x6f, 0x72, 0x7d,
0xf8, 0xde, 0x07, 0x11, 0x2a, 0xc8, 0xc2, 0xcc, 0xd8, 0x76, 0xd1, 0x0b, 0xd8, 0xa3, 0x59, 0xb2,
0xc3, 0xed, 0xfd, 0x3f, 0xae, 0x4b, 0xb3, 0xc4, 0x72, 0xde, 0xc0, 0x87, 0x59, 0x19, 0x57, 0xac,
0x60, 0xa5, 0x9c, 0x89, 0xba, 0x9a, 0xe7, 0x75, 0xb3, 0x38, 0x18, 0xf5, 0x42, 0xdc, 0x38, 0xbe,
0xdd, 0xf6, 0x4f, 0xd2, 0x4c, 0xbe, 0xab, 0x29, 0x8e, 0x79, 0x61, 0x1e, 0xd0, 0xfc, 0x8c, 0x45,
0x72, 0x15, 0xc8, 0xe5, 0x9c, 0x09, 0x3c, 0x65, 0x71, 0xf4, 0xc0, 0x82, 0x2e, 0x34, 0x07, 0x5d,
0xc2, 0xc3, 0x1d, 0x3c, 0x61, 0x54, 0x7a, 0xed, 0x3b, 0x91, 0x0f, 0x2c, 0x65, 0xca, 0xa8, 0x44,
0x04, 0xba, 0x3b, 0x6c, 0xcc, 0xf3, 0x9c, 0x48, 0x56, 0x91, 0xdc, 0xbb, 0x77, 0x27, 0xf8, 0x23,
0xcb, 0x7a, 0x6e, 0x51, 0xe1, 0xf9, 0xea, 0xa7, 0xef, 0xac, 0xd6, 0x3e, 0xb8, 0x59, 0xfb, 0xe0,
0xc7, 0xda, 0x07, 0xef, 0x37, 0xbe, 0x73, 0xb3, 0xf1, 0x9d, 0xaf, 0x1b, 0xdf, 0x79, 0xfd, 0xe4,
0x37, 0x74, 0xf3, 0xd7, 0x1a, 0xe7, 0x84, 0x0a, 0x75, 0x0a, 0x16, 0xf6, 0xb3, 0x52, 0x13, 0x68,
0x47, 0xbd, 0xc4, 0xd3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa5, 0x20, 0xff, 0x87, 0x73, 0x03,
0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Auctions) > 0 {
for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Auctions[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
}
}
{
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
if m.NextAuctionId != 0 {
i = encodeVarintGenesis(dAtA, i, uint64(m.NextAuctionId))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func (m *Params) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Params) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size := m.IncrementCollateral.Size()
i -= size
if _, err := m.IncrementCollateral.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
{
size := m.IncrementDebt.Size()
i -= size
if _, err := m.IncrementDebt.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
{
size := m.IncrementSurplus.Size()
i -= size
if _, err := m.IncrementSurplus.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.BidDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidDuration):])
if err2 != nil {
return 0, err2
}
i -= n2
i = encodeVarintGenesis(dAtA, i, uint64(n2))
i--
dAtA[i] = 0x12
n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAuctionDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration):])
if err3 != nil {
return 0, err3
}
i -= n3
i = encodeVarintGenesis(dAtA, i, uint64(n3))
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
offset -= sovGenesis(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *GenesisState) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.NextAuctionId != 0 {
n += 1 + sovGenesis(uint64(m.NextAuctionId))
}
l = m.Params.Size()
n += 1 + l + sovGenesis(uint64(l))
if len(m.Auctions) > 0 {
for _, e := range m.Auctions {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
return n
}
func (m *Params) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration)
n += 1 + l + sovGenesis(uint64(l))
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidDuration)
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementSurplus.Size()
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementDebt.Size()
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementCollateral.Size()
n += 1 + l + sovGenesis(uint64(l))
return n
}
func sovGenesis(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozGenesis(x uint64) (n int) {
return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *GenesisState) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field NextAuctionId", wireType)
}
m.NextAuctionId = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.NextAuctionId |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Auctions", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Auctions = append(m.Auctions, &types.Any{})
if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Params) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Params: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field MaxAuctionDuration", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxAuctionDuration, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field BidDuration", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.BidDuration, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IncrementSurplus", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.IncrementSurplus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IncrementDebt", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.IncrementDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IncrementCollateral", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.IncrementCollateral.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipGenesis(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowGenesis
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowGenesis
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowGenesis
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthGenesis
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupGenesis
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthGenesis
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -1,91 +0,0 @@
{
"auctions": [
{
"type": "auction/CollateralAuction",
"value": {
"base_auction": {
"bid": {
"amount": "0",
"denom": "bnb"
},
"bidder": "",
"end_time": "9000-01-01T00:00:00Z",
"has_received_bids": false,
"id": "3795",
"initiator": "hard",
"lot": {
"amount": "1",
"denom": "bnb"
},
"max_end_time": "9000-01-01T00:00:00Z"
},
"corresponding_debt": {
"amount": "0",
"denom": "debt"
},
"lot_returns": {
"addresses": ["kava1eevfnzkf2mt6feyttyzh6ektclauq7zlayefwf"],
"weights": ["100"]
},
"max_bid": {
"amount": "1",
"denom": "bnb"
}
}
},
{
"type": "auction/SurplusAuction",
"value": {
"base_auction": {
"bid": {
"amount": "0",
"denom": "bnb"
},
"bidder": "",
"end_time": "9000-01-01T00:00:00Z",
"has_received_bids": false,
"id": "3796",
"initiator": "hard",
"lot": {
"amount": "1",
"denom": "bnb"
},
"max_end_time": "9000-01-01T00:00:00Z"
}
}
},
{
"type": "auction/DebtAuction",
"value": {
"base_auction": {
"bid": {
"amount": "0",
"denom": "bnb"
},
"bidder": "",
"end_time": "9000-01-01T00:00:00Z",
"has_received_bids": false,
"id": "3895",
"initiator": "hard",
"lot": {
"amount": "1",
"denom": "bnb"
},
"max_end_time": "9000-01-01T00:00:00Z"
},
"corresponding_debt": {
"amount": "0",
"denom": "debt"
}
}
}
],
"next_auction_id": "12",
"params": {
"bid_duration": "600000000000",
"increment_collateral": "0.010000000000000000",
"increment_debt": "0.010000000000000000",
"increment_surplus": "0.010000000000000000",
"max_auction_duration": "172800000000000"
}
}

View File

@ -1,58 +0,0 @@
{
"next_auction_id": "12",
"params": {
"max_auction_duration": "172800s",
"bid_duration": "600s",
"increment_surplus": "0.010000000000000000",
"increment_debt": "0.010000000000000000",
"increment_collateral": "0.010000000000000000"
},
"auctions": [
{
"@type": "/kava.auction.v1beta1.CollateralAuction",
"base_auction": {
"id": "3795",
"initiator": "hard",
"lot": { "denom": "bnb", "amount": "1" },
"bidder": "",
"bid": { "denom": "bnb", "amount": "0" },
"has_received_bids": false,
"end_time": "9000-01-01T00:00:00Z",
"max_end_time": "9000-01-01T00:00:00Z"
},
"corresponding_debt": { "denom": "debt", "amount": "0" },
"max_bid": { "denom": "bnb", "amount": "1" },
"lot_returns": {
"addresses": ["kava1eevfnzkf2mt6feyttyzh6ektclauq7zlayefwf"],
"weights": ["100"]
}
},
{
"@type": "/kava.auction.v1beta1.SurplusAuction",
"base_auction": {
"id": "3796",
"initiator": "hard",
"lot": { "denom": "bnb", "amount": "1" },
"bidder": "",
"bid": { "denom": "bnb", "amount": "0" },
"has_received_bids": false,
"end_time": "9000-01-01T00:00:00Z",
"max_end_time": "9000-01-01T00:00:00Z"
}
},
{
"@type": "/kava.auction.v1beta1.DebtAuction",
"base_auction": {
"id": "3895",
"initiator": "hard",
"lot": { "denom": "bnb", "amount": "1" },
"bidder": "",
"bid": { "denom": "bnb", "amount": "0" },
"has_received_bids": false,
"end_time": "9000-01-01T00:00:00Z",
"max_end_time": "9000-01-01T00:00:00Z"
},
"corresponding_debt": { "denom": "debt", "amount": "0" }
}
]
}

View File

@ -1,25 +0,0 @@
package v0_17
import (
v016auction "github.com/kava-labs/kava/x/auction/legacy/v0_16"
v017auction "github.com/kava-labs/kava/x/auction/types"
)
func Migrate(oldState v016auction.GenesisState) *v017auction.GenesisState {
return &v017auction.GenesisState{
NextAuctionId: oldState.NextAuctionId,
Params: migrateParams(oldState.Params),
Auctions: oldState.Auctions,
}
}
func migrateParams(params v016auction.Params) v017auction.Params {
return v017auction.Params{
MaxAuctionDuration: params.MaxAuctionDuration,
ForwardBidDuration: v017auction.DefaultForwardBidDuration,
ReverseBidDuration: v017auction.DefaultReverseBidDuration,
IncrementSurplus: params.IncrementSurplus,
IncrementDebt: params.IncrementDebt,
IncrementCollateral: params.IncrementCollateral,
}
}

View File

@ -1,139 +0,0 @@
package auction
import (
"context"
"encoding/json"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/kava-labs/kava/x/auction/client/cli"
"github.com/kava-labs/kava/x/auction/keeper"
"github.com/kava-labs/kava/x/auction/types"
)
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
)
// AppModuleBasic implements the sdk.AppModuleBasic interface.
type AppModuleBasic struct{}
// Name returns the module name.
func (AppModuleBasic) Name() string {
return types.ModuleName
}
// RegisterLegacyAminoCodec register module codec
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
}
// DefaultGenesis default genesis state
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
}
// ValidateGenesis module validate genesis
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
var gs types.GenesisState
err := cdc.UnmarshalJSON(bz, &gs)
if err != nil {
return err
}
return gs.Validate()
}
// RegisterInterfaces implements InterfaceModule.RegisterInterfaces
func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
types.RegisterInterfaces(registry)
}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module.
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
}
// GetTxCmd returns the root tx command for the swap module.
func (AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.GetTxCmd()
}
// GetQueryCmd returns no root query command for the swap module.
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
return cli.GetQueryCmd()
}
//____________________________________________________________________________
// AppModule implements the sdk.AppModule interface.
type AppModule struct {
AppModuleBasic
keeper keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
}
// NewAppModule creates a new AppModule object
func NewAppModule(keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{},
keeper: keeper,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
}
}
// Name module name
func (AppModule) Name() string {
return types.ModuleName
}
// RegisterInvariants register module invariants
func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 {
return 1
}
// RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
}
// InitGenesis module init-genesis
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {
var genState types.GenesisState
cdc.MustUnmarshalJSON(gs, &genState)
InitGenesis(ctx, am.keeper, am.bankKeeper, am.accountKeeper, &genState)
return []abci.ValidatorUpdate{}
}
// ExportGenesis module export genesis
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
gs := ExportGenesis(ctx, am.keeper)
return cdc.MustMarshalJSON(gs)
}
// BeginBlock module begin-block
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
BeginBlocker(ctx, am.keeper)
}
// EndBlock module end-block
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}

View File

@ -1,13 +0,0 @@
<!--
order: 1
-->
# Concepts
Auctions are broken down into three distinct types, which correspond to three specific functionalities within the CDP system.
* **Surplus Auction:** An auction in which a fixed lot of coins (c1) is sold for increasing amounts of other coins (c2). Bidders increment the amount of c2 they are willing to pay for the lot of c1. After the completion of a surplus auction, the winning bid of c2 is burned, and the bidder receives the lot of c1. As a concrete example, surplus auction are used to sell a fixed amount of USDX stable coins in exchange for increasing bids of KAVA governance tokens. The governance tokens are then burned and the winner receives USDX.
* **Debt Auction:** An auction in which a fixed amount of coins (c1) is bid for a decreasing lot of other coins (c2). Bidders decrement the lot of c2 they are willing to receive for the fixed amount of c1. As a concrete example, debt auctions are used to raise a certain amount of USDX stable coins in exchange for decreasing lots of KAVA governance tokens. The USDX tokens are used to recapitalize the cdp system and the winner receives KAVA.
* **Surplus Reverse Auction:** Are two phase auction is which a fixed lot of coins (c1) is sold for increasing amounts of other coins (c2). Bidders increment the amount of c2 until a specific `maxBid` is reached. Once `maxBid` is reached, a fixed amount of c2 is bid for a decreasing lot of c1. In the second phase, bidders decrement the lot of c1 they are willing to receive for a fixed amount of c2. As a concrete example, collateral auctions are used to sell collateral (ATOM, for example) for up to a `maxBid` amount of USDX. The USDX tokens are used to recapitalize the cdp system and the winner receives the specified lot of ATOM. In the event that the winning lot is smaller than the total lot, the excess ATOM is ratably returned to the original owners of the liquidated CDPs that were collateralized with that ATOM.
Auctions are always initiated by another module, and not directly by users. Auctions start with an expiry, the time at which the auction is guaranteed to end, even if there have been no bidders. After each bid, the auction is extended by a specific amount of time, `BidDuration`. In the case that increasing the auction time by `BidDuration` would cause the auction to go past its expiry, the expiry is chosen as the ending time.

View File

@ -1,82 +0,0 @@
<!--
order: 2
-->
# State
## Parameters and genesis state
`parameters` define the rules according to which auctions are run. There is only one active parameter set at any given time. Updates to the parameter set can be made via on-chain parameter update proposals.
```go
// Params governance parameters for auction module
type Params struct {
MaxAuctionDuration time.Duration `json:"max_auction_duration" yaml:"max_auction_duration"` // max length of auction
MaxBidDuration time.Duration `json:"max_bid_duration" yaml:"max_bid_duration"` // additional time added to the auction end time after each bid, capped by the expiry.
IncrementSurplus sdk.Dec `json:"increment_surplus" yaml:"increment_surplus"` // percentage change (of auc.Bid) required for a new bid on a surplus auction
IncrementDebt sdk.Dec `json:"increment_debt" yaml:"increment_debt"` // percentage change (of auc.Lot) required for a new bid on a debt auction
IncrementCollateral sdk.Dec `json:"increment_collateral" yaml:"increment_collateral"` // percentage change (of auc.Bid or auc.Lot) required for a new bid on a collateral auction
}
```
`GenesisState` defines the state that must be persisted when the blockchain stops/restarts in order for normal function of the auction module to resume.
```go
// GenesisState - auction state that must be provided at genesis
type GenesisState struct {
NextAuctionID uint64 `json:"next_auction_id" yaml:"next_auction_id"` // auctionID that will be used for the next created auction
Params Params `json:"auction_params" yaml:"auction_params"` // auction params
Auctions Auctions `json:"genesis_auctions" yaml:"genesis_auctions"` // auctions currently in the store
}
```
## Base types
```go
// Auction is an interface to several types of auction.
type Auction interface {
GetID() uint64
WithID(uint64) Auction
GetEndTime() time.Time
}
// BaseAuction is a common type shared by all Auctions.
type BaseAuction struct {
ID uint64
Initiator string // Module name that starts the auction. Pays out Lot.
Lot sdk.Coin // Coins that will paid out by Initiator to the winning bidder.
Bidder sdk.AccAddress // Latest bidder. Receiver of Lot.
Bid sdk.Coin // Coins paid into the auction the bidder.
EndTime time.Time // Current auction closing time. Triggers at the end of the block with time ≥ EndTime.
MaxEndTime time.Time // Maximum closing time. Auctions can close before this but never after.
}
// SurplusAuction is a forward auction that burns what it receives from bids.
// It is normally used to sell off excess pegged asset acquired by the CDP system.
type SurplusAuction struct {
BaseAuction
}
// DebtAuction is a reverse auction that mints what it pays out.
// It is normally used to acquire pegged asset to cover the CDP system's debts that were not covered by selling collateral.
type DebtAuction struct {
BaseAuction
}
// WeightedAddresses is a type for storing some addresses and associated weights.
type WeightedAddresses struct {
Addresses []sdk.AccAddress
Weights []sdkmath.Int
}
// CollateralAuction is a two phase auction.
// Initially, in forward auction phase, bids can be placed up to a max bid.
// Then it switches to a reverse auction phase, where the initial amount up for auction is bid down.
// Unsold Lot is sent to LotReturns, being divided among the addresses by weight.
// Collateral auctions are normally used to sell off collateral seized from CDPs.
type CollateralAuction struct {
BaseAuction
MaxBid sdk.Coin
LotReturns WeightedAddresses
}
```

View File

@ -1,36 +0,0 @@
<!--
order: 3
-->
# Messages
## Bidding
Users can bid on auctions using the `MsgPlaceBid` message type. All auction types can be bid on using the same message type.
```go
// MsgPlaceBid is the message type used to place a bid on any type of auction.
type MsgPlaceBid struct {
AuctionID uint64
Bidder sdk.AccAddress
Amount sdk.Coin
}
```
**State Modifications:**
* Update bidder if different than previous bidder
* For Surplus auctions:
* Update Bid to msg.Amount
* Return bid coins to previous bidder
* Burn coins equal to the increment in the bid (CurrentBid - PreviousBid)
* For Debt auctions:
* Update Lot amount to msg.Amount
* Return bid coins to previous bidder
* For Collateral auctions:
* Return bid coins to previous bidder
* If in forward phase:
* Update Bid amount to msg.Amount
* If in reverse phase:
* Update Lot amount to msg.Amount
* Extend auction by `BidDuration`, up to `MaxEndTime`

View File

@ -1,38 +0,0 @@
<!--
order: 4
-->
# Events
The `x/auction` module emits the following events:
## Triggered By Other Modules
| Type | Attribute Key | Attribute Value |
|---------------|---------------|-------------------|
| auction_start | auction_id | `{auction ID}` |
| auction_start | auction_type | `{auction type}` |
| auction_start | lot | `{coin amount}` |
| auction_start | bid | `{coin amount}` |
| auction_start | max_bid | `{coin amount}` |
## Handlers
### MsgPlaceBid
| Type | Attribute Key | Attribute Value |
|-------------|---------------|----------------------|
| auction_bid | auction_id | `{auction ID}` |
| auction_bid | bidder | `{latest bidder}` |
| auction_bid | bid | `{coin amount}` |
| auction_bid | lot | `{coin amount}` |
| auction_bid | end_time | `{auction end time}` |
| message | module | auction |
| message | sender | `{sender address}` |
## BeginBlock
| Type | Attribute Key | Attribute Value |
|---------------|---------------|-------------------|
| auction_close | auction_id | `{auction ID}` |
| auction_close | close_block | `{block height}` |

View File

@ -1,15 +0,0 @@
<!--
order: 5
-->
# Parameters
The auction module contains the following parameters:
| Key | Type | Example | Description |
|---------------------|------------------------|------------------------|---------------------------------------------------------------------------------------|
| MaxAuctionDuration | string (time.Duration) | "48h0m0s" | |
| BidDuration | string (time.Duration) | "3h0m0s" | |
| IncrementSurplus | string (dec) | "0.050000000000000000" | percentage change in bid required for a new bid on a surplus auction |
| IncrementDebt | string (dec) | "0.050000000000000000" | percentage change in lot required for a new bid on a debt auction |
| IncrementCollateral | string (dec) | "0.050000000000000000" | percentage change in either bid or lot required for a new bid on a collateral auction |

View File

@ -1,22 +0,0 @@
<!--
order: 6
-->
# Begin Block
At the start of each block, auctions that have reached `EndTime` are closed. The logic to close auctions is as follows:
```go
var expiredAuctions []uint64
k.IterateAuctionsByTime(ctx, ctx.BlockTime(), func(id uint64) bool {
expiredAuctions = append(expiredAuctions, id)
return false
})
for _, id := range expiredAuctions {
err := k.CloseAuction(ctx, id)
if err != nil {
panic(err)
}
}
```

View File

@ -1,20 +0,0 @@
<!--
order: 0
title: "Auction Overview"
parent:
title: "auction"
-->
# `auction`
<!-- TOC -->
1. **[Concepts](01_concepts.md)**
2. **[State](02_state.md)**
3. **[Messages](03_messages.md)**
4. **[Events](04_events.md)**
5. **[Params](05_params.md)**
6. **[BeginBlock](06_begin_block.md)**
## Abstract
`x/auction` is an implementation of a Cosmos SDK Module that handles the creation, bidding, and payout of 3 distinct auction types. All auction types implement the `Auction` interface. Each auction type is used at different points during the normal functioning of the CDP system.

View File

@ -1,92 +0,0 @@
package testutil
import (
"github.com/stretchr/testify/suite"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtime "github.com/cometbft/cometbft/types/time"
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"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/auction/keeper"
"github.com/kava-labs/kava/x/auction/types"
)
// Suite implements a test suite for the kavadist module integration tests
type Suite struct {
suite.Suite
Keeper keeper.Keeper
BankKeeper bankkeeper.Keeper
AccountKeeper authkeeper.AccountKeeper
App app.TestApp
Ctx sdk.Context
Addrs []sdk.AccAddress
ModAcc *authtypes.ModuleAccount
}
// SetupTest instantiates a new app, keepers, and sets suite state
func (suite *Suite) SetupTest(numAddrs int) {
config := sdk.GetConfig()
app.SetBech32AddressPrefixes(config)
tApp := app.NewTestApp()
_, addrs := app.GeneratePrivKeyAddressPairs(numAddrs)
// Fund liquidator module account
coins := sdk.NewCoins(
sdk.NewCoin("token1", sdkmath.NewInt(100)),
sdk.NewCoin("token2", sdkmath.NewInt(100)),
)
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
modName := "liquidator"
modBaseAcc := authtypes.NewBaseAccount(authtypes.NewModuleAddress(modName), nil, 0, 0)
modAcc := authtypes.NewModuleAccount(modBaseAcc, modName, []string{authtypes.Minter, authtypes.Burner}...)
suite.ModAcc = modAcc
authGS := app.NewFundedGenStateWithSameCoinsWithModuleAccount(tApp.AppCodec(), coins, addrs, modAcc)
params := types.NewParams(
types.DefaultMaxAuctionDuration,
types.DefaultForwardBidDuration,
types.DefaultReverseBidDuration,
types.DefaultIncrement,
types.DefaultIncrement,
types.DefaultIncrement,
)
auctionGs, err := types.NewGenesisState(types.DefaultNextAuctionID, params, []types.GenesisAuction{})
suite.Require().NoError(err)
moduleGs := tApp.AppCodec().MustMarshalJSON(auctionGs)
gs := app.GenesisState{types.ModuleName: moduleGs}
tApp.InitializeFromGenesisStates(authGS, gs)
suite.App = tApp
suite.Ctx = ctx
suite.Addrs = addrs
suite.Keeper = tApp.GetAuctionKeeper()
suite.BankKeeper = tApp.GetBankKeeper()
suite.AccountKeeper = tApp.GetAccountKeeper()
}
// 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 := suite.App.FundModuleAccount(suite.Ctx, moduleName, amount)
suite.Require().NoError(err)
}
// CheckAccountBalanceEqual asserts that
func (suite *Suite) CheckAccountBalanceEqual(owner sdk.AccAddress, expectedCoins sdk.Coins) {
balances := suite.BankKeeper.GetAllBalances(suite.Ctx, owner)
suite.Equal(expectedCoins, balances)
}

Some files were not shown because too many files have changed in this diff Show More