-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenesis.go
86 lines (76 loc) · 3.12 KB
/
genesis.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
package app
import (
"encoding/json"
math "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
marketmaptypes "github.com/skip-mev/connect/v2/x/marketmap/types"
oracletypes "github.com/skip-mev/connect/v2/x/oracle/types"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
)
// GenesisState of the blockchain is represented here as a map of raw json
// messages key'd by a identifier string.
// The identifier is used to determine which module genesis information belongs
// to so it may be appropriately routed during init chain.
// Within this application default genesis information is retrieved from
// the ModuleBasicManager which populates json from each BasicModule
// object provided to it during init.
type GenesisState map[string]json.RawMessage
var FeeDenom = "uom"
// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState {
genesisState := module.BasicManager{}.DefaultGenesis(cdc)
oracleGenesis := oracletypes.DefaultGenesisState()
oracleGenesisStateBytes, err := json.Marshal(oracleGenesis)
if err != nil {
panic("cannot marshal connect genesis state for tests")
}
genesisState[oracletypes.ModuleName] = oracleGenesisStateBytes
marketmapGenesis := marketmaptypes.DefaultGenesisState()
marketmapGenesisStateBytes, err := json.Marshal(marketmapGenesis)
if err != nil {
panic("cannot marshal connect genesis state for tests")
}
genesisState[marketmaptypes.ModuleName] = marketmapGenesisStateBytes
distributionGenesis := distributiontypes.GenesisState{
Params: distributiontypes.Params{
CommunityTax: math.LegacyMustNewDecFromStr("0.01"),
// McaTax: math.LegacyMustNewDecFromStr("0.4"),
// McaAddress: "mantra15m77x4pe6w9vtpuqm22qxu0ds7vn4ehzwx8pls",
WithdrawAddrEnabled: true,
},
}
distributionGenesisStateBytes, err := json.Marshal(distributionGenesis)
if err != nil {
panic("cannot marshal distribution genesis state for tests")
}
genesisState[distributiontypes.ModuleName] = distributionGenesisStateBytes
feemarketFeeGenesis := feemarkettypes.GenesisState{
Params: feemarkettypes.Params{
Alpha: math.LegacyOneDec(),
Beta: math.LegacyOneDec(),
Delta: math.LegacyOneDec(),
MinBaseGasPrice: math.LegacyMustNewDecFromStr("1"),
MinLearningRate: math.LegacyMustNewDecFromStr("0.5"),
MaxLearningRate: math.LegacyMustNewDecFromStr("1.5"),
MaxBlockUtilization: 75_000_000,
Window: 1,
FeeDenom: FeeDenom,
Enabled: false,
DistributeFees: true,
},
State: feemarkettypes.State{
BaseGasPrice: math.LegacyMustNewDecFromStr("1"),
LearningRate: math.LegacyOneDec(),
Window: []uint64{100},
Index: 0,
},
}
feemarketFeeGenesisStateBytes, err := json.Marshal(feemarketFeeGenesis)
if err != nil {
panic("cannot marshal feemarket genesis state for tests")
}
genesisState["feemarket"] = feemarketFeeGenesisStateBytes
return genesisState
}