Skip to content

Commit

Permalink
chore: account pool (#176)
Browse files Browse the repository at this point in the history
* fix git conflict

* fix: fix missing args

* test: list accounted pool test case

* initiate interfaces in margin keeper

* fix: add missing params

* fix: kv store issue in accounted pool module through margin call

* fix: pool address to be normal accaddress

* remove amm reference from accounted pool and updated hooks including the pool instance

* remove all cross dependency in accountedpool keeper

* chore: fix unit tests of margin invariant check

---------

Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com>
  • Loading branch information
kenta-elys and cosmic-vagabond authored Sep 5, 2023
1 parent ed993e6 commit bda883a
Show file tree
Hide file tree
Showing 112 changed files with 7,783 additions and 292 deletions.
32 changes: 32 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ import (
marginmodulekeeper "github.com/elys-network/elys/x/margin/keeper"
marginmoduletypes "github.com/elys-network/elys/x/margin/types"

accountedpoolmodule "github.com/elys-network/elys/x/accountedpool"
accountedpoolmodulekeeper "github.com/elys-network/elys/x/accountedpool/keeper"
accountedpoolmoduletypes "github.com/elys-network/elys/x/accountedpool/types"

// this line is used by starport scaffolding # stargate/app/moduleImport

"github.com/elys-network/elys/docs"
Expand Down Expand Up @@ -257,6 +261,7 @@ var (
ammmodule.AppModuleBasic{},
parametermodule.AppModuleBasic{},
marginmodule.AppModuleBasic{},
accountedpoolmodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -351,6 +356,8 @@ type ElysApp struct {
AmmKeeper ammmodulekeeper.Keeper
ParameterKeeper parametermodulekeeper.Keeper
MarginKeeper marginmodulekeeper.Keeper

AccountedPoolKeeper accountedpoolmodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// mm is the module manager
Expand Down Expand Up @@ -415,6 +422,7 @@ func NewElysApp(
tokenomicsmoduletypes.StoreKey,
incentivemoduletypes.StoreKey,
burnermoduletypes.StoreKey,
accountedpoolmoduletypes.StoreKey,
ammmoduletypes.StoreKey,
parametermoduletypes.StoreKey,
marginmoduletypes.StoreKey,
Expand Down Expand Up @@ -667,6 +675,15 @@ func NewElysApp(
app.AssetprofileKeeper,
)

app.AccountedPoolKeeper = *accountedpoolmodulekeeper.NewKeeper(
appCodec,
keys[accountedpoolmoduletypes.StoreKey],
keys[accountedpoolmoduletypes.MemStoreKey],
app.GetSubspace(accountedpoolmoduletypes.ModuleName),
app.BankKeeper,
)
accountedPoolModule := accountedpoolmodule.NewAppModule(appCodec, app.AccountedPoolKeeper, app.AccountKeeper, app.BankKeeper)

app.AmmKeeper = *ammmodulekeeper.NewKeeper(
appCodec,
keys[ammmoduletypes.StoreKey],
Expand All @@ -677,6 +694,7 @@ func NewElysApp(
app.OracleKeeper,
&app.CommitmentKeeper,
app.AssetprofileKeeper,
app.AccountedPoolKeeper,
)
ammModule := ammmodule.NewAppModule(appCodec, app.AmmKeeper, app.AccountKeeper, app.BankKeeper)

Expand Down Expand Up @@ -859,6 +877,7 @@ func NewElysApp(
ammmoduletypes.NewMultiAmmHooks(
// insert amm hooks receivers here
app.IncentiveKeeper.AmmHooks(),
app.MarginKeeper.AmmHooks(),
),
)

Expand All @@ -869,10 +888,18 @@ func NewElysApp(
app.CommitmentKeeper.Hooks(),
app.IncentiveKeeper.Hooks(),
app.BurnerKeeper.Hooks(),
app.MarginKeeper.Hooks(),
),
)
epochsModule := epochsmodule.NewAppModule(appCodec, app.EpochsKeeper)

app.MarginKeeper.SetHooks(
marginmoduletypes.NewMultiMarginHooks(
// insert margin hooks receivers here
app.AccountedPoolKeeper.MarginHooks(),
),
)

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
Expand Down Expand Up @@ -918,6 +945,7 @@ func NewElysApp(
ammModule,
parameterModule,
marginModule,
accountedPoolModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -960,6 +988,7 @@ func NewElysApp(
parametermoduletypes.ModuleName,
marginmoduletypes.ModuleName,
wasm.ModuleName,
accountedpoolmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -997,6 +1026,7 @@ func NewElysApp(
parametermoduletypes.ModuleName,
marginmoduletypes.ModuleName,
wasm.ModuleName,
accountedpoolmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -1038,6 +1068,7 @@ func NewElysApp(
parametermoduletypes.ModuleName,
marginmoduletypes.ModuleName,
wasm.ModuleName,
accountedpoolmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -1333,6 +1364,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ammmoduletypes.ModuleName)
paramsKeeper.Subspace(parametermoduletypes.ModuleName)
paramsKeeper.Subspace(marginmoduletypes.ModuleName)
paramsKeeper.Subspace(accountedpoolmoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
3 changes: 3 additions & 0 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
accountedpooltypes "github.com/elys-network/elys/x/accountedpool/types"
ammtypes "github.com/elys-network/elys/x/amm/types"
assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types"
burnertypes "github.com/elys-network/elys/x/burner/types"
Expand Down Expand Up @@ -77,6 +78,8 @@ func setUpgradeHandler(app *ElysApp) {
keyTable = parametertypes.ParamKeyTable() //nolint:staticcheck
case tokenomicstypes.ModuleName:
keyTable = tokenomicstypes.ParamKeyTable() //nolint:staticcheck
case accountedpooltypes.ModuleName:
keyTable = accountedpooltypes.ParamKeyTable() //nolint:staticcheck
}

if !subspace.HasKeyTable() {
Expand Down
3 changes: 2 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,6 @@ genesis:
sq_modifier: "1.0"
safety_factor: "1.0"
incremental_interest_payment_enabled: true
whitelisting_enabled: true
whitelisting_enabled: false
invariant_check_epoch: day
chain_id: elystestnet-1
Loading

0 comments on commit bda883a

Please sign in to comment.