/
interface.go
45 lines (41 loc) · 1.26 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Package quotes implements multiple price feed adapters.
package quotes
import "fmt"
type Driver interface {
ActiveDrivers() []DriverType
ExchangeType() ExchangeType
Start() error
Stop() error
Subscribe(market Market) error
Unsubscribe(market Market) error
SetInbox(inbox <-chan TradeEvent)
}
func NewDriver(config Config, outbox chan<- TradeEvent) (Driver, error) {
if len(config.Drivers) == 0 {
return nil, fmt.Errorf("no drivers are configured")
} else if len(config.Drivers) > 1 {
return newIndex(config, outbox), nil
}
switch config.Drivers[0] {
case DriverBinance:
return newBinance(config.Binance, outbox), nil
case DriverKraken:
return newKraken(config.Kraken, outbox), nil
case DriverOpendax:
return newOpendax(config.Opendax, outbox), nil
case DriverBitfaker:
return newBitfaker(config.Bitfaker, outbox), nil
case DriverUniswapV3:
return newUniswapV3(config.UniswapV3, outbox), nil
case DriverSyncswap:
return newSyncswap(config.Syncswap, outbox), nil
case DriverQuickswap:
return newQuickswap(config.Quickswap, outbox), nil
case DriverSectaV2:
return newSectaV2(config.SectaV2, outbox), nil
case DriverSectaV3:
return newSectaV3(config.SectaV3, outbox), nil
default:
return nil, fmt.Errorf("unknown driver: %s", config.Drivers)
}
}