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

refactor: replace"vested" terminology with "locked" #205

Merged
merged 3 commits into from
Nov 26, 2024
Merged
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
48 changes: 24 additions & 24 deletions proto/milkyway/liquidvesting/v1/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ option go_package = "github.com/milkyway-labs/milkyway/x/liquidvesting/types";
service Msg {
option (cosmos.msg.v1.service) = true;

// MintVestedRepresentation defines the operation to mint a user's staked
// vested tokens representation that can be used in the liquid vesting module.
rpc MintVestedRepresentation(MsgMintVestedRepresentation)
returns (MsgMintVestedRepresentationResponse);
// MintLockedRepresentation defines the operation to mint a user's staked
// locked tokens representation that can be used in the liquid vesting module.
rpc MintLockedRepresentation(MsgMintLockedRepresentation)
returns (MsgMintLockedRepresentationResponse);

// BurnVestedRepresentation defines the operation to burn a user's staked
// vested tokens representation.
rpc BurnVestedRepresentation(MsgBurnVestedRepresentation)
returns (MsgBurnVestedRepresentationResponse);
// BurnLockedRepresentation defines the operation to burn a user's staked
// locked tokens representation.
rpc BurnLockedRepresentation(MsgBurnLockedRepresentation)
returns (MsgBurnLockedRepresentationResponse);

// WithdrawInsuranceFund defines the operation to withdraw an amount
// of tokens from the user's insurance fund.
Expand All @@ -39,13 +39,13 @@ service Msg {
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgMintVestedRepresentation defines the message structure for the
// MintVestedRepresentation gRPC service method. It allows an authorized
// account to mint a user's staked vested tokens representation that can be
// MsgMintLockedRepresentation defines the message structure for the
// MintLockedRepresentation gRPC service method. It allows an authorized
// account to mint a user's staked locked tokens representation that can be
// used in the liquid vesting module.
message MsgMintVestedRepresentation {
message MsgMintLockedRepresentation {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "milkyway/MsgMintVestedRepresentation";
option (amino.name) = "milkyway/MsgMintLockedRepresentation";

// User that want to trigger the tokens mint.
string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
Expand All @@ -61,16 +61,16 @@ message MsgMintVestedRepresentation {
];
}

// MsgMintVestedRepresentationResponse is the return value of
// MsgMintVestedRepresentation.
message MsgMintVestedRepresentationResponse {}
// MsgMintLockedRepresentationResponse is the return value of
// MsgMintLockedRepresentation.
message MsgMintLockedRepresentationResponse {}

// MsgBurnVestedRepresentation defines the message structure for the
// BurnVestedRepresentation gRPC service method. It allows an authorized
// account to burn a user's staked vested tokens representation.
message MsgBurnVestedRepresentation {
// MsgBurnLockedRepresentation defines the message structure for the
// BurnLockedRepresentation gRPC service method. It allows an authorized
// account to burn a user's staked locked tokens representation.
message MsgBurnLockedRepresentation {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "milkyway/MsgBurnVestedRepresentation";
option (amino.name) = "milkyway/MsgBurnLockedRepresentation";

// User that want to trigger the tokens burn.
string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
Expand All @@ -86,9 +86,9 @@ message MsgBurnVestedRepresentation {
];
}

// MsgBurnVestedRepresentationResponse is the return value of
// MsgBurnVestedRepresentation.
message MsgBurnVestedRepresentationResponse {}
// MsgBurnLockedRepresentationResponse is the return value of
// MsgBurnLockedRepresentation.
message MsgBurnLockedRepresentationResponse {}

// MsgWithdrawInsuranceFund defines the message structure for the
// WithdrawInsuranceFund gRPC service method.
Expand Down
2 changes: 1 addition & 1 deletion proto/milkyway/liquidvesting/v1/models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ message UserInsuranceFund {
}

// BurnCoins is a struct that contains the information about the coins to burn
// once the unbonding period of the vested representation tokens ends.
// once the unbonding period of the locked representation tokens ends.
message BurnCoins {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
Expand Down
8 changes: 4 additions & 4 deletions proto/milkyway/liquidvesting/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ option go_package = "github.com/milkyway-labs/milkyway/x/liquidvesting/types";
// Params defines the parameters for the module.
message Params {
// This value represents the percentage that needs to be sent to the
// insurance fund in order to restake a certain amount of vested tokens.
// insurance fund in order to restake a certain amount of locked tokens.
// For example, if this value is 2%, a user must send 2 tokens to
// the insurance fund to restake 100 vested tokens
// the insurance fund to restake 100 locked tokens
string insurance_percentage = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// This value represents the list of users who are authorized to execute the
// MsgBurnVestedRepresentation.
// MsgBurnLockedRepresentation.
repeated string burners = 2
[ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// This value represents the list of users who are authorized to execute the
// MsgMintVestedRepresentation.
// MsgMintLockedRepresentation.
repeated string minters = 3
[ (cosmos_proto.scalar) = "cosmos.AddressString" ];

Expand Down
16 changes: 8 additions & 8 deletions x/liquidvesting/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ func (a AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
Service: liquidvestingv1.Msg_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "MintVestedRepresentation",
Use: "mint-vested-representation [sender] [receiver] [amount]",
Short: "Mint an user's staked vested tokens representation",
Example: fmt.Sprintf(`$ %s tx liquidvesting mint-vested-representation init1... init1... 1000umilk`, version.AppName),
RpcMethod: "MintLockedRepresentation",
Use: "mint-locked-representation [sender] [receiver] [amount]",
Short: "Mint an user's staked locked tokens representation",
Example: fmt.Sprintf(`$ %s tx liquidvesting mint-locked-representation init1... init1... 1000umilk`, version.AppName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "sender"},
{ProtoField: "receiver"},
{ProtoField: "amount"},
},
},
{
RpcMethod: "BurnVestedRepresentation",
Use: "burn-vested-representation [sender] [user] [amount]",
Short: "Burns an user's staked vested tokens representation",
Example: fmt.Sprintf(`$ %s tx liquidvesting burn-vested-representation init1... init1... 1000vestd/umilk`, version.AppName),
RpcMethod: "BurnLockedRepresentation",
Use: "burn-locked-representation [sender] [user] [amount]",
Short: "Burns an user's staked locked tokens representation",
Example: fmt.Sprintf(`$ %s tx liquidvesting burn-locked-representation init1... init1... 1000vestd/umilk`, version.AppName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "sender"},
{ProtoField: "user"},
Expand Down
36 changes: 18 additions & 18 deletions x/liquidvesting/keeper/alias_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,53 @@ func (k *Keeper) GetAllUsersInsuranceFundsEntries(ctx sdk.Context) ([]types.User
return usersInsuranceFundState, err
}

// GetAllUserRestakedVestedRepresentations returns all restaked coins that are vested
// GetAllUserRestakedLockedRepresentations returns all restaked coins that are locked
// representation tokens for the provided user.
func (k *Keeper) GetAllUserRestakedVestedRepresentations(ctx context.Context, userAddress string) (sdk.DecCoins, error) {
func (k *Keeper) GetAllUserRestakedLockedRepresentations(ctx context.Context, userAddress string) (sdk.DecCoins, error) {
restakedCoins, err := k.restakingKeeper.GetAllUserRestakedCoins(ctx, userAddress)
if err != nil {
return nil, err
}

vestedRepresentations := sdk.NewDecCoins()
lockedRepresentations := sdk.NewDecCoins()
for _, coin := range restakedCoins {
if types.IsVestedRepresentationDenom(coin.Denom) {
vestedRepresentations = vestedRepresentations.Add(coin)
if types.IsLockedRepresentationDenom(coin.Denom) {
lockedRepresentations = lockedRepresentations.Add(coin)
}
}

return vestedRepresentations, nil
return lockedRepresentations, nil
}

// GetAllUserUnbondingVestedRepresentations returns all the vested representation
// GetAllUserUnbondingLockedRepresentations returns all the locked representation
// tokens that are currently unbonding for the provided user.
func (k *Keeper) GetAllUserUnbondingVestedRepresentations(ctx context.Context, userAddress string) sdk.Coins {
vestedRepresentations := sdk.NewCoins()
func (k *Keeper) GetAllUserUnbondingLockedRepresentations(ctx context.Context, userAddress string) sdk.Coins {
lockedRepresentations := sdk.NewCoins()

userUndelegations := k.restakingKeeper.GetAllUserUnbondingDelegations(ctx, userAddress)
for _, undelegation := range userUndelegations {
for _, entry := range undelegation.Entries {
for _, coin := range entry.Balance {
if types.IsVestedRepresentationDenom(coin.Denom) {
vestedRepresentations = vestedRepresentations.Add(coin)
if types.IsLockedRepresentationDenom(coin.Denom) {
lockedRepresentations = lockedRepresentations.Add(coin)
}
}
}
}

return vestedRepresentations
return lockedRepresentations
}

// GetAllUserActiveVestedRepresentations gets all the vested representation tokens
// GetAllUserActiveLockedRepresentations gets all the locked representation tokens
// that are restaked or are currently unbonding for the provided user.
func (k *Keeper) GetAllUserActiveVestedRepresentations(ctx context.Context, userAddress string) (sdk.DecCoins, error) {
restakedCoins, err := k.GetAllUserRestakedVestedRepresentations(ctx, userAddress)
func (k *Keeper) GetAllUserActiveLockedRepresentations(ctx context.Context, userAddress string) (sdk.DecCoins, error) {
restakedCoins, err := k.GetAllUserRestakedLockedRepresentations(ctx, userAddress)
if err != nil {
return nil, err
}

// Get the vested representation tokens that are currently unbonding
userUnbondingVestedRepresentations := k.GetAllUserUnbondingVestedRepresentations(ctx, userAddress)
// Get the locked representation tokens that are currently unbonding
userUnbondingLockedRepresentations := k.GetAllUserUnbondingLockedRepresentations(ctx, userAddress)

return restakedCoins.Add(sdk.NewDecCoinsFromCoins(userUnbondingVestedRepresentations...)...), nil
return restakedCoins.Add(sdk.NewDecCoinsFromCoins(userUnbondingLockedRepresentations...)...), nil
}
Loading
Loading