1
- import { Exchange } from 'ccxt' ;
2
1
import { concat , Observable } from 'rxjs' ;
3
2
import { catchError , mergeMap , takeUntil } from 'rxjs/operators' ;
4
3
import { getExchange } from './centralized/ccxt/exchange' ;
5
- import { initBinance$ , InitBinanceParams } from './centralized/ccxt/init' ;
4
+ import {
5
+ initCEX$ ,
6
+ InitCEXparams ,
7
+ InitCEXResponse ,
8
+ } from './centralized/ccxt/init' ;
6
9
import { loadMarkets$ } from './centralized/ccxt/load-markets' ;
7
10
import { getCentralizedExchangePrice$ } from './centralized/exchange-price' ;
8
11
import { getCentralizedExchangeOrder$ } from './centralized/order' ;
@@ -12,10 +15,12 @@ import { Logger, Loggers } from './logger';
12
15
import { catchOpenDEXerror } from './opendex/catch-error' ;
13
16
import { getOpenDEXcomplete$ } from './opendex/complete' ;
14
17
import { removeOpenDEXorders$ } from './opendex/remove-orders' ;
18
+ import { getArbyStore } from './store' ;
15
19
import { getCleanup$ , GetCleanupParams } from './trade/cleanup' ;
16
20
import { getNewTrade$ , GetTradeParams } from './trade/trade' ;
17
21
import { getStartShutdown$ } from './utils' ;
18
- import { getArbyStore } from './store' ;
22
+ import { Dictionary , Market } from 'ccxt' ;
23
+ import { verifyMarkets } from './centralized/verify-markets' ;
19
24
20
25
type StartArbyParams = {
21
26
config$ : Observable < Config > ;
@@ -32,11 +37,12 @@ type StartArbyParams = {
32
37
config,
33
38
removeOpenDEXorders$,
34
39
} : GetCleanupParams ) => Observable < unknown > ;
35
- initBinance $ : ( {
40
+ initCEX $ : ( {
36
41
getExchange,
37
42
config,
38
43
loadMarkets$,
39
- } : InitBinanceParams ) => Observable < Exchange > ;
44
+ } : InitCEXparams ) => Observable < InitCEXResponse > ;
45
+ verifyMarkets : ( config : Config , CEXmarkets : Dictionary < Market > ) => boolean ;
40
46
} ;
41
47
42
48
const logConfig = ( config : Config , logger : Logger ) => {
@@ -79,21 +85,23 @@ export const startArby = ({
79
85
shutdown$,
80
86
trade$,
81
87
cleanup$,
82
- initBinance$,
88
+ initCEX$,
89
+ verifyMarkets,
83
90
} : StartArbyParams ) : Observable < any > => {
84
91
const store = getArbyStore ( ) ;
85
92
return config$ . pipe (
86
93
mergeMap ( config => {
87
- const CEX$ = initBinance $( {
94
+ const CEX$ = initCEX $( {
88
95
config,
89
96
loadMarkets$,
90
97
getExchange,
91
98
} ) ;
92
99
return CEX$ . pipe (
93
- mergeMap ( CEX => {
100
+ mergeMap ( ( { markets : CEXmarkets , exchange : CEX } ) => {
94
101
const loggers = getLoggers ( config ) ;
95
102
loggers . global . info ( 'Starting. Hello, Arby.' ) ;
96
103
logConfig ( config , loggers . global ) ;
104
+ verifyMarkets ( config , CEXmarkets ) ;
97
105
const tradeComplete$ = trade$ ( {
98
106
config,
99
107
loggers,
@@ -145,7 +153,8 @@ if (!module.parent) {
145
153
getLoggers,
146
154
shutdown$ : getStartShutdown$ ( ) ,
147
155
cleanup$ : getCleanup$ ,
148
- initBinance$,
156
+ initCEX$,
157
+ verifyMarkets,
149
158
} ) . subscribe ( {
150
159
error : error => {
151
160
if ( error . message ) {
0 commit comments