Skip to content

Commit

Permalink
Discount changes (#957)
Browse files Browse the repository at this point in the history
* change discount values

* more changes

* get discount in amm:

* ifx tests

* fix tests

* fix

* tradeshield fix

* use tier structure

* update tests

* fixing tier keeper pointers (#958)

* fixing tier keeper pointers

* fixing tier keeper pointers

* fixing tier keeper pointers

* fix

* fix

* add discoumt to perpetual

* fix tests

* review changes

---------

Co-authored-by: Abhinav Kumar <[email protected]>
  • Loading branch information
amityadav0 and avkr003 authored Nov 18, 2024
1 parent f899c02 commit 3f1478d
Show file tree
Hide file tree
Showing 70 changed files with 754 additions and 450 deletions.
10 changes: 7 additions & 3 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ type AppKeepers struct {
LeveragelpKeeper *leveragelpmodulekeeper.Keeper
MasterchefKeeper masterchefmodulekeeper.Keeper
EstakingKeeper *estakingmodulekeeper.Keeper
TierKeeper tiermodulekeeper.Keeper
TierKeeper *tiermodulekeeper.Keeper
TradeshieldKeeper tradeshieldmodulekeeper.Keeper

// FIXME: disabled to avoid dependency with wasm
Expand Down Expand Up @@ -478,6 +478,7 @@ func NewAppKeeper(
app.CommitmentKeeper,
app.AssetprofileKeeper,
app.AccountedPoolKeeper,
app.TierKeeper,
)

app.StablestakeKeeper = stablestakekeeper.NewKeeper(
Expand Down Expand Up @@ -514,6 +515,7 @@ func NewAppKeeper(
app.OracleKeeper,
app.AssetprofileKeeper,
&app.ParameterKeeper,
app.TierKeeper,
)

app.MasterchefKeeper = *masterchefmodulekeeper.NewKeeper(
Expand Down Expand Up @@ -544,7 +546,7 @@ func NewAppKeeper(
app.TransferhookKeeper = *transferhookkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(app.keys[transferhooktypes.StoreKey]),
*app.AmmKeeper)
app.AmmKeeper)

//app.ConsumerKeeper = ccvconsumerkeeper.NewKeeper(
// appCodec,
Expand Down Expand Up @@ -621,7 +623,7 @@ func NewAppKeeper(
app.AccountedPoolKeeper,
)

app.TierKeeper = *tiermodulekeeper.NewKeeper(
app.TierKeeper = tiermodulekeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(app.keys[tiermoduletypes.StoreKey]),
app.BankKeeper,
Expand All @@ -636,6 +638,8 @@ func NewAppKeeper(
app.LeveragelpKeeper,
app.StablestakeKeeper,
)
app.AmmKeeper.SetTierKeeper(app.TierKeeper)
app.PerpetualKeeper.SetTierKeeper(app.TierKeeper)

app.TradeshieldKeeper = *tradeshieldmodulekeeper.NewKeeper(
appCodec,
Expand Down
4 changes: 2 additions & 2 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func appModules(
masterchefmodule.NewAppModule(appCodec, app.MasterchefKeeper, app.AccountKeeper, app.BankKeeper),
estakingmodule.NewAppModule(appCodec, *app.EstakingKeeper, app.AccountKeeper, app.BankKeeper),
perpetualmodule.NewAppModule(appCodec, app.PerpetualKeeper, app.AccountKeeper, app.BankKeeper),
tiermodule.NewAppModule(appCodec, app.TierKeeper, app.AccountKeeper, app.BankKeeper),
tiermodule.NewAppModule(appCodec, *app.TierKeeper, app.AccountKeeper, app.BankKeeper),
tradeshieldmodule.NewAppModule(appCodec, app.TradeshieldKeeper, app.AccountKeeper, app.BankKeeper),
}
}
Expand Down Expand Up @@ -220,7 +220,7 @@ func simulationModules(
masterchefmodule.NewAppModule(appCodec, app.MasterchefKeeper, app.AccountKeeper, app.BankKeeper),
estakingmodule.NewAppModule(appCodec, *app.EstakingKeeper, app.AccountKeeper, app.BankKeeper),
perpetualmodule.NewAppModule(appCodec, app.PerpetualKeeper, app.AccountKeeper, app.BankKeeper),
tiermodule.NewAppModule(appCodec, app.TierKeeper, app.AccountKeeper, app.BankKeeper),
tiermodule.NewAppModule(appCodec, *app.TierKeeper, app.AccountKeeper, app.BankKeeper),
tradeshieldmodule.NewAppModule(appCodec, app.TradeshieldKeeper, app.AccountKeeper, app.BankKeeper),
}
}
Expand Down
5 changes: 2 additions & 3 deletions proto/elys/tier/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ message QueryAllPortfolioResponse {
message QueryCalculateDiscountRequest { string user = 1; }

message QueryCalculateDiscountResponse {
string discount = 1;
string tier = 2;
string portfolio = 3;
MembershipTier membership_tier = 1;
string portfolio = 2;
}

message QueryLeverageLpTotalRequest { string user = 1; }
Expand Down
22 changes: 22 additions & 0 deletions proto/elys/tier/userdata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package elys.tier;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/elys-network/elys/x/tier/types";

Expand All @@ -18,4 +19,25 @@ message Pool {
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
}

enum MembershipTierType {
BRONZE = 0;
SILVER = 1;
GOLD = 2;
PLATINUM = 3;
}

message MembershipTier {
string minimum_portfolio = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
MembershipTierType membership = 2;
string discount = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
4 changes: 3 additions & 1 deletion testutil/keeper/amm.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package keeper

import (
"testing"

"cosmossdk.io/store/metrics"
"github.com/cosmos/cosmos-sdk/runtime"
"testing"

"cosmossdk.io/log"
"cosmossdk.io/store"
Expand Down Expand Up @@ -50,6 +51,7 @@ func AmmKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, *mocks.AccountedPoolK
nil,
nil,
accountedPoolKeeper,
nil,
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
Expand Down
4 changes: 2 additions & 2 deletions testutil/keeper/tradeshield.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package keeper

import (
"testing"

"cosmossdk.io/store/metrics"
"github.com/cosmos/cosmos-sdk/runtime"
"testing"

"cosmossdk.io/log"
"cosmossdk.io/store"
Expand Down Expand Up @@ -36,7 +37,6 @@ func TradeshieldKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, *mocks.AmmKee
ammKeeper := mocks.NewAmmKeeper(t)
tierKeeper := mocks.NewTierKeeper(t)
perpetualKeeper := mocks.NewPerpetualKeeper(t)

k := keeper.NewKeeper(
cdc,
storeService,
Expand Down
2 changes: 1 addition & 1 deletion x/accountedpool/types/mocks/amm_keeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3f1478d

Please sign in to comment.