github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/dex/types/params.go (about)

     1  package types
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
     8  	"github.com/fibonacci-chain/fbc/x/common"
     9  	"github.com/fibonacci-chain/fbc/x/params"
    10  )
    11  
    12  var (
    13  	keyDexListFee             = []byte("DexListFee")
    14  	keyTransferOwnershipFee   = []byte("TransferOwnershipFee")
    15  	keyRegisterOperatorFee    = []byte("RegisterOperatorFee")
    16  	keyDelistMaxDepositPeriod = []byte("DelistMaxDepositPeriod")
    17  	keyDelistMinDeposit       = []byte("DelistMinDeposit")
    18  	keyDelistVotingPeriod     = []byte("DelistVotingPeriod")
    19  	keyWithdrawPeriod         = []byte("WithdrawPeriod")
    20  	keyOwnershipConfirmWindow = []byte("OwnershipConfirmWindow")
    21  )
    22  
    23  // Params defines param object
    24  type Params struct {
    25  	ListFee              sdk.SysCoin `json:"list_fee"`
    26  	TransferOwnershipFee sdk.SysCoin `json:"transfer_ownership_fee"`
    27  	RegisterOperatorFee  sdk.SysCoin `json:"register_operator_fee"`
    28  
    29  	//  maximum period for fibo holders to deposit on a dex delist proposal
    30  	DelistMaxDepositPeriod time.Duration `json:"delist_max_deposit_period"`
    31  	//  minimum deposit for a critical dex delist proposal to enter voting period
    32  	DelistMinDeposit sdk.SysCoins `json:"delist_min_deposit"`
    33  	//  length of the critical voting period for dex delist proposal
    34  	DelistVotingPeriod time.Duration `json:"delist_voting_period"`
    35  
    36  	WithdrawPeriod         time.Duration `json:"withdraw_period"`
    37  	OwnershipConfirmWindow time.Duration `json:"ownership_confirm_window"`
    38  }
    39  
    40  // ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
    41  func (p *Params) ParamSetPairs() params.ParamSetPairs {
    42  	return params.ParamSetPairs{
    43  		{Key: keyDexListFee, Value: &p.ListFee, ValidatorFn: common.ValidateSysCoin("list fee")},
    44  		{Key: keyTransferOwnershipFee, Value: &p.TransferOwnershipFee, ValidatorFn: common.ValidateSysCoin("transfer ownership fee")},
    45  		{Key: keyRegisterOperatorFee, Value: &p.RegisterOperatorFee, ValidatorFn: common.ValidateSysCoin("register operator fee")},
    46  		{Key: keyDelistMaxDepositPeriod, Value: &p.DelistMaxDepositPeriod, ValidatorFn: common.ValidateDurationPositive("delist max deposit period")},
    47  		{Key: keyDelistMinDeposit, Value: &p.DelistMinDeposit, ValidatorFn: common.ValidateSysCoins("delist min deposit")},
    48  		{Key: keyDelistVotingPeriod, Value: &p.DelistVotingPeriod, ValidatorFn: common.ValidateDurationPositive("delist voting period")},
    49  		{Key: keyWithdrawPeriod, Value: &p.WithdrawPeriod, ValidatorFn: common.ValidateDurationPositive("withdraw period")},
    50  		{Key: keyOwnershipConfirmWindow, Value: &p.OwnershipConfirmWindow, ValidatorFn: common.ValidateDurationPositive("ownership confirm window")},
    51  	}
    52  }
    53  
    54  // ParamKeyTable for auth module
    55  func ParamKeyTable() params.KeyTable {
    56  	return params.NewKeyTable().RegisterParamSet(&Params{})
    57  }
    58  
    59  // DefaultParams returns a default set of parameters.
    60  func DefaultParams() *Params {
    61  	defaultListFee := sdk.NewDecCoinFromDec(common.NativeToken, sdk.MustNewDecFromStr(defaultFeeList))
    62  	defaultTransferOwnershipFee := sdk.NewDecCoinFromDec(common.NativeToken, sdk.MustNewDecFromStr(defaultFeeTransferOwnership))
    63  	defaultDelistMinDeposit := sdk.NewDecCoinFromDec(common.NativeToken, sdk.MustNewDecFromStr(defaultDelistMinDeposit))
    64  	return &Params{
    65  		ListFee:                defaultListFee,
    66  		TransferOwnershipFee:   defaultTransferOwnershipFee,
    67  		RegisterOperatorFee:    sdk.NewDecCoinFromDec(common.NativeToken, sdk.ZeroDec()),
    68  		DelistMaxDepositPeriod: time.Hour * 24,
    69  		DelistMinDeposit:       sdk.SysCoins{defaultDelistMinDeposit},
    70  		DelistVotingPeriod:     time.Hour * 72,
    71  		WithdrawPeriod:         DefaultWithdrawPeriod,
    72  		OwnershipConfirmWindow: DefaultOwnershipConfirmWindow,
    73  	}
    74  }
    75  
    76  // String implements the stringer interface.
    77  func (p Params) String() string {
    78  	return fmt.Sprintf("Params: \nDexListFee:%s\nTransferOwnershipFee:%s\nRegisterOperatorFee:%s\nDelistMaxDepositPeriod:%s\n"+
    79  		"DelistMinDeposit:%s\nDelistVotingPeriod:%s\nWithdrawPeriod:%d\nOwnershipConfirmWindow: %s\n",
    80  		p.ListFee, p.TransferOwnershipFee, p.RegisterOperatorFee, p.DelistMaxDepositPeriod, p.DelistMinDeposit, p.DelistVotingPeriod, p.WithdrawPeriod, p.OwnershipConfirmWindow)
    81  }