-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v1.7.2] Liquid vesting module (#275)
* scaffold liquidvesting module * fix linter * fix linter * outline liquidvesting proto interface * liquidate tx implementation * increase test coverage for liquidvesting module * implement liquid denom queries * add tests for liquidate handler and some other stuff * refactor convert into vesting account * redeem handler first iteration * fix build * redeem tests and bug fixes * adds erc20 checks * add review fixes * add review fixes pt 2 * minor review fixes * add module param minimumLiquidationAmount * add auto erc20 conversion during redeem * fix linter * disable token pair after it is went down to zero total supply * add enable check on token pair * fix lint * fix lint * chore: add upgrade handler * change default param * change default param * fix: cli query denoms for liquid vesting * fix: msg_server reduce vesting periods * chore: add force conversion into erc20 tokens on liquidation * chore: fix tests * chore(liquidation): update store key for param * chore: inlcude escrowed liquid vesting balance into total locked stats --------- Co-authored-by: Petr Ivanov <[email protected]> Co-authored-by: Yuri Surbashev <[email protected]> Co-authored-by: Evgeniy Abramov <[email protected]>
- Loading branch information
1 parent
20dfe01
commit 1e0f366
Showing
46 changed files
with
6,330 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package v172 | ||
|
||
const ( | ||
// UpgradeName is the shared upgrade plan name for mainnet and testnet | ||
UpgradeName = "v1.7.2" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package v172 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
// CreateUpgradeHandler creates an SDK upgrade handler for v1.7.2 | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
logger := ctx.Logger() | ||
logger.Info("run migration v1.7.2") | ||
|
||
return mm.RunMigrations(ctx, configurator, vm) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
syntax = "proto3"; | ||
package haqq.liquidvesting.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/haqq-network/haqq/x/liquidvesting/types"; | ||
|
||
// GenesisState defines the liquidvesting module's genesis state. | ||
message GenesisState { | ||
// params defines all the paramaters of the module. | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// Params holds parameters for the liquidvesting module. | ||
message Params { | ||
string minimum_liquidation_amount = 1 [ | ||
(gogoproto.customtype) = "cosmossdk.io/math.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
syntax = "proto3"; | ||
package haqq.liquidvesting.v1; | ||
|
||
import "amino/amino.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "cosmos/vesting/v1beta1/vesting.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
|
||
option go_package = "github.com/haqq-network/haqq/x/liquidvesting/types"; | ||
|
||
// Denom represents liquid token bonded to some specific vesting schedule | ||
message Denom { | ||
// base_denom main identifier for the denom, used to query it from store. | ||
string base_denom = 1; | ||
// display_denom identifier used for display name for broad audience | ||
string display_denom = 2; | ||
// original_denom which liquid denom derived from | ||
string original_denom = 3; | ||
// start date | ||
google.protobuf.Timestamp start_time = 4 | ||
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; | ||
// end_date | ||
google.protobuf.Timestamp end_time = 5 | ||
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; | ||
// lockup periods | ||
repeated cosmos.vesting.v1beta1.Period lockup_periods = 6 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.castrepeated) = | ||
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types.Periods" | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
syntax = "proto3"; | ||
package haqq.liquidvesting.v1; | ||
|
||
import "amino/amino.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "cosmos/base/query/v1beta1/pagination.proto"; | ||
import "haqq/liquidvesting/v1/liquidvesting.proto"; | ||
|
||
option go_package = "github.com/haqq-network/haqq/x/liquidvesting/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Denom queries liquid vesting token info by denom | ||
rpc Denom(QueryDenomRequest) returns (QueryDenomResponse) { | ||
option (google.api.http).get = "/haqq/liquidvesting/v1/denom"; | ||
}; | ||
// Denoms queries liquid vesting tokens info | ||
rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) { | ||
option (google.api.http).get = "/haqq/liquidvesting/v1/denoms"; | ||
}; | ||
} | ||
|
||
// QueryDenomRequest is request fo Denom rpc method | ||
message QueryDenomRequest { | ||
// denom is liquidated vesting token | ||
string denom = 1; | ||
} | ||
|
||
// QueryDenomResponse is response for Denom rpc method | ||
message QueryDenomResponse { | ||
// denom is liquidated vesting token | ||
Denom denom = 1 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true | ||
]; | ||
} | ||
|
||
// QueryDenomsRequest is request for Denoms rpc method | ||
message QueryDenomsRequest { | ||
// pagination defines an optional pagination for the request. | ||
cosmos.base.query.v1beta1.PageRequest pagination = 1; | ||
} | ||
|
||
// QueryDenomsResponse is response for Denoms rpc method | ||
message QueryDenomsResponse { | ||
// denoms are liquidated vesting tokens | ||
repeated Denom denoms = 1 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true | ||
]; | ||
|
||
// pagination defines the pagination in the response. | ||
cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
syntax = "proto3"; | ||
package haqq.liquidvesting.v1; | ||
|
||
import "amino/amino.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
|
||
option go_package = "github.com/haqq-network/haqq/x/liquidvesting/types"; | ||
|
||
// Msg defines the Msg service. | ||
service Msg { | ||
// Liquidate transforms specified amount of tokens locked on vesting account into a new liquid token | ||
rpc Liquidate(MsgLiquidate) returns (MsgLiquidateResponse) { | ||
option (google.api.http).post = "/haqq/liquidvesting/v1/tx/liquidate"; | ||
}; | ||
|
||
// Redeem burns liquid token and deposits corresponding amount of vesting token to the specified account | ||
rpc Redeem (MsgRedeem) returns (MsgRedeemResponse) { | ||
option (google.api.http).post = "/haqq/liquidvesting/v1/tx/redeem"; | ||
}; | ||
} | ||
|
||
// MsgLiquidate represents message to liquidate arbitrary amount of tokens locked in vesting | ||
message MsgLiquidate { | ||
// account for liquidation of locked vesting tokens | ||
string liquidate_from = 1; | ||
// account to send resulted liquid token | ||
string liquidate_to = 2; | ||
// amount of tokens subject for liquidation | ||
cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; | ||
} | ||
|
||
// MsgLiquidateResponse defines the Msg/Liquidate response type | ||
message MsgLiquidateResponse {} | ||
|
||
// MsgLiquidate represents message to redeem arbitrary amount of liquid vesting tokens | ||
message MsgRedeem { | ||
string redeem_from = 1; | ||
// destination address for vesting tokens | ||
string redeem_to = 2; | ||
// amount of vesting tokens to redeem from liquidation module | ||
cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; | ||
} | ||
|
||
// MsgRedeemResponse defines the Msg/Redeem response type | ||
message MsgRedeemResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.