diff --git a/daemons/constants/static_exchange_market_config_test.go b/daemons/constants/static_exchange_market_config_test.go index d090c25ac..f55d001fb 100644 --- a/daemons/constants/static_exchange_market_config_test.go +++ b/daemons/constants/static_exchange_market_config_test.go @@ -20,6 +20,10 @@ func TestGenerateExchangeConfigJson(t *testing.T) { id: exchange_config.MARKET_BTC_USD, expectedExchangeConfigJsonFile: "btc_exchange_config.json", }, + "TRB exchange config": { + id: exchange_config.MARKET_TRB_USD, + expectedExchangeConfigJsonFile: "trb_exchange_config.json", + }, "ETH exchange config": { id: exchange_config.MARKET_ETH_USD, expectedExchangeConfigJsonFile: "eth_exchange_config.json", diff --git a/daemons/constants/static_market_params_config.go b/daemons/constants/static_market_params_config.go index ac269dece..60edf385c 100644 --- a/daemons/constants/static_market_params_config.go +++ b/daemons/constants/static_market_params_config.go @@ -25,5 +25,14 @@ var ( ExchangeConfigJson: `{\"exchanges\":[{\"exchangeName\":\"Binance\",\"ticker\":\"\\\"ETHUSDT\\\"\"},{\"exchangeName\":\"BinanceUS\",\"ticker\":\"\\\"ETHUSD\\\"\"},{\"exchangeName\":\"Bitfinex\",\"ticker\":\"tETHUSD\"},{\"exchangeName\":\"Bitstamp\",\"ticker\":\"ETH/USD\"},{\"exchangeName\":\"Bybit\",\"ticker\":\"ETHUSDT\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"ETH-USD\"},{\"exchangeName\":\"CryptoCom\",\"ticker\":\"ETH_USD\"},{\"exchangeName\":\"Kraken\",\"ticker\":\"XETHZUSD\"},{\"exchangeName\":\"Okx\",\"ticker\":\"ETH-USDT\"}]}`, QueryData: `"00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706F745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003657468000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000"`, }, + exchange_common.TRBUSD_ID: { + Id: exchange_common.TRBUSD_ID, + Pair: `"TRB-USD"`, + Exponent: -6, + MinExchanges: 1, + MinPriceChangePpm: 1000, + ExchangeConfigJson: `{\"exchanges\":[{\"exchangeName\":\"Binance\",\"ticker\":\"\\\"TRBUSDT\\\"\"},{\"exchangeName\":\"Bybit\",\"ticker\":\"TRBUSDT\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"TRB-USD\"}]}`, + QueryData: `"00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706f745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003747262000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000"`, + }, } ) diff --git a/daemons/constants/testdata/btc_exchange_config.json b/daemons/constants/testdata/btc_exchange_config.json index d2b6fc50e..f48b394de 100644 --- a/daemons/constants/testdata/btc_exchange_config.json +++ b/daemons/constants/testdata/btc_exchange_config.json @@ -39,4 +39,4 @@ "adjustByMarket": "USDT-USD" } ] -} +} \ No newline at end of file diff --git a/daemons/constants/testdata/trb_exchange_config.json b/daemons/constants/testdata/trb_exchange_config.json new file mode 100644 index 000000000..aedfdf86c --- /dev/null +++ b/daemons/constants/testdata/trb_exchange_config.json @@ -0,0 +1,33 @@ +{ + "exchanges": [ + { + "exchangeName": "Binance", + "ticker": "TRBUSDT", + "adjustByMarket": "USDT-USD" + }, + { + "exchangeName": "Bybit", + "ticker": "TRBUSDT", + "adjustByMarket": "USDT-USD" + }, + { + "exchangeName": "CoinbasePro", + "ticker": "TRB-USD" + }, + { + "exchangeName": "Gate", + "ticker": "TRB_USDT", + "adjustByMarket": "USDT-USD" + }, + { + "exchangeName": "Kucoin", + "ticker": "TRB-USDT", + "adjustByMarket": "USDT-USD" + }, + { + "exchangeName": "Okx", + "ticker": "TRB-USDT", + "adjustByMarket": "USDT-USD" + } + ] +} diff --git a/daemons/constants/testdata/usdt_exchange_config.json b/daemons/constants/testdata/usdt_exchange_config.json index 34878965c..8454230fe 100644 --- a/daemons/constants/testdata/usdt_exchange_config.json +++ b/daemons/constants/testdata/usdt_exchange_config.json @@ -36,4 +36,4 @@ "invert": true } ] -} +} \ No newline at end of file diff --git a/daemons/exchange_common/market_id.go b/daemons/exchange_common/market_id.go index fed6a32f7..56c6bf517 100644 --- a/daemons/exchange_common/market_id.go +++ b/daemons/exchange_common/market_id.go @@ -3,4 +3,5 @@ package exchange_common const ( BTCUSD_ID uint32 = 0 ETHUSD_ID uint32 = 1 + TRBUSD_ID uint32 = 69 ) diff --git a/daemons/readme.md b/daemons/readme.md index 8bcf99b03..9c8dd637c 100644 --- a/daemons/readme.md +++ b/daemons/readme.md @@ -1,27 +1,8 @@ -# Daemon gRPC Server +# Daemon **Note:** Daemon services code was adopted from dydx [](https://github.com/dydxprotocol/v4-chain/tree/main/protocol/daemons) and reconfigured. -## Overview - -Implements a gRPC server for daemon processes using Unix Domain Sockets (UDS) for communication. - -## Usage - -### Starting the Server - -```go -server := NewServer(logger, grpcServer, fileHandler, socketAddress) -server.Start() -``` - -### Stopping the server - -```go -server.Stop() -``` - -### Task loops +## Task loops ## PriceFetcher @@ -99,3 +80,30 @@ Median server was added for a way to query median values that were from an endpo All median values or median value given query data using the following commands respectively. `layerd query oracle get-all-median-values` `layerd query oracle get-median-value ` + +## How to add a market pair as defaults to be queried with existing APIs [Exchange_Details](./constants/static_exchange_details.go)? + +- Add market_id for your pair in [exchange_common](./exchange_common/market_id.go) + +```go +const ( + BTCUSD_ID uint32 = 0 + ETHUSD_ID uint32 = 1 + TRBUSD_ID uint32 = 69 + NEWPAIR_ID uint32 = +) +``` + +- Add market param config to [static_market_params_config](./constants/static_market_params_config.go) + +```go +exchange_common.TRBUSD_ID: { + Id: exchange_common.TRBUSD_ID, + Pair: `"TRB-USD"`, + Exponent: -6, + MinExchanges: 1, + MinPriceChangePpm: 1000, + ExchangeConfigJson: `{\"exchanges\":[{\"exchangeName\":\"Binance\",\"ticker\":\"\\\"TRBUSDT\\\"\"},{\"exchangeName\":\"Bybit\",\"ticker\":\"TRBUSDT\"},{\"exchangeName\":\"CoinbasePro\",\"ticker\":\"TRB-USD\"}]}`, + QueryData: `"00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706f745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003747262000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000"`, + }, +``` diff --git a/testutil/daemons/pricefeed/exchange_config/market_id.go b/testutil/daemons/pricefeed/exchange_config/market_id.go index 146d90272..892c8df95 100644 --- a/testutil/daemons/pricefeed/exchange_config/market_id.go +++ b/testutil/daemons/pricefeed/exchange_config/market_id.go @@ -70,7 +70,8 @@ const ( MARKET_SUI_USD types.MarketId = 31 // MARKET_XRP_USD is the id for the XRP-USD market pair. MARKET_XRP_USD types.MarketId = 32 - +// MARKET_XRP_USD is the id for the XRP-USD market pair. + MARKET_TRB_USD types.MarketId = 69 // Testing markets used in local, staging, dev // MARKET_TEST_USD is the id used for the TEST-USD market pair. MARKET_TEST_USD types.MarketId = 33 diff --git a/testutil/daemons/pricefeed/exchange_config/static_market_names.go b/testutil/daemons/pricefeed/exchange_config/static_market_names.go index 3928e27b5..afd577ecc 100644 --- a/testutil/daemons/pricefeed/exchange_config/static_market_names.go +++ b/testutil/daemons/pricefeed/exchange_config/static_market_names.go @@ -41,6 +41,7 @@ var ( MARKET_SHIB_USD: "SHIB-USD", MARKET_SUI_USD: "SUI-USD", MARKET_XRP_USD: "XRP-USD", + MARKET_TRB_USD: "TRB-USD", MARKET_USDT_USD: "USDT-USD", } ) diff --git a/testutil/daemons/pricefeed/exchange_config/testnet_exchange_market_config.go b/testutil/daemons/pricefeed/exchange_config/testnet_exchange_market_config.go index 3a48c8d0a..5101ab9b4 100644 --- a/testutil/daemons/pricefeed/exchange_config/testnet_exchange_market_config.go +++ b/testutil/daemons/pricefeed/exchange_config/testnet_exchange_market_config.go @@ -146,6 +146,10 @@ var ( Ticker: "XRPUSDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), }, + MARKET_TRB_USD: { + Ticker: "TRBUSDT", + AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), + }, MARKET_USDT_USD: { Ticker: "USDCUSDT", Invert: true, @@ -250,6 +254,10 @@ var ( Ticker: "CRV_USDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), }, + MARKET_TRB_USD: { + Ticker: "TRB_USDT", + AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), + }, MARKET_ADA_USD: { Ticker: "ADA_USDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), @@ -375,6 +383,10 @@ var ( Ticker: "ATOMUSDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), }, + MARKET_TRB_USD: { + Ticker: "TRBUSDT", + AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), + }, MARKET_UNI_USD: { Ticker: "UNIUSDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), @@ -554,6 +566,10 @@ var ( Ticker: "LINK-USDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), }, + MARKET_TRB_USD: { + Ticker: "TRB-USDT", + AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), + }, MARKET_MATIC_USD: { Ticker: "MATIC-USDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), @@ -692,6 +708,10 @@ var ( Ticker: "BTC-USDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), }, + MARKET_TRB_USD: { + Ticker: "TRB-USDT", + AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), + }, MARKET_ETH_USD: { Ticker: "ETH-USDT", AdjustByMarket: newMarketIdWithValue(MARKET_USDT_USD), @@ -963,6 +983,9 @@ var ( MARKET_ETH_USD: { Ticker: "ETH-USD", }, + MARKET_TRB_USD: { + Ticker: "TRB-USD", + }, MARKET_LINK_USD: { Ticker: "LINK-USD", },