From 515976b1c78f53f6737b611645d97b97b803db1d Mon Sep 17 00:00:00 2001 From: Chenyao Yu <4844716+chenyaoy@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:59:37 -0400 Subject: [PATCH] add binance --- .../static_exchange_market_config.go | 2 +- .../testdata/pol_exchange_config.json | 5 +++ .../scripts/genesis/sample_pregenesis.json | 15 ++++++--- .../containertest/preupgrade_genesis.json | 26 +++++++--------- protocol/testing/genesis.sh | 1 + protocol/testing/mainnet/genesis.json | 2 +- protocol/testing/testnet/genesis.json | 2 +- protocol/testutil/constants/genesis.go | 31 +++++++++---------- .../testnet_exchange_market_config.go | 4 +++ 9 files changed, 50 insertions(+), 38 deletions(-) diff --git a/protocol/daemons/pricefeed/client/constants/static_exchange_market_config.go b/protocol/daemons/pricefeed/client/constants/static_exchange_market_config.go index 9f1bd5a890..2362e0cad4 100644 --- a/protocol/daemons/pricefeed/client/constants/static_exchange_market_config.go +++ b/protocol/daemons/pricefeed/client/constants/static_exchange_market_config.go @@ -16,7 +16,7 @@ const ( // by the pricefeed daemon. This number was chosen to supply the minimum number of prices required to // compute an index price for a market, given exchange unavailability due to exchange geo-fencing, // downtime, etc. - MinimumRequiredExchangesPerMarket = 4 + MinimumRequiredExchangesPerMarket = 5 ) // GenerateExchangeConfigJson generates human-readable exchange config json for each market based on the contents diff --git a/protocol/daemons/pricefeed/client/constants/testdata/pol_exchange_config.json b/protocol/daemons/pricefeed/client/constants/testdata/pol_exchange_config.json index 1af05f8980..ba784b1f20 100644 --- a/protocol/daemons/pricefeed/client/constants/testdata/pol_exchange_config.json +++ b/protocol/daemons/pricefeed/client/constants/testdata/pol_exchange_config.json @@ -1,5 +1,10 @@ { "exchanges": [ + { + "exchangeName": "Binance", + "ticker": "POLUSDT", + "adjustByMarket": "USDT-USD" + }, { "exchangeName": "Bybit", "ticker": "POLUSDT", diff --git a/protocol/scripts/genesis/sample_pregenesis.json b/protocol/scripts/genesis/sample_pregenesis.json index 2643da3381..7f15e44022 100644 --- a/protocol/scripts/genesis/sample_pregenesis.json +++ b/protocol/scripts/genesis/sample_pregenesis.json @@ -2279,6 +2279,14 @@ }, "POL/USD": { "provider_configs": [ + { + "binance_ws", + "normalize_by_pair": { + "Base": "USDT", + "Quote": "USD" + }, + "off_chain_ticker": "POLUSDT" + }, { "name": "bybit_ws", "normalize_by_pair": { @@ -2309,10 +2317,9 @@ "Base": "POL", "Quote": "USD" }, - "decimals": "10", - "min_provider_count": "3", - "enabled": true, - "metadata_JSON": "" + "decimals": 10, + "min_provider_count": 3, + "enabled": true } }, "SEI/USD": { diff --git a/protocol/testing/containertest/preupgrade_genesis.json b/protocol/testing/containertest/preupgrade_genesis.json index 426036685b..612ed3f5f5 100644 --- a/protocol/testing/containertest/preupgrade_genesis.json +++ b/protocol/testing/containertest/preupgrade_genesis.json @@ -1438,29 +1438,29 @@ "metadata_JSON": "" }, "provider_configs": [ + { + "name": "binance_ws", + "off_chain_ticker": "POLUSDT", + "normalize_by_pair": { + "Base": "USDT", + "Quote": "USD" + } + }, { "name": "bybit_ws", "off_chain_ticker": "POLUSDT", "normalize_by_pair": { "Base": "USDT", "Quote": "USD" - }, - "invert": false, - "metadata_JSON": "" + } }, { "name": "coinbase_ws", - "off_chain_ticker": "POL-USD", - "normalize_by_pair": null, - "invert": false, - "metadata_JSON": "" + "off_chain_ticker": "POL-USD" }, { "name": "crypto_dot_com_ws", - "off_chain_ticker": "POL_USD", - "normalize_by_pair": null, - "invert": false, - "metadata_JSON": "" + "off_chain_ticker": "POL_USD" }, { "name": "okx_ws", @@ -1468,9 +1468,7 @@ "normalize_by_pair": { "Base": "USDT", "Quote": "USD" - }, - "invert": false, - "metadata_JSON": "" + } } ] }, diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index de2d6a431d..e9c60e5adc 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -619,6 +619,7 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.marketmap.market_map.markets.POL/USD.ticker.min_provider_count' -v '3' dasel put -t bool -f "$GENESIS" '.app_state.marketmap.market_map.markets.POL/USD.ticker.enabled' -v 'true' + dasel put -t json -f "$GENESIS" '.app_state.marketmap.market_map.markets.POL/USD.provider_configs.[]' -v '{"name": "binance_ws", "off_chain_ticker": "POLUSDT", "normalize_by_pair": {"Base": "USDT", "Quote": "USD"}}' dasel put -t json -f "$GENESIS" '.app_state.marketmap.market_map.markets.POL/USD.provider_configs.[]' -v '{"name": "bybit_ws", "off_chain_ticker": "POLUSDT", "normalize_by_pair": {"Base": "USDT", "Quote": "USD"}}' dasel put -t json -f "$GENESIS" '.app_state.marketmap.market_map.markets.POL/USD.provider_configs.[]' -v '{"name": "coinbase_ws", "off_chain_ticker": "POL-USD"}' dasel put -t json -f "$GENESIS" '.app_state.marketmap.market_map.markets.POL/USD.provider_configs.[]' -v '{"name": "crypto_dot_com_ws", "off_chain_ticker": "POL_USD"}' diff --git a/protocol/testing/mainnet/genesis.json b/protocol/testing/mainnet/genesis.json index 73a9e0afe6..c535a63708 100644 --- a/protocol/testing/mainnet/genesis.json +++ b/protocol/testing/mainnet/genesis.json @@ -3322,7 +3322,7 @@ "exponent": -10, "min_exchanges": 3, "min_price_change_ppm": 2500, - "exchange_config_json": "{\"exchanges\":[{\"exchangeName\":\"Bybit\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"POL-USD\"},{\"exchangeName\":\"CryptoCom\",\"ticker\":\"POL_USD\"},{\"exchangeName\":\"Okx\",\"ticker\":\"POL-USDT\",\"adjustByMarket\":\"USDT-USD\"}]}" + "exchange_config_json": "{\"exchanges\":[{\"exchangeName\":\"Binance\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"Bybit\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"POL-USD\"},{\"exchangeName\":\"CryptoCom\",\"ticker\":\"POL_USD\"},{\"exchangeName\":\"Okx\",\"ticker\":\"POL-USDT\",\"adjustByMarket\":\"USDT-USD\"}]}" }, { "pair": "CRV-USD", diff --git a/protocol/testing/testnet/genesis.json b/protocol/testing/testnet/genesis.json index 4954d06eeb..3fe44a2f9b 100644 --- a/protocol/testing/testnet/genesis.json +++ b/protocol/testing/testnet/genesis.json @@ -6130,7 +6130,7 @@ "pair": "LINK-USD" }, { - "exchange_config_json": "{\"exchanges\":[{\"exchangeName\":\"Bybit\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"POL-USD\"},{\"exchangeName\":\"CryptoCom\",\"ticker\":\"POL_USD\"},{\"exchangeName\":\"Okx\",\"ticker\":\"POL-USDT\",\"adjustByMarket\":\"USDT-USD\"}]}", + "exchange_config_json": "{\"exchanges\":[{\"exchangeName\":\"Binance\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"Bybit\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"POL-USD\"},{\"exchangeName\":\"CryptoCom\",\"ticker\":\"POL_USD\"},{\"exchangeName\":\"Okx\",\"ticker\":\"POL-USDT\",\"adjustByMarket\":\"USDT-USD\"}]}", "exponent": -10, "id": 3, "min_exchanges": 3, diff --git a/protocol/testutil/constants/genesis.go b/protocol/testutil/constants/genesis.go index 3eb50b7ad1..ec81ede004 100644 --- a/protocol/testutil/constants/genesis.go +++ b/protocol/testutil/constants/genesis.go @@ -2805,33 +2805,32 @@ const GenesisState = `{ }, "decimals": "10", "min_provider_count": "3", - "enabled": true, - "metadata_JSON": "" + "enabled": true }, "provider_configs": [ + { + "name": "binance_ws", + "off_chain_ticker": "POLUSDT", + "normalize_by_pair": { + "Base": "USDT", + "Quote": "USD" + } + }, { "name": "bybit_ws", "off_chain_ticker": "POLUSDT", "normalize_by_pair": { "Base": "USDT", "Quote": "USD" - }, - "invert": false, - "metadata_JSON": "" + } }, { "name": "coinbase_ws", - "off_chain_ticker": "POL-USD", - "normalize_by_pair": null, - "invert": false, - "metadata_JSON": "" + "off_chain_ticker": "POL-USD" }, { "name": "crypto_dot_com_ws", - "off_chain_ticker": "POL_USD", - "normalize_by_pair": null, - "invert": false, - "metadata_JSON": "" + "off_chain_ticker": "POL_USD" }, { "name": "okx_ws", @@ -2839,9 +2838,7 @@ const GenesisState = `{ "normalize_by_pair": { "Base": "USDT", "Quote": "USD" - }, - "invert": false, - "metadata_JSON": "" + } } ] }, @@ -3993,7 +3990,7 @@ const GenesisState = `{ "pair": "LINK-USD" }, { - "exchange_config_json": "{\"exchanges\":[{\"exchangeName\":\"Bybit\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"POL-USD\"},{\"exchangeName\":\"CryptoCom\",\"ticker\":\"POL_USD\"},{\"exchangeName\":\"Okx\",\"ticker\":\"POL-USDT\",\"adjustByMarket\":\"USDT-USD\"}]}", + "exchange_config_json": "{\"exchanges\":[{\"exchangeName\":\"Binance\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"Bybit\",\"ticker\":\"POLUSDT\",\"adjustByMarket\":\"USDT-USD\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"POL-USD\"},{\"exchangeName\":\"CryptoCom\",\"ticker\":\"POL_USD\"},{\"exchangeName\":\"Okx\",\"ticker\":\"POL-USDT\",\"adjustByMarket\":\"USDT-USD\"}]}", "exponent": -10, "id": 3, "min_exchanges": 1, diff --git a/protocol/testutil/daemons/pricefeed/exchange_config/testnet_exchange_market_config.go b/protocol/testutil/daemons/pricefeed/exchange_config/testnet_exchange_market_config.go index 9260606c37..b785ae00bf 100644 --- a/protocol/testutil/daemons/pricefeed/exchange_config/testnet_exchange_market_config.go +++ b/protocol/testutil/daemons/pricefeed/exchange_config/testnet_exchange_market_config.go @@ -30,6 +30,10 @@ var ( Ticker: "LINKUSDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), }, + MARKET_POL_USD: { + Ticker: "POLUSDT", + AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), + }, MARKET_CRV_USD: { Ticker: "CRVUSDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD),