From 28bb08fa2a11c30aff449b37a72d9450d57b2b0d Mon Sep 17 00:00:00 2001 From: cryptokage <26vivek06@gmail.com> Date: Fri, 25 Oct 2024 13:21:14 +0530 Subject: [PATCH] Dev 1930 set max value for pool (#863) * feat: add param * add check * fix: migration and test * update * update * update proto * update * update * fix: proto * update migration * update * update * update * Update pool.proto * update * test(leveragelp): fix tests * fix(leveragelp): migration * fix(leveragelp): fix data structure * fix(leveragelp): new pool * fix(leveragelp): migration * fix(leveragelp): fix tests and doc --------- Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> --- proto/elys/incentive/genesis.proto | 10 -- proto/elys/incentive/query.proto | 113 ------------ proto/elys/incentive/tx.proto | 36 ---- proto/elys/leveragelp/pool.proto | 12 +- x/leveragelp/keeper/msg_server_open.go | 15 +- x/leveragelp/keeper/msg_server_open_test.go | 32 +++- x/leveragelp/keeper/pool.go | 10 ++ x/leveragelp/migrations/v15_migration.go | 23 +++ x/leveragelp/module.go | 8 +- x/leveragelp/spec/07_pool_status.md | 18 +- x/leveragelp/types/pool.go | 9 +- x/leveragelp/types/pool.pb.go | 186 ++++++++------------ 12 files changed, 162 insertions(+), 310 deletions(-) delete mode 100644 proto/elys/incentive/genesis.proto delete mode 100644 proto/elys/incentive/query.proto delete mode 100644 proto/elys/incentive/tx.proto create mode 100644 x/leveragelp/migrations/v15_migration.go diff --git a/proto/elys/incentive/genesis.proto b/proto/elys/incentive/genesis.proto deleted file mode 100644 index 327abeaaf..000000000 --- a/proto/elys/incentive/genesis.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; - -package elys.incentive; - -option go_package = "github.com/elys-network/elys/x/incentive/types"; - - -// GenesisState defines the incentive module's genesis state. -message GenesisState { -} diff --git a/proto/elys/incentive/query.proto b/proto/elys/incentive/query.proto deleted file mode 100644 index 49fecbc15..000000000 --- a/proto/elys/incentive/query.proto +++ /dev/null @@ -1,113 +0,0 @@ -syntax = "proto3"; - -package elys.incentive; - -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "elys/commitment/params.proto"; - -option go_package = "github.com/elys-network/elys/x/incentive/types"; - -// Query defines the gRPC querier service. -service Query { - // Calculate APR - rpc Apr (QueryAprRequest) returns (QueryAprResponse) { - option (google.api.http).get = "/elys-network/elys/incentive/apr/{withdraw_type}/{denom}"; - } - - // Calculate APRs - rpc Aprs (QueryAprsRequest) returns (QueryAprsResponse) { - option (google.api.http).get = "/elys-network/elys/incentive/aprs"; - } - - // Queries PoolReward items - rpc PoolRewards(QueryPoolRewardsRequest) returns (QueryPoolRewardsResponse) { - option (google.api.http).get = "/elys-network/elys/incentive/pool_rewards"; - } -} - -message QueryAprRequest { - elys.commitment.EarnType withdraw_type = 1; - string denom = 2; -} - -message QueryAprResponse { - string apr = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - -message QueryAprsRequest { -} - -message QueryAprsResponse { - string usdc_apr_usdc = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string eden_apr_usdc = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string usdc_apr_edenb = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string eden_apr_edenb = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string usdc_apr_eden = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string eden_apr_eden = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string edenb_apr_eden = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string usdc_apr_elys = 8 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string eden_apr_elys = 9 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string edenb_apr_elys = 10 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - -message QueryPoolRewardsRequest { - repeated uint64 pool_ids = 1; - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -message PoolRewards { - uint64 pool_id = 1; - string rewards_usd = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - repeated cosmos.base.v1beta1.Coin reward_coins = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - cosmos.base.v1beta1.Coin eden_forward = 4 [ - (gogoproto.nullable) = false - ]; -} - -message QueryPoolRewardsResponse { - repeated PoolRewards pools = 1 [ (gogoproto.nullable) = false ]; -} - \ No newline at end of file diff --git a/proto/elys/incentive/tx.proto b/proto/elys/incentive/tx.proto deleted file mode 100644 index ff2fb6b45..000000000 --- a/proto/elys/incentive/tx.proto +++ /dev/null @@ -1,36 +0,0 @@ -syntax = "proto3"; - -package elys.incentive; - -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -option go_package = "github.com/elys-network/elys/x/incentive/types"; - -// Msg defines the Msg service. -service Msg { -} - -message MsgBeginRedelegate { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string validator_src_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string validator_dst_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false]; -} - -message MsgCancelUnbondingDelegation{ - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // amount is always less than or equal to unbonding delegation entry balance - cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; - // creation_height is the height which the unbonding took place. - int64 creation_height = 4; -} - diff --git a/proto/elys/leveragelp/pool.proto b/proto/elys/leveragelp/pool.proto index 1c559801f..f82ebff0e 100644 --- a/proto/elys/leveragelp/pool.proto +++ b/proto/elys/leveragelp/pool.proto @@ -19,6 +19,10 @@ message Pool { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + string max_leveragelp_percent = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } message LegacyPool { @@ -27,14 +31,12 @@ message LegacyPool { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - bool enabled = 3; - bool closed = 4; - string leveraged_lp_amount = 5 [ + string leveraged_lp_amount = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string leverage_max = 6 [ + string leverage_max = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; -} \ No newline at end of file +} diff --git a/x/leveragelp/keeper/msg_server_open.go b/x/leveragelp/keeper/msg_server_open.go index dde994587..79e0fe4b9 100644 --- a/x/leveragelp/keeper/msg_server_open.go +++ b/x/leveragelp/keeper/msg_server_open.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "strconv" errorsmod "cosmossdk.io/errors" @@ -33,7 +34,19 @@ func (k Keeper) Open(ctx sdk.Context, msg *types.MsgOpen) (*types.MsgOpenRespons borrowRatio = borrowed.ToLegacyDec().Add(msg.Leverage.Mul(msg.CollateralAmount.ToLegacyDec())). Quo(params.TotalValue.ToLegacyDec()) } - if borrowRatio.GTE(params.MaxLeverageRatio) { + + var pool_leveragelp sdk.Dec + pool, found := k.GetPool(ctx, msg.AmmPoolId) + if !found { + return nil, errorsmod.Wrap(types.ErrPoolDoesNotExist, fmt.Sprintf("poolId: %d", msg.AmmPoolId)) + } + amm_pool, found := k.amm.GetPool(ctx, msg.AmmPoolId) + if !found { + return nil, errorsmod.Wrap(types.ErrPoolDoesNotExist, fmt.Sprintf("poolId: %d", msg.AmmPoolId)) + } + pool_leveragelp = pool.LeveragedLpAmount.ToLegacyDec().Quo(amm_pool.TotalShares.Amount.ToLegacyDec()).Mul(sdk.NewDec(100)) + + if pool_leveragelp.GTE(pool.MaxLeveragelpPercent) || borrowRatio.GTE(params.MaxLeverageRatio) { return nil, errorsmod.Wrap(types.ErrMaxLeverageLpExists, "no new position can be open") } diff --git a/x/leveragelp/keeper/msg_server_open_test.go b/x/leveragelp/keeper/msg_server_open_test.go index 3e3a7aead..09e029f4d 100644 --- a/x/leveragelp/keeper/msg_server_open_test.go +++ b/x/leveragelp/keeper/msg_server_open_test.go @@ -17,7 +17,7 @@ import ( func initializeForOpen(suite *KeeperTestSuite, addresses []sdk.AccAddress, asset1, asset2 string) { fee := sdk.MustNewDecFromStr("0.0002") - issueAmount := sdk.NewInt(10_000_000_000_000) + issueAmount := sdk.NewInt(10_000_000_000_000_000) for _, address := range addresses { coins := sdk.NewCoins( sdk.NewCoin(ptypes.ATOM, issueAmount), @@ -48,11 +48,11 @@ func initializeForOpen(suite *KeeperTestSuite, addresses []sdk.AccAddress, asset }, PoolAssets: []ammtypes.PoolAsset{ { - Token: sdk.NewInt64Coin(asset1, 100_000_000), + Token: sdk.NewInt64Coin(asset1, 100_000_000_000_000), Weight: sdk.NewInt(50), }, { - Token: sdk.NewInt64Coin(asset2, 1000_000_000), + Token: sdk.NewInt64Coin(asset2, 1000_000_000_000_000), Weight: sdk.NewInt(50), }, }, @@ -137,7 +137,7 @@ func (suite *KeeperTestSuite) TestOpen_PoolWithBaseCurrencyAsset() { Creator: addresses[0].String(), CollateralAsset: ptypes.BaseCurrency, CollateralAmount: sdk.NewInt(1000), - AmmPoolId: 10, + AmmPoolId: 1, Leverage: sdk.MustNewDecFromStr("2.0"), StopLossPrice: sdk.MustNewDecFromStr("100.0"), }, @@ -171,7 +171,7 @@ func (suite *KeeperTestSuite) TestOpen_PoolWithBaseCurrencyAsset() { StopLossPrice: sdk.MustNewDecFromStr("100.0"), }, expectErr: true, - expectErrMsg: "invalid pool id", + expectErrMsg: "pool does not exis", prerequisiteFunction: func() { pool := types.NewPool(2, math.LegacyMustNewDecFromStr("10")) suite.app.LeveragelpKeeper.SetPool(suite.ctx, pool) @@ -189,11 +189,29 @@ func (suite *KeeperTestSuite) TestOpen_PoolWithBaseCurrencyAsset() { StopLossPrice: sdk.MustNewDecFromStr("100.0"), }, expectErr: true, - expectErrMsg: "invalid pool id", + expectErrMsg: "pool does not exis", prerequisiteFunction: func() { suite.SetupCoinPrices(suite.ctx) }, }, + {name: "Pool not enabled", + input: &types.MsgOpen{ + Creator: addresses[0].String(), + CollateralAsset: ptypes.BaseCurrency, + CollateralAmount: sdk.NewInt(1000), + AmmPoolId: 2, + Leverage: sdk.MustNewDecFromStr("2.0"), + StopLossPrice: sdk.MustNewDecFromStr("100.0"), + }, + expectErr: true, + expectErrMsg: "denom does not exist in pool", + prerequisiteFunction: func() { + pool := types.NewPool(2, sdk.NewDec(60)) + suite.app.LeveragelpKeeper.SetPool(suite.ctx, pool) + amm_pool := ammtypes.Pool{PoolId: 2, TotalShares: sdk.Coin{Amount: sdk.NewInt(100)}} + suite.app.AmmKeeper.SetPool(suite.ctx, amm_pool) + }, + }, {"Collateral asset not equal to base currency", &types.MsgOpen{ Creator: addresses[0].String(), @@ -258,7 +276,7 @@ func (suite *KeeperTestSuite) TestOpen_PoolWithBaseCurrencyAsset() { &types.MsgOpen{ Creator: addresses[0].String(), CollateralAsset: ptypes.BaseCurrency, - CollateralAmount: sdk.NewInt(1_000_000_000_000), + CollateralAmount: sdk.NewInt(1_000_000_000_000_000_000), AmmPoolId: 1, Leverage: sdk.MustNewDecFromStr("2.0"), StopLossPrice: sdk.MustNewDecFromStr("50.0"), diff --git a/x/leveragelp/keeper/pool.go b/x/leveragelp/keeper/pool.go index a4e1a8c6f..1a23854a6 100644 --- a/x/leveragelp/keeper/pool.go +++ b/x/leveragelp/keeper/pool.go @@ -68,3 +68,13 @@ func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (val types.Pool, found b k.cdc.MustUnmarshal(b, &val) return val, true } + +func (k Keeper) DeleteLegacyPool(ctx sdk.Context, poolId uint64) error { + store := ctx.KVStore(k.storeKey) + key := types.PoolKey(poolId) + if !store.Has(key) { + return types.ErrPositionDoesNotExist + } + store.Delete(key) + return nil +} diff --git a/x/leveragelp/migrations/v15_migration.go b/x/leveragelp/migrations/v15_migration.go new file mode 100644 index 000000000..d551f2a79 --- /dev/null +++ b/x/leveragelp/migrations/v15_migration.go @@ -0,0 +1,23 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/leveragelp/types" +) + +func (m Migrator) V15Migration(ctx sdk.Context) error { + legacyPools := m.keeper.GetAllLegacyPools(ctx) + + for _, legacyPool := range legacyPools { + newPool := types.Pool{ + AmmPoolId: legacyPool.AmmPoolId, + Health: legacyPool.Health, + LeveragedLpAmount: legacyPool.LeveragedLpAmount, + LeverageMax: legacyPool.LeverageMax, + MaxLeveragelpPercent: sdk.NewDec(60), + } + m.keeper.SetPool(ctx, newPool) + } + + return nil +} diff --git a/x/leveragelp/module.go b/x/leveragelp/module.go index 5a34fe2b9..7f4b6c3f5 100644 --- a/x/leveragelp/module.go +++ b/x/leveragelp/module.go @@ -117,11 +117,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := migrations.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 12, m.V13Migration) - if err != nil { - panic(err) - } - err = cfg.RegisterMigration(types.ModuleName, 13, m.V14Migration) + err := cfg.RegisterMigration(types.ModuleName, 14, m.V15Migration) if err != nil { panic(err) } @@ -148,7 +144,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 14 } +func (AppModule) ConsensusVersion() uint64 { return 15 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/leveragelp/spec/07_pool_status.md b/x/leveragelp/spec/07_pool_status.md index cf0f3db6a..b00297d69 100644 --- a/x/leveragelp/spec/07_pool_status.md +++ b/x/leveragelp/spec/07_pool_status.md @@ -11,15 +11,6 @@ Managing pool status is crucial. Two key states are whether a pool is enabled or #### Pool Status Functions ```go -func (k Keeper) IsPoolEnabled(ctx sdk.Context, poolId uint64) bool { - pool, found := k.GetPool(ctx, poolId) - if (!found) { - pool = types.NewPool(poolId) - k.SetPool(ctx, pool) - } - return pool.Enabled -} - func (k Keeper) IsPoolClosed(ctx sdk.Context, poolId uint64) bool { pool, found := k.GetPool(ctx, poolId) if (!found) { @@ -32,18 +23,11 @@ func (k Keeper) IsPoolClosed(ctx sdk.Context, poolId uint64) bool { #### Functionality -1. **IsPoolEnabled**: - - - Checks if a pool is enabled. - - If not found, initializes and sets a new pool. - - An enabled pool is processed by the module. - -2. **IsPoolClosed**: +1. **IsPoolClosed**: - Checks if a pool is closed. - If not found, initializes and sets a new pool. - A closed pool prevents new positions but allows existing ones to be processed. #### Key Differences -- **Enabled**: The pool is either processed or excluded entirely. - **Closed**: Only affects the opening of new positions; existing positions continue as usual. diff --git a/x/leveragelp/types/pool.go b/x/leveragelp/types/pool.go index 5faae5cf7..93e17db19 100644 --- a/x/leveragelp/types/pool.go +++ b/x/leveragelp/types/pool.go @@ -10,10 +10,11 @@ import ( func NewPool(poolId uint64, maxLeverage math.LegacyDec) Pool { return Pool{ - AmmPoolId: poolId, - Health: math.LegacyOneDec(), - LeveragedLpAmount: math.ZeroInt(), - LeverageMax: maxLeverage, + AmmPoolId: poolId, + Health: sdk.NewDec(100), + LeveragedLpAmount: sdk.ZeroInt(), + LeverageMax: sdk.NewDec(10), + MaxLeveragelpPercent: sdk.NewDec(60), } } diff --git a/x/leveragelp/types/pool.pb.go b/x/leveragelp/types/pool.pb.go index 7e73d540f..dd9ece96d 100644 --- a/x/leveragelp/types/pool.pb.go +++ b/x/leveragelp/types/pool.pb.go @@ -25,10 +25,11 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Pool struct { - AmmPoolId uint64 `protobuf:"varint,1,opt,name=amm_pool_id,json=ammPoolId,proto3" json:"amm_pool_id,omitempty"` - Health github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=health,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"health"` - LeveragedLpAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=leveraged_lp_amount,json=leveragedLpAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"leveraged_lp_amount"` - LeverageMax github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=leverage_max,json=leverageMax,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"leverage_max"` + AmmPoolId uint64 `protobuf:"varint,1,opt,name=amm_pool_id,json=ammPoolId,proto3" json:"amm_pool_id,omitempty"` + Health github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=health,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"health"` + LeveragedLpAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=leveraged_lp_amount,json=leveragedLpAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"leveraged_lp_amount"` + LeverageMax github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=leverage_max,json=leverageMax,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"leverage_max"` + MaxLeveragelpPercent github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=max_leveragelp_percent,json=maxLeveragelpPercent,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_leveragelp_percent"` } func (m *Pool) Reset() { *m = Pool{} } @@ -74,10 +75,8 @@ func (m *Pool) GetAmmPoolId() uint64 { type LegacyPool struct { AmmPoolId uint64 `protobuf:"varint,1,opt,name=amm_pool_id,json=ammPoolId,proto3" json:"amm_pool_id,omitempty"` Health github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=health,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"health"` - Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` - Closed bool `protobuf:"varint,4,opt,name=closed,proto3" json:"closed,omitempty"` - LeveragedLpAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=leveraged_lp_amount,json=leveragedLpAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"leveraged_lp_amount"` - LeverageMax github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=leverage_max,json=leverageMax,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"leverage_max"` + LeveragedLpAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=leveraged_lp_amount,json=leveragedLpAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"leveraged_lp_amount"` + LeverageMax github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=leverage_max,json=leverageMax,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"leverage_max"` } func (m *LegacyPool) Reset() { *m = LegacyPool{} } @@ -120,20 +119,6 @@ func (m *LegacyPool) GetAmmPoolId() uint64 { return 0 } -func (m *LegacyPool) GetEnabled() bool { - if m != nil { - return m.Enabled - } - return false -} - -func (m *LegacyPool) GetClosed() bool { - if m != nil { - return m.Closed - } - return false -} - func init() { proto.RegisterType((*Pool)(nil), "elys.leveragelp.Pool") proto.RegisterType((*LegacyPool)(nil), "elys.leveragelp.LegacyPool") @@ -142,29 +127,28 @@ func init() { func init() { proto.RegisterFile("elys/leveragelp/pool.proto", fileDescriptor_c3d30fce7b985054) } var fileDescriptor_c3d30fce7b985054 = []byte{ - // 338 bytes of a gzipped FileDescriptorProto + // 331 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xcd, 0xa9, 0x2c, 0xd6, 0xcf, 0x49, 0x2d, 0x4b, 0x2d, 0x4a, 0x4c, 0x4f, 0xcd, 0x29, 0xd0, 0x2f, 0xc8, 0xcf, 0xcf, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x07, 0xc9, 0xe9, 0x21, 0xe4, 0xa4, 0x44, 0xd2, - 0xf3, 0xd3, 0xf3, 0xc1, 0x72, 0xfa, 0x20, 0x16, 0x44, 0x99, 0xd2, 0x42, 0x26, 0x2e, 0x96, 0x80, - 0xfc, 0xfc, 0x1c, 0x21, 0x39, 0x2e, 0xee, 0xc4, 0xdc, 0xdc, 0x78, 0x90, 0x09, 0xf1, 0x99, 0x29, - 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x9c, 0x89, 0xb9, 0xb9, 0x20, 0x59, 0xcf, 0x14, 0x21, - 0x37, 0x2e, 0xb6, 0x8c, 0xd4, 0xc4, 0x9c, 0x92, 0x0c, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x4e, 0x27, - 0xbd, 0x13, 0xf7, 0xe4, 0x19, 0x6e, 0xdd, 0x93, 0x57, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, - 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x86, 0x52, 0xba, 0xc5, 0x29, 0xd9, - 0xfa, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x7a, 0x2e, 0xa9, 0xc9, 0x41, 0x50, 0xdd, 0x42, 0x71, 0x5c, - 0xc2, 0x30, 0x47, 0xa5, 0xc4, 0xe7, 0x14, 0xc4, 0x27, 0xe6, 0xe6, 0x97, 0xe6, 0x95, 0x48, 0x30, - 0x93, 0x6c, 0xa8, 0x67, 0x5e, 0x49, 0x90, 0x20, 0xdc, 0x28, 0x9f, 0x02, 0x47, 0xb0, 0x41, 0x42, - 0x81, 0x5c, 0x3c, 0x30, 0xc1, 0xf8, 0xdc, 0xc4, 0x0a, 0x09, 0x16, 0xb2, 0x5c, 0xcb, 0x0d, 0x33, - 0xc3, 0x37, 0xb1, 0x42, 0xe9, 0x26, 0x13, 0x17, 0x97, 0x4f, 0x6a, 0x7a, 0x62, 0x72, 0x25, 0x5d, - 0x43, 0x4a, 0x82, 0x8b, 0x3d, 0x35, 0x2f, 0x31, 0x29, 0x27, 0x35, 0x05, 0x1c, 0x3a, 0x1c, 0x41, - 0x30, 0xae, 0x90, 0x18, 0x17, 0x5b, 0x72, 0x4e, 0x7e, 0x71, 0x6a, 0x0a, 0xd8, 0x77, 0x1c, 0x41, - 0x50, 0x1e, 0xae, 0xb0, 0x65, 0xa5, 0x55, 0xd8, 0xb2, 0x51, 0x1c, 0xb6, 0x4e, 0x9e, 0x27, 0x1e, - 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, - 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x8f, 0x64, 0x1c, 0x28, 0x2d, 0xeb, 0xe6, - 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0x83, 0x39, 0xfa, 0x15, 0xc8, 0xc9, 0x1e, 0x6c, 0x76, 0x12, - 0x1b, 0x38, 0x45, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x01, 0xdb, 0x4e, 0xfa, 0x16, 0x03, - 0x00, 0x00, + 0xf3, 0xd3, 0xf3, 0xc1, 0x72, 0xfa, 0x20, 0x16, 0x44, 0x99, 0x52, 0x3b, 0x33, 0x17, 0x4b, 0x40, + 0x7e, 0x7e, 0x8e, 0x90, 0x1c, 0x17, 0x77, 0x62, 0x6e, 0x6e, 0x3c, 0xc8, 0x84, 0xf8, 0xcc, 0x14, + 0x09, 0x46, 0x05, 0x46, 0x0d, 0x96, 0x20, 0xce, 0xc4, 0xdc, 0x5c, 0x90, 0xac, 0x67, 0x8a, 0x90, + 0x1b, 0x17, 0x5b, 0x46, 0x6a, 0x62, 0x4e, 0x49, 0x86, 0x04, 0x93, 0x02, 0xa3, 0x06, 0xa7, 0x93, + 0xde, 0x89, 0x7b, 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0xab, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0x43, 0x29, 0xdd, 0xe2, 0x94, 0x6c, + 0xfd, 0x92, 0xca, 0x82, 0xd4, 0x62, 0x3d, 0x97, 0xd4, 0xe4, 0x20, 0xa8, 0x6e, 0xa1, 0x38, 0x2e, + 0x61, 0x98, 0xa3, 0x52, 0xe2, 0x73, 0x0a, 0xe2, 0x13, 0x73, 0xf3, 0x4b, 0xf3, 0x4a, 0x24, 0x98, + 0x49, 0x36, 0xd4, 0x33, 0xaf, 0x24, 0x48, 0x10, 0x6e, 0x94, 0x4f, 0x81, 0x23, 0xd8, 0x20, 0xa1, + 0x40, 0x2e, 0x1e, 0x98, 0x60, 0x7c, 0x6e, 0x62, 0x85, 0x04, 0x0b, 0x59, 0xae, 0xe5, 0x86, 0x99, + 0xe1, 0x9b, 0x58, 0x21, 0x94, 0xc2, 0x25, 0x96, 0x9b, 0x58, 0x11, 0x8f, 0x08, 0xcb, 0xf8, 0x82, + 0xd4, 0xa2, 0xe4, 0xd4, 0xbc, 0x12, 0x09, 0x56, 0xb2, 0x0c, 0x17, 0xc9, 0x4d, 0xac, 0xf0, 0x81, + 0x1b, 0x16, 0x00, 0x31, 0x4b, 0x69, 0x39, 0x13, 0x17, 0x97, 0x4f, 0x6a, 0x7a, 0x62, 0x72, 0xe5, + 0x68, 0x7c, 0xe0, 0x8d, 0x0f, 0x27, 0xcf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, + 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, + 0x88, 0xd2, 0x47, 0x32, 0x0e, 0x94, 0xfe, 0x75, 0xf3, 0x52, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xc1, + 0x1c, 0xfd, 0x0a, 0xe4, 0xac, 0x02, 0x36, 0x3b, 0x89, 0x0d, 0x9c, 0x0b, 0x8c, 0x01, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x85, 0x80, 0xbd, 0xf0, 0x4a, 0x03, 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -187,6 +171,16 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.MaxLeveragelpPercent.Size() + i -= size + if _, err := m.MaxLeveragelpPercent.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a { size := m.LeverageMax.Size() i -= size @@ -254,7 +248,7 @@ func (m *LegacyPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x22 { size := m.LeveragedLpAmount.Size() i -= size @@ -264,27 +258,7 @@ func (m *LegacyPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a - if m.Closed { - i-- - if m.Closed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x18 - } + dAtA[i] = 0x1a { size := m.Health.Size() i -= size @@ -329,6 +303,8 @@ func (m *Pool) Size() (n int) { n += 1 + l + sovPool(uint64(l)) l = m.LeverageMax.Size() n += 1 + l + sovPool(uint64(l)) + l = m.MaxLeveragelpPercent.Size() + n += 1 + l + sovPool(uint64(l)) return n } @@ -343,12 +319,6 @@ func (m *LegacyPool) Size() (n int) { } l = m.Health.Size() n += 1 + l + sovPool(uint64(l)) - if m.Enabled { - n += 2 - } - if m.Closed { - n += 2 - } l = m.LeveragedLpAmount.Size() n += 1 + l + sovPool(uint64(l)) l = m.LeverageMax.Size() @@ -512,6 +482,40 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxLeveragelpPercent", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxLeveragelpPercent.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPool(dAtA[iNdEx:]) @@ -616,46 +620,6 @@ func (m *LegacyPool) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Closed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Closed = bool(v != 0) - case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LeveragedLpAmount", wireType) } @@ -689,7 +653,7 @@ func (m *LegacyPool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LeverageMax", wireType) }