-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
73 lines (64 loc) · 2.48 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
package simulation
// import (
// "fmt"
// "time"
// "github.com/cosmos/cosmos-sdk/codec"
// sdk "github.com/cosmos/cosmos-sdk/types"
// "github.com/cosmos/cosmos-sdk/types/module"
// "github.com/cosmos/cosmos-sdk/x/simulation"
// "github.com/incubus-network/fury/x/pricefeed/types"
// pricefeed "github.com/incubus-network/fury/x/pricefeed/types"
// )
// var (
// // BaseAssets is a list of collateral asset denoms
// BaseAssets = [3]string{"bnb", "xrp", "btc"}
// QuoteAsset = "usd"
// )
// // RandomizedGenState generates a random GenesisState for pricefeed
// func RandomizedGenState(simState *module.SimulationState) {
// pricefeedGenesis := loadPricefeedGenState(simState)
// fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, pricefeedGenesis))
// simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(pricefeedGenesis)
// }
// // loadPricefeedGenState loads a valid pricefeed gen state
// func loadPricefeedGenState(simState *module.SimulationState) pricefeed.GenesisState {
// var markets []pricefeed.Market
// var postedPrices []pricefeed.PostedPrice
// for _, denom := range BaseAssets {
// // Select an account to be the oracle
// oracle, _ := simulation.RandomAcc(simState.Rand, simState.Accounts)
// marketID := fmt.Sprintf("%s:%s", denom, QuoteAsset)
// // Construct market for asset
// market := pricefeed.Market{
// MarketID: marketID,
// BaseAsset: denom,
// QuoteAsset: QuoteAsset,
// Oracles: []sdk.AccAddress{oracle.Address},
// Active: true,
// }
// // Construct posted price for asset
// postedPrice := pricefeed.PostedPrice{
// MarketID: market.MarketId,
// OracleAddress: oracle.Address,
// Price: getInitialPrice(marketID),
// Expiry: simState.GenTimestamp.Add(time.Hour * 24),
// }
// markets = append(markets, market)
// postedPrices = append(postedPrices, postedPrice)
// }
// params := pricefeed.NewParams(markets)
// return pricefeed.NewGenesisState(params, postedPrices)
// }
// // getInitialPrice gets the starting price for each of the base assets
// func getInitialPrice(marketID string) (price sdk.Dec) {
// switch marketID {
// case "btc:usd":
// return sdk.MustNewDecFromStr("7000")
// case "bnb:usd":
// return sdk.MustNewDecFromStr("14")
// case "xrp:usd":
// return sdk.MustNewDecFromStr("0.2")
// default:
// return sdk.MustNewDecFromStr("20") // Catch future additional assets
// }
// }