2020-01-17 12:29:19 +00:00
|
|
|
package pricefeed_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
|
|
|
"github.com/kava-labs/kava/app"
|
2022-01-08 00:39:27 +00:00
|
|
|
"github.com/kava-labs/kava/x/pricefeed/types"
|
2020-01-17 12:29:19 +00:00
|
|
|
)
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
func NewPricefeedGen() types.GenesisState {
|
|
|
|
return types.GenesisState{
|
|
|
|
Params: types.Params{
|
|
|
|
Markets: []types.Market{
|
2020-04-30 14:13:31 +00:00
|
|
|
{MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
|
|
{MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
2020-01-17 12:29:19 +00:00
|
|
|
},
|
|
|
|
},
|
2022-01-08 00:39:27 +00:00
|
|
|
PostedPrices: []types.PostedPrice{
|
2020-04-30 14:13:31 +00:00
|
|
|
{
|
2020-01-17 12:29:19 +00:00
|
|
|
MarketID: "btc:usd",
|
2022-01-08 00:39:27 +00:00
|
|
|
OracleAddress: sdk.AccAddress("oracle1"),
|
2020-01-17 12:29:19 +00:00
|
|
|
Price: sdk.MustNewDecFromStr("8000.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
2020-04-30 14:13:31 +00:00
|
|
|
{
|
2020-01-17 12:29:19 +00:00
|
|
|
MarketID: "xrp:usd",
|
2022-01-08 00:39:27 +00:00
|
|
|
OracleAddress: sdk.AccAddress("oracle2"),
|
2020-01-17 12:29:19 +00:00
|
|
|
Price: sdk.MustNewDecFromStr("0.25"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2022-01-08 00:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewPricefeedGenStateMulti() app.GenesisState {
|
|
|
|
pfGenesis := NewPricefeedGen()
|
|
|
|
return app.GenesisState{types.ModuleName: types.ModuleCdc.LegacyAmino.MustMarshalJSON(pfGenesis)}
|
2020-01-17 12:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewPricefeedGenStateWithOracles(addrs []sdk.AccAddress) app.GenesisState {
|
2022-01-08 00:39:27 +00:00
|
|
|
pfGenesis := types.GenesisState{
|
|
|
|
Params: types.Params{
|
|
|
|
Markets: []types.Market{
|
2020-04-30 14:13:31 +00:00
|
|
|
{MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: addrs, Active: true},
|
|
|
|
{MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: addrs, Active: true},
|
2020-01-17 12:29:19 +00:00
|
|
|
},
|
|
|
|
},
|
2022-01-08 00:39:27 +00:00
|
|
|
PostedPrices: []types.PostedPrice{
|
2020-04-30 14:13:31 +00:00
|
|
|
{
|
2020-01-17 12:29:19 +00:00
|
|
|
MarketID: "btc:usd",
|
|
|
|
OracleAddress: addrs[0],
|
|
|
|
Price: sdk.MustNewDecFromStr("8000.00"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
2020-04-30 14:13:31 +00:00
|
|
|
{
|
2020-01-17 12:29:19 +00:00
|
|
|
MarketID: "xrp:usd",
|
|
|
|
OracleAddress: addrs[0],
|
|
|
|
Price: sdk.MustNewDecFromStr("0.25"),
|
|
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2022-01-08 00:39:27 +00:00
|
|
|
return app.GenesisState{types.ModuleName: types.ModuleCdc.LegacyAmino.MustMarshalJSON(pfGenesis)}
|
2020-01-17 12:29:19 +00:00
|
|
|
}
|