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

Commitment updates - vesting, committing, and uncommitting #211

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
129 changes: 127 additions & 2 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39105,6 +39105,47 @@ paths:
params:
description: params holds all the parameters of this module.
type: object
properties:
leverage_max:
type: string
interest_rate_max:
type: string
interest_rate_min:
type: string
interest_rate_increase:
type: string
interest_rate_decrease:
type: string
health_gain_factor:
type: string
epoch_length:
type: string
format: int64
removal_queue_threshold:
type: string
max_open_positions:
type: string
format: int64
pool_open_threshold:
type: string
force_close_fund_percentage:
type: string
force_close_fund_address:
type: string
incremental_interest_payment_fund_percentage:
type: string
incremental_interest_payment_fund_address:
type: string
sq_modifier:
type: string
safety_factor:
type: string
incremental_interest_payment_enabled:
type: boolean
whitelisting_enabled:
type: boolean
invariant_check_epoch:
type: string
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
Expand Down Expand Up @@ -81404,14 +81445,16 @@ definitions:
type: string
elys.commitment.MsgCancelVestResponse:
type: object
elys.commitment.MsgCommitTokensResponse:
elys.commitment.MsgCommitLiquidTokensResponse:
type: object
elys.commitment.MsgDepositTokensResponse:
elys.commitment.MsgCommitTokensResponse:
type: object
elys.commitment.MsgUncommitTokensResponse:
type: object
elys.commitment.MsgUpdateVestingInfoResponse:
type: object
elys.commitment.MsgVestLiquidResponse:
type: object
elys.commitment.MsgVestNowResponse:
type: object
elys.commitment.MsgVestResponse:
Expand Down Expand Up @@ -81927,13 +81970,95 @@ definitions:
description: QueryParamsResponse is response type for the Query/Params RPC method.
elys.leveragelp.Params:
type: object
properties:
leverage_max:
type: string
interest_rate_max:
type: string
interest_rate_min:
type: string
interest_rate_increase:
type: string
interest_rate_decrease:
type: string
health_gain_factor:
type: string
epoch_length:
type: string
format: int64
removal_queue_threshold:
type: string
max_open_positions:
type: string
format: int64
pool_open_threshold:
type: string
force_close_fund_percentage:
type: string
force_close_fund_address:
type: string
incremental_interest_payment_fund_percentage:
type: string
incremental_interest_payment_fund_address:
type: string
sq_modifier:
type: string
safety_factor:
type: string
incremental_interest_payment_enabled:
type: boolean
whitelisting_enabled:
type: boolean
invariant_check_epoch:
type: string
description: Params defines the parameters for the module.
elys.leveragelp.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
leverage_max:
type: string
interest_rate_max:
type: string
interest_rate_min:
type: string
interest_rate_increase:
type: string
interest_rate_decrease:
type: string
health_gain_factor:
type: string
epoch_length:
type: string
format: int64
removal_queue_threshold:
type: string
max_open_positions:
type: string
format: int64
pool_open_threshold:
type: string
force_close_fund_percentage:
type: string
force_close_fund_address:
type: string
incremental_interest_payment_fund_percentage:
type: string
incremental_interest_payment_fund_address:
type: string
sq_modifier:
type: string
safety_factor:
type: string
incremental_interest_payment_enabled:
type: boolean
whitelisting_enabled:
type: boolean
invariant_check_epoch:
type: string
description: QueryParamsResponse is response type for the Query/Params RPC method.
elys.liquidityprovider.Params:
type: object
Expand Down
37 changes: 23 additions & 14 deletions proto/elys/commitment/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ option go_package = "github.com/elys-network/elys/x/commitment/types";

// Msg defines the Msg service.
service Msg {
rpc CommitTokens (MsgCommitTokens ) returns (MsgCommitTokensResponse );
rpc UncommitTokens (MsgUncommitTokens ) returns (MsgUncommitTokensResponse );
rpc WithdrawTokens (MsgWithdrawTokens ) returns (MsgWithdrawTokensResponse );
rpc DepositTokens (MsgDepositTokens ) returns (MsgDepositTokensResponse );
rpc Vest (MsgVest ) returns (MsgVestResponse );
rpc CancelVest (MsgCancelVest ) returns (MsgCancelVestResponse );
rpc VestNow (MsgVestNow ) returns (MsgVestNowResponse );
rpc UpdateVestingInfo (MsgUpdateVestingInfo) returns (MsgUpdateVestingInfoResponse);
rpc CommitTokens (MsgCommitTokens ) returns (MsgCommitTokensResponse );
rpc UncommitTokens (MsgUncommitTokens ) returns (MsgUncommitTokensResponse );
rpc WithdrawTokens (MsgWithdrawTokens ) returns (MsgWithdrawTokensResponse );
rpc CommitLiquidTokens (MsgCommitLiquidTokens) returns (MsgCommitLiquidTokensResponse);
rpc Vest (MsgVest ) returns (MsgVestResponse );
rpc CancelVest (MsgCancelVest ) returns (MsgCancelVestResponse );
rpc VestNow (MsgVestNow ) returns (MsgVestNowResponse );
rpc UpdateVestingInfo (MsgUpdateVestingInfo ) returns (MsgUpdateVestingInfoResponse );
rpc VestLiquid (MsgVestLiquid ) returns (MsgVestLiquidResponse );
}
message MsgCommitTokens {
string creator = 1;
Expand All @@ -41,13 +42,13 @@ message MsgWithdrawTokens {

message MsgWithdrawTokensResponse {}

message MsgDepositTokens {
message MsgCommitLiquidTokens {
string creator = 1;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string denom = 3;
}

message MsgDepositTokensResponse {}
message MsgCommitLiquidTokensResponse {}

message MsgVest {
string creator = 1;
Expand All @@ -74,14 +75,22 @@ message MsgVestNow {
message MsgVestNowResponse {}

message MsgUpdateVestingInfo {
string authority = 1;
string authority = 1;
string baseDenom = 2;
string vestingDenom = 3;
string epochIdentifier = 4;
int64 numEpochs = 5;
int64 vestNowFactor = 6;
int64 numMaxVestings = 7;
int64 numEpochs = 5;
int64 vestNowFactor = 6;
int64 numMaxVestings = 7;
}

message MsgUpdateVestingInfoResponse {}

message MsgVestLiquid {
string creator = 1;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string denom = 3;
}

message MsgVestLiquidResponse {}

23 changes: 5 additions & 18 deletions x/amm/keeper/mint_pool_share_to_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,18 @@ func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool types.Pool, addr sd
k.apKeeper.SetEntry(ctx, entry)
}

// Deposit and commit LP token minted
// Commit LP token minted
msgServer := commitmentkeeper.NewMsgServerImpl(*k.commitmentKeeper)

// Create a deposit token message
msgDepositToken := &ctypes.MsgDepositTokens{
// Create a commit LP token liquidated message
msgLiquidCommitLPToken := &ctypes.MsgCommitLiquidTokens{
Creator: addr.String(),
Denom: poolShareDenom,
Amount: amount,
}

// Deposit LP token
_, err = msgServer.DepositTokens(sdk.WrapSDKContext(ctx), msgDepositToken)
if err != nil {
return err
}

// Create a commit token message
msgCommitToken := &ctypes.MsgCommitTokens{
Creator: addr.String(),
Denom: poolShareDenom,
Amount: amount,
}

// Commit LP token
_, err = msgServer.CommitTokens(sdk.WrapSDKContext(ctx), msgCommitToken)
// Commit LP token liquidated
_, err = msgServer.CommitLiquidTokens(sdk.WrapSDKContext(ctx), msgLiquidCommitLPToken)
if err != nil {
return err
}
Expand Down
19 changes: 18 additions & 1 deletion x/amm/types/query.pb.gw.go

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

3 changes: 2 additions & 1 deletion x/commitment/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ func GetTxCmd() *cobra.Command {
}

cmd.AddCommand(CmdCommitTokens())
cmd.AddCommand(CmdCommitLiquidTokens())
cmd.AddCommand(CmdUncommitTokens())
cmd.AddCommand(CmdWithdrawTokens())
cmd.AddCommand(CmdDepositTokens())
cmd.AddCommand(CmdVest())
cmd.AddCommand(CmdCancelVest())
cmd.AddCommand(CmdVestNow())
cmd.AddCommand(CmdUpdateVestingInfo())
cmd.AddCommand(CmdVestLiquid())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
Loading