diff --git a/config/config.go b/config/config.go index e5e7657..95377cc 100644 --- a/config/config.go +++ b/config/config.go @@ -76,6 +76,9 @@ func (cfg *Config) CheckConfig() error { if len(bot.MarketProposalConfig.Description) == 0 { return fmt.Errorf("%s: %s", errors.ErrMissingEmptyConfigSection.Error(), "bots.marketProposalConfig.description") } + if bot.MarketProposalConfig.DecimalPlaces == nil { + return fmt.Errorf("%s: %s", errors.ErrMissingEmptyConfigSection.Error(), "bots.marketProposalConfig.decimalPlaces") + } } return nil @@ -200,6 +203,6 @@ type MarketProposalConfig struct { Name string `yaml:"name"` Title string `yaml:"title"` Description string `yaml:"description"` - DecimalPlaces uint64 `yaml:"decimalPlaces"` + DecimalPlaces *uint64 `yaml:"decimalPlaces,omitempty"` Metadata []string `yaml:"metadata"` } diff --git a/config/config_test.go b/config/config_test.go index 44a3d7d..53cd738 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -43,6 +43,7 @@ func TestCheckConfig(t *testing.T) { cfg.Bots = []config.BotConfig{} err = cfg.CheckConfig() assert.True(t, strings.HasPrefix(err.Error(), errors.ErrMissingEmptyConfigSection.Error())) + decimalPlaces := uint64(18) botConfig := config.BotConfig{ Name: "test", @@ -60,7 +61,7 @@ func TestCheckConfig(t *testing.T) { Name: "Apple Monthly (Feb 2024)", Title: "New USD market", Description: "New USD market", - DecimalPlaces: 18, + DecimalPlaces: &decimalPlaces, Metadata: []string{ "class:equities/single-stock-futures", "sector:tech", diff --git a/market/service.go b/market/service.go index 8b06876..1db6b80 100644 --- a/market/service.go +++ b/market/service.go @@ -250,7 +250,7 @@ func (m *Service) sendNewMarketProposal(ctx context.Context) error { InstrumentCode: m.config.MarketProposalConfig.InstrumentCode, DataSubmitterPubKey: m.config.MarketProposalConfig.DataSubmitterPubKey, SettlementVegaAssetId: m.config.SettlementAssetID, - DecimalPlaces: m.config.MarketProposalConfig.DecimalPlaces, + DecimalPlaces: *m.config.MarketProposalConfig.DecimalPlaces, ExtraMetadata: m.config.MarketProposalConfig.Metadata, ClosingTime: time.Now().Add(time.Second * 20).Add(proposalParams.MinClose), EnactmentTime: time.Now().Add(time.Second * 30).Add(proposalParams.MinClose).Add(proposalParams.MinEnact),