diff --git a/app/app.go b/app/app.go index b0e0a36d0..7909e6115 100644 --- a/app/app.go +++ b/app/app.go @@ -796,6 +796,7 @@ func NewElysApp( appCodec, keys[stablestaketypes.StoreKey], keys[stablestaketypes.MemStoreKey], + authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.GetSubspace(stablestaketypes.ModuleName), app.BankKeeper, &app.CommitmentKeeper, diff --git a/app/setup_handlers.go b/app/setup_handlers.go index ca67a20d4..60d86d8ed 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -3,8 +3,6 @@ package app import ( "fmt" - wasmmodule "github.com/CosmWasm/wasmd/x/wasm" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" m "github.com/cosmos/cosmos-sdk/types/module" @@ -24,49 +22,6 @@ func setUpgradeHandler(app *ElysApp) { func(ctx sdk.Context, plan upgradetypes.Plan, vm m.VersionMap) (m.VersionMap, error) { app.Logger().Info("Running upgrade handler for " + version.Version) - if version.Version == "v0.38.2" || version.Version == "v999.999.999" { - // Retrieve the wasm module store key - storeKey := app.keys[wasmmodule.StoreKey] - - // Retrieve the wasm module store - store := ctx.KVStore(storeKey) - - // List of prefixes to clear - prefixes := [][]byte{ - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys1s37xz7tzrru2cpl96juu9lfqrsd4jh73j9slyv440q5vttx2uyesetjpne")), // AH - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys1x8gwn06l85q0lyncy7zsde8zzdn588k2dck00a8j6lkprydcutwqa9tv6n")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys1657pee2jhf4jk8pq6yq64e758ngvum45gl866knmjkd83w6jgn3s923j5j")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys1xhcxq4fvxth2hn3msmkpftkfpw73um7s4et3lh4r8cfmumk3qsmsmgjjrc")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys1wr6vc3g4caz9aclgjacxewr0pjlre9wl2uhq73rp8mawwmqaczsq3ppn83")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys15m728qxvtat337jdu2f0uk6pu905kktrxclgy36c0wd822tpxcmqfzew4d")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys1ul4msjc3mmaxsscdgdtjds85rg50qrepvrczp0ldgma5mm9xv8yqxhk8nu")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys1mx32w9tnfxv0z5j000750h8ver7qf3xpj09w3uzvsr3hq68f4hxqte4gam")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys14zykjnz94dr9nj4v2yzpvnlrw5uurk5h7d5w0wug902vxdynm6xsue684e")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys175r6y463k8cdcte6dzrxydxnwfkhz9afdghzcjxxhzfmm6rgu64qdp9z37")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys1jyhyqjxf3pc7vzwyqhwe53up5pj0e53zw3xu2589uqgkvqngswnqtxfw4e")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys14see2dq4nu37yk9qhjn2laqxrmzzjyxwhfgnxw4nuzpm7vc6ztysxjv4p5")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys15qe27v4z7j78g5g4ak2ftftky3c078zvtr9qtv5lhxwc54ccf4asggmyyp")), // old contract - wasmtypes.GetContractStorePrefix(sdk.MustAccAddressFromBech32("elys193dzg6ealfymax4pyrkge60swlr2tjupwegdemgalzhkkxc8kzyqh5qw9c")), // old contract - } - - // Add old code keys to the list of prefixes to clear - for i := uint64(1); i < 675; i++ { - codeKey := wasmtypes.GetCodeKey(i) - // append the code key to the prefixes - prefixes = append(prefixes, codeKey) - } - - // Clear all keys in the store - for _, prefix := range prefixes { - iter := sdk.KVStorePrefixIterator(store, prefix) - defer iter.Close() - - for ; iter.Valid(); iter.Next() { - store.Delete(iter.Key()) - } - } - } - return app.mm.RunMigrations(ctx, app.configurator, vm) }, ) diff --git a/proto/elys/stablestake/tx.proto b/proto/elys/stablestake/tx.proto index 18cc63337..a95ba3910 100644 --- a/proto/elys/stablestake/tx.proto +++ b/proto/elys/stablestake/tx.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package elys.stablestake; import "gogoproto/gogo.proto"; +import "elys/stablestake/params.proto"; option go_package = "github.com/elys-network/elys/x/stablestake/types"; @@ -10,6 +11,7 @@ option go_package = "github.com/elys-network/elys/x/stablestake/types"; service Msg { rpc Bond(MsgBond) returns (MsgBondResponse); rpc Unbond(MsgUnbond) returns (MsgUnbondResponse); + rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse ); } message MsgBond { string creator = 1; @@ -31,3 +33,14 @@ message MsgUnbond { message MsgUnbondResponse {} +message MsgUpdateParams { + + // authority is the address that controls the module (defaults to x/gov unless + // overwritten). + string authority = 1; + + // NOTE: All parameters must be supplied. + Params params = 2; +} + +message MsgUpdateParamsResponse {} diff --git a/testutil/keeper/stablestake.go b/testutil/keeper/stablestake.go index 44c51c5a8..2803bf0a3 100644 --- a/testutil/keeper/stablestake.go +++ b/testutil/keeper/stablestake.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/elys-network/elys/x/stablestake/keeper" "github.com/elys-network/elys/x/stablestake/types" @@ -29,6 +30,7 @@ func StablestakeKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { registry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(registry) + govAddress := sdk.AccAddress(address.Module("gov")) paramsSubspace := typesparams.NewSubspace(cdc, types.Amino, @@ -40,6 +42,7 @@ func StablestakeKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { cdc, storeKey, memStoreKey, + govAddress.String(), paramsSubspace, nil, nil, diff --git a/x/leveragelp/spec/07_pool_status.md b/x/leveragelp/spec/07_pool_status.md new file mode 100644 index 000000000..cf0f3db6a --- /dev/null +++ b/x/leveragelp/spec/07_pool_status.md @@ -0,0 +1,49 @@ + + +### Pool Status + +#### Overview + +Managing pool status is crucial. Two key states are whether a pool is enabled or closed. + +#### 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) { + pool = types.NewPool(poolId) + k.SetPool(ctx, pool) + } + return pool.Closed +} +``` + +#### 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**: + - 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/spec/README.md b/x/leveragelp/spec/README.md index 413586f43..5a2506ed0 100644 --- a/x/leveragelp/spec/README.md +++ b/x/leveragelp/spec/README.md @@ -23,3 +23,4 @@ For more detailed information, please refer to the individual sections listed in 4. **[Endpoints](04_endpoints.md)** 5. **[CLI](05_cli.md)** 6. **[Position Workflow](06_position_workflow.md)** +7. **[Pool Status](07_pool_status.md)** diff --git a/x/perpetual/spec/07_pool_status.md b/x/perpetual/spec/07_pool_status.md new file mode 100644 index 000000000..cf0f3db6a --- /dev/null +++ b/x/perpetual/spec/07_pool_status.md @@ -0,0 +1,49 @@ + + +### Pool Status + +#### Overview + +Managing pool status is crucial. Two key states are whether a pool is enabled or closed. + +#### 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) { + pool = types.NewPool(poolId) + k.SetPool(ctx, pool) + } + return pool.Closed +} +``` + +#### 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**: + - 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/perpetual/spec/README.md b/x/perpetual/spec/README.md index 90acb6074..ab3d8b51e 100644 --- a/x/perpetual/spec/README.md +++ b/x/perpetual/spec/README.md @@ -1,108 +1,29 @@ - +# Perpetual module -# Concepts +The `perpetual` module in the Elys Network facilitates perpetual trading, allowing users to open and close leveraged positions on various assets without expiry dates. Positions, either long or short, are determined by the leverage applied and the amount of collateral provided. Leverage allows traders to borrow funds to open larger positions, amplifying potential profits and losses. -The `perpetual` module in the Elys Network facilitates perpetual trading, allowing users to open and close positions on various assets. This guide provides an overview of the key concepts and mechanisms involved in the perpetual module. +Collateral acts as a security deposit to cover potential losses, and if it falls below the maintenance margin, the position may be liquidated. The safety factor is a threshold to keep positions open, and position health indicates the risk level of a position. Liquidation occurs when the position's value drops below the safety factor, ensuring platform stability. -## Key Concepts +The funding rate is a periodic payment exchanged between long and short positions to align contract prices with underlying asset prices. Whitelisting controls access to the module, allowing only trusted participants to trade. The module has configurable parameters, such as leverage limits and interest rates, adjustable through governance proposals to maintain efficiency and security. -### Perpetual Trading +## Key Features -Perpetual trading allows users to trade assets with leverage without the need for expiry dates on their positions. This type of trading is popular in the cryptocurrency market as it offers flexibility and continuous trading opportunities. +- **Perpetual Trading**: Trade assets with leverage without expiry dates. +- **Positions**: Open long or short leveraged positions based on collateral and leverage. +- **Leverage**: Borrow funds to open larger positions, amplifying profits and losses. +- **Collateral**: Security deposit to cover potential losses and prevent liquidation. +- **Safety Factor**: Threshold to keep positions open and prevent liquidation. +- **Position Health**: Metric indicating the risk level of a position. +- **Liquidation**: Forcibly close positions below the safety factor to prevent further losses. -### Positions +For more detailed information, please refer to the individual sections listed in the contents below. -A position in perpetual trading represents an open contract on an asset. Positions can be either long (betting that the asset price will rise) or short (betting that the asset price will fall). The size of the position is determined by the leverage applied and the amount of collateral provided. +## Contents -### Leverage - -Leverage allows traders to open positions larger than their collateral by borrowing funds. For example, with 5x leverage, a trader can open a position five times the size of their collateral. While leverage amplifies potential profits, it also increases potential losses. - -### Collateral - -Collateral is the amount of assets locked to open a leveraged position. It acts as a security deposit to cover potential losses. If the value of the position falls below the maintenance margin, the position may be liquidated to prevent further losses. - -### Safety Factor - -The safety factor is the threshold to keep a position open. If the position health value falls below this threshold, the position may be subject to liquidation. - -### Position Health - -Position health is a metric that indicates the risk level of a position. It is calculated based on the position's value, leverage, and collateral. Monitoring position health helps prevent excessive risk-taking and ensures the stability of the perpetual trading system. - -### Liquidation - -Liquidation occurs when a position's value drops below the safety factor. The position is forcibly closed to prevent further losses. This mechanism ensures the stability of the perpetual trading system and protects the platform from significant losses. - -### Funding Rate - -The funding rate is a periodic payment exchanged between long and short positions. It ensures that the perpetual contract price closely tracks the underlying asset price. When the funding rate is positive, longs pay shorts, and when it is negative, shorts pay longs. - -### Whitelisting - -Whitelisting is a mechanism to control access to the perpetual module. Only addresses that are whitelisted can participate in trading. This helps maintain the security and integrity of the platform by allowing only trusted participants. - -### Parameters - -The perpetual module has several configurable parameters that govern its operation. These include leverage limits, interest rates, maintenance margins, and more. These parameters can be updated through governance proposals to adapt to changing market conditions and ensure the module's efficiency and security. - -## Perpetual Module Overview - -The perpetual module supports perpetual trading on molecule token pools. Initially, isolated perpetual trading is supported, with plans to include cross perpetual trading in the future. - -### Pools - -Perpetual trading utilizes AMM (Automated Market Maker) pools and maintains position records. When a trader closes a position or it is liquidated, pool tokens are transferred to the perpetual trader for profit and loss (P&L). - -### Perpetual Limits - -Perpetual trading limits are based on the pool size. To maintain pool health, perpetual positions are restricted to ensure that no more than 50% of the pool's assets are borrowed. - -### Race Condition Between AMM and Perpetual - -Due to the possibility of pool balance insufficiency, a healthy buffer must be maintained when setting perpetual positions. The position should be auto-closed before the pool becomes insufficient to cover it. Any action affecting the position's health should trigger position closing. - -### Risks - -Perpetual trading will not be offered on shallow pools to mitigate risk. - -### Oracle - -The oracle should use average prices to prevent large liquidations caused by sudden, short-term price dumps. In cases where multiple oracle price sources are used, exceptions may need to be made for anomalies such as massive candle spikes from one source. - -### Reference Codebases for Perpetual - -- To Be Determined (TBD) - -### Notes - -- The perpetual code will serve as the base for LP leveraging, with the primary difference being that perpetual trading borrows from the pool liquidity itself, while LP leveraging borrows from base currency deposits. -- Cross perpetual trading will enable interactions between perpetual positions and LP positions once implemented. - -## Transaction Commands - -The perpetual module supports various transaction commands for managing positions and parameters. Key commands include: - -- `open`: Opens a new perpetual position. -- `close`: Closes an existing perpetual position. -- `whitelist`: Adds an address to the whitelist. -- `dewhitelist`: Removes an address from the whitelist. -- `update-params`: Updates the module parameters through a governance proposal. - -## Query Commands - -Users can query various aspects of the perpetual module using the following commands: - -- `params`: Retrieves the current parameters of the module. -- `get-positions`: Lists all open positions. -- `get-positions-by-pool`: Lists positions for a specific pool. -- `get-positions-for-address`: Lists positions for a specific address. -- `get-status`: Retrieves the current status of the module. -- `get-whitelist`: Lists all whitelisted addresses. -- `is-whitelisted`: Checks if a specific address is whitelisted. -- `list-pool`: Lists all available pools. -- `show-pool`: Retrieves details of a specific pool. -- `get-mtp`: Retrieves details of a specific margin trading position (MTP). -- `open-estimation`: Provides an estimation for opening a position. +1. **[Concepts](01_concepts.md)** +2. **[Mechanisms](02_mechanisms.md)** +3. **[Usage](03_usage.md)** +4. **[Keeper](04_keeper.md)** +5. **[Protobuf Definitions](05_protobuf_definitions.md)** +6. **[Functions](06_functions.md)** +7. **[Pool Status](07_pool_status.md)** diff --git a/x/stablestake/keeper/keeper.go b/x/stablestake/keeper/keeper.go index 08e7bd643..fc50d1828 100644 --- a/x/stablestake/keeper/keeper.go +++ b/x/stablestake/keeper/keeper.go @@ -17,6 +17,7 @@ type ( cdc codec.BinaryCodec storeKey storetypes.StoreKey memKey storetypes.StoreKey + authority string paramstore paramtypes.Subspace bk types.BankKeeper commitmentKeeper *commitmentkeeper.Keeper @@ -29,6 +30,7 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, + authority string, ps paramtypes.Subspace, bk types.BankKeeper, commitmentKeeper *commitmentkeeper.Keeper, @@ -39,10 +41,16 @@ func NewKeeper( ps = ps.WithKeyTable(types.ParamKeyTable()) } + // ensure that authority is a valid AccAddress + if _, err := sdk.AccAddressFromBech32(authority); err != nil { + panic("authority is not a valid acc address") + } + return &Keeper{ cdc: cdc, storeKey: storeKey, memKey: memKey, + authority: authority, paramstore: ps, bk: bk, commitmentKeeper: commitmentKeeper, diff --git a/x/stablestake/keeper/msg_server_update_params.go b/x/stablestake/keeper/msg_server_update_params.go new file mode 100644 index 000000000..b15568d39 --- /dev/null +++ b/x/stablestake/keeper/msg_server_update_params.go @@ -0,0 +1,28 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/elys-network/elys/x/stablestake/types" +) + +// Update params through gov proposal +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + // overwrite total value in params + params := k.GetParams(ctx) + msg.Params.TotalValue = params.TotalValue + + // store params + k.SetParams(ctx, *msg.Params) + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/stablestake/types/codec.go b/x/stablestake/types/codec.go index 55d72e402..da01aec3f 100644 --- a/x/stablestake/types/codec.go +++ b/x/stablestake/types/codec.go @@ -11,15 +11,15 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgBond{}, "stablestake/Stake", nil) cdc.RegisterConcrete(&MsgUnbond{}, "stablestake/Unbond", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "stablestake/UpdateParams", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgBond{}, - ) - registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUnbond{}, + &MsgUpdateParams{}, ) // this line is used by starport scaffolding # 3 diff --git a/x/stablestake/types/message_update_params.go b/x/stablestake/types/message_update_params.go new file mode 100644 index 000000000..d17d39881 --- /dev/null +++ b/x/stablestake/types/message_update_params.go @@ -0,0 +1,47 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUpdateParams = "update_params" + +var _ sdk.Msg = &MsgUpdateParams{} + +func NewMsgUpdateParams(signer string, params *Params) *MsgUpdateParams { + return &MsgUpdateParams{ + Authority: signer, + Params: params, + } +} + +func (msg *MsgUpdateParams) Route() string { + return RouterKey +} + +func (msg *MsgUpdateParams) Type() string { + return TypeMsgUpdateParams +} + +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateParams) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateParams) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/stablestake/types/message_update_params_test.go b/x/stablestake/types/message_update_params_test.go new file mode 100644 index 000000000..c9b0bfdb6 --- /dev/null +++ b/x/stablestake/types/message_update_params_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/elys-network/elys/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgUpdateParams_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateParams + err error + }{ + { + name: "invalid address", + msg: MsgUpdateParams{ + Authority: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgUpdateParams{ + Authority: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/stablestake/types/tx.pb.go b/x/stablestake/types/tx.pb.go index 5f1ea77a8..e1bbf864f 100644 --- a/x/stablestake/types/tx.pb.go +++ b/x/stablestake/types/tx.pb.go @@ -191,36 +191,134 @@ func (m *MsgUnbondResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUnbondResponse proto.InternalMessageInfo +type MsgUpdateParams struct { + // authority is the address that controls the module (defaults to x/gov unless + // overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // NOTE: All parameters must be supplied. + Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_289b7c948da33393, []int{4} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_289b7c948da33393, []int{5} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgBond)(nil), "elys.stablestake.MsgBond") proto.RegisterType((*MsgBondResponse)(nil), "elys.stablestake.MsgBondResponse") proto.RegisterType((*MsgUnbond)(nil), "elys.stablestake.MsgUnbond") proto.RegisterType((*MsgUnbondResponse)(nil), "elys.stablestake.MsgUnbondResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "elys.stablestake.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "elys.stablestake.MsgUpdateParamsResponse") } func init() { proto.RegisterFile("elys/stablestake/tx.proto", fileDescriptor_289b7c948da33393) } var fileDescriptor_289b7c948da33393 = []byte{ - // 298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcd, 0xa9, 0x2c, - 0xd6, 0x2f, 0x2e, 0x49, 0x4c, 0xca, 0x49, 0x2d, 0x2e, 0x49, 0xcc, 0x4e, 0xd5, 0x2f, 0xa9, 0xd0, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x00, 0x49, 0xe9, 0x21, 0x49, 0x49, 0x89, 0xa4, 0xe7, - 0xa7, 0xe7, 0x83, 0x25, 0xf5, 0x41, 0x2c, 0x88, 0x3a, 0xa5, 0x6c, 0x2e, 0x76, 0xdf, 0xe2, 0x74, - 0xa7, 0xfc, 0xbc, 0x14, 0x21, 0x09, 0x2e, 0xf6, 0xe4, 0xa2, 0xd4, 0xc4, 0x92, 0xfc,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71, 0x90, 0x41, 0xba, 0x79, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0x60, 0x8e, - 0x7e, 0x05, 0x6a, 0xa2, 0x00, 0x05, 0x43, 0x12, 0x1b, 0x38, 0xc2, 0x8d, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x53, 0x77, 0xfa, 0xea, 0x35, 0x02, 0x00, 0x00, + // 377 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x53, 0xcd, 0x4a, 0xc3, 0x40, + 0x18, 0x4c, 0x54, 0x52, 0xfa, 0x29, 0x68, 0xa3, 0x60, 0x1a, 0x35, 0xd5, 0x08, 0xa2, 0x87, 0x26, + 0xa5, 0xbe, 0x41, 0x11, 0xc1, 0x42, 0x41, 0x02, 0xbd, 0x88, 0x97, 0x4d, 0xbb, 0xa4, 0x25, 0x4d, + 0x36, 0x64, 0xb7, 0xd8, 0xbe, 0x85, 0x8f, 0xd5, 0x63, 0x8f, 0xe2, 0xa1, 0x48, 0xfb, 0x0c, 0xde, + 0x25, 0x9b, 0x4d, 0xed, 0x9f, 0x7a, 0xf3, 0x94, 0x6c, 0x66, 0x32, 0x33, 0xcc, 0x24, 0x50, 0xc4, + 0xbd, 0x21, 0xb5, 0x29, 0x43, 0x6e, 0x0f, 0x53, 0x86, 0x7c, 0x6c, 0xb3, 0x81, 0x15, 0xc5, 0x84, + 0x11, 0xf5, 0x20, 0x81, 0xac, 0x05, 0x48, 0x3f, 0xf2, 0x88, 0x47, 0x38, 0x68, 0x27, 0x77, 0x29, + 0x4f, 0x3f, 0x5b, 0x93, 0x88, 0x50, 0x8c, 0x02, 0x9a, 0xc2, 0xa6, 0x0f, 0xb9, 0x06, 0xf5, 0x6a, + 0x24, 0x6c, 0xab, 0x1a, 0xe4, 0x5a, 0x31, 0x46, 0x8c, 0xc4, 0x9a, 0x7c, 0x2e, 0x5f, 0xe7,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0x53, 0x43, 0x7e, 0x9d, 0x19, 0xd2, 0x78, 0x66, 0x48, 0x6f, + 0x33, 0x43, 0x7a, 0xaa, 0x2c, 0x8c, 0x9a, 0xc8, 0x95, 0x43, 0xcc, 0x5e, 0x48, 0xec, 0xf3, 0x83, + 0x3d, 0x58, 0xfe, 0x1f, 0x92, 0x89, 0x5d, 0x85, 0x7f, 0xcc, 0xb7, 0x5f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x80, 0x67, 0x94, 0x0b, 0x30, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -237,6 +335,7 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { Bond(ctx context.Context, in *MsgBond, opts ...grpc.CallOption) (*MsgBondResponse, error) Unbond(ctx context.Context, in *MsgUnbond, opts ...grpc.CallOption) (*MsgUnbondResponse, error) + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -265,10 +364,20 @@ func (c *msgClient) Unbond(ctx context.Context, in *MsgUnbond, opts ...grpc.Call return out, nil } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/elys.stablestake.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { Bond(context.Context, *MsgBond) (*MsgBondResponse, error) Unbond(context.Context, *MsgUnbond) (*MsgUnbondResponse, error) + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -281,6 +390,9 @@ func (*UnimplementedMsgServer) Bond(ctx context.Context, req *MsgBond) (*MsgBond func (*UnimplementedMsgServer) Unbond(ctx context.Context, req *MsgUnbond) (*MsgUnbondResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Unbond not implemented") } +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -322,6 +434,24 @@ func _Msg_Unbond_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.stablestake.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.stablestake.Msg", HandlerType: (*MsgServer)(nil), @@ -334,6 +464,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "Unbond", Handler: _Msg_Unbond_Handler, }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/stablestake/tx.proto", @@ -465,6 +599,71 @@ func (m *MsgUnbondResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -524,6 +723,32 @@ func (m *MsgUnbondResponse) Size() (n int) { return n } +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -862,6 +1087,174 @@ func (m *MsgUnbondResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0