Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addedTRB #79

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions daemons/constants/static_exchange_market_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions daemons/constants/static_market_params_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`,
},
}
)
2 changes: 1 addition & 1 deletion daemons/constants/testdata/btc_exchange_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"adjustByMarket": "USDT-USD"
}
]
}
}
33 changes: 33 additions & 0 deletions daemons/constants/testdata/trb_exchange_config.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
2 changes: 1 addition & 1 deletion daemons/constants/testdata/usdt_exchange_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"invert": true
}
]
}
}
1 change: 1 addition & 0 deletions daemons/exchange_common/market_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package exchange_common
const (
BTCUSD_ID uint32 = 0
ETHUSD_ID uint32 = 1
TRBUSD_ID uint32 = 69
)
50 changes: 29 additions & 21 deletions daemons/readme.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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 <querydata>`

## 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 = <unique-number>
)
```

- 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"`,
},
```
3 changes: 2 additions & 1 deletion testutil/daemons/pricefeed/exchange_config/market_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -963,6 +983,9 @@ var (
MARKET_ETH_USD: {
Ticker: "ETH-USD",
},
MARKET_TRB_USD: {
Ticker: "TRB-USD",
},
MARKET_LINK_USD: {
Ticker: "LINK-USD",
},
Expand Down
Loading