Skip to content

Commit

Permalink
feat: add check forex markets to constants for checking (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Dec 11, 2024
1 parent f73a9b0 commit c3b9b1f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
90 changes: 90 additions & 0 deletions cmd/constants/marketmaps/markets.go
Original file line number Diff line number Diff line change
Expand Up @@ -9754,6 +9754,95 @@ var (
}
}
}`

// ForexMarketMap is used to initialize the forex market map. This only includes
// forex markets quoted in usdt.
ForexMarketMap mmtypes.MarketMap

// ForexMarketMapJSON is the JSON representation of ForexMarketMap.
ForexMarketMapJSON = `
{
"markets": {
"TRY/USDT": {
"ticker": {
"currency_pair": {
"Base": "TRY",
"Quote": "USDT"
},
"decimals": 11,
"min_provider_count": 1,
"enabled": false,
"metadata_JSON": "{\"reference_price\":2935133548,\"liquidity\":1504939,\"aggregate_ids\":[{\"venue\":\"coinmarketcap\",\"ID\":\"2810\"}]}"
},
"provider_configs": [
{
"name": "binance_ws",
"off_chain_ticker": "USDTTRY",
"invert": true,
"metadata_JSON": ""
},
{
"name": "okx_ws",
"off_chain_ticker": "TRY-USDT",
"invert": false,
"metadata_JSON": ""
}
]
},
"EUR/USDT": {
"ticker": {
"currency_pair": {
"Base": "EUR",
"Quote": "USDT"
},
"decimals": 9,
"min_provider_count": 1,
"enabled": false,
"metadata_JSON": "{\"reference_price\":1100800000,\"liquidity\":3843298,\"aggregate_ids\":[{\"venue\":\"coinmarketcap\",\"ID\":\"2790\"}]}"
},
"provider_configs": [
{
"name": "binance_ws",
"off_chain_ticker": "EURUSDT",
"invert": false,
"metadata_JSON": ""
},
{
"name": "okx_ws",
"off_chain_ticker": "EUR-USDT",
"invert": false,
"metadata_JSON": ""
}
]
},
"BRL/USDT": {
"ticker": {
"currency_pair": {
"Base": "BRL",
"Quote": "USDT"
},
"decimals": 10,
"min_provider_count": 1,
"enabled": false,
"metadata_JSON": "{\"reference_price\":1760563380,\"liquidity\":2479974,\"aggregate_ids\":[{\"venue\":\"coinmarketcap\",\"ID\":\"2783\"}]}"
},
"provider_configs": [
{
"name": "binance_ws",
"off_chain_ticker": "USDTBRL",
"invert": true,
"metadata_JSON": ""
},
{
"name": "okx_ws",
"off_chain_ticker": "BRL-USDT",
"invert": false,
"metadata_JSON": ""
}
]
}
}
}`
)

func init() {
Expand All @@ -9765,6 +9854,7 @@ func init() {
unmarshalValidate("CoinGecko", CoinGeckoMarketMapJSON, &CoinGeckoMarketMap),
unmarshalValidate("Osmosis", OsmosisMarketMapJSON, &OsmosisMarketMap),
unmarshalValidate("Polymarket", PolymarketMarketMapJSON, &PolymarketMarketMap),
unmarshalValidate("Forex", ForexMarketMapJSON, &ForexMarketMap),
)
if err != nil {
panic(err)
Expand Down
1 change: 1 addition & 0 deletions cmd/constants/marketmaps/markets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestMarkets(t *testing.T) {
marketmaps.CoinGeckoMarketMap.Markets,
marketmaps.OsmosisMarketMap.Markets,
marketmaps.PolymarketMarketMap.Markets,
marketmaps.ForexMarketMap.Markets,
}
for _, m := range markets {
require.NotEmpty(t, m)
Expand Down
6 changes: 6 additions & 0 deletions scripts/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
useCoinMarketCap = flag.Bool("use-coinmarketcap", false, "use coinmarketcap markets")
useOsmosis = flag.Bool("use-osmosis", false, "use osmosis markets")
usePolymarket = flag.Bool("use-polymarket", false, "use polymarket markets")
useForex = flag.Bool("use-forex", false, "use forex markets")
tempFile = flag.String("temp-file", "markets.json", "temporary file to store the market map")
)

Expand Down Expand Up @@ -99,6 +100,11 @@ func main() {
marketMap = mergeMarketMaps(marketMap, marketmaps.PolymarketMarketMap)
}

if *useForex {
fmt.Fprintf(flag.CommandLine.Output(), "Using forex markets\n")
marketMap = mergeMarketMaps(marketMap, marketmaps.ForexMarketMap)
}

Check warning on line 106 in scripts/genesis.go

View check run for this annotation

Codecov / codecov/patch

scripts/genesis.go#L103-L106

Added lines #L103 - L106 were not covered by tests

if err := marketMap.ValidateBasic(); err != nil {
fmt.Fprintf(flag.CommandLine.Output(), "failed to validate market map: %s\n", err)
panic(err)
Expand Down

0 comments on commit c3b9b1f

Please sign in to comment.