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

feat! [WIP] Break out LSM module from SDK #3455

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions proto/gaia/lsm/module/v1/module.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";

package gaia.lsm.module.v1;

import "cosmos/app/v1alpha1/module.proto";

// Module is the config object of the staking module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import : "github.com/cosmos/gaia/x/lsm"
};

// authority defines the custom module authority. If not set, defaults to the
// governance module.
string authority = 1;

// bech32_prefix_validator is the bech32 validator prefix for the app.
string bech32_prefix_validator = 2;

// bech32_prefix_consensus is the bech32 consensus node prefix for the app.
string bech32_prefix_consensus = 3;
}
48 changes: 48 additions & 0 deletions proto/gaia/lsm/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
syntax = "proto3";
package gaia.lsm.v1beta1;

option go_package = "github.com/cosmos/gaia/x/lsm/types";

import "gogoproto/gogo.proto";
import "gaia/lsm/v1beta1/lsm.proto";
import "amino/amino.proto";
import "google/protobuf/timestamp.proto";

// GenesisState defines the lsm module's genesis state.
message GenesisState {
// params defines all the parameters of related to deposit.
Params params = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// store tokenize share records to provide reward to record owners
repeated TokenizeShareRecord tokenize_share_records = 9
[ (gogoproto.nullable) = false ];

// last tokenize share record id, used for next share record id calculation
uint64 last_tokenize_share_record_id = 10;

// total number of liquid staked tokens at genesis
bytes total_liquid_staked_tokens = 11 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"total_liquid_staked_tokens\"",
(gogoproto.nullable) = false
];

// tokenize shares locks at genesis
repeated TokenizeShareLock tokenize_share_locks = 12
[ (gogoproto.nullable) = false ];
}

// TokenizeSharesLock required for specifying account locks at genesis
message TokenizeShareLock {
// Address of the account that is locked
string address = 1;
// Status of the lock (LOCKED or LOCK_EXPIRING)
string status = 2;
// Completion time if the lock is expiring
google.protobuf.Timestamp completion_time = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"completion_time\""
];
}
88 changes: 88 additions & 0 deletions proto/gaia/lsm/v1beta1/lsm.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
syntax = "proto3";
package gaia.lsm.v1beta1;

import "gogoproto/gogo.proto";

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/gaia/x/lsm/types";

// Params defines the parameters for the x/lsm module.
message Params {
option (amino.name) = "gaia/x/lsm/Params";
option (gogoproto.equal) = true;

// validator_bond_factor is required as a safety check for tokenizing shares
// and delegations from liquid staking providers
string validator_bond_factor = 7 [
(gogoproto.moretags) = "yaml:\"validator_bond_factor\"",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(cosmos_proto.scalar) = "cosmos.Dec"
];
// global_liquid_staking_cap represents a cap on the portion of stake that
// comes from liquid staking providers
string global_liquid_staking_cap = 8 [
(gogoproto.moretags) = "yaml:\"global_liquid_staking_cap\"",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(cosmos_proto.scalar) = "cosmos.Dec"
];
// validator_liquid_staking_cap represents a cap on the portion of stake that
// comes from liquid staking providers for a specific validator
string validator_liquid_staking_cap = 9 [
(gogoproto.moretags) = "yaml:\"validator_liquid_staking_cap\"",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(cosmos_proto.scalar) = "cosmos.Dec"
];
}

// TokenizeShareRecord represents a tokenized delegation
message TokenizeShareRecord {
option (gogoproto.equal) = true;

uint64 id = 1;
string owner = 2;
string module_account = 3; // module account take the role of delegator
string validator =
4; // validator delegated to for tokenize share record creation
}

// PendingTokenizeShareAuthorizations stores a list of addresses that have their
// tokenize share enablement in progress
message PendingTokenizeShareAuthorizations { repeated string addresses = 1; }

// TokenizeShareLockStatus indicates whether the address is able to tokenize
// shares
enum TokenizeShareLockStatus {
option (gogoproto.goproto_enum_prefix) = false;

// UNSPECIFIED defines an empty tokenize share lock status
TOKENIZE_SHARE_LOCK_STATUS_UNSPECIFIED = 0;
// LOCKED indicates the account is locked and cannot tokenize shares
TOKENIZE_SHARE_LOCK_STATUS_LOCKED = 1;
// UNLOCKED indicates the account is unlocked and can tokenize shares
TOKENIZE_SHARE_LOCK_STATUS_UNLOCKED = 2;
// LOCK_EXPIRING indicates the account is unable to tokenize shares, but
// will be able to tokenize shortly (after 1 unbonding period)
TOKENIZE_SHARE_LOCK_STATUS_LOCK_EXPIRING = 3;
}

// TokenizeShareRecordReward represents the properties of tokenize share
message TokenizeShareRecordReward {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = true;

uint64 record_id = 1;

repeated cosmos.base.v1beta1.DecCoin reward = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(gogoproto.nullable) = false
];
}
198 changes: 198 additions & 0 deletions proto/gaia/lsm/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
syntax = "proto3";
package gaia.lsm.v1beta1;

import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "gaia/lsm/v1beta1/lsm.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/query/v1/query.proto";
import "amino/amino.proto";

option go_package = "github.com/cosmos/gaia/x/lsm/types";

// Query defines the gRPC querier service.
service Query {

// Query for individual tokenize share record information by share by id
rpc TokenizeShareRecordById(QueryTokenizeShareRecordByIdRequest)
returns (QueryTokenizeShareRecordByIdResponse) {
option (google.api.http).get =
"/gaia/lsm/v1beta1/tokenize_share_record_by_id/{id}";
}

// Query for individual tokenize share record information by share denom
rpc TokenizeShareRecordByDenom(QueryTokenizeShareRecordByDenomRequest)
returns (QueryTokenizeShareRecordByDenomResponse) {
option (google.api.http).get =
"/gaia/lsm/v1beta1/tokenize_share_record_by_denom/{denom}";
}

// Query tokenize share records by address
rpc TokenizeShareRecordsOwned(QueryTokenizeShareRecordsOwnedRequest)
returns (QueryTokenizeShareRecordsOwnedResponse) {
option (google.api.http).get =
"/gaia/lsm/v1beta1/tokenize_share_record_owned/{owner}";
}

// Query for all tokenize share records
rpc AllTokenizeShareRecords(QueryAllTokenizeShareRecordsRequest)
returns (QueryAllTokenizeShareRecordsResponse) {
option (google.api.http).get = "/gaia/lsm/v1beta1/tokenize_share_records";
}

// Query for last tokenize share record id
rpc LastTokenizeShareRecordId(QueryLastTokenizeShareRecordIdRequest)
returns (QueryLastTokenizeShareRecordIdResponse) {
option (google.api.http).get =
"/gaia/lsm/v1beta1/last_tokenize_share_record_id";
}

// Query for total tokenized staked assets
rpc TotalTokenizeSharedAssets(QueryTotalTokenizeSharedAssetsRequest)
returns (QueryTotalTokenizeSharedAssetsResponse) {
option (google.api.http).get =
"/gaia/lsm/v1beta1/total_tokenize_shared_assets";
}

// Query for total liquid staked (including tokenized shares or owned by an
// liquid staking provider)
rpc TotalLiquidStaked(QueryTotalLiquidStaked)
returns (QueryTotalLiquidStakedResponse) {
option (google.api.http).get = "/gaia/lsm/v1beta1/total_liquid_staked";
}

// Query tokenize share locks
rpc TokenizeShareLockInfo(QueryTokenizeShareLockInfo)
returns (QueryTokenizeShareLockInfoResponse) {
option (google.api.http).get =
"/gaia/lsm/v1beta1/tokenize_share_lock_info/{address}";
}

// Parameters queries the lsm parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/gaia/lsm/v1beta1/params";
}

// TokenizeShareRecordReward queries the tokenize share record rewards
rpc TokenizeShareRecordReward(QueryTokenizeShareRecordRewardRequest)
returns (QueryTokenizeShareRecordRewardResponse) {
option (google.api.http).get =
"/gaia/lsm/v1beta1/{owner_address}/tokenize_share_record_rewards";
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// QueryTokenizeShareRecordByIdRequest is request type for the
// Query/QueryTokenizeShareRecordById RPC method.
message QueryTokenizeShareRecordByIdRequest { uint64 id = 1; }

// QueryTokenizeShareRecordByIdRequest is response type for the
// Query/QueryTokenizeShareRecordById RPC method.
message QueryTokenizeShareRecordByIdResponse {
TokenizeShareRecord record = 1 [ (gogoproto.nullable) = false ];
}

// QueryTokenizeShareRecordByDenomRequest is request type for the
// Query/QueryTokenizeShareRecordByDenom RPC method.
message QueryTokenizeShareRecordByDenomRequest { string denom = 1; }

// QueryTokenizeShareRecordByDenomResponse is response type for the
// Query/QueryTokenizeShareRecordByDenom RPC method.
message QueryTokenizeShareRecordByDenomResponse {
TokenizeShareRecord record = 1 [ (gogoproto.nullable) = false ];
}

// QueryTokenizeShareRecordsOwnedRequest is request type for the
// Query/QueryTokenizeShareRecordsOwned RPC method.
message QueryTokenizeShareRecordsOwnedRequest { string owner = 1; }

// QueryTokenizeShareRecordsOwnedResponse is response type for the
// Query/QueryTokenizeShareRecordsOwned RPC method.
message QueryTokenizeShareRecordsOwnedResponse {
repeated TokenizeShareRecord records = 1 [ (gogoproto.nullable) = false ];
}

// QueryAllTokenizeShareRecordsRequest is request type for the
// Query/QueryAllTokenizeShareRecords RPC method.
message QueryAllTokenizeShareRecordsRequest {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// QueryAllTokenizeShareRecordsResponse is response type for the
// Query/QueryAllTokenizeShareRecords RPC method.
message QueryAllTokenizeShareRecordsResponse {
repeated TokenizeShareRecord records = 1 [ (gogoproto.nullable) = false ];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryLastTokenizeShareRecordIdRequest is request type for the
// Query/QueryLastTokenizeShareRecordId RPC method.
message QueryLastTokenizeShareRecordIdRequest {}

// QueryLastTokenizeShareRecordIdResponse is response type for the
// Query/QueryLastTokenizeShareRecordId RPC method.
message QueryLastTokenizeShareRecordIdResponse { uint64 id = 1; }

// QueryTotalTokenizeSharedAssetsRequest is request type for the
// Query/QueryTotalTokenizeSharedAssets RPC method.
message QueryTotalTokenizeSharedAssetsRequest {}

// QueryTotalTokenizeSharedAssetsResponse is response type for the
// Query/QueryTotalTokenizeSharedAssets RPC method.
message QueryTotalTokenizeSharedAssetsResponse {
cosmos.base.v1beta1.Coin value = 1 [ (gogoproto.nullable) = false ];
}

// QueryTotalLiquidStakedRequest is request type for the
// Query/QueryQueryTotalLiquidStaked RPC method.
message QueryTotalLiquidStaked {}

// QueryTotalLiquidStakedResponse is response type for the
// Query/QueryQueryTotalLiquidStaked RPC method.
message QueryTotalLiquidStakedResponse { string tokens = 1; }

// QueryTokenizeShareLockInfo queries the tokenize share lock information
// associated with given account
message QueryTokenizeShareLockInfo { string address = 1; }

// QueryTokenizeShareLockInfoResponse is the response from the
// QueryTokenizeShareLockInfo query
message QueryTokenizeShareLockInfoResponse {
string status = 1;
string expiration_time = 2;
}

// QueryTokenizeShareRecordRewardRequest is the request type for the
// Query/TokenizeShareRecordReward RPC method.
message QueryTokenizeShareRecordRewardRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string owner_address = 1 [ (gogoproto.moretags) = "yaml:\"owner_address\"" ];
}

// QueryTokenizeShareRecordRewardResponse is the response type for the
// Query/TokenizeShareRecordReward RPC method.
message QueryTokenizeShareRecordRewardResponse {
// rewards defines all the rewards accrued by a delegator.
repeated TokenizeShareRecordReward rewards = 1
[ (gogoproto.nullable) = false ];
// total defines the sum of all the rewards.
repeated cosmos.base.v1beta1.DecCoin total = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
];
}
Loading
Loading