Skip to content

Commit

Permalink
chore: Remove crescent provider (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari authored Aug 15, 2024
1 parent 804a2f4 commit 2216d80
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 441 deletions.
60 changes: 9 additions & 51 deletions config/currency_provider_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import (
)

const (
coinGeckoRestURL = "https://api.coingecko.com/api/v3/coins"
coinGeckoListEndpoint = "list"
coinGeckoTickersEndpoint = "tickers"
osmosisRestURL = "https://api.osmo-api.prod.ojo.network"
osmosisAssetPairsEndpoint = "assetpairs"
crescentRestURL = "https://api.cresc-api.prod.ojo.network"
crescentAssetPairsEndpoint = "assetpairs"
requestTimeout = time.Second * 2
trackingPeriod = time.Hour * 24
coinGeckoRestURL = "https://api.coingecko.com/api/v3/coins"
coinGeckoListEndpoint = "list"
coinGeckoTickersEndpoint = "tickers"
osmosisRestURL = "https://api.osmo-api.prod.ojo.network"
osmosisAssetPairsEndpoint = "assetpairs"
requestTimeout = time.Second * 2
trackingPeriod = time.Hour * 24
)

type (
Expand Down Expand Up @@ -90,12 +88,7 @@ func NewCurrencyProviderTracker(
return nil, err
}

crescentAPIPairs, err := currencyProviderTracker.getCrescentAPIPairs()
if err != nil {
return nil, err
}

if err := currencyProviderTracker.setCurrencyProviders(osmosisAPIPairs, crescentAPIPairs); err != nil {
if err := currencyProviderTracker.setCurrencyProviders(osmosisAPIPairs); err != nil {
return nil, err
}

Expand Down Expand Up @@ -159,36 +152,10 @@ func (t *CurrencyProviderTracker) getOsmosisAPIPairs() (map[string]string, error
return osmosisAPIPairs, nil
}

// getCrescentAPIPairs queries the crescent-api assetpairs endpoint to get the asset pairs
// supported by it.
func (t *CurrencyProviderTracker) getCrescentAPIPairs() (map[string]string, error) {
client := &http.Client{
Timeout: requestTimeout,
}
crescentAPIPairs := make(map[string]string)

crescentResp, err := client.Get(fmt.Sprintf("%s/%s", crescentRestURL, crescentAssetPairsEndpoint))
if err != nil {
return nil, err
}
defer crescentResp.Body.Close()
var assetPairsResponse []assetPair
if err = json.NewDecoder(crescentResp.Body).Decode(&assetPairsResponse); err != nil {
return nil, err
}

for _, assetPair := range assetPairsResponse {
crescentAPIPairs[assetPair.Base] = assetPair.Quote
}

return crescentAPIPairs, nil
}

// setCurrencyProviders queries CoinGecko's tickers endpoint to get all the exchanges
// that support each price feeder currency pair and store it in the CurrencyProviders map.
func (t *CurrencyProviderTracker) setCurrencyProviders(
osmosisAPIPairs map[string]string,
crescentAPIPairs map[string]string,
) error {
client := &http.Client{
Timeout: requestTimeout,
Expand All @@ -199,11 +166,6 @@ func (t *CurrencyProviderTracker) setCurrencyProviders(
t.CurrencyProviders[pair.Base] = append(t.CurrencyProviders[pair.Base], "osmosis")
}

// check if its a pair supported by the crescent api
if crescentAPIPairs[strings.ToUpper(pair.Base)] == strings.ToUpper(pair.Quote) {
t.CurrencyProviders[pair.Base] = append(t.CurrencyProviders[pair.Base], "crescent")
}

// check if CoinGecko API supports pair
pairBaseID := t.coinIDSymbolMap[strings.ToLower(pair.Base)]
coinGeckoResp, err := client.Get(fmt.Sprintf("%s/%s/%s", coinGeckoRestURL, pairBaseID, coinGeckoTickersEndpoint))
Expand Down Expand Up @@ -259,11 +221,7 @@ func (t *CurrencyProviderTracker) trackCurrencyProviders(ctx context.Context) {
if err != nil {
t.logger.Error().Err(err).Msg("failed to query osmosis-api for available asset pairs")
}
crescentAPIPairs, err := t.getOsmosisAPIPairs()
if err != nil {
t.logger.Error().Err(err).Msg("failed to query crescent-api for available asset pairs")
}
if err := t.setCurrencyProviders(osmosisAPIPairs, crescentAPIPairs); err != nil {
if err := t.setCurrencyProviders(osmosisAPIPairs); err != nil {
t.logger.Error().Err(err).Msg("failed to set available providers for currencies")
}

Expand Down
1 change: 0 additions & 1 deletion config/supported_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var (
provider.ProviderKraken: false,
provider.ProviderBinance: false,
provider.ProviderBinanceUS: false,
provider.ProviderCrescent: false,
provider.ProviderOsmosis: false,
provider.ProviderOkx: false,
provider.ProviderHuobi: false,
Expand Down
3 changes: 0 additions & 3 deletions oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,6 @@ func NewProvider(
case provider.ProviderPolygon:
return provider.NewPolygonProvider(ctx, logger, endpoint, providerPairs...)

case provider.ProviderCrescent:
return provider.NewCrescentProvider(ctx, logger, endpoint, providerPairs...)

case provider.ProviderKujira:
return provider.NewKujiraProvider(ctx, logger, endpoint, providerPairs...)

Expand Down
269 changes: 0 additions & 269 deletions oracle/provider/crescent.go

This file was deleted.

Loading

0 comments on commit 2216d80

Please sign in to comment.