service

package
v0.0.0-...-930562d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrDefault

func GetOrDefault(slice []string, index int, defaultValue string) string

func GetOrNil

func GetOrNil(slice []string, index int) *string

Types

type AppTokenService

type AppTokenService interface {
	GetAppTokenByToken(token string) (*schema.AppToken, error)
	GetAllAppTokens() ([]schema.AppToken, error)
	AddAppToken(appToken *schema.AppToken) error
	UpdateAppToken(appToken *schema.AppToken) error
	DeleteAppToken(token string) error
}

func NewAppTokenService

func NewAppTokenService(appTokenRepo repository.AppTokenRepository) AppTokenService

type AssetPlatform

type AssetPlatform struct {
	ID           string `json:"id"`
	ChainID      *int   `json:"chain_identifier"`
	Name         string `json:"name"`
	ShortName    string `json:"shortname"`
	NativeCoinID string `json:"native_coin_id"`
}

type CoinGeckoCoin

type CoinGeckoCoin struct {
	ID        string            `json:"id"`
	Symbol    string            `json:"symbol"`
	Name      string            `json:"name"`
	Platforms map[string]string `json:"platforms"`
}

type CoinGeckoOnChainService

type CoinGeckoOnChainService interface {
	GetCoinGeckoOnChainNetwork(coingeckoAssetPlatformId string, isCache bool) (string, error)
	GetCurrentPriceOnChain(chainId, address string, symbol string, isCache bool) (*string, error)
	GetHistoricalPriceOnChain(chainId, address string, unixTimeStamp int64) (*string, error)
	GetBatchCurrentPricesOnChain(addresses []string, chainIds []string, symbols []string, networks []string, isCache bool) ([]PriceResult, error)
	GetBatchHistoricalPricesOnChain(addresses []string, chainIds []string, symbols []string, networks []string, unixTimeStamps []int64) ([]PriceResult, error)
}

func NewCoinGeckoOnChainService

func NewCoinGeckoOnChainService(cfg *koanf.Koanf, redisClient *shared.RedisClient, logger zerolog.Logger, coinRepository repository.CoinRepository, coinHistoricalPriceRepo repository.CoinHistoricalPriceRepository, coinGeckoService CoinGeckoService) CoinGeckoOnChainService

type CoinGeckoService

type CoinGeckoService interface {
	CoinsList(useCache bool) ([]schema.Coins, error)

	GetCoinGeckoChainIdByAssetPlatformId(assetPlatformId string) (string, error) // get chain id by asset platform id
	GetAssetPlatformIdByChainId(chainId string) (string, error)
	SyncCoins() error
	GetBatchPrice(addresses []string, chainIds []string, symbols []string, networks []string, isCache bool) ([]PriceResult, error)
	GetBatchHistoricalPrices(addresses []string, chainIds []string, symbols []string, networks []string, dates []int64) ([]PriceResult, error)
	GetSinglePrice(chainID string, address string, symbol string, network string, isCache bool) (*string, error)
	GetSingleHistoricalPrice(date int64, chainID string, address string, symbol string, network string) (*string, error)
	// contains filtered or unexported methods
}

func NewCoinGeckoService

func NewCoinGeckoService(cfg *koanf.Koanf, coinRepository repository.CoinRepository, coinHistoricalPriceRepo repository.CoinHistoricalPriceRepository, redisClient *shared.RedisClient, logger zerolog.Logger) CoinGeckoService

type CoinsService

type CoinsService interface {
	AddCoin(coin schema.Coins) error
	UpdateCoin(id string, updatedCoin schema.Coins) error
	DeleteCoin(id string) error
	GetCoinByID(id string) (*schema.Coins, error)
	RefreshAllCoinsCache() error
	RefreshCoinListCache(ids []string) error
}

func NewCoinsService

func NewCoinsService(coinsRepo repository.CoinRepository) CoinsService

type DefiLlamaService

type DefiLlamaService interface {
	GetCurrentPrice(chainId, address string, isCache bool) (*string, error)
	GetHistoricalPrice(chainId, address string, unixTimeStamp int64) (*string, error)
	GetBatchCurrentPrices(addresses []string, chainIds []string, symbols []string, networks []string, isCache bool) ([]PriceResult, error)
	GetBatchHistoricalPrices(addresses []string, chainIds []string, symbols []string, networks []string, unixTimeStamps []int64) ([]PriceResult, error)
}

func NewDefiLlamaService

func NewDefiLlamaService(cfg *koanf.Koanf, redisClient *shared.RedisClient, logger zerolog.Logger, coinRepository repository.CoinRepository, coinHistoricalPriceRepo repository.CoinHistoricalPriceRepository) DefiLlamaService

type DodoexRouteService

type DodoexRouteService interface {
	GetCurrentPrice(address string, chainId string, isCache bool) (*string, error)
	GetBatchCurrentPrices(addresses []string, chainIds []string, symbols []string, networks []string, isCache bool) ([]PriceResult, error)
}

func NewDodoexRouteService

func NewDodoexRouteService(cfg *koanf.Koanf, redisClient *shared.RedisClient, logger zerolog.Logger, coinRepository repository.CoinRepository, coinHistoricalPriceRepo repository.CoinHistoricalPriceRepository) DodoexRouteService

type GeckoTerminalService

type GeckoTerminalService interface {
	GetCurrentPrice(chainId, address string, isCache bool) (*string, error)
	GetHistoricalPrice(chainId, address string, unixTimeStamp int64) (*string, error)
	GetBatchCurrentPrices(addresses []string, chainIds []string, symbols []string, networks []string, isCache bool) ([]PriceResult, error)
	GetBatchHistoricalPrices(addresses []string, chainIds []string, symbols []string, networks []string, unixTimeStamps []int64) ([]PriceResult, error)
}

func NewGeckoTerminalService

func NewGeckoTerminalService(cfg *koanf.Koanf, redisClient *shared.RedisClient, logger zerolog.Logger, coinRepository repository.CoinRepository, coinHistoricalPriceRepo repository.CoinHistoricalPriceRepository) GeckoTerminalService

type PriceResult

type PriceResult struct {
	ChainID       string  `json:"chainId"`
	Address       string  `json:"address"`
	Price         *string `json:"price"`
	Symbol        *string `json:"symbol"`
	Network       *string `json:"network"`
	TimeStamp     string  `json:"date"`
	RequestStatus *string `json:"-"`
	Serial        int     `json:"serial"`
}

定义价格结果结构体

type PriceService

type PriceService interface {
	GetPrice(chainId, address, symbol, network string, useCache bool, excludeRoute bool) (*string, error)
	GetHistoricalPrice(chainId, address, symbol, network string, unixTimeStamp int64) (*string, error)
	GetBatchPrice(ctx context.Context, chainIds []string, addresses []string, symbols []string, networks []string, useCache bool, excludeRoute bool) ([]PriceResult, error)
	GetBatchHistoricalPrice(chainIds []string, addresses []string, symbols []string, networks []string, unixTimeStamp []int64, datesStr []string) ([]PriceResult, error)
}

func NewPriceService

func NewPriceService(cfg *koanf.Koanf, slack SlackNotificationService, coinGeckoService CoinGeckoService, geckoTerminalService GeckoTerminalService, defiLlamaService DefiLlamaService, dodoexRouteService DodoexRouteService, coinGeckoOnChainService CoinGeckoOnChainService, coinRepository repository.CoinRepository, logger zerolog.Logger, throttler *shared.CoinsThrottler, redisClient *shared.RedisClient) PriceService

type RateLimiterService

type RateLimiterService struct {
	// contains filtered or unexported fields
}

func NewRateLimiterService

func NewRateLimiterService(appTokenRepo repository.AppTokenRepository, redisClient *shared.RedisClient) *RateLimiterService

func (*RateLimiterService) Allow

func (s *RateLimiterService) Allow(ctx context.Context, token string) (bool, error)

type SlackNotificationService

type SlackNotificationService interface {
	SaveLog(ctx context.Context, source, chainID, address, dateDay string, timestamp int64) error
}

func NewSlackNotificationService

func NewSlackNotificationService(slackRepo repository.SlackNotificationRepository, redisClient *shared.RedisClient, logger zerolog.Logger) SlackNotificationService

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL