Skip to content
Open
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
3 changes: 3 additions & 0 deletions config/generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ type GenerateConfig struct {
// You must have MinProviderCountOverride <= MinDexProviderCount.
MinDexProviderCount uint64 `json:"min_dex_provider_count" mapstructure:"min_dex_provider_count"`

// ExcludeCMCIDs specifies a list of CMC IDs of markets that should be excluded.
ExcludeCMCIDs []string `json:"exclude_cmc_ids" mapstructure:"exclude_cmc_ids"`

// ExcludeCMCTags specifies a list of CMC tags of markets that should be excluded.
ExcludeCMCTags []string `json:"exclude_cmc_tags" mapstructure:"exclude_cmc_tags"`
// DisableProviders specifies a list of providers that should not be allowed to provide for a market.
Expand Down
24 changes: 24 additions & 0 deletions generator/transformer/asset_transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import (
"context"
"slices"
"strings"
"strconv"

"go.uber.org/zap"

Expand Down Expand Up @@ -39,6 +41,28 @@
}
}

func FilterOutCMCIDs() TransformAsset {
return func(_ context.Context, logger *zap.Logger, cfg config.GenerateConfig, feeds types.Feeds, cmcIDToAssetInfo map[int64]provider.AssetInfo) (types.Feeds, types.ExclusionReasons, error) {

Check failure on line 45 in generator/transformer/asset_transforms.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unused-parameter: parameter 'cmcIDToAssetInfo' seems to be unused, consider removing or renaming it as _ (revive)
idsToExclude := cfg.ExcludeCMCIDs
logger.Info("filtering out cmc ids", zap.Int("feeds", len(feeds)), zap.Strings("ids", idsToExclude))
out := make([]types.Feed, 0, len(feeds))
exclusions := types.NewExclusionReasons()

for _, feed := range feeds {
baseAssetCMCID := feed.CMCInfo.BaseID
if slices.Contains(idsToExclude, strconv.FormatInt(baseAssetCMCID, 10)) {
logger.Info("dropping feed because it has excluded CMC ids", zap.Any("feed", feed))
exclusions.AddExclusionReasonFromFeed(feed, feed.ProviderConfig.Name, "FilterOutCMCID: has cmc id to exclude")
continue
}
out = append(out, feed)
}

logger.Info("filtering out cmc ids", zap.Int("feeds remaining", len(out)))
return out, exclusions, nil
}
}

func HasCMCTag(assetInfo provider.AssetInfo, tagsToExclude []string) bool {
for _, tagToExclude := range tagsToExclude {
for _, assetTag := range assetInfo.CMCTags {
Expand Down
1 change: 1 addition & 0 deletions generator/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func New(logger *zap.Logger) Transformer {
},
assetTransforms: []TransformAsset{ // Separate from feed transforms because these require extra metadata from asset infos
FilterOutCMCTags(),
FilterOutCMCIDs(),
},
mmTransforms: []TransformMarketMap{
PruneMarkets(),
Expand Down
5 changes: 4 additions & 1 deletion local/config-dydx-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
},
"min_cex_provider_count": 2,
"min_dex_provider_count": 1,
"exclude_cmc_ids": ["29035"],
"exclude_cmc_tags": ["wrapped-tokens", "algorithmic-stablecoin"],
"disable_providers": {
"IOTX/USD": ["coinbase_ws"]
Expand All @@ -210,11 +211,13 @@
"MATIC/USD": {},
"MXN/USD": {},
"NZD/USD": {},
"WTAO/USD": {}
"WTAO/USD": {},
"OGN/USD": {}
},
"allowed_currency_pairs": null,
"market_map_override": {
"markets": {
"METH/USD": {},
"BRL/USD": {
"ticker": {
"currency_pair": { "Base": "BRL", "Quote": "USD" },
Expand Down
Loading