/
keys.go
131 lines (100 loc) · 4.05 KB
/
keys.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package types
import (
"strconv"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
)
const (
// ModuleName defines the module name
ModuleName = "liquidstakeibc"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey is the message route for slashing
RouterKey = ModuleName
// DepositModuleAccount DepositModuleAccountName
DepositModuleAccount = ModuleName + "_deposit_account"
// UndelegationModuleAccount UndelegationModuleAccountName
UndelegationModuleAccount = ModuleName + "_undelegation_account"
// Epoch identifiers
DelegationEpoch = "day"
UndelegationEpoch = "day"
RewardsEpochIdentifier = "day"
RedelegationEpochIdentifer = "day"
CValueEpoch = "hour"
// ICA types
DelegateICAType = "delegate"
RewardsICAType = "rewards"
// ICQ query types
// /key is required for proof generation
StakingStoreQuery = "store/staking/key"
BankStoreQuery = "store/bank/key"
// Host chain flags
LSMFlag = "lsm"
LiquidStakeDenomPrefix = "stk"
IBCTimeoutTimestamp = 120 * time.Minute
ICAMessagesChunkSize = 10
IBCPrefix = transfertypes.DenomPrefix + "/"
UnbondingStateEpochLimit = 4
LSMDepositFilterLimit = 10000
Percentage int64 = 100
DaysInYear int64 = 365
CValueDynamicLowerDiff int64 = 2
CValueDynamicUpperDiff int64 = 10
)
// Consts for KV updates, update host chain
const (
KeyAddValidator string = "add_validator"
KeyRemoveValidator string = "remove_validator"
KeyValidatorUpdate string = "validator_update"
KeyValidatorWeight string = "validator_weight"
KeyDepositFee string = "deposit_fee"
KeyRestakeFee string = "restake_fee"
KeyUnstakeFee string = "unstake_fee"
KeyRedemptionFee string = "redemption_fee"
KeyLSMValidatorCap string = "lsm_validator_cap"
KeyLSMBondFactor string = "lsm_bond_factor"
KeyMaxEntries string = "max_entries"
KeyUpperCValueLimit string = "upper_c_value_limit"
KeyLowerCValueLimit string = "lower_c_value_limit"
KeyRedelegationAcceptableDelta string = "redelegation_acceptable_delta"
KeyMinimumDeposit string = "min_deposit"
KeyActive string = "active"
KeySetWithdrawAddress string = "set_withdraw_address"
KeyAutocompoundFactor string = "autocompound_factor"
KeyFlags string = "flags"
KeyRewardParams string = "reward_params"
)
var (
HostChainKey = []byte{0x01}
DepositKey = []byte{0x02}
UnbondingKey = []byte{0x03}
UserUnbondingKey = []byte{0x04}
ValidatorUnbondingKey = []byte{0x05}
ParamsKey = []byte{0x06}
LSMDepositKey = []byte{0x07}
RedelegationsKey = []byte{0x08}
RedelegationTxKey = []byte{0x09}
)
var MaxFee = sdk.MustNewDecFromStr("0.5")
func GetUnbondingStoreKey(chainID string, epochNumber int64) []byte {
return append([]byte(chainID), []byte(strconv.FormatInt(epochNumber, 10))...)
}
func GetUserUnbondingStoreKey(chainID, delegatorAddress string, epochNumber int64) []byte {
return append([]byte(chainID), append([]byte(delegatorAddress), []byte(strconv.FormatInt(epochNumber, 10))...)...)
}
func GetValidatorUnbondingStoreKey(chainID, validatorAddress string, epochNumber int64) []byte {
return append([]byte(chainID), append([]byte(validatorAddress), []byte(strconv.FormatInt(epochNumber, 10))...)...)
}
func GetDepositStoreKey(chainID string, epochNumber int64) []byte {
return append([]byte(chainID), []byte(strconv.FormatInt(epochNumber, 10))...)
}
func GetLSMDepositStoreKey(chainID, delegatorAddress, denom string) []byte {
return append(append([]byte(chainID), []byte(delegatorAddress)...), []byte(denom)...)
}
func GetRedelegationsStoreKey(chainID string) []byte {
return []byte(chainID)
}
func GetRedelegationTxStoreKey(chainID, ibcSequenceID string) []byte {
return append([]byte(chainID), []byte(ibcSequenceID)...)
}