/
genesis.go
111 lines (98 loc) · 3.4 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
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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/osmomath"
)
var (
// Configuration of the default genesis state for the module.
DefaultTokenPairArbRoutes = []TokenPairArbRoutes{}
// Configure the initial base denoms used for cyclic route building. The order of the list of base
// denoms is the order in which routes will be prioritized i.e. routes will be built and simulated in a
// first come first serve basis that is based on the order of the base denoms.
DefaultBaseDenoms = []BaseDenom{
{
Denom: OsmosisDenomination,
StepSize: osmomath.NewInt(1_000_000),
},
}
DefaultPoolTypeInfo = InfoByPoolType{
Balancer: BalancerPoolInfo{
Weight: 2, // it takes around 2 ms to simulate and execute a balancer swap
},
Stable: StablePoolInfo{
Weight: 5, // it takes around 5 ms to simulate and execute a stable swap
},
Concentrated: ConcentratedPoolInfo{
Weight: 7, // it takes around 7 ms to simulate and execute a concentrated swap
MaxTicksCrossed: 5,
},
Cosmwasm: CosmwasmPoolInfo{},
}
DefaultDaysSinceModuleGenesis = uint64(0)
DefaultDeveloperFees = []sdk.Coin{}
DefaultLatestBlockHeight = uint64(0)
DefaultDeveloperAddress = ""
DefaultMaxPoolPointsPerBlock = uint64(100)
DefaultMaxPoolPointsPerTx = uint64(18)
DefaultPoolPointsConsumedInBlock = uint64(0)
DefaultProfits = []sdk.Coin{}
DefaultCyclicArbTracker = CyclicArbTracker{
CyclicArb: sdk.Coins(nil),
HeightAccountingStartsFrom: 0,
}
)
// DefaultGenesis returns the default genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{
Params: DefaultParams(),
TokenPairArbRoutes: DefaultTokenPairArbRoutes,
BaseDenoms: DefaultBaseDenoms,
InfoByPoolType: DefaultPoolTypeInfo,
DaysSinceModuleGenesis: DefaultDaysSinceModuleGenesis,
DeveloperFees: DefaultDeveloperFees,
DeveloperAddress: DefaultDeveloperAddress,
LatestBlockHeight: DefaultLatestBlockHeight,
MaxPoolPointsPerBlock: DefaultMaxPoolPointsPerBlock,
MaxPoolPointsPerTx: DefaultMaxPoolPointsPerTx,
PointCountForBlock: DefaultPoolPointsConsumedInBlock,
Profits: DefaultProfits,
CyclicArbTracker: &DefaultCyclicArbTracker,
}
}
// Validate performs basic genesis state validation returning an error upon any failure.
func (gs GenesisState) Validate() error {
// Validate the token pair arb routes
if err := ValidateTokenPairArbRoutes(gs.TokenPairArbRoutes); err != nil {
return err
}
// Validate the base denoms
if err := ValidateBaseDenoms(gs.BaseDenoms); err != nil {
return err
}
// Validate the pool type information
if err := gs.InfoByPoolType.Validate(); err != nil {
return err
}
// Validate the developer fees
if err := ValidateDeveloperFees(gs.DeveloperFees); err != nil {
return err
}
// Validate the developer address if it is set
if gs.DeveloperAddress != "" {
if _, err := sdk.AccAddressFromBech32(gs.DeveloperAddress); err != nil {
return err
}
}
// Validate the max pool points per block
if err := ValidateMaxPoolPointsPerBlock(gs.MaxPoolPointsPerBlock); err != nil {
return err
}
// Validate the max pool points per tx
if err := ValidateMaxPoolPointsPerTx(gs.MaxPoolPointsPerTx); err != nil {
return err
}
return gs.Params.Validate()
}
func init() {
// no-op
}