Skip to content

Commit

Permalink
Merge branch 'terpay/api-provider-tickers' into refactor/goodbye
Browse files Browse the repository at this point in the history
  • Loading branch information
davidterpay authored Apr 9, 2024
2 parents d00f558 + 4e159c4 commit b3d3265
Show file tree
Hide file tree
Showing 26 changed files with 21 additions and 569 deletions.
5 changes: 2 additions & 3 deletions cmd/slinky-config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func createMarketMap() error {

// Iterate through all of the provider ticker configurations and update the
// tickers and tickers to providers maps.
for _, providerConfig := range ProviderToMarkets {
for provider, providerConfig := range ProviderToMarkets {
for cp, config := range providerConfig {
ticker := mmtypes.Ticker{
CurrencyPair: cp,
Expand All @@ -467,7 +467,7 @@ func createMarketMap() error {

market := marketMap.Markets[ticker.String()]
market.ProviderConfigs = append(market.ProviderConfigs, mmtypes.ProviderConfig{
Name: config.Name,
Name: provider,
OffChainTicker: config.OffChainTicker,
Metadata_JSON: config.JSON,
})
Expand Down Expand Up @@ -541,7 +541,6 @@ func addRaydiumMarkets(providerToMarkets map[string]types.CurrencyPairsToProvide
providerToMarkets[raydium.Name] = make(types.CurrencyPairsToProviderTickers)
for _, pair := range raydiumPairs {
providerToMarkets[raydium.Name][pair.Cp] = types.DefaultProviderTicker{
Name: raydium.Name,
OffChainTicker: pair.Cp.String(),
JSON: marshalToJSONString(pair.TickerMetaData),
}
Expand Down
6 changes: 3 additions & 3 deletions oracle/oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (s *OracleTestSuite) SetupTest() {
s.logger = zap.NewExample()

s.currencyPairs = []types.ProviderTicker{
types.NewProviderTicker("test", "BTC/USD", "{}"),
types.NewProviderTicker("test", "ETH/USD", "{}"),
types.NewProviderTicker("test", "ATOM/USD", "{}"),
types.NewProviderTicker("BTC/USD", "{}"),
types.NewProviderTicker("ETH/USD", "{}"),
types.NewProviderTicker("ATOM/USD", "{}"),
}
}
8 changes: 4 additions & 4 deletions oracle/orchestrator/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ var (
Decimals: 8,
},
ProviderConfigs: []mmtypes.ProviderConfig{
coinbase.DefaultMarketConfig.MustGetProviderConfig(constants.BITCOIN_USD),
okx.DefaultMarketConfig.MustGetProviderConfig(constants.BITCOIN_USD),
coinbase.DefaultMarketConfig.MustGetProviderConfig(coinbase.Name, constants.BITCOIN_USD),
okx.DefaultMarketConfig.MustGetProviderConfig(okx.Name, constants.BITCOIN_USD),
},
},
constants.ETHEREUM_USD.String(): {
Expand All @@ -174,8 +174,8 @@ var (
Decimals: 8,
},
ProviderConfigs: []mmtypes.ProviderConfig{
coinbase.DefaultMarketConfig.MustGetProviderConfig(constants.ETHEREUM_USD),
okx.DefaultMarketConfig.MustGetProviderConfig(constants.ETHEREUM_USD),
coinbase.DefaultMarketConfig.MustGetProviderConfig(coinbase.Name, constants.ETHEREUM_USD),
okx.DefaultMarketConfig.MustGetProviderConfig(okx.Name, constants.ETHEREUM_USD),
},
},
},
Expand Down
5 changes: 2 additions & 3 deletions oracle/types/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func ProviderTickersFromMarketMap(
}

providerTicker := NewProviderTicker(
cfg.Name,
cfg.OffChainTicker,
cfg.Metadata_JSON,
)
Expand Down Expand Up @@ -78,10 +77,10 @@ func (tpt CurrencyPairsToProviderTickers) MustGetProviderTicker(cp pkgtypes.Curr

// MustGetProviderConfig returns the provider config for the given currency pair.
// This function is mostly used for testing.
func (tpt CurrencyPairsToProviderTickers) MustGetProviderConfig(cp pkgtypes.CurrencyPair) mmtypes.ProviderConfig {
func (tpt CurrencyPairsToProviderTickers) MustGetProviderConfig(name string, cp pkgtypes.CurrencyPair) mmtypes.ProviderConfig {
providerTicker := tpt.MustGetProviderTicker(cp)
return mmtypes.ProviderConfig{
Name: providerTicker.GetProvider(),
Name: name,
OffChainTicker: providerTicker.GetOffChainTicker(),
Metadata_JSON: providerTicker.GetJSON(),
}
Expand Down
2 changes: 0 additions & 2 deletions oracle/types/market_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func TestProviderTickersFromMarketMap(t *testing.T) {
},
expected: []types.ProviderTicker{
types.NewProviderTicker(
"test",
"BTC/USDT",
"{}",
),
Expand Down Expand Up @@ -120,7 +119,6 @@ func TestProviderTickersFromMarketMap(t *testing.T) {
},
expected: []types.ProviderTicker{
types.NewProviderTicker(
"test",
"ETH/USDT",
"{}",
),
Expand Down
11 changes: 1 addition & 10 deletions oracle/types/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ type (
ProviderTicker interface {
fmt.Stringer

// GetProvider returns the provider for the ticker.
GetProvider() string
// GetOffChainTicker returns the off-chain representation for the ticker.
GetOffChainTicker() string
// GetJSON returns additional JSON data for the ticker.
Expand All @@ -22,7 +20,6 @@ type (
// Provider's that utilize this implementation should be able to easily configure
// custom json data for their tickers.
DefaultProviderTicker struct {
Name string
OffChainTicker string
JSON string
}
Expand All @@ -37,20 +34,14 @@ type (

// NewProviderTicker returns a new provider ticker.
func NewProviderTicker(
provider, offChain, json string,
offChain, json string,
) ProviderTicker {
return DefaultProviderTicker{
Name: provider,
OffChainTicker: offChain,
JSON: json,
}
}

// Provider returns the provider for the ticker.
func (t DefaultProviderTicker) GetProvider() string {
return t.Name
}

// OffChainTicker returns the off-chain representation for the ticker.
func (t DefaultProviderTicker) GetOffChainTicker() string {
return t.OffChainTicker
Expand Down
Loading

0 comments on commit b3d3265

Please sign in to comment.