mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 23:35:19 +00:00
gofumpt - apply format changes for readability and consistency (#1248)
This commit is contained in:
parent
f472d119cc
commit
09ddb3e367
@ -168,10 +168,12 @@ func TestAppImportExport(t *testing.T) {
|
|||||||
storeKeysPrefixes := []StoreKeysPrefixes{
|
storeKeysPrefixes := []StoreKeysPrefixes{
|
||||||
{app.keys[baseapp.MainStoreKey], newApp.keys[baseapp.MainStoreKey], [][]byte{}},
|
{app.keys[baseapp.MainStoreKey], newApp.keys[baseapp.MainStoreKey], [][]byte{}},
|
||||||
{app.keys[auth.StoreKey], newApp.keys[auth.StoreKey], [][]byte{}},
|
{app.keys[auth.StoreKey], newApp.keys[auth.StoreKey], [][]byte{}},
|
||||||
{app.keys[staking.StoreKey], newApp.keys[staking.StoreKey],
|
{
|
||||||
|
app.keys[staking.StoreKey], newApp.keys[staking.StoreKey],
|
||||||
[][]byte{
|
[][]byte{
|
||||||
staking.UnbondingQueueKey, staking.RedelegationQueueKey, staking.ValidatorQueueKey,
|
staking.UnbondingQueueKey, staking.RedelegationQueueKey, staking.ValidatorQueueKey,
|
||||||
}}, // ordering may change but it doesn't matter
|
},
|
||||||
|
}, // ordering may change but it doesn't matter
|
||||||
{app.keys[slashing.StoreKey], newApp.keys[slashing.StoreKey], [][]byte{}},
|
{app.keys[slashing.StoreKey], newApp.keys[slashing.StoreKey], [][]byte{}},
|
||||||
{app.keys[mint.StoreKey], newApp.keys[mint.StoreKey], [][]byte{}},
|
{app.keys[mint.StoreKey], newApp.keys[mint.StoreKey], [][]byte{}},
|
||||||
{app.keys[distr.StoreKey], newApp.keys[distr.StoreKey], [][]byte{}},
|
{app.keys[distr.StoreKey], newApp.keys[distr.StoreKey], [][]byte{}},
|
||||||
@ -320,7 +322,6 @@ func TestAppStateDeterminism(t *testing.T) {
|
|||||||
func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simulation.AppStateFn {
|
func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simulation.AppStateFn {
|
||||||
return func(r *rand.Rand, accs []simulation.Account, config simulation.Config,
|
return func(r *rand.Rand, accs []simulation.Account, config simulation.Config,
|
||||||
) (appState json.RawMessage, simAccs []simulation.Account, chainID string, genesisTimestamp time.Time) {
|
) (appState json.RawMessage, simAccs []simulation.Account, chainID string, genesisTimestamp time.Time) {
|
||||||
|
|
||||||
if simapp.FlagGenesisTimeValue == 0 {
|
if simapp.FlagGenesisTimeValue == 0 {
|
||||||
genesisTimestamp = time.Unix(r.Int63n(190288396800), 0) // 1st Jan year 8000
|
genesisTimestamp = time.Unix(r.Int63n(190288396800), 0) // 1st Jan year 8000
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,9 +12,7 @@ import (
|
|||||||
"github.com/kava-labs/kava/app/ante"
|
"github.com/kava-labs/kava/app/ante"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var _ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle
|
||||||
_ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle
|
|
||||||
)
|
|
||||||
|
|
||||||
type MockAnteHandler struct {
|
type MockAnteHandler struct {
|
||||||
WasCalled bool
|
WasCalled bool
|
||||||
|
@ -211,7 +211,6 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
|
||||||
tx, err := helpers.GenTx(
|
tx, err := helpers.GenTx(
|
||||||
txConfig,
|
txConfig,
|
||||||
tc.msgs,
|
tc.msgs,
|
||||||
|
@ -323,7 +323,6 @@ func NewApp(
|
|||||||
options Options,
|
options Options,
|
||||||
baseAppOptions ...func(*baseapp.BaseApp),
|
baseAppOptions ...func(*baseapp.BaseApp),
|
||||||
) *App {
|
) *App {
|
||||||
|
|
||||||
appCodec := encodingConfig.Marshaler
|
appCodec := encodingConfig.Marshaler
|
||||||
legacyAmino := encodingConfig.Amino
|
legacyAmino := encodingConfig.Amino
|
||||||
interfaceRegistry := encodingConfig.InterfaceRegistry
|
interfaceRegistry := encodingConfig.InterfaceRegistry
|
||||||
@ -348,7 +347,7 @@ func NewApp(
|
|||||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey)
|
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey)
|
||||||
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
||||||
|
|
||||||
var app = &App{
|
app := &App{
|
||||||
BaseApp: bApp,
|
BaseApp: bApp,
|
||||||
legacyAmino: legacyAmino,
|
legacyAmino: legacyAmino,
|
||||||
appCodec: appCodec,
|
appCodec: appCodec,
|
||||||
|
@ -46,7 +46,7 @@ func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []
|
|||||||
func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) {
|
func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) {
|
||||||
applyWhiteList := false
|
applyWhiteList := false
|
||||||
|
|
||||||
//Check if there is a whitelist
|
// Check if there is a whitelist
|
||||||
if len(jailWhiteList) > 0 {
|
if len(jailWhiteList) > 0 {
|
||||||
applyWhiteList = true
|
applyWhiteList = true
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,6 @@ func (builder *AuthBankGenesisBuilder) WithSimpleModuleAccount(moduleName string
|
|||||||
|
|
||||||
// WithSimplePeriodicVestingAccount adds a periodic vesting account to the genesis state.
|
// WithSimplePeriodicVestingAccount adds a periodic vesting account to the genesis state.
|
||||||
func (builder *AuthBankGenesisBuilder) WithSimplePeriodicVestingAccount(address sdk.AccAddress, balance sdk.Coins, periods vestingtypes.Periods, firstPeriodStartTimestamp int64) *AuthBankGenesisBuilder {
|
func (builder *AuthBankGenesisBuilder) WithSimplePeriodicVestingAccount(address sdk.AccAddress, balance sdk.Coins, periods vestingtypes.Periods, firstPeriodStartTimestamp int64) *AuthBankGenesisBuilder {
|
||||||
|
|
||||||
vestingAccount := newPeriodicVestingAccount(address, periods, firstPeriodStartTimestamp)
|
vestingAccount := newPeriodicVestingAccount(address, periods, firstPeriodStartTimestamp)
|
||||||
|
|
||||||
return builder.
|
return builder.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//go:build cli_test
|
||||||
// +build cli_test
|
// +build cli_test
|
||||||
|
|
||||||
package clitest
|
package clitest
|
||||||
@ -1137,7 +1138,8 @@ func TestKvCLIMultisignSortSignatures(t *testing.T) {
|
|||||||
|
|
||||||
// Multisign, keys in different order
|
// Multisign, keys in different order
|
||||||
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
|
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
|
||||||
bazSignatureFile.Name(), fooSignatureFile.Name()})
|
bazSignatureFile.Name(), fooSignatureFile.Name(),
|
||||||
|
})
|
||||||
require.True(t, success)
|
require.True(t, success)
|
||||||
|
|
||||||
// Write the output to disk
|
// Write the output to disk
|
||||||
@ -1205,13 +1207,15 @@ func TestKvCLIMultisign(t *testing.T) {
|
|||||||
|
|
||||||
// Does not work in offline mode
|
// Does not work in offline mode
|
||||||
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
|
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
|
||||||
fooSignatureFile.Name(), barSignatureFile.Name()}, "--offline")
|
fooSignatureFile.Name(), barSignatureFile.Name(),
|
||||||
|
}, "--offline")
|
||||||
require.Contains(t, "couldn't verify signature", stdout)
|
require.Contains(t, "couldn't verify signature", stdout)
|
||||||
require.False(t, success)
|
require.False(t, success)
|
||||||
|
|
||||||
// Success multisign
|
// Success multisign
|
||||||
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
|
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
|
||||||
fooSignatureFile.Name(), barSignatureFile.Name()})
|
fooSignatureFile.Name(), barSignatureFile.Name(),
|
||||||
|
})
|
||||||
require.True(t, success)
|
require.True(t, success)
|
||||||
|
|
||||||
// Write the output to disk
|
// Write the output to disk
|
||||||
|
@ -367,8 +367,8 @@ func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, str
|
|||||||
|
|
||||||
// TxMultisign is kvcli tx multisign
|
// TxMultisign is kvcli tx multisign
|
||||||
func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string,
|
func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string,
|
||||||
flags ...string) (bool, string, string) {
|
flags ...string,
|
||||||
|
) (bool, string, string) {
|
||||||
cmd := fmt.Sprintf("%s tx multisign --keyring-backend=test %v %s %s %s", f.KvcliBinary, f.Flags(),
|
cmd := fmt.Sprintf("%s tx multisign --keyring-backend=test %v %s %s %s", f.KvcliBinary, f.Flags(),
|
||||||
fileName, name, strings.Join(signaturesFiles, " "),
|
fileName, name, strings.Join(signaturesFiles, " "),
|
||||||
)
|
)
|
||||||
@ -425,7 +425,6 @@ func (f *Fixtures) TxGovVote(proposalID int, option gov.VoteOption, from string,
|
|||||||
func (f *Fixtures) TxGovSubmitParamChangeProposal(
|
func (f *Fixtures) TxGovSubmitParamChangeProposal(
|
||||||
from, proposalPath string, deposit sdk.Coin, flags ...string,
|
from, proposalPath string, deposit sdk.Coin, flags ...string,
|
||||||
) (bool, string, string) {
|
) (bool, string, string) {
|
||||||
|
|
||||||
cmd := fmt.Sprintf(
|
cmd := fmt.Sprintf(
|
||||||
"%s tx gov submit-proposal param-change %s --keyring-backend=test --from=%s %v",
|
"%s tx gov submit-proposal param-change %s --keyring-backend=test --from=%s %v",
|
||||||
f.KvcliBinary, proposalPath, from, f.Flags(),
|
f.KvcliBinary, proposalPath, from, f.Flags(),
|
||||||
@ -439,7 +438,6 @@ func (f *Fixtures) TxGovSubmitParamChangeProposal(
|
|||||||
func (f *Fixtures) TxGovSubmitCommunityPoolSpendProposal(
|
func (f *Fixtures) TxGovSubmitCommunityPoolSpendProposal(
|
||||||
from, proposalPath string, deposit sdk.Coin, flags ...string,
|
from, proposalPath string, deposit sdk.Coin, flags ...string,
|
||||||
) (bool, string, string) {
|
) (bool, string, string) {
|
||||||
|
|
||||||
cmd := fmt.Sprintf(
|
cmd := fmt.Sprintf(
|
||||||
"%s tx gov submit-proposal community-pool-spend %s --keyring-backend=test --from=%s %v",
|
"%s tx gov submit-proposal community-pool-spend %s --keyring-backend=test --from=%s %v",
|
||||||
f.KvcliBinary, proposalPath, from, f.Flags(),
|
f.KvcliBinary, proposalPath, from, f.Flags(),
|
||||||
|
@ -16,9 +16,7 @@ import (
|
|||||||
"github.com/tharsis/ethermint/crypto/hd"
|
"github.com/tharsis/ethermint/crypto/hd"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var ethFlag = "eth"
|
||||||
ethFlag = "eth"
|
|
||||||
)
|
|
||||||
|
|
||||||
// KeyCommands registers a sub-tree of commands to interact with
|
// KeyCommands registers a sub-tree of commands to interact with
|
||||||
// local private key storage.
|
// local private key storage.
|
||||||
|
@ -43,7 +43,6 @@ func (ac appCreator) newApp(
|
|||||||
traceStore io.Writer,
|
traceStore io.Writer,
|
||||||
appOpts servertypes.AppOptions,
|
appOpts servertypes.AppOptions,
|
||||||
) servertypes.Application {
|
) servertypes.Application {
|
||||||
|
|
||||||
var cache sdk.MultiStorePersistentCache
|
var cache sdk.MultiStorePersistentCache
|
||||||
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
|
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
|
||||||
cache = store.NewCommitKVStoreCacheManager()
|
cache = store.NewCommitKVStoreCacheManager()
|
||||||
@ -114,7 +113,6 @@ func (ac appCreator) appExport(
|
|||||||
jailAllowedAddrs []string,
|
jailAllowedAddrs []string,
|
||||||
appOpts servertypes.AppOptions,
|
appOpts servertypes.AppOptions,
|
||||||
) (servertypes.ExportedApp, error) {
|
) (servertypes.ExportedApp, error) {
|
||||||
|
|
||||||
homePath, ok := appOpts.Get(flags.FlagHome).(string)
|
homePath, ok := appOpts.Get(flags.FlagHome).(string)
|
||||||
if !ok || homePath == "" {
|
if !ok || homePath == "" {
|
||||||
return servertypes.ExportedApp{}, errors.New("application home not set")
|
return servertypes.ExportedApp{}, errors.New("application home not set")
|
||||||
|
@ -83,7 +83,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
|
|||||||
expectedEndtime := newVestingStartTime.Add(15 * 24 * time.Hour).Unix()
|
expectedEndtime := newVestingStartTime.Add(15 * 24 * time.Hour).Unix()
|
||||||
// new period length changed, amount unchanged
|
// new period length changed, amount unchanged
|
||||||
expectedPeriods := []vestingtypes.Period{
|
expectedPeriods := []vestingtypes.Period{
|
||||||
vestingtypes.Period{
|
{
|
||||||
Length: 15 * 24 * 60 * 60, // 15 days
|
Length: 15 * 24 * 60 * 60, // 15 days
|
||||||
Amount: balance,
|
Amount: balance,
|
||||||
},
|
},
|
||||||
@ -156,11 +156,11 @@ func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
|
|||||||
expectedEndtime := newVestingStartTime.Add(30 * 24 * time.Hour).Unix()
|
expectedEndtime := newVestingStartTime.Add(30 * 24 * time.Hour).Unix()
|
||||||
// new period length changed, amount unchanged
|
// new period length changed, amount unchanged
|
||||||
expectedPeriods := []vestingtypes.Period{
|
expectedPeriods := []vestingtypes.Period{
|
||||||
vestingtypes.Period{
|
{
|
||||||
Length: 15 * 24 * 60 * 60, // 15 days
|
Length: 15 * 24 * 60 * 60, // 15 days
|
||||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
|
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
|
||||||
},
|
},
|
||||||
vestingtypes.Period{
|
{
|
||||||
Length: 15 * 24 * 60 * 60, // 15 days
|
Length: 15 * 24 * 60 * 60, // 15 days
|
||||||
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
|
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
|
||||||
},
|
},
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
// v40 cosmos auth module genesis state, returning a copy of the original state where all
|
// v40 cosmos auth module genesis state, returning a copy of the original state where all
|
||||||
// periodic vesting accounts have been zeroed out.
|
// periodic vesting accounts have been zeroed out.
|
||||||
func MigrateAuthV040(authGenState v040auth.GenesisState, genesisTime time.Time, ctx client.Context) *v040auth.GenesisState {
|
func MigrateAuthV040(authGenState v040auth.GenesisState, genesisTime time.Time, ctx client.Context) *v040auth.GenesisState {
|
||||||
var anyAccounts = make([]*codectypes.Any, len(authGenState.Accounts))
|
anyAccounts := make([]*codectypes.Any, len(authGenState.Accounts))
|
||||||
for i, anyAcc := range authGenState.Accounts {
|
for i, anyAcc := range authGenState.Accounts {
|
||||||
// Only need to make modifications to vesting accounts
|
// Only need to make modifications to vesting accounts
|
||||||
if anyAcc.TypeUrl != "/cosmos.vesting.v1beta1.PeriodicVestingAccount" {
|
if anyAcc.TypeUrl != "/cosmos.vesting.v1beta1.PeriodicVestingAccount" {
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func migrateCommitteePermissions(genState committeetypes.GenesisState) committeetypes.GenesisState {
|
func migrateCommitteePermissions(genState committeetypes.GenesisState) committeetypes.GenesisState {
|
||||||
|
|
||||||
var newCommittees committeetypes.Committees
|
var newCommittees committeetypes.Committees
|
||||||
for _, committee := range genState.GetCommittees() {
|
for _, committee := range genState.GetCommittees() {
|
||||||
switch committee.GetDescription() {
|
switch committee.GetDescription() {
|
||||||
|
@ -33,7 +33,6 @@ func GetTxCmd() *cobra.Command {
|
|||||||
txCmd.AddCommand(cmds...)
|
txCmd.AddCommand(cmds...)
|
||||||
|
|
||||||
return txCmd
|
return txCmd
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCmdPlaceBid cli command for placing bids on auctions
|
// GetCmdPlaceBid cli command for placing bids on auctions
|
||||||
|
@ -3,7 +3,6 @@ package rest
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
@ -16,16 +16,18 @@ import (
|
|||||||
"github.com/kava-labs/kava/x/auction/types"
|
"github.com/kava-labs/kava/x/auction/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _, testAddrs = app.GeneratePrivKeyAddressPairs(2)
|
var (
|
||||||
var testTime = time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
|
_, testAddrs = app.GeneratePrivKeyAddressPairs(2)
|
||||||
var testAuction = types.NewCollateralAuction(
|
testTime = time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||||
|
testAuction = types.NewCollateralAuction(
|
||||||
"seller",
|
"seller",
|
||||||
c("lotdenom", 10),
|
c("lotdenom", 10),
|
||||||
testTime,
|
testTime,
|
||||||
c("biddenom", 1000),
|
c("biddenom", 1000),
|
||||||
types.WeightedAddresses{Addresses: testAddrs, Weights: []sdk.Int{sdk.OneInt(), sdk.OneInt()}},
|
types.WeightedAddresses{Addresses: testAddrs, Weights: []sdk.Int{sdk.OneInt(), sdk.OneInt()}},
|
||||||
c("debt", 1000),
|
c("debt", 1000),
|
||||||
).WithID(3).(types.GenesisAuction)
|
).WithID(3).(types.GenesisAuction)
|
||||||
|
)
|
||||||
|
|
||||||
func TestInitGenesis(t *testing.T) {
|
func TestInitGenesis(t *testing.T) {
|
||||||
t.Run("valid", func(t *testing.T) {
|
t.Run("valid", func(t *testing.T) {
|
||||||
|
@ -46,7 +46,6 @@ func (k Keeper) StartSurplusAuction(ctx sdk.Context, seller string, lot sdk.Coin
|
|||||||
|
|
||||||
// StartDebtAuction starts a new debt (reverse) auction.
|
// 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) {
|
func (k Keeper) StartDebtAuction(ctx sdk.Context, buyer string, bid sdk.Coin, initialLot sdk.Coin, debt sdk.Coin) (uint64, error) {
|
||||||
|
|
||||||
auction := types.NewDebtAuction(
|
auction := types.NewDebtAuction(
|
||||||
buyer,
|
buyer,
|
||||||
bid,
|
bid,
|
||||||
@ -132,7 +131,6 @@ func (k Keeper) StartCollateralAuction(
|
|||||||
|
|
||||||
// PlaceBid places a bid on any auction.
|
// PlaceBid places a bid on any auction.
|
||||||
func (k Keeper) PlaceBid(ctx sdk.Context, auctionID uint64, bidder sdk.AccAddress, newAmount sdk.Coin) error {
|
func (k Keeper) PlaceBid(ctx sdk.Context, auctionID uint64, bidder sdk.AccAddress, newAmount sdk.Coin) error {
|
||||||
|
|
||||||
auction, found := k.GetAuction(ctx, auctionID)
|
auction, found := k.GetAuction(ctx, auctionID)
|
||||||
if !found {
|
if !found {
|
||||||
return sdkerrors.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)
|
return sdkerrors.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)
|
||||||
|
@ -25,11 +25,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestAuctionBidding(t *testing.T) {
|
func TestAuctionBidding(t *testing.T) {
|
||||||
|
|
||||||
config := sdk.GetConfig()
|
config := sdk.GetConfig()
|
||||||
app.SetBech32AddressPrefixes(config)
|
app.SetBech32AddressPrefixes(config)
|
||||||
|
|
||||||
someTime := time.Date(0001, time.January, 1, 0, 0, 0, 0, time.UTC)
|
someTime := time.Date(0o001, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
|
|
||||||
_, addrs := app.GeneratePrivKeyAddressPairs(5)
|
_, addrs := app.GeneratePrivKeyAddressPairs(5)
|
||||||
buyer := addrs[0]
|
buyer := addrs[0]
|
||||||
|
@ -117,7 +117,6 @@ func TestGrpcAuctionsFilter(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.giveName, func(t *testing.T) {
|
t.Run(tc.giveName, func(t *testing.T) {
|
||||||
|
|
||||||
res, err := qs.Auctions(sdk.WrapSDKContext(ctx), &tc.giveRequest)
|
res, err := qs.Auctions(sdk.WrapSDKContext(ctx), &tc.giveRequest)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
// RegisterInvariants registers all staking invariants
|
// RegisterInvariants registers all staking invariants
|
||||||
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
|
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
|
||||||
|
|
||||||
ir.RegisterRoute(types.ModuleName, "module-account",
|
ir.RegisterRoute(types.ModuleName, "module-account",
|
||||||
ModuleAccountInvariants(k))
|
ModuleAccountInvariants(k))
|
||||||
ir.RegisterRoute(types.ModuleName, "valid-auctions",
|
ir.RegisterRoute(types.ModuleName, "valid-auctions",
|
||||||
@ -24,7 +23,6 @@ func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
|
|||||||
// ModuleAccountInvariants checks that the module account's coins matches those stored in auctions
|
// ModuleAccountInvariants checks that the module account's coins matches those stored in auctions
|
||||||
func ModuleAccountInvariants(k Keeper) sdk.Invariant {
|
func ModuleAccountInvariants(k Keeper) sdk.Invariant {
|
||||||
return func(ctx sdk.Context) (string, bool) {
|
return func(ctx sdk.Context) (string, bool) {
|
||||||
|
|
||||||
totalAuctionCoins := sdk.NewCoins()
|
totalAuctionCoins := sdk.NewCoins()
|
||||||
k.IterateAuctions(ctx, func(auction types.Auction) bool {
|
k.IterateAuctions(ctx, func(auction types.Auction) bool {
|
||||||
a, ok := auction.(types.GenesisAuction)
|
a, ok := auction.(types.GenesisAuction)
|
||||||
|
@ -24,7 +24,8 @@ type Keeper struct {
|
|||||||
|
|
||||||
// NewKeeper returns a new auction keeper.
|
// NewKeeper returns a new auction keeper.
|
||||||
func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramstore paramtypes.Subspace,
|
func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramstore paramtypes.Subspace,
|
||||||
bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper) Keeper {
|
bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper,
|
||||||
|
) Keeper {
|
||||||
if !paramstore.HasKeyTable() {
|
if !paramstore.HasKeyTable() {
|
||||||
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
||||||
}
|
}
|
||||||
@ -81,7 +82,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
|||||||
func (k Keeper) SetNextAuctionID(ctx sdk.Context, id uint64) {
|
func (k Keeper) SetNextAuctionID(ctx sdk.Context, id uint64) {
|
||||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.NextAuctionIDKey)
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.NextAuctionIDKey)
|
||||||
store.Set(types.NextAuctionIDKey, types.Uint64ToBytes(id))
|
store.Set(types.NextAuctionIDKey, types.Uint64ToBytes(id))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNextAuctionID reads the next available global ID from store
|
// GetNextAuctionID reads the next available global ID from store
|
||||||
|
@ -124,7 +124,6 @@ func TestIterateAuctionsByTime(t *testing.T) {
|
|||||||
if v.endTime.Before(cutoffTime) || v.endTime.Equal(cutoffTime) { // endTime ≤ cutoffTime
|
if v.endTime.Before(cutoffTime) || v.endTime.Equal(cutoffTime) { // endTime ≤ cutoffTime
|
||||||
expectedIndex = append(expectedIndex, v.auctionID)
|
expectedIndex = append(expectedIndex, v.auctionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
var readIndex []uint64
|
var readIndex []uint64
|
||||||
keeper.IterateAuctionsByTime(ctx, cutoffTime, func(id uint64) bool {
|
keeper.IterateAuctionsByTime(ctx, cutoffTime, func(id uint64) bool {
|
||||||
|
@ -36,6 +36,7 @@ func GenBidDuration(r *rand.Rand) time.Duration {
|
|||||||
}
|
}
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenMaxAuctionDuration(r *rand.Rand) time.Duration {
|
func GenMaxAuctionDuration(r *rand.Rand) time.Duration {
|
||||||
d, err := RandomPositiveDuration(r, MaxBidDuration, AverageBlockTime*200)
|
d, err := RandomPositiveDuration(r, MaxBidDuration, AverageBlockTime*200)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -48,12 +49,13 @@ func GenIncrementCollateral(r *rand.Rand) sdk.Dec {
|
|||||||
return simulation.RandomDecAmount(r, sdk.MustNewDecFromStr("1"))
|
return simulation.RandomDecAmount(r, sdk.MustNewDecFromStr("1"))
|
||||||
}
|
}
|
||||||
|
|
||||||
var GenIncrementDebt = GenIncrementCollateral
|
var (
|
||||||
var GenIncrementSurplus = GenIncrementCollateral
|
GenIncrementDebt = GenIncrementCollateral
|
||||||
|
GenIncrementSurplus = GenIncrementCollateral
|
||||||
|
)
|
||||||
|
|
||||||
// RandomizedGenState generates a random GenesisState for auction
|
// RandomizedGenState generates a random GenesisState for auction
|
||||||
func RandomizedGenState(simState *module.SimulationState) {
|
func RandomizedGenState(simState *module.SimulationState) {
|
||||||
|
|
||||||
p := types.NewParams(
|
p := types.NewParams(
|
||||||
GenMaxAuctionDuration(simState.Rand),
|
GenMaxAuctionDuration(simState.Rand),
|
||||||
GenBidDuration(simState.Rand),
|
GenBidDuration(simState.Rand),
|
||||||
@ -80,7 +82,7 @@ func RandomizedGenState(simState *module.SimulationState) {
|
|||||||
sdk.NewInt64Coin("debt", 100), // same as usdx
|
sdk.NewInt64Coin("debt", 100), // same as usdx
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
var startingID = auctionGenesis.NextAuctionID
|
startingID := auctionGenesis.NextAuctionID
|
||||||
var ok bool
|
var ok bool
|
||||||
var totalAuctionCoins sdk.Coins
|
var totalAuctionCoins sdk.Coins
|
||||||
for i, a := range auctions {
|
for i, a := range auctions {
|
||||||
|
@ -122,7 +122,8 @@ func SimulateMsgPlaceBid(ak auth.AccountKeeper, keeper keeper.Keeper) simulation
|
|||||||
|
|
||||||
func generateBidAmount(
|
func generateBidAmount(
|
||||||
r *rand.Rand, params types.Params, auc types.Auction,
|
r *rand.Rand, params types.Params, auc types.Auction,
|
||||||
bidder authexported.Account, blockTime time.Time) (sdk.Coin, error) {
|
bidder authexported.Account, blockTime time.Time,
|
||||||
|
) (sdk.Coin, error) {
|
||||||
bidderBalance := bidder.SpendableCoins(blockTime)
|
bidderBalance := bidder.SpendableCoins(blockTime)
|
||||||
|
|
||||||
switch a := auc.(type) {
|
switch a := auc.(type) {
|
||||||
|
@ -20,7 +20,6 @@ func newTestModuleCodec() codec.Codec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGenesisState_Validate(t *testing.T) {
|
func TestGenesisState_Validate(t *testing.T) {
|
||||||
|
|
||||||
arbitraryTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
|
arbitraryTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||||
validAuction := &CollateralAuction{
|
validAuction := &CollateralAuction{
|
||||||
BaseAuction: BaseAuction{
|
BaseAuction: BaseAuction{
|
||||||
@ -82,7 +81,6 @@ func TestGenesisState_Validate(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
|
||||||
err := tc.genesis.Validate()
|
err := tc.genesis.Validate()
|
||||||
if tc.expectPass {
|
if tc.expectPass {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -91,11 +89,9 @@ func TestGenesisState_Validate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenesisState_UnmarshalAnys(t *testing.T) {
|
func TestGenesisState_UnmarshalAnys(t *testing.T) {
|
||||||
|
|
||||||
cdc := newTestModuleCodec()
|
cdc := newTestModuleCodec()
|
||||||
|
|
||||||
arbitraryTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
|
arbitraryTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||||
|
@ -14,8 +14,10 @@ import (
|
|||||||
"github.com/kava-labs/kava/x/bep3/types"
|
"github.com/kava-labs/kava/x/bep3/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const restSwapID = "swap-id"
|
const (
|
||||||
const restDenom = "denom"
|
restSwapID = "swap-id"
|
||||||
|
restDenom = "denom"
|
||||||
|
)
|
||||||
|
|
||||||
func registerQueryRoutes(cliCtx client.Context, r *mux.Router) {
|
func registerQueryRoutes(cliCtx client.Context, r *mux.Router) {
|
||||||
r.HandleFunc(fmt.Sprintf("/%s/swap/{%s}", types.ModuleName, restSwapID), queryAtomicSwapHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/%s/swap/{%s}", types.ModuleName, restSwapID), queryAtomicSwapHandlerFn(cliCtx)).Methods("GET")
|
||||||
@ -23,7 +25,6 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) {
|
|||||||
r.HandleFunc(fmt.Sprintf("/%s/supply/{%s}", types.ModuleName, restDenom), queryAssetSupplyHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/%s/supply/{%s}", types.ModuleName, restDenom), queryAssetSupplyHandlerFn(cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/%s/supplies", types.ModuleName), queryAssetSuppliesHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/%s/supplies", types.ModuleName), queryAssetSuppliesHandlerFn(cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/%s/parameters", types.ModuleName), queryParamsHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/%s/parameters", types.ModuleName), queryParamsHandlerFn(cliCtx)).Methods("GET")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func queryAtomicSwapHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
func queryAtomicSwapHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||||
|
@ -340,7 +340,6 @@ func (suite *GenesisTestSuite) TestGenesisState() {
|
|||||||
}, tc.name)
|
}, tc.name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,6 @@ func (suite *AssetTestSuite) TestIncrementCurrentAssetSupply() {
|
|||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
suite.SetupTest()
|
suite.SetupTest()
|
||||||
suite.Run(tc.name, func() {
|
suite.Run(tc.name, func() {
|
||||||
|
|
||||||
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
||||||
err := suite.keeper.IncrementCurrentAssetSupply(suite.ctx, tc.args.coin)
|
err := suite.keeper.IncrementCurrentAssetSupply(suite.ctx, tc.args.coin)
|
||||||
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
||||||
@ -138,7 +137,8 @@ func (suite *AssetTestSuite) TestIncrementTimeLimitedCurrentAssetSupply() {
|
|||||||
OutgoingSupply: c("inc", 5),
|
OutgoingSupply: c("inc", 5),
|
||||||
CurrentSupply: c("inc", 10),
|
CurrentSupply: c("inc", 10),
|
||||||
TimeLimitedCurrentSupply: c("inc", 5),
|
TimeLimitedCurrentSupply: c("inc", 5),
|
||||||
TimeElapsed: time.Duration(0)},
|
TimeElapsed: time.Duration(0),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
errArgs{
|
errArgs{
|
||||||
expectPass: true,
|
expectPass: true,
|
||||||
@ -215,7 +215,6 @@ func (suite *AssetTestSuite) TestDecrementCurrentAssetSupply() {
|
|||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
suite.SetupTest()
|
suite.SetupTest()
|
||||||
suite.Run(tc.name, func() {
|
suite.Run(tc.name, func() {
|
||||||
|
|
||||||
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
||||||
err := suite.keeper.DecrementCurrentAssetSupply(suite.ctx, tc.args.coin)
|
err := suite.keeper.DecrementCurrentAssetSupply(suite.ctx, tc.args.coin)
|
||||||
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
||||||
@ -313,7 +312,8 @@ func (suite *AssetTestSuite) TestIncrementTimeLimitedIncomingAssetSupply() {
|
|||||||
OutgoingSupply: c("inc", 5),
|
OutgoingSupply: c("inc", 5),
|
||||||
CurrentSupply: c("inc", 5),
|
CurrentSupply: c("inc", 5),
|
||||||
TimeLimitedCurrentSupply: c("inc", 0),
|
TimeLimitedCurrentSupply: c("inc", 0),
|
||||||
TimeElapsed: time.Duration(0)},
|
TimeElapsed: time.Duration(0),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
errArgs{
|
errArgs{
|
||||||
expectPass: true,
|
expectPass: true,
|
||||||
@ -390,7 +390,6 @@ func (suite *AssetTestSuite) TestDecrementIncomingAssetSupply() {
|
|||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
suite.SetupTest()
|
suite.SetupTest()
|
||||||
suite.Run(tc.name, func() {
|
suite.Run(tc.name, func() {
|
||||||
|
|
||||||
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
||||||
err := suite.keeper.DecrementIncomingAssetSupply(suite.ctx, tc.args.coin)
|
err := suite.keeper.DecrementIncomingAssetSupply(suite.ctx, tc.args.coin)
|
||||||
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
||||||
@ -449,7 +448,6 @@ func (suite *AssetTestSuite) TestIncrementOutgoingAssetSupply() {
|
|||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
suite.SetupTest()
|
suite.SetupTest()
|
||||||
suite.Run(tc.name, func() {
|
suite.Run(tc.name, func() {
|
||||||
|
|
||||||
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
||||||
err := suite.keeper.IncrementOutgoingAssetSupply(suite.ctx, tc.args.coin)
|
err := suite.keeper.IncrementOutgoingAssetSupply(suite.ctx, tc.args.coin)
|
||||||
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
|
||||||
|
@ -25,7 +25,8 @@ type Keeper struct {
|
|||||||
|
|
||||||
// NewKeeper creates a bep3 keeper
|
// NewKeeper creates a bep3 keeper
|
||||||
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, sk types.BankKeeper, ak types.AccountKeeper,
|
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, sk types.BankKeeper, ak types.AccountKeeper,
|
||||||
paramstore paramtypes.Subspace, maccs map[string]bool) Keeper {
|
paramstore paramtypes.Subspace, maccs map[string]bool,
|
||||||
|
) Keeper {
|
||||||
if !paramstore.HasKeyTable() {
|
if !paramstore.HasKeyTable() {
|
||||||
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
||||||
}
|
}
|
||||||
@ -160,7 +161,8 @@ func (k Keeper) RemoveFromLongtermStorage(ctx sdk.Context, atomicSwap types.Atom
|
|||||||
// IterateAtomicSwapsLongtermStorage provides an iterator over AtomicSwaps ordered by deletion height.
|
// IterateAtomicSwapsLongtermStorage provides an iterator over AtomicSwaps ordered by deletion height.
|
||||||
// For each AtomicSwap cb will be called. If cb returns true the iterator will close and stop.
|
// For each AtomicSwap cb will be called. If cb returns true the iterator will close and stop.
|
||||||
func (k Keeper) IterateAtomicSwapsLongtermStorage(ctx sdk.Context, inclusiveCutoffTime uint64,
|
func (k Keeper) IterateAtomicSwapsLongtermStorage(ctx sdk.Context, inclusiveCutoffTime uint64,
|
||||||
cb func(swapID []byte) (stop bool)) {
|
cb func(swapID []byte) (stop bool),
|
||||||
|
) {
|
||||||
store := prefix.NewStore(ctx.KVStore(k.key), types.AtomicSwapLongtermStoragePrefix)
|
store := prefix.NewStore(ctx.KVStore(k.key), types.AtomicSwapLongtermStoragePrefix)
|
||||||
iterator := store.Iterator(
|
iterator := store.Iterator(
|
||||||
nil, // start at the very start of the prefix store
|
nil, // start at the very start of the prefix store
|
||||||
|
@ -78,6 +78,7 @@ func (suite *KeeperTestSuite) TestRemoveAtomicSwap() {
|
|||||||
_, found = suite.keeper.GetAtomicSwap(suite.ctx, atomicSwap.GetSwapID())
|
_, found = suite.keeper.GetAtomicSwap(suite.ctx, atomicSwap.GetSwapID())
|
||||||
suite.False(found)
|
suite.False(found)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestIterateAtomicSwaps() {
|
func (suite *KeeperTestSuite) TestIterateAtomicSwaps() {
|
||||||
suite.ResetChain()
|
suite.ResetChain()
|
||||||
|
|
||||||
@ -324,7 +325,6 @@ func (suite *KeeperTestSuite) TestGetSetAssetSupply() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestGetAllAssetSupplies() {
|
func (suite *KeeperTestSuite) TestGetAllAssetSupplies() {
|
||||||
|
|
||||||
// Put asset supply in store
|
// Put asset supply in store
|
||||||
assetSupply := types.NewAssetSupply(c("bnb", 0), c("bnb", 0), c("bnb", 50000), c("bnb", 0), time.Duration(0))
|
assetSupply := types.NewAssetSupply(c("bnb", 0), c("bnb", 0), c("bnb", 50000), c("bnb", 0), time.Duration(0))
|
||||||
suite.keeper.SetAssetSupply(suite.ctx, assetSupply, "bnb")
|
suite.keeper.SetAssetSupply(suite.ctx, assetSupply, "bnb")
|
||||||
|
@ -63,7 +63,6 @@ func (suite *ParamsTestSuite) TestGetSetDeputyAddress() {
|
|||||||
addr, err := suite.keeper.GetDeputyAddress(suite.ctx, "bnb")
|
addr, err := suite.keeper.GetDeputyAddress(suite.ctx, "bnb")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
suite.Equal(suite.addrs[1], addr)
|
suite.Equal(suite.addrs[1], addr)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ParamsTestSuite) TestGetDeputyFixedFee() {
|
func (suite *ParamsTestSuite) TestGetDeputyFixedFee() {
|
||||||
|
@ -15,7 +15,8 @@ import (
|
|||||||
// CreateAtomicSwap creates a new atomic swap.
|
// CreateAtomicSwap creates a new atomic swap.
|
||||||
func (k Keeper) CreateAtomicSwap(ctx sdk.Context, randomNumberHash []byte, timestamp int64, heightSpan uint64,
|
func (k Keeper) CreateAtomicSwap(ctx sdk.Context, randomNumberHash []byte, timestamp int64, heightSpan uint64,
|
||||||
sender, recipient sdk.AccAddress, senderOtherChain, recipientOtherChain string,
|
sender, recipient sdk.AccAddress, senderOtherChain, recipientOtherChain string,
|
||||||
amount sdk.Coins, crossChain bool) error {
|
amount sdk.Coins, crossChain bool,
|
||||||
|
) error {
|
||||||
// Confirm that this is not a duplicate swap
|
// Confirm that this is not a duplicate swap
|
||||||
swapID := types.CalculateSwapID(randomNumberHash, sender, senderOtherChain)
|
swapID := types.CalculateSwapID(randomNumberHash, sender, senderOtherChain)
|
||||||
_, found := k.GetAtomicSwap(ctx, swapID)
|
_, found := k.GetAtomicSwap(ctx, swapID)
|
||||||
|
@ -197,7 +197,6 @@ func (suite *AtomicSwapTestSuite) TestCreateAtomicSwap() {
|
|||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
"outgoing swap amount not greater than fixed fee",
|
"outgoing swap amount not greater than fixed fee",
|
||||||
currentTmTime,
|
currentTmTime,
|
||||||
args{
|
args{
|
||||||
@ -453,8 +452,7 @@ func (suite *AtomicSwapTestSuite) TestCreateAtomicSwap() {
|
|||||||
suite.NotNil(actualSwap)
|
suite.NotNil(actualSwap)
|
||||||
|
|
||||||
// Confirm swap contents
|
// Confirm swap contents
|
||||||
expectedSwap :=
|
expectedSwap := types.AtomicSwap{
|
||||||
types.AtomicSwap{
|
|
||||||
Amount: tc.args.coins,
|
Amount: tc.args.coins,
|
||||||
RandomNumberHash: tc.args.randomNumberHash,
|
RandomNumberHash: tc.args.randomNumberHash,
|
||||||
ExpireHeight: uint64(suite.ctx.BlockHeight()) + tc.args.heightSpan,
|
ExpireHeight: uint64(suite.ctx.BlockHeight()) + tc.args.heightSpan,
|
||||||
|
@ -78,7 +78,6 @@ func GenMaxBlockLock(r *rand.Rand, minBlockLock uint64) uint64 {
|
|||||||
|
|
||||||
// GenSupportedAssets gets randomized SupportedAssets
|
// GenSupportedAssets gets randomized SupportedAssets
|
||||||
func GenSupportedAssets(r *rand.Rand) types.AssetParams {
|
func GenSupportedAssets(r *rand.Rand) types.AssetParams {
|
||||||
|
|
||||||
numAssets := (r.Intn(10) + 1)
|
numAssets := (r.Intn(10) + 1)
|
||||||
assets := make(types.AssetParams, numAssets+1)
|
assets := make(types.AssetParams, numAssets+1)
|
||||||
for i := 0; i < numAssets; i++ {
|
for i := 0; i < numAssets; i++ {
|
||||||
@ -113,7 +112,8 @@ func genSupportedAsset(r *rand.Rand, denom string) types.AssetParam {
|
|||||||
Limit: limit,
|
Limit: limit,
|
||||||
TimeLimited: timeLimited,
|
TimeLimited: timeLimited,
|
||||||
TimePeriod: time.Hour * 24,
|
TimePeriod: time.Hour * 24,
|
||||||
TimeBasedLimit: timeBasedLimit},
|
TimeBasedLimit: timeBasedLimit,
|
||||||
|
},
|
||||||
Active: true,
|
Active: true,
|
||||||
DeputyAddress: GenRandBnbDeputy(r).Address,
|
DeputyAddress: GenRandBnbDeputy(r).Address,
|
||||||
FixedFee: GenRandFixedFee(r),
|
FixedFee: GenRandFixedFee(r),
|
||||||
@ -146,7 +146,6 @@ func RandomizedGenState(simState *module.SimulationState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadRandomBep3GenState(simState *module.SimulationState) types.GenesisState {
|
func loadRandomBep3GenState(simState *module.SimulationState) types.GenesisState {
|
||||||
|
|
||||||
supportedAssets := GenSupportedAssets(simState.Rand)
|
supportedAssets := GenSupportedAssets(simState.Rand)
|
||||||
supplies := types.AssetSupplies{}
|
supplies := types.AssetSupplies{}
|
||||||
for _, asset := range supportedAssets {
|
for _, asset := range supportedAssets {
|
||||||
|
@ -133,7 +133,6 @@ func SimulateMsgCreateAtomicSwap(ak types.AccountKeeper, k keeper.Keeper) simula
|
|||||||
}
|
}
|
||||||
// The maximum amount for outgoing swaps is limited by the asset's current supply
|
// The maximum amount for outgoing swaps is limited by the asset's current supply
|
||||||
if recipient.Address.Equals(asset.DeputyAddress) {
|
if recipient.Address.Equals(asset.DeputyAddress) {
|
||||||
|
|
||||||
if maximumAmount.GT(assetSupply.CurrentSupply.Amount.Sub(assetSupply.OutgoingSupply.Amount)) {
|
if maximumAmount.GT(assetSupply.CurrentSupply.Amount.Sub(assetSupply.OutgoingSupply.Amount)) {
|
||||||
maximumAmount = assetSupply.CurrentSupply.Amount.Sub(assetSupply.OutgoingSupply.Amount)
|
maximumAmount = assetSupply.CurrentSupply.Amount.Sub(assetSupply.OutgoingSupply.Amount)
|
||||||
}
|
}
|
||||||
@ -330,7 +329,8 @@ func operationRefundAtomicSwap(ak types.AccountKeeper, k keeper.Keeper, swapID [
|
|||||||
|
|
||||||
// findValidAccountAssetSupplyPair finds an account for which the callback func returns true
|
// findValidAccountAssetSupplyPair finds an account for which the callback func returns true
|
||||||
func findValidAccountAssetPair(accounts []simulation.Account, assets types.AssetParams,
|
func findValidAccountAssetPair(accounts []simulation.Account, assets types.AssetParams,
|
||||||
cb func(simulation.Account, types.AssetParam) bool) (simulation.Account, types.AssetParam, bool) {
|
cb func(simulation.Account, types.AssetParam) bool,
|
||||||
|
) (simulation.Account, types.AssetParam, bool) {
|
||||||
for _, asset := range assets {
|
for _, asset := range assets {
|
||||||
for _, acc := range accounts {
|
for _, acc := range accounts {
|
||||||
if isValid := cb(acc, asset); isValid {
|
if isValid := cb(acc, asset); isValid {
|
||||||
|
@ -113,7 +113,6 @@ func (suite *GenesisTestSuite) TestValidate() {
|
|||||||
} else {
|
} else {
|
||||||
suite.Require().Error(err, tc.name)
|
suite.Require().Error(err, tc.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,8 @@ var (
|
|||||||
// NewMsgCreateAtomicSwap initializes a new MsgCreateAtomicSwap
|
// NewMsgCreateAtomicSwap initializes a new MsgCreateAtomicSwap
|
||||||
func NewMsgCreateAtomicSwap(from, to string, recipientOtherChain,
|
func NewMsgCreateAtomicSwap(from, to string, recipientOtherChain,
|
||||||
senderOtherChain string, randomNumberHash tmbytes.HexBytes, timestamp int64,
|
senderOtherChain string, randomNumberHash tmbytes.HexBytes, timestamp int64,
|
||||||
amount sdk.Coins, heightSpan uint64) MsgCreateAtomicSwap {
|
amount sdk.Coins, heightSpan uint64,
|
||||||
|
) MsgCreateAtomicSwap {
|
||||||
return MsgCreateAtomicSwap{
|
return MsgCreateAtomicSwap{
|
||||||
From: from,
|
From: from,
|
||||||
To: to,
|
To: to,
|
||||||
|
@ -39,7 +39,6 @@ func (suite *ParamsTestSuite) SetupTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ParamsTestSuite) TestParamValidation() {
|
func (suite *ParamsTestSuite) TestParamValidation() {
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
assetParams types.AssetParams
|
assetParams types.AssetParams
|
||||||
}
|
}
|
||||||
@ -83,7 +82,8 @@ func (suite *ParamsTestSuite) TestParamValidation() {
|
|||||||
{
|
{
|
||||||
name: "valid multi asset",
|
name: "valid multi asset",
|
||||||
args: args{
|
args: args{
|
||||||
assetParams: types.AssetParams{types.NewAssetParam(
|
assetParams: types.AssetParams{
|
||||||
|
types.NewAssetParam(
|
||||||
"bnb", 714, suite.supply[0], true,
|
"bnb", 714, suite.supply[0], true,
|
||||||
suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000),
|
suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000),
|
||||||
types.DefaultMinBlockLock, types.DefaultMaxBlockLock),
|
types.DefaultMinBlockLock, types.DefaultMaxBlockLock),
|
||||||
@ -213,7 +213,8 @@ func (suite *ParamsTestSuite) TestParamValidation() {
|
|||||||
{
|
{
|
||||||
name: "duplicate denom",
|
name: "duplicate denom",
|
||||||
args: args{
|
args: args{
|
||||||
assetParams: types.AssetParams{types.NewAssetParam(
|
assetParams: types.AssetParams{
|
||||||
|
types.NewAssetParam(
|
||||||
"bnb", 714, suite.supply[0], true,
|
"bnb", 714, suite.supply[0], true,
|
||||||
suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000),
|
suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000),
|
||||||
types.DefaultMinBlockLock, types.DefaultMaxBlockLock),
|
types.DefaultMinBlockLock, types.DefaultMaxBlockLock),
|
||||||
|
@ -70,7 +70,8 @@ type QueryAtomicSwaps struct {
|
|||||||
|
|
||||||
// NewQueryAtomicSwaps creates a new instance of QueryAtomicSwaps
|
// NewQueryAtomicSwaps creates a new instance of QueryAtomicSwaps
|
||||||
func NewQueryAtomicSwaps(page, limit int, involve sdk.AccAddress, expiration uint64,
|
func NewQueryAtomicSwaps(page, limit int, involve sdk.AccAddress, expiration uint64,
|
||||||
status SwapStatus, direction SwapDirection) QueryAtomicSwaps {
|
status SwapStatus, direction SwapDirection,
|
||||||
|
) QueryAtomicSwaps {
|
||||||
return QueryAtomicSwaps{
|
return QueryAtomicSwaps{
|
||||||
Page: page,
|
Page: page,
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
|
@ -15,7 +15,8 @@ import (
|
|||||||
// NewAtomicSwap returns a new AtomicSwap
|
// NewAtomicSwap returns a new AtomicSwap
|
||||||
func NewAtomicSwap(amount sdk.Coins, randomNumberHash tmbytes.HexBytes, expireHeight uint64, timestamp int64,
|
func NewAtomicSwap(amount sdk.Coins, randomNumberHash tmbytes.HexBytes, expireHeight uint64, timestamp int64,
|
||||||
sender, recipient sdk.AccAddress, senderOtherChain, recipientOtherChain string, closedBlock int64,
|
sender, recipient sdk.AccAddress, senderOtherChain, recipientOtherChain string, closedBlock int64,
|
||||||
status SwapStatus, crossChain bool, direction SwapDirection) AtomicSwap {
|
status SwapStatus, crossChain bool, direction SwapDirection,
|
||||||
|
) AtomicSwap {
|
||||||
return AtomicSwap{
|
return AtomicSwap{
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
RandomNumberHash: randomNumberHash,
|
RandomNumberHash: randomNumberHash,
|
||||||
|
@ -120,6 +120,7 @@ func (suite *ModuleTestSuite) setPrice(price sdk.Dec, market string) {
|
|||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Equal(price, pp.Price)
|
suite.Equal(price, pp.Price)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ModuleTestSuite) TestBeginBlock() {
|
func (suite *ModuleTestSuite) TestBeginBlock() {
|
||||||
suite.createCdps()
|
suite.createCdps()
|
||||||
ak := suite.app.GetAccountKeeper()
|
ak := suite.app.GetAccountKeeper()
|
||||||
@ -147,7 +148,6 @@ func (suite *ModuleTestSuite) TestBeginBlock() {
|
|||||||
|
|
||||||
acc = ak.GetModuleAccount(suite.ctx, auctiontypes.ModuleName)
|
acc = ak.GetModuleAccount(suite.ctx, auctiontypes.ModuleName)
|
||||||
suite.Equal(int64(71955653865), bk.GetBalance(suite.ctx, acc.GetAddress(), "debt").Amount.Int64())
|
suite.Equal(int64(71955653865), bk.GetBalance(suite.ctx, acc.GetAddress(), "debt").Amount.Int64())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ModuleTestSuite) TestSeizeSingleCdpWithFees() {
|
func (suite *ModuleTestSuite) TestSeizeSingleCdpWithFees() {
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
// InitGenesis sets initial genesis state for cdp module
|
// InitGenesis sets initial genesis state for cdp module
|
||||||
func InitGenesis(ctx sdk.Context, k keeper.Keeper, pk types.PricefeedKeeper, ak types.AccountKeeper, gs types.GenesisState) {
|
func InitGenesis(ctx sdk.Context, k keeper.Keeper, pk types.PricefeedKeeper, ak types.AccountKeeper, gs types.GenesisState) {
|
||||||
|
|
||||||
if err := gs.Validate(); err != nil {
|
if err := gs.Validate(); err != nil {
|
||||||
panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err))
|
panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err))
|
||||||
}
|
}
|
||||||
@ -85,7 +84,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, pk types.PricefeedKeeper, ak
|
|||||||
for _, d := range gs.Deposits {
|
for _, d := range gs.Deposits {
|
||||||
k.SetDeposit(ctx, d)
|
k.SetDeposit(ctx, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportGenesis export genesis state for cdp module
|
// ExportGenesis export genesis state for cdp module
|
||||||
|
@ -168,7 +168,6 @@ func (suite *GenesisTestSuite) TestValidGenState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GenesisTestSuite) Test_InitExportGenesis() {
|
func (suite *GenesisTestSuite) Test_InitExportGenesis() {
|
||||||
|
|
||||||
cdps := types.CDPs{
|
cdps := types.CDPs{
|
||||||
{
|
{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
|
@ -108,6 +108,7 @@ func NewPricefeedGenStateMulti(cdc codec.JSONCodec) app.GenesisState {
|
|||||||
}
|
}
|
||||||
return app.GenesisState{pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pfGenesis)}
|
return app.GenesisState{pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pfGenesis)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCDPGenStateMulti(cdc codec.JSONCodec) app.GenesisState {
|
func NewCDPGenStateMulti(cdc codec.JSONCodec) app.GenesisState {
|
||||||
cdpGenesis := types.GenesisState{
|
cdpGenesis := types.GenesisState{
|
||||||
Params: types.Params{
|
Params: types.Params{
|
||||||
|
@ -27,8 +27,8 @@ func (k Keeper) AuctionCollateral(ctx sdk.Context, deposits types.Deposits, coll
|
|||||||
// CreateAuctionsFromDeposit creates auctions from the input deposit
|
// CreateAuctionsFromDeposit creates auctions from the input deposit
|
||||||
func (k Keeper) CreateAuctionsFromDeposit(
|
func (k Keeper) CreateAuctionsFromDeposit(
|
||||||
ctx sdk.Context, collateral sdk.Coin, collateralType string, returnAddr sdk.AccAddress, debt, auctionSize sdk.Int,
|
ctx sdk.Context, collateral sdk.Coin, collateralType string, returnAddr sdk.AccAddress, debt, auctionSize sdk.Int,
|
||||||
principalDenom string) error {
|
principalDenom string,
|
||||||
|
) error {
|
||||||
// number of auctions of auctionSize
|
// number of auctions of auctionSize
|
||||||
numberOfAuctions := collateral.Amount.Quo(auctionSize)
|
numberOfAuctions := collateral.Amount.Quo(auctionSize)
|
||||||
debtPerAuction := debt.Mul(auctionSize).Quo(collateral.Amount)
|
debtPerAuction := debt.Mul(auctionSize).Quo(collateral.Amount)
|
||||||
@ -73,7 +73,6 @@ func (k Keeper) CreateAuctionsFromDeposit(
|
|||||||
sdk.NewCoin(principalDenom, debtAmount.Add(penalty)), []sdk.AccAddress{returnAddr},
|
sdk.NewCoin(principalDenom, debtAmount.Add(penalty)), []sdk.AccAddress{returnAddr},
|
||||||
[]sdk.Int{auctionSize}, sdk.NewCoin(debtDenom, debtAmount),
|
[]sdk.Int{auctionSize}, sdk.NewCoin(debtDenom, debtAmount),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,6 @@ func (k Keeper) BurnDebtCoins(ctx sdk.Context, moduleAccount string, denom strin
|
|||||||
|
|
||||||
// GetCdpID returns the id of the cdp corresponding to a specific owner and collateral denom
|
// GetCdpID returns the id of the cdp corresponding to a specific owner and collateral denom
|
||||||
func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType string) (uint64, bool) {
|
func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType string) (uint64, bool) {
|
||||||
|
|
||||||
cdpIDs, found := k.GetCdpIdsByOwner(ctx, owner)
|
cdpIDs, found := k.GetCdpIdsByOwner(ctx, owner)
|
||||||
if !found {
|
if !found {
|
||||||
return 0, false
|
return 0, false
|
||||||
@ -185,7 +184,6 @@ func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0, false
|
return 0, false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCdpIdsByOwner returns all the ids of cdps corresponding to a particular owner
|
// GetCdpIdsByOwner returns all the ids of cdps corresponding to a particular owner
|
||||||
@ -256,7 +254,6 @@ func (k Keeper) DeleteCDP(ctx sdk.Context, cdp types.CDP) error {
|
|||||||
}
|
}
|
||||||
store.Delete(types.CdpKey(cdp.Type, cdp.ID))
|
store.Delete(types.CdpKey(cdp.Type, cdp.ID))
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAllCdps returns all cdps from the store
|
// GetAllCdps returns all cdps from the store
|
||||||
|
@ -124,7 +124,6 @@ func (k Keeper) GetDeposit(ctx sdk.Context, cdpID uint64, depositor sdk.AccAddre
|
|||||||
}
|
}
|
||||||
k.cdc.MustUnmarshal(bz, &deposit)
|
k.cdc.MustUnmarshal(bz, &deposit)
|
||||||
return deposit, true
|
return deposit, true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDeposit sets the deposit in the store
|
// SetDeposit sets the deposit in the store
|
||||||
@ -133,7 +132,6 @@ func (k Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit) {
|
|||||||
bz := k.cdc.MustMarshal(&deposit)
|
bz := k.cdc.MustMarshal(&deposit)
|
||||||
|
|
||||||
store.Set(types.DepositKey(deposit.CdpID, deposit.Depositor), bz)
|
store.Set(types.DepositKey(deposit.CdpID, deposit.Depositor), bz)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteDeposit deletes a deposit from the store
|
// DeleteDeposit deletes a deposit from the store
|
||||||
|
@ -35,7 +35,8 @@ func (suite *DepositTestSuite) SetupTest() {
|
|||||||
cdc,
|
cdc,
|
||||||
[]sdk.Coins{
|
[]sdk.Coins{
|
||||||
cs(c("xrp", 500000000), c("btc", 500000000)),
|
cs(c("xrp", 500000000), c("btc", 500000000)),
|
||||||
cs(c("xrp", 200000000))},
|
cs(c("xrp", 200000000)),
|
||||||
|
},
|
||||||
addrs[0:2],
|
addrs[0:2],
|
||||||
)
|
)
|
||||||
tApp.InitializeFromGenesisStates(
|
tApp.InitializeFromGenesisStates(
|
||||||
|
@ -53,7 +53,6 @@ func (suite *DrawTestSuite) SetupTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DrawTestSuite) TestAddRepayPrincipal() {
|
func (suite *DrawTestSuite) TestAddRepayPrincipal() {
|
||||||
|
|
||||||
err := suite.keeper.AddPrincipal(suite.ctx, suite.addrs[0], "xrp-a", c("usdx", 10000000))
|
err := suite.keeper.AddPrincipal(suite.ctx, suite.addrs[0], "xrp-a", c("usdx", 10000000))
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
@ -125,7 +124,6 @@ func (suite *DrawTestSuite) TestAddRepayPrincipal() {
|
|||||||
bk = suite.app.GetBankKeeper()
|
bk = suite.app.GetBankKeeper()
|
||||||
acc = ak.GetModuleAccount(suite.ctx, types.ModuleName)
|
acc = ak.GetModuleAccount(suite.ctx, types.ModuleName)
|
||||||
suite.Equal(sdk.Coins{}, bk.GetAllBalances(suite.ctx, acc.GetAddress()))
|
suite.Equal(sdk.Coins{}, bk.GetAllBalances(suite.ctx, acc.GetAddress()))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DrawTestSuite) TestRepayPrincipalOverpay() {
|
func (suite *DrawTestSuite) TestRepayPrincipalOverpay() {
|
||||||
|
@ -97,8 +97,7 @@ func (s QueryServer) TotalCollateral(c context.Context, req *types.QueryTotalCol
|
|||||||
|
|
||||||
// collect collateral types for each denom
|
// collect collateral types for each denom
|
||||||
for _, collateralParam := range params.CollateralParams {
|
for _, collateralParam := range params.CollateralParams {
|
||||||
denomCollateralTypes[collateralParam.Denom] =
|
denomCollateralTypes[collateralParam.Denom] = append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type)
|
||||||
append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort collateral types alphabetically
|
// sort collateral types alphabetically
|
||||||
|
@ -217,6 +217,7 @@ func (suite *grpcQueryTestSuite) TestGrpcQueryCdp() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *grpcQueryTestSuite) TestGrpcQueryDeposits() {
|
func (suite *grpcQueryTestSuite) TestGrpcQueryDeposits() {
|
||||||
suite.addCdp()
|
suite.addCdp()
|
||||||
|
|
||||||
|
@ -9,9 +9,7 @@ import (
|
|||||||
"github.com/kava-labs/kava/x/cdp/types"
|
"github.com/kava-labs/kava/x/cdp/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var scalingFactor = 1e18
|
||||||
scalingFactor = 1e18
|
|
||||||
)
|
|
||||||
|
|
||||||
// AccumulateInterest calculates the new interest that has accrued for the input collateral type based on the total amount of principal
|
// AccumulateInterest calculates the new interest that has accrued for the input collateral type based on the total amount of principal
|
||||||
// that has been created with that collateral type and the amount of time that has passed since interest was last accumulated
|
// that has been created with that collateral type and the amount of time that has passed since interest was last accumulated
|
||||||
|
@ -146,7 +146,6 @@ func (suite *InterestTestSuite) TestCalculateInterestFactor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InterestTestSuite) TestAccumulateInterest() {
|
func (suite *InterestTestSuite) TestAccumulateInterest() {
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
ctype string
|
ctype string
|
||||||
initialTime time.Time
|
initialTime time.Time
|
||||||
@ -385,7 +384,6 @@ func (suite *InterestTestSuite) TestSynchronizeInterest() {
|
|||||||
|
|
||||||
suite.Require().Equal(tc.args.expectedFees, cdp.AccumulatedFees)
|
suite.Require().Equal(tc.args.expectedFees, cdp.AccumulatedFees)
|
||||||
suite.Require().Equal(tc.args.expectedFeesUpdatedTime, cdp.FeesUpdated)
|
suite.Require().Equal(tc.args.expectedFeesUpdatedTime, cdp.FeesUpdated)
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,7 +530,6 @@ func (suite *InterestTestSuite) TestMultipleCDPInterest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suite.Require().Equal(tc.args.expectedSumOfCDPPrincipal, sumOfCDPPrincipal)
|
suite.Require().Equal(tc.args.expectedSumOfCDPPrincipal, sumOfCDPPrincipal)
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -640,7 +637,6 @@ func (suite *InterestTestSuite) TestCalculateCDPInterest() {
|
|||||||
newInterest := suite.keeper.CalculateNewInterest(suite.ctx, cdp)
|
newInterest := suite.keeper.CalculateNewInterest(suite.ctx, cdp)
|
||||||
|
|
||||||
suite.Require().Equal(tc.args.expectedFees, newInterest)
|
suite.Require().Equal(tc.args.expectedFees, newInterest)
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -665,7 +661,6 @@ func (suite *InterestTestSuite) TestSyncInterestForRiskyCDPs() {
|
|||||||
|
|
||||||
oneYearInSeconds := 31536000
|
oneYearInSeconds := 31536000
|
||||||
testCases := []test{
|
testCases := []test{
|
||||||
|
|
||||||
{
|
{
|
||||||
"1 year",
|
"1 year",
|
||||||
args{
|
args{
|
||||||
|
@ -27,7 +27,8 @@ type Keeper struct {
|
|||||||
|
|
||||||
// NewKeeper creates a new keeper
|
// NewKeeper creates a new keeper
|
||||||
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace, pfk types.PricefeedKeeper,
|
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace, pfk types.PricefeedKeeper,
|
||||||
ak types.AuctionKeeper, bk types.BankKeeper, ack types.AccountKeeper, maccs map[string][]string) Keeper {
|
ak types.AuctionKeeper, bk types.BankKeeper, ack types.AccountKeeper, maccs map[string][]string,
|
||||||
|
) Keeper {
|
||||||
if !paramstore.HasKeyTable() {
|
if !paramstore.HasKeyTable() {
|
||||||
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,6 @@ func BenchmarkCdpIteration(b *testing.B) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var errResult error
|
var errResult error
|
||||||
|
@ -68,7 +68,6 @@ func queryGetCdp(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQu
|
|||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||||
}
|
}
|
||||||
return bz, nil
|
return bz, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// query deposits on a particular cdp
|
// query deposits on a particular cdp
|
||||||
@ -96,7 +95,6 @@ func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, leg
|
|||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||||
}
|
}
|
||||||
return bz, nil
|
return bz, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// query cdps with matching denom and ratio LESS THAN the input ratio
|
// query cdps with matching denom and ratio LESS THAN the input ratio
|
||||||
@ -264,8 +262,7 @@ func queryGetTotalCollateral(ctx sdk.Context, req abci.RequestQuery, keeper Keep
|
|||||||
|
|
||||||
// collect collateral types for each denom
|
// collect collateral types for each denom
|
||||||
for _, collateralParam := range params.CollateralParams {
|
for _, collateralParam := range params.CollateralParams {
|
||||||
denomCollateralTypes[collateralParam.Denom] =
|
denomCollateralTypes[collateralParam.Denom] = append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type)
|
||||||
append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort collateral types alphabetically
|
// sort collateral types alphabetically
|
||||||
|
@ -152,7 +152,6 @@ func (suite *QuerierTestSuite) TestQueryCdp() {
|
|||||||
}
|
}
|
||||||
_, err = suite.querier(ctx, []string{types.QueryGetCdp}, query)
|
_, err = suite.querier(ctx, []string{types.QueryGetCdp}, query)
|
||||||
suite.Error(err)
|
suite.Error(err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *QuerierTestSuite) TestQueryCdpsByCollateralType() {
|
func (suite *QuerierTestSuite) TestQueryCdpsByCollateralType() {
|
||||||
@ -282,7 +281,6 @@ func (suite *QuerierTestSuite) TestQueryDeposits() {
|
|||||||
var d types.Deposits
|
var d types.Deposits
|
||||||
suite.Nil(suite.legacyAmino.UnmarshalJSON(bz, &d))
|
suite.Nil(suite.legacyAmino.UnmarshalJSON(bz, &d))
|
||||||
suite.Equal(deposits, d)
|
suite.Equal(deposits, d)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *QuerierTestSuite) TestQueryAccounts() {
|
func (suite *QuerierTestSuite) TestQueryAccounts() {
|
||||||
|
@ -27,11 +27,11 @@ var (
|
|||||||
ErrInvalidDeposit = sdkerrors.Register(ModuleName, 10, "invalid deposit")
|
ErrInvalidDeposit = sdkerrors.Register(ModuleName, 10, "invalid deposit")
|
||||||
// ErrInvalidPayment error for invalid payment
|
// ErrInvalidPayment error for invalid payment
|
||||||
ErrInvalidPayment = sdkerrors.Register(ModuleName, 11, "invalid payment")
|
ErrInvalidPayment = sdkerrors.Register(ModuleName, 11, "invalid payment")
|
||||||
//ErrDepositNotAvailable error for withdrawing deposits in liquidation
|
// ErrDepositNotAvailable error for withdrawing deposits in liquidation
|
||||||
ErrDepositNotAvailable = sdkerrors.Register(ModuleName, 12, "deposit in liquidation")
|
ErrDepositNotAvailable = sdkerrors.Register(ModuleName, 12, "deposit in liquidation")
|
||||||
// ErrInvalidWithdrawAmount error for invalid withdrawal amount
|
// ErrInvalidWithdrawAmount error for invalid withdrawal amount
|
||||||
ErrInvalidWithdrawAmount = sdkerrors.Register(ModuleName, 13, "withdrawal amount exceeds deposit")
|
ErrInvalidWithdrawAmount = sdkerrors.Register(ModuleName, 13, "withdrawal amount exceeds deposit")
|
||||||
//ErrCdpNotAvailable error for depositing to a CDP in liquidation
|
// ErrCdpNotAvailable error for depositing to a CDP in liquidation
|
||||||
ErrCdpNotAvailable = sdkerrors.Register(ModuleName, 14, "cannot modify cdp in liquidation")
|
ErrCdpNotAvailable = sdkerrors.Register(ModuleName, 14, "cannot modify cdp in liquidation")
|
||||||
// ErrBelowDebtFloor error for creating a cdp with debt below the minimum
|
// ErrBelowDebtFloor error for creating a cdp with debt below the minimum
|
||||||
ErrBelowDebtFloor = sdkerrors.Register(ModuleName, 15, "proposed cdp debt is below minimum")
|
ErrBelowDebtFloor = sdkerrors.Register(ModuleName, 15, "proposed cdp debt is below minimum")
|
||||||
|
@ -11,7 +11,8 @@ import (
|
|||||||
// NewGenesisState returns a new genesis state
|
// NewGenesisState returns a new genesis state
|
||||||
func NewGenesisState(params Params, cdps CDPs, deposits Deposits, startingCdpID uint64,
|
func NewGenesisState(params Params, cdps CDPs, deposits Deposits, startingCdpID uint64,
|
||||||
debtDenom, govDenom string, prevAccumTimes GenesisAccumulationTimes,
|
debtDenom, govDenom string, prevAccumTimes GenesisAccumulationTimes,
|
||||||
totalPrincipals GenesisTotalPrincipals) GenesisState {
|
totalPrincipals GenesisTotalPrincipals,
|
||||||
|
) GenesisState {
|
||||||
return GenesisState{
|
return GenesisState{
|
||||||
Params: params,
|
Params: params,
|
||||||
CDPs: cdps,
|
CDPs: cdps,
|
||||||
@ -41,7 +42,6 @@ func DefaultGenesisState() GenesisState {
|
|||||||
// Validate performs basic validation of genesis data returning an
|
// Validate performs basic validation of genesis data returning an
|
||||||
// error for any failed validation criteria.
|
// error for any failed validation criteria.
|
||||||
func (gs GenesisState) Validate() error {
|
func (gs GenesisState) Validate() error {
|
||||||
|
|
||||||
if err := gs.Params.Validate(); err != nil {
|
if err := gs.Params.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,6 @@ func CollateralRatioKey(collateralType string, cdpID uint64, ratio sdk.Dec) []by
|
|||||||
|
|
||||||
// SplitCollateralRatioKey split the collateral ratio key and return the denom, cdp id, and collateral:debt ratio
|
// SplitCollateralRatioKey split the collateral ratio key and return the denom, cdp id, and collateral:debt ratio
|
||||||
func SplitCollateralRatioKey(key []byte) (string, uint64, sdk.Dec) {
|
func SplitCollateralRatioKey(key []byte) (string, uint64, sdk.Dec) {
|
||||||
|
|
||||||
cdpID := GetCdpIDFromBytes(key[len(key)-8:])
|
cdpID := GetCdpIDFromBytes(key[len(key)-8:])
|
||||||
split := bytes.Split(key[:len(key)-8], sep)
|
split := bytes.Split(key[:len(key)-8], sep)
|
||||||
collateralType := string(split[0])
|
collateralType := string(split[0])
|
||||||
|
@ -68,7 +68,8 @@ func DefaultParams() Params {
|
|||||||
// NewCollateralParam returns a new CollateralParam
|
// NewCollateralParam returns a new CollateralParam
|
||||||
func NewCollateralParam(
|
func NewCollateralParam(
|
||||||
denom, ctype string, liqRatio sdk.Dec, debtLimit sdk.Coin, stabilityFee sdk.Dec, auctionSize sdk.Int,
|
denom, ctype string, liqRatio sdk.Dec, debtLimit sdk.Coin, stabilityFee sdk.Dec, auctionSize sdk.Int,
|
||||||
liqPenalty sdk.Dec, spotMarketID, liquidationMarketID string, keeperReward sdk.Dec, checkIndexCount sdk.Int, conversionFactor sdk.Int) CollateralParam {
|
liqPenalty sdk.Dec, spotMarketID, liquidationMarketID string, keeperReward sdk.Dec, checkIndexCount sdk.Int, conversionFactor sdk.Int,
|
||||||
|
) CollateralParam {
|
||||||
return CollateralParam{
|
return CollateralParam{
|
||||||
Denom: denom,
|
Denom: denom,
|
||||||
Type: ctype,
|
Type: ctype,
|
||||||
|
@ -31,7 +31,6 @@ type PostProposalReq struct {
|
|||||||
|
|
||||||
func postProposalHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
func postProposalHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// Parse and validate url params
|
// Parse and validate url params
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
if len(vars[RestCommitteeID]) == 0 {
|
if len(vars[RestCommitteeID]) == 0 {
|
||||||
@ -78,7 +77,6 @@ type PostVoteReq struct {
|
|||||||
|
|
||||||
func postVoteHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
func postVoteHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// Parse and validate url params
|
// Parse and validate url params
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
if len(vars[RestProposalID]) == 0 {
|
if len(vars[RestProposalID]) == 0 {
|
||||||
@ -148,7 +146,6 @@ func ProposalRESTHandler(cliCtx client.Context) govrest.ProposalRESTHandler {
|
|||||||
|
|
||||||
func postGovProposalHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
func postGovProposalHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// Parse and validate http request body
|
// Parse and validate http request body
|
||||||
var req PostGovProposalReq
|
var req PostGovProposalReq
|
||||||
if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) {
|
if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) {
|
||||||
|
@ -33,7 +33,6 @@ func (suite *GenesisTestSuite) SetupTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GenesisTestSuite) TestInitGenesis() {
|
func (suite *GenesisTestSuite) TestInitGenesis() {
|
||||||
|
|
||||||
memberCom := types.MustNewMemberCommittee(
|
memberCom := types.MustNewMemberCommittee(
|
||||||
1,
|
1,
|
||||||
"This member committee is for testing.",
|
"This member committee is for testing.",
|
||||||
|
@ -260,8 +260,8 @@ func (suite *PermissionTestSuite) TestSubParamChangePermission_Allows() {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPermissionTestSuite(t *testing.T) {
|
func TestPermissionTestSuite(t *testing.T) {
|
||||||
suite.Run(t, new(PermissionTestSuite))
|
suite.Run(t, new(PermissionTestSuite))
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import (
|
|||||||
|
|
||||||
// getProposalVoteMap collects up votes into a map indexed by proposalID
|
// getProposalVoteMap collects up votes into a map indexed by proposalID
|
||||||
func getProposalVoteMap(k keeper.Keeper, ctx sdk.Context) map[uint64]([]types.Vote) {
|
func getProposalVoteMap(k keeper.Keeper, ctx sdk.Context) map[uint64]([]types.Vote) {
|
||||||
|
|
||||||
proposalVoteMap := map[uint64]([]types.Vote){}
|
proposalVoteMap := map[uint64]([]types.Vote){}
|
||||||
|
|
||||||
k.IterateProposals(ctx, func(p types.Proposal) bool {
|
k.IterateProposals(ctx, func(p types.Proposal) bool {
|
||||||
|
@ -25,7 +25,8 @@ type Keeper struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, router govtypes.Router,
|
func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, router govtypes.Router,
|
||||||
paramKeeper types.ParamKeeper, ak types.AccountKeeper, sk types.BankKeeper) Keeper {
|
paramKeeper types.ParamKeeper, ak types.AccountKeeper, sk types.BankKeeper,
|
||||||
|
) Keeper {
|
||||||
// Logic in the keeper methods assume the set of gov handlers is fixed.
|
// Logic in the keeper methods assume the set of gov handlers is fixed.
|
||||||
// So the gov router must be sealed so no handlers can be added or removed after the keeper is created.
|
// So the gov router must be sealed so no handlers can be added or removed after the keeper is created.
|
||||||
router.Seal()
|
router.Seal()
|
||||||
|
@ -66,7 +66,7 @@ func (suite *MsgServerTestSuite) SetupTest() {
|
|||||||
suite.app.InitializeFromGenesisStates(
|
suite.app.InitializeFromGenesisStates(
|
||||||
app.GenesisState{types.ModuleName: cdc.MustMarshalJSON(testGenesis)},
|
app.GenesisState{types.ModuleName: cdc.MustMarshalJSON(testGenesis)},
|
||||||
// TODO: not used?
|
// TODO: not used?
|
||||||
//NewDistributionGenesisWithPool(suite.communityPoolAmt),
|
// NewDistributionGenesisWithPool(suite.communityPoolAmt),
|
||||||
)
|
)
|
||||||
suite.ctx = suite.app.NewContext(true, tmproto.Header{Height: 1, Time: firstBlockTime})
|
suite.ctx = suite.app.NewContext(true, tmproto.Header{Height: 1, Time: firstBlockTime})
|
||||||
}
|
}
|
||||||
@ -118,7 +118,6 @@ func (suite *MsgServerTestSuite) TestSubmitProposalMsg_Invalid() {
|
|||||||
suite.keeper.GetProposalsByCommittee(suite.ctx, committeeID),
|
suite.keeper.GetProposalsByCommittee(suite.ctx, committeeID),
|
||||||
"proposal found when none should exist",
|
"proposal found when none should exist",
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *MsgServerTestSuite) TestSubmitProposalMsg_ValidUpgrade() {
|
func (suite *MsgServerTestSuite) TestSubmitProposalMsg_ValidUpgrade() {
|
||||||
|
@ -57,7 +57,6 @@ func (k Keeper) AddVote(ctx sdk.Context, proposalID uint64, voter sdk.AccAddress
|
|||||||
}
|
}
|
||||||
if pr.HasExpiredBy(ctx.BlockTime()) {
|
if pr.HasExpiredBy(ctx.BlockTime()) {
|
||||||
return sdkerrors.Wrapf(types.ErrProposalExpired, "%s ≥ %s", ctx.BlockTime(), pr.Deadline)
|
return sdkerrors.Wrapf(types.ErrProposalExpired, "%s ≥ %s", ctx.BlockTime(), pr.Deadline)
|
||||||
|
|
||||||
}
|
}
|
||||||
com, found := k.GetCommittee(ctx, pr.CommitteeID)
|
com, found := k.GetCommittee(ctx, pr.CommitteeID)
|
||||||
if !found {
|
if !found {
|
||||||
@ -189,7 +188,8 @@ func (k Keeper) GetTokenCommitteeProposalResult(ctx sdk.Context, proposalID uint
|
|||||||
// total current votes, total possible votes (equal to token supply), vote threshold (yes vote ratio
|
// total current votes, total possible votes (equal to token supply), vote threshold (yes vote ratio
|
||||||
// required for proposal to pass), and quorum (votes tallied at this percentage).
|
// required for proposal to pass), and quorum (votes tallied at this percentage).
|
||||||
func (k Keeper) TallyTokenCommitteeVotes(ctx sdk.Context, proposalID uint64,
|
func (k Keeper) TallyTokenCommitteeVotes(ctx sdk.Context, proposalID uint64,
|
||||||
tallyDenom string) (yesVotes, noVotes, totalVotes, possibleVotes sdk.Dec) {
|
tallyDenom string,
|
||||||
|
) (yesVotes, noVotes, totalVotes, possibleVotes sdk.Dec) {
|
||||||
votes := k.GetVotesByProposal(ctx, proposalID)
|
votes := k.GetVotesByProposal(ctx, proposalID)
|
||||||
|
|
||||||
yesVotes = sdk.ZeroDec()
|
yesVotes = sdk.ZeroDec()
|
||||||
|
@ -43,7 +43,6 @@ func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
|
|
||||||
func queryCommittees(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
func queryCommittees(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
||||||
|
|
||||||
committees := keeper.GetCommittees(ctx)
|
committees := keeper.GetCommittees(ctx)
|
||||||
|
|
||||||
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, committees)
|
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, committees)
|
||||||
@ -128,7 +127,6 @@ func queryNextProposalID(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac
|
|||||||
func queryVotes(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
func queryVotes(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
||||||
var params types.QueryProposalParams
|
var params types.QueryProposalParams
|
||||||
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,6 @@ func (suite *QuerierTestSuite) TestQueryVote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *QuerierTestSuite) TestQueryTally() {
|
func (suite *QuerierTestSuite) TestQueryTally() {
|
||||||
|
|
||||||
ctx := suite.ctx.WithIsCheckTx(false)
|
ctx := suite.ctx.WithIsCheckTx(false)
|
||||||
|
|
||||||
// Expected result
|
// Expected result
|
||||||
@ -236,6 +235,7 @@ func (p *TestParams) ParamSetPairs() paramstypes.ParamSetPairs {
|
|||||||
paramstypes.NewParamSetPair([]byte(paramKey), &p.TestKey, func(interface{}) error { return nil }),
|
paramstypes.NewParamSetPair([]byte(paramKey), &p.TestKey, func(interface{}) error { return nil }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *QuerierTestSuite) TestQueryRawParams() {
|
func (suite *QuerierTestSuite) TestQueryRawParams() {
|
||||||
ctx := suite.ctx.WithIsCheckTx(false)
|
ctx := suite.ctx.WithIsCheckTx(false)
|
||||||
|
|
||||||
|
@ -239,7 +239,8 @@ type MemberCommittee struct {
|
|||||||
|
|
||||||
// NewMemberCommittee instantiates a new instance of MemberCommittee
|
// NewMemberCommittee instantiates a new instance of MemberCommittee
|
||||||
func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
||||||
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) MemberCommittee {
|
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption,
|
||||||
|
) MemberCommittee {
|
||||||
return MemberCommittee{
|
return MemberCommittee{
|
||||||
BaseCommittee: BaseCommittee{
|
BaseCommittee: BaseCommittee{
|
||||||
ID: id,
|
ID: id,
|
||||||
@ -276,7 +277,8 @@ type TokenCommittee struct {
|
|||||||
|
|
||||||
// NewTokenCommittee instantiates a new instance of TokenCommittee
|
// NewTokenCommittee instantiates a new instance of TokenCommittee
|
||||||
func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
||||||
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) TokenCommittee {
|
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string,
|
||||||
|
) TokenCommittee {
|
||||||
return TokenCommittee{
|
return TokenCommittee{
|
||||||
BaseCommittee: BaseCommittee{
|
BaseCommittee: BaseCommittee{
|
||||||
ID: id,
|
ID: id,
|
||||||
|
@ -112,7 +112,8 @@ type AllowedCollateralParam struct {
|
|||||||
func NewAllowedCollateralParam(
|
func NewAllowedCollateralParam(
|
||||||
ctype string, denom, liqRatio, debtLimit,
|
ctype string, denom, liqRatio, debtLimit,
|
||||||
stabilityFee, auctionSize, liquidationPenalty,
|
stabilityFee, auctionSize, liquidationPenalty,
|
||||||
prefix, spotMarket, liquidationMarket, conversionFactor, keeperReward, ltvIndexCount bool) AllowedCollateralParam {
|
prefix, spotMarket, liquidationMarket, conversionFactor, keeperReward, ltvIndexCount bool,
|
||||||
|
) AllowedCollateralParam {
|
||||||
return AllowedCollateralParam{
|
return AllowedCollateralParam{
|
||||||
Type: ctype,
|
Type: ctype,
|
||||||
Denom: denom,
|
Denom: denom,
|
||||||
|
@ -105,7 +105,7 @@ func (s *migrateTestSuite) TestMigrate_PricefeedPermissions() {
|
|||||||
|
|
||||||
genstate := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
genstate := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||||
|
|
||||||
var uniqueMarkets = make(map[string]bool)
|
uniqueMarkets := make(map[string]bool)
|
||||||
|
|
||||||
for _, permission := range genstate.GetCommittees()[0].GetPermissions() {
|
for _, permission := range genstate.GetCommittees()[0].GetPermissions() {
|
||||||
paramChangePermission, ok := permission.(v016committee.ParamsChangePermission)
|
paramChangePermission, ok := permission.(v016committee.ParamsChangePermission)
|
||||||
|
@ -16,9 +16,7 @@ import (
|
|||||||
"github.com/kava-labs/kava/x/committee/types"
|
"github.com/kava-labs/kava/x/committee/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var proposalPassPercentage = 0.9
|
||||||
proposalPassPercentage = 0.9
|
|
||||||
)
|
|
||||||
|
|
||||||
type AccountKeeper interface {
|
type AccountKeeper interface {
|
||||||
GetAccount(sdk.Context, sdk.AccAddress) authexported.Account
|
GetAccount(sdk.Context, sdk.AccAddress) authexported.Account
|
||||||
@ -27,8 +25,8 @@ type AccountKeeper interface {
|
|||||||
// WeightedOperations creates an operation (with weight) for each type of proposal generator.
|
// WeightedOperations creates an operation (with weight) for each type of proposal generator.
|
||||||
// Custom proposal generators can be added for more control over types of proposal submitted, eg to increase likelyhood of particular cdp param changes.
|
// Custom proposal generators can be added for more control over types of proposal submitted, eg to increase likelyhood of particular cdp param changes.
|
||||||
func WeightedOperations(appParams simulation.AppParams, cdc *codec.Codec, ak AccountKeeper,
|
func WeightedOperations(appParams simulation.AppParams, cdc *codec.Codec, ak AccountKeeper,
|
||||||
k keeper.Keeper, wContents []simulation.WeightedProposalContent) simulation.WeightedOperations {
|
k keeper.Keeper, wContents []simulation.WeightedProposalContent,
|
||||||
|
) simulation.WeightedOperations {
|
||||||
var wops simulation.WeightedOperations
|
var wops simulation.WeightedOperations
|
||||||
|
|
||||||
for _, wContent := range wContents {
|
for _, wContent := range wContents {
|
||||||
@ -59,7 +57,6 @@ func WeightedOperations(appParams simulation.AppParams, cdc *codec.Codec, ak Acc
|
|||||||
// For each submit proposal msg, future ops for the vote messages are generated. Sometimes it doesn't run enough votes to allow the proposal to timeout - the likelihood of this happening is controlled by a parameter.
|
// For each submit proposal msg, future ops for the vote messages are generated. Sometimes it doesn't run enough votes to allow the proposal to timeout - the likelihood of this happening is controlled by a parameter.
|
||||||
func SimulateMsgSubmitProposal(cdc *codec.Codec, ak AccountKeeper, k keeper.Keeper, contentSim simulation.ContentSimulatorFn) simulation.Operation {
|
func SimulateMsgSubmitProposal(cdc *codec.Codec, ak AccountKeeper, k keeper.Keeper, contentSim simulation.ContentSimulatorFn) simulation.Operation {
|
||||||
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string) (simulation.OperationMsg, []simulation.FutureOperation, error) {
|
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string) (simulation.OperationMsg, []simulation.FutureOperation, error) {
|
||||||
|
|
||||||
// 1) Send a submit proposal msg
|
// 1) Send a submit proposal msg
|
||||||
|
|
||||||
committees := k.GetCommittees(ctx)
|
committees := k.GetCommittees(ctx)
|
||||||
@ -176,8 +173,8 @@ func SimulateMsgSubmitProposal(cdc *codec.Codec, ak AccountKeeper, k keeper.Keep
|
|||||||
|
|
||||||
func SimulateMsgVote(k keeper.Keeper, ak AccountKeeper, voter sdk.AccAddress, proposalID uint64, voteType types.VoteType) simulation.Operation {
|
func SimulateMsgVote(k keeper.Keeper, ak AccountKeeper, voter sdk.AccAddress, proposalID uint64, voteType types.VoteType) simulation.Operation {
|
||||||
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string) (
|
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string) (
|
||||||
opMsg simulation.OperationMsg, fOps []simulation.FutureOperation, err error) {
|
opMsg simulation.OperationMsg, fOps []simulation.FutureOperation, err error,
|
||||||
|
) {
|
||||||
msg := types.NewMsgVote(voter, proposalID, voteType)
|
msg := types.NewMsgVote(voter, proposalID, voteType)
|
||||||
|
|
||||||
account := ak.GetAccount(ctx, voter)
|
account := ak.GetAccount(ctx, voter)
|
||||||
|
@ -242,7 +242,8 @@ func (c BaseCommittee) Validate() error {
|
|||||||
|
|
||||||
// NewMemberCommittee instantiates a new instance of MemberCommittee
|
// NewMemberCommittee instantiates a new instance of MemberCommittee
|
||||||
func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
||||||
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) (*MemberCommittee, error) {
|
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption,
|
||||||
|
) (*MemberCommittee, error) {
|
||||||
permissionsAny, err := PackPermissions(permissions)
|
permissionsAny, err := PackPermissions(permissions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -262,7 +263,8 @@ func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress,
|
|||||||
|
|
||||||
// MustNewMemberCommittee instantiates a new instance of MemberCommittee and panics on error
|
// MustNewMemberCommittee instantiates a new instance of MemberCommittee and panics on error
|
||||||
func MustNewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
func MustNewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
||||||
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) *MemberCommittee {
|
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption,
|
||||||
|
) *MemberCommittee {
|
||||||
committee, err := NewMemberCommittee(id, description, members, permissions, threshold, duration, tallyOption)
|
committee, err := NewMemberCommittee(id, description, members, permissions, threshold, duration, tallyOption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -275,7 +277,8 @@ func (c MemberCommittee) GetType() string { return MemberCommitteeType }
|
|||||||
|
|
||||||
// NewTokenCommittee instantiates a new instance of TokenCommittee
|
// NewTokenCommittee instantiates a new instance of TokenCommittee
|
||||||
func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
||||||
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) (*TokenCommittee, error) {
|
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string,
|
||||||
|
) (*TokenCommittee, error) {
|
||||||
permissionsAny, err := PackPermissions(permissions)
|
permissionsAny, err := PackPermissions(permissions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -297,7 +300,8 @@ func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress,
|
|||||||
|
|
||||||
// MustNewTokenCommittee instantiates a new instance of TokenCommittee and panics on error
|
// MustNewTokenCommittee instantiates a new instance of TokenCommittee and panics on error
|
||||||
func MustNewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
func MustNewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
|
||||||
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) *TokenCommittee {
|
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string,
|
||||||
|
) *TokenCommittee {
|
||||||
committee, err := NewTokenCommittee(id, description, members, permissions, threshold, duration, tallyOption, quorum, tallyDenom)
|
committee, err := NewTokenCommittee(id, description, members, permissions, threshold, duration, tallyOption, quorum, tallyDenom)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -57,7 +57,8 @@ func TestGenesisState_Validate(t *testing.T) {
|
|||||||
"hard",
|
"hard",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
types.Proposals{types.MustNewProposal(
|
types.Proposals{
|
||||||
|
types.MustNewProposal(
|
||||||
govtypes.NewTextProposal("A Title", "A description of this proposal."), 1, 1, testTime.Add(7*24*time.Hour)),
|
govtypes.NewTextProposal("A Title", "A description of this proposal."), 1, 1, testTime.Add(7*24*time.Hour)),
|
||||||
},
|
},
|
||||||
[]types.Vote{
|
[]types.Vote{
|
||||||
|
@ -45,7 +45,6 @@ func TestMsgSubmitProposal_ValidateBasic(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
|
||||||
err := tc.msg.ValidateBasic()
|
err := tc.msg.ValidateBasic()
|
||||||
|
|
||||||
if tc.expectPass {
|
if tc.expectPass {
|
||||||
@ -98,7 +97,6 @@ func TestMsgVote_ValidateBasic(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
|
||||||
err := tc.msg.ValidateBasic()
|
err := tc.msg.ValidateBasic()
|
||||||
|
|
||||||
if tc.expectPass {
|
if tc.expectPass {
|
||||||
|
@ -794,7 +794,8 @@ func (s *ParamsChangeTestSuite) TestParamsChangePermission_NoSubparamRequirement
|
|||||||
{
|
{
|
||||||
name: "fail if one change is not allowed",
|
name: "fail if one change is not allowed",
|
||||||
expected: false,
|
expected: false,
|
||||||
changes: []paramsproposal.ParamChange{{
|
changes: []paramsproposal.ParamChange{
|
||||||
|
{
|
||||||
Subspace: cdptypes.ModuleName,
|
Subspace: cdptypes.ModuleName,
|
||||||
Key: string(cdptypes.KeySurplusThreshold),
|
Key: string(cdptypes.KeySurplusThreshold),
|
||||||
Value: sdk.NewInt(120).String(),
|
Value: sdk.NewInt(120).String(),
|
||||||
@ -803,7 +804,8 @@ func (s *ParamsChangeTestSuite) TestParamsChangePermission_NoSubparamRequirement
|
|||||||
Subspace: cdptypes.ModuleName,
|
Subspace: cdptypes.ModuleName,
|
||||||
Key: string(cdptypes.KeySurplusLot),
|
Key: string(cdptypes.KeySurplusLot),
|
||||||
Value: sdk.NewInt(120).String(),
|
Value: sdk.NewInt(120).String(),
|
||||||
}},
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -834,7 +836,6 @@ func TestParamsChangeTestSuite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAllowedParamsChanges_Get(t *testing.T) {
|
func TestAllowedParamsChanges_Get(t *testing.T) {
|
||||||
|
|
||||||
exampleAPCs := types.AllowedParamsChanges{
|
exampleAPCs := types.AllowedParamsChanges{
|
||||||
{
|
{
|
||||||
Subspace: "subspaceA",
|
Subspace: "subspaceA",
|
||||||
@ -907,7 +908,6 @@ func TestAllowedParamsChanges_Get(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAllowedParamsChanges_Set(t *testing.T) {
|
func TestAllowedParamsChanges_Set(t *testing.T) {
|
||||||
|
|
||||||
exampleAPCs := types.AllowedParamsChanges{
|
exampleAPCs := types.AllowedParamsChanges{
|
||||||
{
|
{
|
||||||
Subspace: "subspaceA",
|
Subspace: "subspaceA",
|
||||||
@ -1029,7 +1029,6 @@ func TestAllowedParamsChanges_Set(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAllowedParamsChanges_Delete(t *testing.T) {
|
func TestAllowedParamsChanges_Delete(t *testing.T) {
|
||||||
|
|
||||||
exampleAPCs := types.AllowedParamsChanges{
|
exampleAPCs := types.AllowedParamsChanges{
|
||||||
{
|
{
|
||||||
Subspace: "subspaceA",
|
Subspace: "subspaceA",
|
||||||
|
@ -150,7 +150,7 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromModuleToAccount() {
|
|||||||
sdk.NewCoins(sdk.NewInt64Coin("akava", 98_000_000_000_000)),
|
sdk.NewCoins(sdk.NewInt64Coin("akava", 98_000_000_000_000)),
|
||||||
sdk.Coins{},
|
sdk.Coins{},
|
||||||
sdk.NewCoins(
|
sdk.NewCoins(
|
||||||
sdk.NewInt64Coin("akava", 00),
|
sdk.NewInt64Coin("akava", 0o0),
|
||||||
sdk.NewInt64Coin("ukava", 98),
|
sdk.NewInt64Coin("ukava", 98),
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
|
@ -33,7 +33,6 @@ func FullyBackedInvariant(bankK types.BankKeeper, k Keeper) sdk.Invariant {
|
|||||||
message := sdk.FormatInvariant(types.ModuleName, "fully backed broken", "sum of minor balances greater than module account")
|
message := sdk.FormatInvariant(types.ModuleName, "fully backed broken", "sum of minor balances greater than module account")
|
||||||
|
|
||||||
return func(ctx sdk.Context) (string, bool) {
|
return func(ctx sdk.Context) (string, bool) {
|
||||||
|
|
||||||
totalMinorBalances := sdk.ZeroInt()
|
totalMinorBalances := sdk.ZeroInt()
|
||||||
k.IterateAllAccounts(ctx, func(acc types.Account) bool {
|
k.IterateAllAccounts(ctx, func(acc types.Account) bool {
|
||||||
totalMinorBalances = totalMinorBalances.Add(acc.Balance)
|
totalMinorBalances = totalMinorBalances.Add(acc.Balance)
|
||||||
@ -55,7 +54,6 @@ func SmallBalancesInvariant(_ types.BankKeeper, k Keeper) sdk.Invariant {
|
|||||||
message := sdk.FormatInvariant(types.ModuleName, "small balances broken", "minor balances not all less than overflow")
|
message := sdk.FormatInvariant(types.ModuleName, "small balances broken", "minor balances not all less than overflow")
|
||||||
|
|
||||||
return func(ctx sdk.Context) (string, bool) {
|
return func(ctx sdk.Context) (string, bool) {
|
||||||
|
|
||||||
k.IterateAllAccounts(ctx, func(account types.Account) bool {
|
k.IterateAllAccounts(ctx, func(account types.Account) bool {
|
||||||
if account.Balance.GTE(ConversionMultiplier) {
|
if account.Balance.GTE(ConversionMultiplier) {
|
||||||
broken = true
|
broken = true
|
||||||
|
@ -78,7 +78,6 @@ func (suite *invariantTestSuite) runInvariant(route string, invariant func(bankK
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *invariantTestSuite) TestFullyBackedInvariant() {
|
func (suite *invariantTestSuite) TestFullyBackedInvariant() {
|
||||||
|
|
||||||
// default state is valid
|
// default state is valid
|
||||||
_, broken := suite.runInvariant("fully-backed", keeper.FullyBackedInvariant)
|
_, broken := suite.runInvariant("fully-backed", keeper.FullyBackedInvariant)
|
||||||
suite.Equal(false, broken)
|
suite.Equal(false, broken)
|
||||||
|
@ -12,9 +12,7 @@ const (
|
|||||||
StoreKey = "utilevm" // cannot be emvutil due to collision with x/evm
|
StoreKey = "utilevm" // cannot be emvutil due to collision with x/evm
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var AccountStoreKeyPrefix = []byte{0x00} // prefix for keys that store accounts
|
||||||
AccountStoreKeyPrefix = []byte{0x00} // prefix for keys that store accounts
|
|
||||||
)
|
|
||||||
|
|
||||||
// AccountStoreKey turns an address to a key used to get the account from the store
|
// AccountStoreKey turns an address to a key used to get the account from the store
|
||||||
func AccountStoreKey(addr sdk.AccAddress) []byte {
|
func AccountStoreKey(addr sdk.AccAddress) []byte {
|
||||||
|
@ -39,7 +39,6 @@ func (suite *GenesisTestSuite) SetupTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GenesisTestSuite) Test_InitExportGenesis() {
|
func (suite *GenesisTestSuite) Test_InitExportGenesis() {
|
||||||
|
|
||||||
loanToValue, _ := sdk.NewDecFromStr("0.6")
|
loanToValue, _ := sdk.NewDecFromStr("0.6")
|
||||||
params := types.NewParams(
|
params := types.NewParams(
|
||||||
types.MoneyMarkets{
|
types.MoneyMarkets{
|
||||||
|
@ -427,7 +427,6 @@ func (suite *KeeperTestSuite) TestBorrow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestValidateBorrow() {
|
func (suite *KeeperTestSuite) TestValidateBorrow() {
|
||||||
|
|
||||||
blockDuration := time.Second * 3600 * 24 // long blocks to accumulate larger interest
|
blockDuration := time.Second * 3600 * 24 // long blocks to accumulate larger interest
|
||||||
|
|
||||||
_, addrs := app.GeneratePrivKeyAddressPairs(5)
|
_, addrs := app.GeneratePrivKeyAddressPairs(5)
|
||||||
|
@ -55,7 +55,6 @@ func (suite *grpcQueryTestSuite) SetupTest() {
|
|||||||
addrs,
|
addrs,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *grpcQueryTestSuite) TestGrpcQueryParams() {
|
func (suite *grpcQueryTestSuite) TestGrpcQueryParams() {
|
||||||
|
@ -60,7 +60,6 @@ func (k Keeper) ApplyInterestRateUpdates(ctx sdk.Context) {
|
|||||||
// AccrueInterest applies accrued interest to total borrows and reserves by calculating
|
// AccrueInterest applies accrued interest to total borrows and reserves by calculating
|
||||||
// interest from the last checkpoint time and writing the updated values to the store.
|
// interest from the last checkpoint time and writing the updated values to the store.
|
||||||
func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error {
|
func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error {
|
||||||
|
|
||||||
previousAccrualTime, found := k.GetPreviousAccrualTime(ctx, denom)
|
previousAccrualTime, found := k.GetPreviousAccrualTime(ctx, denom)
|
||||||
if !found {
|
if !found {
|
||||||
k.SetPreviousAccrualTime(ctx, denom, ctx.BlockTime())
|
k.SetPreviousAccrualTime(ctx, denom, ctx.BlockTime())
|
||||||
|
@ -26,7 +26,8 @@ type Keeper struct {
|
|||||||
// NewKeeper creates a new keeper
|
// NewKeeper creates a new keeper
|
||||||
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace,
|
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace,
|
||||||
ak types.AccountKeeper, bk types.BankKeeper,
|
ak types.AccountKeeper, bk types.BankKeeper,
|
||||||
pfk types.PricefeedKeeper, auk types.AuctionKeeper) Keeper {
|
pfk types.PricefeedKeeper, auk types.AuctionKeeper,
|
||||||
|
) Keeper {
|
||||||
if !paramstore.HasKeyTable() {
|
if !paramstore.HasKeyTable() {
|
||||||
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ func (suite *KeeperTestSuite) TestGetSetDeleteDeposit() {
|
|||||||
|
|
||||||
_, f = suite.keeper.GetDeposit(suite.ctx, sdk.AccAddress("test"))
|
_, f = suite.keeper.GetDeposit(suite.ctx, sdk.AccAddress("test"))
|
||||||
suite.Require().False(f)
|
suite.Require().False(f)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestIterateDeposits() {
|
func (suite *KeeperTestSuite) TestIterateDeposits() {
|
||||||
|
@ -73,7 +73,8 @@ func (k Keeper) AttemptKeeperLiquidation(ctx sdk.Context, keeper sdk.AccAddress,
|
|||||||
|
|
||||||
// SeizeDeposits seizes a list of deposits and sends them to auction
|
// SeizeDeposits seizes a list of deposits and sends them to auction
|
||||||
func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit types.Deposit,
|
func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit types.Deposit,
|
||||||
borrow types.Borrow, dDenoms, bDenoms []string) error {
|
borrow types.Borrow, dDenoms, bDenoms []string,
|
||||||
|
) error {
|
||||||
liqMap, err := k.LoadLiquidationData(ctx, deposit, borrow)
|
liqMap, err := k.LoadLiquidationData(ctx, deposit, borrow)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -146,7 +147,8 @@ func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit ty
|
|||||||
|
|
||||||
// StartAuctions attempts to start auctions for seized assets
|
// StartAuctions attempts to start auctions for seized assets
|
||||||
func (k Keeper) StartAuctions(ctx sdk.Context, borrower sdk.AccAddress, borrows, deposits sdk.Coins,
|
func (k Keeper) StartAuctions(ctx sdk.Context, borrower sdk.AccAddress, borrows, deposits sdk.Coins,
|
||||||
depositCoinValues, borrowCoinValues types.ValuationMap, ltv sdk.Dec, liqMap map[string]LiqData) (sdk.Coins, error) {
|
depositCoinValues, borrowCoinValues types.ValuationMap, ltv sdk.Dec, liqMap map[string]LiqData,
|
||||||
|
) (sdk.Coins, error) {
|
||||||
// Sort keys to ensure deterministic behavior
|
// Sort keys to ensure deterministic behavior
|
||||||
bKeys := borrowCoinValues.GetSortedKeys()
|
bKeys := borrowCoinValues.GetSortedKeys()
|
||||||
dKeys := depositCoinValues.GetSortedKeys()
|
dKeys := depositCoinValues.GetSortedKeys()
|
||||||
@ -387,7 +389,6 @@ func (k Keeper) LoadLiquidationData(ctx sdk.Context, deposit types.Deposit, borr
|
|||||||
mm, found := k.GetMoneyMarket(ctx, denom)
|
mm, found := k.GetMoneyMarket(ctx, denom)
|
||||||
if !found {
|
if !found {
|
||||||
return liqMap, sdkerrors.Wrapf(types.ErrMarketNotFound, "no market found for denom %s", denom)
|
return liqMap, sdkerrors.Wrapf(types.ErrMarketNotFound, "no market found for denom %s", denom)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priceData, err := k.pricefeedKeeper.GetCurrentPrice(ctx, mm.SpotMarketID)
|
priceData, err := k.pricefeedKeeper.GetCurrentPrice(ctx, mm.SpotMarketID)
|
||||||
|
@ -82,7 +82,6 @@ func queryGetModAccounts(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac
|
|||||||
}
|
}
|
||||||
|
|
||||||
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, response)
|
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, response)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||||
}
|
}
|
||||||
@ -91,7 +90,6 @@ func queryGetModAccounts(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac
|
|||||||
}
|
}
|
||||||
|
|
||||||
func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
||||||
|
|
||||||
var params types.QueryDepositsParams
|
var params types.QueryDepositsParams
|
||||||
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -163,7 +161,6 @@ func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQu
|
|||||||
}
|
}
|
||||||
|
|
||||||
func queryGetUnsyncedDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
func queryGetUnsyncedDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
||||||
|
|
||||||
var params types.QueryUnsyncedDepositsParams
|
var params types.QueryUnsyncedDepositsParams
|
||||||
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -219,7 +216,6 @@ func queryGetUnsyncedDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func queryGetBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
func queryGetBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
||||||
|
|
||||||
var params types.QueryBorrowsParams
|
var params types.QueryBorrowsParams
|
||||||
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -291,7 +287,6 @@ func queryGetBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQue
|
|||||||
}
|
}
|
||||||
|
|
||||||
func queryGetUnsyncedBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
func queryGetUnsyncedBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
||||||
|
|
||||||
var params types.QueryUnsyncedBorrowsParams
|
var params types.QueryUnsyncedBorrowsParams
|
||||||
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -207,7 +207,6 @@ func (suite *KeeperTestSuite) TestWithdraw() {
|
|||||||
suite.Require().True(strings.Contains(err.Error(), tc.errArgs.contains))
|
suite.Require().True(strings.Contains(err.Error(), tc.errArgs.contains))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,6 @@ func (bif BorrowInterestFactor) Validate() error {
|
|||||||
}
|
}
|
||||||
if bif.Value.IsNegative() {
|
if bif.Value.IsNegative() {
|
||||||
return fmt.Errorf("borrow interest factor value cannot be negative: %s", bif)
|
return fmt.Errorf("borrow interest factor value cannot be negative: %s", bif)
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -113,5 +113,4 @@ func TestBorrow_NormalizedBorrow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,6 @@ func (sif SupplyInterestFactor) Validate() error {
|
|||||||
}
|
}
|
||||||
if sif.Value.IsNegative() {
|
if sif.Value.IsNegative() {
|
||||||
return fmt.Errorf("supply interest factor value cannot be negative: %s", sif)
|
return fmt.Errorf("supply interest factor value cannot be negative: %s", sif)
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -113,5 +113,4 @@ func TestDeposit_NormalizedDeposit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ import (
|
|||||||
// NewGenesisState returns a new genesis state
|
// NewGenesisState returns a new genesis state
|
||||||
func NewGenesisState(
|
func NewGenesisState(
|
||||||
params Params, prevAccumulationTimes GenesisAccumulationTimes, deposits Deposits,
|
params Params, prevAccumulationTimes GenesisAccumulationTimes, deposits Deposits,
|
||||||
borrows Borrows, totalSupplied, totalBorrowed, totalReserves sdk.Coins) GenesisState {
|
borrows Borrows, totalSupplied, totalBorrowed, totalReserves sdk.Coins,
|
||||||
|
) GenesisState {
|
||||||
return GenesisState{
|
return GenesisState{
|
||||||
Params: params,
|
Params: params,
|
||||||
PreviousAccumulationTimes: prevAccumulationTimes,
|
PreviousAccumulationTimes: prevAccumulationTimes,
|
||||||
@ -38,7 +39,6 @@ func DefaultGenesisState() GenesisState {
|
|||||||
// Validate performs basic validation of genesis data returning an
|
// Validate performs basic validation of genesis data returning an
|
||||||
// error for any failed validation criteria.
|
// error for any failed validation criteria.
|
||||||
func (gs GenesisState) Validate() error {
|
func (gs GenesisState) Validate() error {
|
||||||
|
|
||||||
if err := gs.Params.Validate(); err != nil {
|
if err := gs.Params.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,8 @@ func (bl BorrowLimit) Equal(blCompareTo BorrowLimit) bool {
|
|||||||
|
|
||||||
// NewMoneyMarket returns a new MoneyMarket
|
// NewMoneyMarket returns a new MoneyMarket
|
||||||
func NewMoneyMarket(denom string, borrowLimit BorrowLimit, spotMarketID string, conversionFactor sdk.Int,
|
func NewMoneyMarket(denom string, borrowLimit BorrowLimit, spotMarketID string, conversionFactor sdk.Int,
|
||||||
interestRateModel InterestRateModel, reserveFactor, keeperRewardPercentage sdk.Dec) MoneyMarket {
|
interestRateModel InterestRateModel, reserveFactor, keeperRewardPercentage sdk.Dec,
|
||||||
|
) MoneyMarket {
|
||||||
return MoneyMarket{
|
return MoneyMarket{
|
||||||
Denom: denom,
|
Denom: denom,
|
||||||
BorrowLimit: borrowLimit,
|
BorrowLimit: borrowLimit,
|
||||||
|
@ -14,8 +14,10 @@ import (
|
|||||||
"github.com/kava-labs/kava/x/incentive/types"
|
"github.com/kava-labs/kava/x/incentive/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const multiplierFlag = "multiplier"
|
const (
|
||||||
const multiplierFlagShort = "m"
|
multiplierFlag = "multiplier"
|
||||||
|
multiplierFlagShort = "m"
|
||||||
|
)
|
||||||
|
|
||||||
// GetTxCmd returns the transaction cli commands for the incentive module
|
// GetTxCmd returns the transaction cli commands for the incentive module
|
||||||
func GetTxCmd() *cobra.Command {
|
func GetTxCmd() *cobra.Command {
|
||||||
@ -42,7 +44,6 @@ func GetTxCmd() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getCmdClaimCdp() *cobra.Command {
|
func getCmdClaimCdp() *cobra.Command {
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "claim-cdp [multiplier]",
|
Use: "claim-cdp [multiplier]",
|
||||||
Short: "claim USDX minting rewards using a given multiplier",
|
Short: "claim USDX minting rewards using a given multiplier",
|
||||||
|
@ -183,7 +183,6 @@ func executeSwapRewardsQuery(w http.ResponseWriter, cliCtx client.Context, param
|
|||||||
}
|
}
|
||||||
|
|
||||||
func executeAllRewardQueries(w http.ResponseWriter, cliCtx client.Context, params types.QueryRewardsParams) {
|
func executeAllRewardQueries(w http.ResponseWriter, cliCtx client.Context, params types.QueryRewardsParams) {
|
||||||
|
|
||||||
paramsBz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
paramsBz, err := cliCtx.LegacyAmino.MarshalJSON(params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
|
||||||
|
@ -29,14 +29,17 @@ func usdxMintingGenerator(req PostClaimReq) (sdk.Msg, error) {
|
|||||||
msg := types.NewMsgClaimUSDXMintingReward(req.Sender.String(), req.DenomsToClaim[0].MultiplierName)
|
msg := types.NewMsgClaimUSDXMintingReward(req.Sender.String(), req.DenomsToClaim[0].MultiplierName)
|
||||||
return &msg, nil
|
return &msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func hardGenerator(req PostClaimReq) (sdk.Msg, error) {
|
func hardGenerator(req PostClaimReq) (sdk.Msg, error) {
|
||||||
msg := types.NewMsgClaimHardReward(req.Sender.String(), req.DenomsToClaim)
|
msg := types.NewMsgClaimHardReward(req.Sender.String(), req.DenomsToClaim)
|
||||||
return &msg, nil
|
return &msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func delegatorGenerator(req PostClaimReq) (sdk.Msg, error) {
|
func delegatorGenerator(req PostClaimReq) (sdk.Msg, error) {
|
||||||
msg := types.NewMsgClaimDelegatorReward(req.Sender.String(), req.DenomsToClaim)
|
msg := types.NewMsgClaimDelegatorReward(req.Sender.String(), req.DenomsToClaim)
|
||||||
return &msg, nil
|
return &msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func swapGenerator(req PostClaimReq) (sdk.Msg, error) {
|
func swapGenerator(req PostClaimReq) (sdk.Msg, error) {
|
||||||
msg := types.NewMsgClaimSwapReward(req.Sender.String(), req.DenomsToClaim)
|
msg := types.NewMsgClaimSwapReward(req.Sender.String(), req.DenomsToClaim)
|
||||||
return &msg, nil
|
return &msg, nil
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user