Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Membership Tier Module #552

Merged
merged 44 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cb15f0c
create new module membershiptier
amityadav0 May 31, 2024
176e0e3
add portfolio storage
amityadav0 May 31, 2024
06dc8b3
change key type for get and set for better traversal in compute
amityadav0 May 31, 2024
5b17e5d
update DS, add date
amityadav0 Jun 3, 2024
709a181
fixes
amityadav0 Jun 3, 2024
97cf568
add minimum per day calculation for liquid assets
amityadav0 Jun 3, 2024
a18a8e1
add perp logic
amityadav0 Jun 3, 2024
b7378f2
add a function in keeper to get tier, disc, totalPort
amityadav0 Jun 4, 2024
b2acecc
add tests
amityadav0 Jun 4, 2024
77d443a
add keeper functions tests
amityadav0 Jun 5, 2024
957ba2c
add getall portfolio
amityadav0 Jun 6, 2024
a167132
add exec, query
amityadav0 Jun 6, 2024
75261cb
fixes
amityadav0 Jun 6, 2024
80d3cae
add store upgrade
amityadav0 Jun 6, 2024
1d59140
fix
amityadav0 Jun 6, 2024
cd8657d
add upgrade logs
amityadav0 Jun 10, 2024
5105715
del
amityadav0 Jun 10, 2024
b4e0c51
fix
amityadav0 Jun 10, 2024
3672f80
clean up
amityadav0 Jun 10, 2024
a284a69
fix tests
amityadav0 Jun 10, 2024
ce24177
Merge branch 'main' into membership
amityadav0 Jun 10, 2024
4d7b034
update query tests
amityadav0 Jun 11, 2024
9543212
Merge branch 'membership' of https://github.com/elys-network/elys int…
amityadav0 Jun 11, 2024
9f6651d
add tests
amityadav0 Jun 12, 2024
34ec19e
ds
amityadav0 Jun 12, 2024
88faa03
perp tests
amityadav0 Jun 12, 2024
c5c10c7
add tier query
amityadav0 Jun 12, 2024
ed5a105
rename
amityadav0 Jun 12, 2024
f7184c6
rename
amityadav0 Jun 12, 2024
34a3f91
Merge branch 'main' into membership
cosmic-vagabond Jun 14, 2024
0982514
add wasmbinding
amityadav0 Jun 14, 2024
55368bf
upgrade handler, add query bindings
amityadav0 Jun 14, 2024
af24964
Merge branch 'membership' of https://github.com/elys-network/elys int…
amityadav0 Jun 14, 2024
5b71cab
register module
amityadav0 Jun 14, 2024
1f157e2
fix
amityadav0 Jun 14, 2024
df7b1a3
fix
amityadav0 Jun 14, 2024
fbb588e
update
amityadav0 Jun 14, 2024
b00c3a2
add dep
amityadav0 Jun 14, 2024
b582b65
add path
amityadav0 Jun 14, 2024
00c4d17
add libwasm
amityadav0 Jun 14, 2024
b78df46
restore
amityadav0 Jun 14, 2024
f46db7f
try fix
amityadav0 Jun 14, 2024
2920f0b
try fix
amityadav0 Jun 14, 2024
0d71039
restore
amityadav0 Jun 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ import (
masterchefmodulekeeper "github.com/elys-network/elys/x/masterchef/keeper"
masterchefmoduletypes "github.com/elys-network/elys/x/masterchef/types"

tiermodule "github.com/elys-network/elys/x/tier"
tiermodulekeeper "github.com/elys-network/elys/x/tier/keeper"
tiermoduletypes "github.com/elys-network/elys/x/tier/types"

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

"github.com/elys-network/elys/docs"
Expand Down Expand Up @@ -293,6 +297,7 @@ var (
leveragelpmodule.AppModuleBasic{},
masterchefmodule.AppModuleBasic{},
estakingmodule.AppModuleBasic{},
tiermodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -402,6 +407,8 @@ type ElysApp struct {
MasterchefKeeper masterchefmodulekeeper.Keeper

EstakingKeeper estakingmodulekeeper.Keeper

TierKeeper tiermodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// mm is the module manager
Expand Down Expand Up @@ -481,6 +488,7 @@ func NewElysApp(
leveragelpmoduletypes.StoreKey,
masterchefmoduletypes.StoreKey,
estakingmoduletypes.StoreKey,
tiermoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, ammmoduletypes.TStoreKey)
Expand Down Expand Up @@ -900,6 +908,7 @@ func NewElysApp(
&app.TransferhookKeeper,
&app.MasterchefKeeper,
&app.EstakingKeeper,
&app.TierKeeper,
),
wasmOpts...,
)
Expand Down Expand Up @@ -1009,6 +1018,23 @@ func NewElysApp(
)
leveragelpModule := leveragelpmodule.NewAppModule(appCodec, app.LeveragelpKeeper, app.AccountKeeper, app.BankKeeper)

app.TierKeeper = *tiermodulekeeper.NewKeeper(
appCodec,
keys[tiermoduletypes.StoreKey],
keys[tiermoduletypes.MemStoreKey],
app.GetSubspace(tiermoduletypes.ModuleName),
app.BankKeeper,
app.OracleKeeper,
app.AssetprofileKeeper,
app.AmmKeeper,
app.EstakingKeeper,
app.MasterchefKeeper,
app.CommitmentKeeper,
app.StakingKeeper,
app.PerpetualKeeper,
)
tierModule := tiermodule.NewAppModule(appCodec, app.TierKeeper, app.AccountKeeper, app.BankKeeper)

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

/**** IBC Routing ****/
Expand Down Expand Up @@ -1132,6 +1158,7 @@ func NewElysApp(
leveragelpModule,
masterchefModule,
estakingModule,
tierModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -1180,6 +1207,7 @@ func NewElysApp(
leveragelpmoduletypes.ModuleName,
masterchefmoduletypes.ModuleName,
estakingmoduletypes.ModuleName,
tiermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -1223,6 +1251,7 @@ func NewElysApp(
leveragelpmoduletypes.ModuleName,
masterchefmoduletypes.ModuleName,
estakingmoduletypes.ModuleName,
tiermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -1270,6 +1299,7 @@ func NewElysApp(
leveragelpmoduletypes.ModuleName,
masterchefmoduletypes.ModuleName,
estakingmoduletypes.ModuleName,
tiermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -1568,6 +1598,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(stablestaketypes.ModuleName)
paramsKeeper.Subspace(leveragelpmoduletypes.ModuleName)
paramsKeeper.Subspace(masterchefmoduletypes.ModuleName)
paramsKeeper.Subspace(tiermoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
16 changes: 13 additions & 3 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app

import (
"fmt"

"cosmossdk.io/math"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -10,6 +12,7 @@ import (
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
tiermoduletypes "github.com/elys-network/elys/x/tier/types"
)

func SetupHandlers(app *ElysApp) {
Expand Down Expand Up @@ -61,22 +64,29 @@ func setUpgradeHandler(app *ElysApp) {
func loadUpgradeStore(app *ElysApp) {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
panic(fmt.Sprintf("Failed to read upgrade info from disk: %v", err))
}

fmt.Printf("Upgrade info: %+v\n", upgradeInfo)

if shouldLoadUpgradeStore(app, upgradeInfo) {
storeUpgrades := storetypes.StoreUpgrades{
// Added: []string{},
// Deleted: []string{},
Added: []string{tiermoduletypes.StoreKey},
}
fmt.Printf("Setting store loader with height %d and store upgrades: %+v\n", upgradeInfo.Height, storeUpgrades)

// Use upgrade store loader for the initial loading of all stores when app starts,
// it checks if version == upgradeHeight and applies store upgrades before loading the stores,
// so that new stores start with the correct version (the current height of chain),
// instead the default which is the latest version that store last committed i.e 0 for new stores.
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
} else {
fmt.Println("No need to load upgrade store.")
}
}

func shouldLoadUpgradeStore(app *ElysApp, upgradeInfo upgradetypes.Plan) bool {
currentHeight := app.LastBlockHeight()
fmt.Printf("Current block height: %d, Upgrade height: %d\n", currentHeight, upgradeInfo.Height)
return upgradeInfo.Name == version.Version && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height)
}
Loading
Loading