-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR: v0.11.0 migrate feature (#313)
* v0.11 migrate feature * fix staking migrate issue * update genesis.json * update comments * delete history migrate Co-authored-by: Zhong Qiu <[email protected]>
- Loading branch information
1 parent
7b42378
commit 811f2b5
Showing
48 changed files
with
622 additions
and
2,317 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
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,71 @@ | ||
package v0_10 | ||
|
||
import ( | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
const ModuleName = "dex" | ||
|
||
type ( | ||
// GenesisState - all dex state that must be provided at genesis | ||
GenesisState struct { | ||
Params Params `json:"params"` | ||
TokenPairs []*TokenPair `json:"token_pairs"` | ||
WithdrawInfos WithdrawInfos `json:"withdraw_infos"` | ||
ProductLocks ProductLockMap `json:"product_locks"` | ||
} | ||
|
||
// Params defines param object | ||
Params struct { | ||
ListFee sdk.DecCoin `json:"list_fee"` | ||
TransferOwnershipFee sdk.DecCoin `json:"transfer_ownership_fee"` | ||
|
||
// maximum period for okt holders to deposit on a dex delist proposal | ||
DelistMaxDepositPeriod time.Duration `json:"delist_max_deposit_period"` | ||
// minimum deposit for a critical dex delist proposal to enter voting period | ||
DelistMinDeposit sdk.DecCoins `json:"delist_min_deposit"` | ||
// length of the critical voting period for dex delist proposal | ||
DelistVotingPeriod time.Duration `json:"delist_voting_period"` | ||
|
||
WithdrawPeriod time.Duration `json:"withdraw_period"` | ||
} | ||
|
||
// TokenPair represents token pair object | ||
TokenPair struct { | ||
BaseAssetSymbol string `json:"base_asset_symbol"` | ||
QuoteAssetSymbol string `json:"quote_asset_symbol"` | ||
InitPrice sdk.Dec `json:"price"` | ||
MaxPriceDigit int64 `json:"max_price_digit"` | ||
MaxQuantityDigit int64 `json:"max_size_digit"` | ||
MinQuantity sdk.Dec `json:"min_trade_size"` | ||
ID uint64 `json:"token_pair_id"` | ||
Delisting bool `json:"delisting"` | ||
Owner sdk.AccAddress `json:"owner"` | ||
Deposits sdk.DecCoin `json:"deposits"` | ||
BlockHeight int64 `json:"block_height"` | ||
} | ||
|
||
// WithdrawInfo represents infos for withdrawing | ||
WithdrawInfo struct { | ||
Owner sdk.AccAddress `json:"owner"` | ||
Deposits sdk.DecCoin `json:"deposits"` | ||
CompleteTime time.Time `json:"complete_time"` | ||
} | ||
|
||
// WithdrawInfos defines list of WithdrawInfo | ||
WithdrawInfos []WithdrawInfo | ||
|
||
ProductLock struct { | ||
BlockHeight int64 | ||
Price sdk.Dec | ||
Quantity sdk.Dec | ||
BuyExecuted sdk.Dec | ||
SellExecuted sdk.Dec | ||
} | ||
|
||
ProductLockMap struct { | ||
Data map[string]*ProductLock | ||
} | ||
) |
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,50 @@ | ||
package v0_11 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/okex/okchain/x/common" | ||
"github.com/okex/okchain/x/dex/legacy/v0_10" | ||
) | ||
|
||
func Migrate(oldGenState v0_10.GenesisState) GenesisState { | ||
params := Params{ | ||
ListFee: oldGenState.Params.ListFee, | ||
TransferOwnershipFee: oldGenState.Params.TransferOwnershipFee, | ||
DelistMaxDepositPeriod: oldGenState.Params.DelistMaxDepositPeriod, | ||
DelistMinDeposit: oldGenState.Params.DelistMinDeposit, | ||
DelistVotingPeriod: oldGenState.Params.DelistVotingPeriod, | ||
WithdrawPeriod: oldGenState.Params.WithdrawPeriod, | ||
RegisterOperatorFee: sdk.NewDecCoinFromDec(common.NativeToken, sdk.ZeroDec()), | ||
} | ||
|
||
operatorMap := make(map[string]struct{}) | ||
var operators DEXOperators | ||
var maxTokenPairID uint64 = 0 | ||
for _, pair := range oldGenState.TokenPairs { | ||
if pair.ID > maxTokenPairID { | ||
maxTokenPairID = pair.ID | ||
} | ||
|
||
if _, exist := operatorMap[pair.Owner.String()]; exist { | ||
continue | ||
} | ||
operatorMap[pair.Owner.String()] = struct{}{} | ||
operator := DEXOperator{ | ||
Address: pair.Owner, | ||
HandlingFeeAddress: pair.Owner, | ||
Website: "", | ||
InitHeight: pair.BlockHeight, | ||
TxHash: "", | ||
} | ||
operators = append(operators, operator) | ||
} | ||
|
||
return GenesisState{ | ||
Params: params, | ||
TokenPairs: oldGenState.TokenPairs, | ||
WithdrawInfos: oldGenState.WithdrawInfos, | ||
ProductLocks: oldGenState.ProductLocks, | ||
Operators: operators, | ||
MaxTokenPairID: maxTokenPairID, | ||
} | ||
} |
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,53 @@ | ||
package v0_11 | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/okex/okchain/x/dex/legacy/v0_10" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
const ( | ||
ModuleName = "dex" | ||
) | ||
|
||
type ( | ||
// GenesisState - all dex state that must be provided at genesis | ||
GenesisState struct { | ||
Params Params `json:"params"` | ||
TokenPairs []*v0_10.TokenPair `json:"token_pairs"` | ||
WithdrawInfos v0_10.WithdrawInfos `json:"withdraw_infos"` | ||
ProductLocks v0_10.ProductLockMap `json:"product_locks"` | ||
Operators DEXOperators `json:"operators"` | ||
MaxTokenPairID uint64 `json:"max_token_pair_id" yaml:"max_token_pair_id"` | ||
} | ||
|
||
// Params defines param object | ||
Params struct { | ||
ListFee sdk.DecCoin `json:"list_fee"` | ||
TransferOwnershipFee sdk.DecCoin `json:"transfer_ownership_fee"` | ||
RegisterOperatorFee sdk.DecCoin `json:"register_operator_fee"` | ||
|
||
// maximum period for okt holders to deposit on a dex delist proposal | ||
DelistMaxDepositPeriod time.Duration `json:"delist_max_deposit_period"` | ||
// minimum deposit for a critical dex delist proposal to enter voting period | ||
DelistMinDeposit sdk.DecCoins `json:"delist_min_deposit"` | ||
// length of the critical voting period for dex delist proposal | ||
DelistVotingPeriod time.Duration `json:"delist_voting_period"` | ||
|
||
WithdrawPeriod time.Duration `json:"withdraw_period"` | ||
} | ||
|
||
// OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` | ||
DEXOperator struct { | ||
Address sdk.AccAddress `json:"address"` | ||
HandlingFeeAddress sdk.AccAddress `json:"handling_fee_address"` | ||
Website string `json:"website"` | ||
InitHeight int64 `json:"init_height"` | ||
TxHash string `json:"tx_hash"` | ||
} | ||
|
||
// nolint | ||
DEXOperators []DEXOperator | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.